Re: [PATCH v8 3/6] launcher-logind: only get a VT on seat0, as only seat0 supports VTs

2018-06-29 Thread Pekka Paalanen
On Wed, 27 Jun 2018 20:44:19 -0400
nerdopolis  wrote:

> As only seat0 supports TTYs, this changes the logind launcher where
> it detects a TTY, only if the seat is seat0. This has only been
> tested for logind
> ---
>  libweston/launcher-logind.c | 23 +--
>  libweston/launcher-util.c   |  4 
>  2 files changed, 17 insertions(+), 10 deletions(-)
> 
> diff --git a/libweston/launcher-logind.c b/libweston/launcher-logind.c
> index d0559c8f..34e6e5ca 100644
> --- a/libweston/launcher-logind.c
> +++ b/libweston/launcher-logind.c
> @@ -762,17 +762,20 @@ launcher_logind_connect(struct weston_launcher **out, 
> struct weston_compositor *
>   free(t);
>   goto err_session;
>   }
> - free(t);
>  
> - r = weston_sd_session_get_vt(wl->sid, >vtnr);
> - if (r < 0) {
> - weston_log("logind: session not running on a VT\n");
> - goto err_session;
> - } else if (tty > 0 && wl->vtnr != (unsigned int )tty) {
> - weston_log("logind: requested VT --tty=%d differs from real 
> session VT %u\n",
> -tty, wl->vtnr);
> - r = -EINVAL;
> - goto err_session;
> + r = strcmp(t, "seat0");
> + free(t);
> + if (r == 0) {
> + r = weston_sd_session_get_vt(wl->sid, >vtnr);
> + if (r < 0) {
> + weston_log("logind: session not running on a VT\n");
> + goto err_session;
> + } else if (tty > 0 && wl->vtnr != (unsigned int )tty) {
> + weston_log("logind: requested VT --tty=%d differs from 
> real session VT %u\n",
> +tty, wl->vtnr);
> + r = -EINVAL;
> + goto err_session;
> + }
>   }
>  
>   loop = wl_display_get_event_loop(compositor->wl_display);
> diff --git a/libweston/launcher-util.c b/libweston/launcher-util.c
> index 03f3219b..41ac7950 100644
> --- a/libweston/launcher-util.c
> +++ b/libweston/launcher-util.c
> @@ -104,6 +104,10 @@ WL_EXPORT void
>  weston_setup_vt_switch_bindings(struct weston_compositor *compositor)
>  {
>   uint32_t key;
> + struct weston_launcher *launcher = compositor->launcher;
> +
> + if (launcher->iface->get_vt(launcher) <= 0)
> + return;
>  
>   if (compositor->vt_switching == false)
>   return;

All looks good to me.

Reviewed-by: Pekka Paalanen 


Thanks,
pq


pgpyS9bbyoTvH.pgp
Description: OpenPGP digital signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH v8 3/6] launcher-logind: only get a VT on seat0, as only seat0 supports VTs

2018-06-27 Thread nerdopolis
As only seat0 supports TTYs, this changes the logind launcher where
it detects a TTY, only if the seat is seat0. This has only been
tested for logind
---
 libweston/launcher-logind.c | 23 +--
 libweston/launcher-util.c   |  4 
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/libweston/launcher-logind.c b/libweston/launcher-logind.c
index d0559c8f..34e6e5ca 100644
--- a/libweston/launcher-logind.c
+++ b/libweston/launcher-logind.c
@@ -762,17 +762,20 @@ launcher_logind_connect(struct weston_launcher **out, 
struct weston_compositor *
free(t);
goto err_session;
}
-   free(t);
 
-   r = weston_sd_session_get_vt(wl->sid, >vtnr);
-   if (r < 0) {
-   weston_log("logind: session not running on a VT\n");
-   goto err_session;
-   } else if (tty > 0 && wl->vtnr != (unsigned int )tty) {
-   weston_log("logind: requested VT --tty=%d differs from real 
session VT %u\n",
-  tty, wl->vtnr);
-   r = -EINVAL;
-   goto err_session;
+   r = strcmp(t, "seat0");
+   free(t);
+   if (r == 0) {
+   r = weston_sd_session_get_vt(wl->sid, >vtnr);
+   if (r < 0) {
+   weston_log("logind: session not running on a VT\n");
+   goto err_session;
+   } else if (tty > 0 && wl->vtnr != (unsigned int )tty) {
+   weston_log("logind: requested VT --tty=%d differs from 
real session VT %u\n",
+  tty, wl->vtnr);
+   r = -EINVAL;
+   goto err_session;
+   }
}
 
loop = wl_display_get_event_loop(compositor->wl_display);
diff --git a/libweston/launcher-util.c b/libweston/launcher-util.c
index 03f3219b..41ac7950 100644
--- a/libweston/launcher-util.c
+++ b/libweston/launcher-util.c
@@ -104,6 +104,10 @@ WL_EXPORT void
 weston_setup_vt_switch_bindings(struct weston_compositor *compositor)
 {
uint32_t key;
+   struct weston_launcher *launcher = compositor->launcher;
+
+   if (launcher->iface->get_vt(launcher) <= 0)
+   return;
 
if (compositor->vt_switching == false)
return;
-- 
2.17.1

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel