From a44e73900e6ec7134d721804350e5b03424857ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret=20=28fepitre=29?= Date: Sat, 2 Nov 2019 18:55:01 +0100 Subject: [PATCH] qubes.WaitForSession: refactor by waiting for qrexec-fork-server socket --- qubes-rpc/qubes.WaitForSession | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/qubes-rpc/qubes.WaitForSession b/qubes-rpc/qubes.WaitForSession index ba1fbe2..9d43a19 100755 --- a/qubes-rpc/qubes.WaitForSession +++ b/qubes-rpc/qubes.WaitForSession @@ -1,16 +1,8 @@ #!/bin/sh -# old API - get the user from caller -#read -r IGNORE_USERNAME +USERNAME="$(qubesdb-read /default-user || echo 'user')" -# use default user provided in QubesDB, or hardcoded 'user' - this must be the -# same as the X session owner -USERNAME=$(qubesdb-read /default-user || echo 'user') -cmd='echo $$ >> /tmp/qubes-session-waiter; [ ! -f /tmp/qubes-session-env ] && exec sleep inf' -if [ "$(id -un)" = "$USERNAME" ]; then - sh -c "$cmd" 2>/dev/null -else - su -s /bin/sh -c "$cmd" - "$USERNAME" 2> /dev/null -fi -# the above line is _expected_ to be terminated by a signal, don't treat this as a failure -exit 0 +while ! [ -e "/var/run/qubes/qrexec-server.$USERNAME.sock" ] +do + sleep 0.1 +done