All of lore.kernel.org
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 2/2] weston-init: Add support for non-root start
Date: Thu,  9 May 2019 11:03:24 +0100	[thread overview]
Message-ID: <20190509100324.85677-2-leit@fb.com> (raw)
In-Reply-To: <20190509100324.85677-1-leit@fb.com>

From: Breno Leitao <leitao@debian.org>

This commit adds support for two variables (WESTON_USER and WESTON_TTY) that
would be passed to weston_launch. It allows starting weston as a non-root user.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 .../wayland/weston-init/weston-start            | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-graphics/wayland/weston-init/weston-start b/meta/recipes-graphics/wayland/weston-init/weston-start
index 0c4fee23d5..86c68fc533 100755
--- a/meta/recipes-graphics/wayland/weston-init/weston-start
+++ b/meta/recipes-graphics/wayland/weston-init/weston-start
@@ -27,10 +27,19 @@ if [ -n "$WAYLAND_DISPLAY" ]; then
 	echo "ERROR: A Wayland compositor is already running, nested Weston instance is not supported yet."
 	exit 1
 fi
+
+if [ -n "$WESTON_USER" ]; then
+	if [ -z "$WESTON_TTY" ]; then
+		echo "ERROR: If you have WESTON_USER variable set, you also need WESTON_TTY."
+		exit 1
+	fi
+	weston_args_user="-u $WESTON_USER -t $WESTON_TTY"
+fi
+
 if [ -n "$DISPLAY" ]; then
 	launcher="weston"
 else
-	launcher="weston-launch --"
+	launcher="weston-launch $weston_args_user --"
 fi
 
 openvt_args="-s"
@@ -59,11 +68,15 @@ if [ -d "$modules_dir" ]; then
 fi
 
 if test -z "$XDG_RUNTIME_DIR"; then
-	export XDG_RUNTIME_DIR=/run/user/`id -u`
+	export XDG_RUNTIME_DIR=/run/user/`id -u ${WESTON_USER}`
 	if ! test -d "$XDG_RUNTIME_DIR"; then
 		mkdir --parents $XDG_RUNTIME_DIR
 		chmod 0700 $XDG_RUNTIME_DIR
 	fi
+	if [ -n "$WESTON_USER" ]
+	then
+		chown $WEST_USER:$WESTON_USER $XDG_RUNTIME_DIR
+	fi
 fi
 
 exec openvt $openvt_args -- $launcher $weston_args --log=@LOCALSTATEDIR@/log/weston.log
-- 
2.17.1



      reply	other threads:[~2019-05-09 10:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-09 10:03 [PATCH 1/2] weston-init: Fix tab indentation Breno Leitao
2019-05-09 10:03 ` Breno Leitao [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190509100324.85677-2-leit@fb.com \
    --to=leitao@debian.org \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.