]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
weston-init: improve XDG_RUNTIME_DIR fallback creation
authorRoss Burton <ross.burton@arm.com>
Tue, 4 Mar 2025 11:12:32 +0000 (11:12 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 5 Mar 2025 21:26:16 +0000 (21:26 +0000)
Sanity-check the permissions of the directory already exists, and clean
up the creation code.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
meta/recipes-graphics/wayland/weston-init/weston-start

index 01670cd4f51504c28f3632e482275fe5d9599758..3b13a0047a905bf072d109ef7e0a613734236e11 100755 (executable)
@@ -58,14 +58,19 @@ fi
 
 if test -z "$XDG_RUNTIME_DIR"; then
        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 $WESTON_USER:$WESTON_GROUP $XDG_RUNTIME_DIR
+       if test -d "$XDG_RUNTIME_DIR"; then
+           # Check permissions on existing directory
+           if [ "$(stat -c %u-%a "$XDG_RUNTIME_DIR")" != "$(id -u ${WESTON_USER})-700" ]; then
+                       echo "ERROR: $XDG_RUNTIME_DIR has incorrect permissions"
+                       exit 1
+               fi
+       else
+               mkdir --mode 0700 --parents $XDG_RUNTIME_DIR
+               if [ -n "$WESTON_USER" ]
+               then
+                       chown $WESTON_USER:$WESTON_GROUP $XDG_RUNTIME_DIR
+               fi
        fi
 fi
 
-su -c "XDG_RUNTIME_DIR=/run/user/`id -u ${WESTON_USER}` weston $weston_args --log=/tmp/weston.log" $WESTON_USER
+su -c "XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR weston $weston_args --log=/tmp/weston.log" $WESTON_USER