From 4e9f4d04745049ca3d763f447bfd853a0e3532a9 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Wed, 9 Sep 2020 17:10:10 +0300 Subject: [PATCH] launcher-direct: allow non-root on non-seat0 If the launcher is told to use a non-default seat (not seat0), there will not be a VT or tty to set up. VT/tty setup requires privileges. This patch allows a non-root user to use launcher-direct, provided that the seat is not the default. There is still the problem of opening DRM and input devices, which is left for the user to solve. This mode of operation is useful for developers who can set up a secondary seat on their machine. You can run Weston/DRM from a terminal window by pointing it to a non-default seat. You have to arrange a DRM device by having an extra unused graphics card in the machine. You also need dedicated input devices. Both the DRM device and the input devices must be assigned to the secondary seat and device file permissions adjusted so that they can be opened. Doing so is an obvious security risk, as input could easily be eavesdropped. Signed-off-by: Pekka Paalanen --- libweston/launcher-direct.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libweston/launcher-direct.c b/libweston/launcher-direct.c index c20d70f2..3bee27a2 100644 --- a/libweston/launcher-direct.c +++ b/libweston/launcher-direct.c @@ -127,6 +127,9 @@ setup_tty(struct launcher_direct *launcher, int tty) char tty_device[32] =""; int ret, kd_mode; + if (geteuid() != 0) + return -1; + if (tty == 0) { launcher->tty = dup(tty); if (launcher->tty == -1) { @@ -290,9 +293,6 @@ launcher_direct_connect(struct weston_launcher **out, struct weston_compositor * { struct launcher_direct *launcher; - if (geteuid() != 0) - return -EINVAL; - launcher = zalloc(sizeof(*launcher)); if (launcher == NULL) return -ENOMEM;