From e9e8d01c5a2f57d330d42c9a772cf67d89b43650 Mon Sep 17 00:00:00 2001 From: nzbr Date: Mon, 14 Nov 2022 00:47:49 +0100 Subject: Fix syschdemd exit code (#140) * use systemd-run instead of machinectl * fix systemd user sessions by launching through runuser * fix: add which to path --- scripts/syschdemd.nix | 5 +++-- scripts/syschdemd.sh | 14 +++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/syschdemd.nix b/scripts/syschdemd.nix index 9415dc9..b7b42fd 100644 --- a/scripts/syschdemd.nix +++ b/scripts/syschdemd.nix @@ -7,6 +7,7 @@ , gnugrep , systemd , util-linux +, which , defaultUser , automountPath , @@ -44,10 +45,10 @@ mkWrappedScript { glibc # getent gnugrep systemd # machinectl - util-linux # nsenter + util-linux # nsenter, runuser + which wrapper ]; username = defaultUser.name; - uid = defaultUser.uid; inherit automountPath; } diff --git a/scripts/syschdemd.sh b/scripts/syschdemd.sh index 33dbc00..73adb40 100644 --- a/scripts/syschdemd.sh +++ b/scripts/syschdemd.sh @@ -106,7 +106,7 @@ main() { shift command="$*" else - command=$(get_shell @username@) + command="$(get_shell @username@)" fi # If we're executed from inside the container, e.g. sudo @@ -124,13 +124,17 @@ main() { exportCmd="$(export -p | grep -vE ' (HOME|LOGNAME|SHELL|USER)=')" run_in_namespace \ - machinectl \ + systemd-run \ --quiet \ - --uid=@uid@ \ + --collect \ + --wait \ + --pty \ + --service-type=exec \ --setenv=INSIDE_NAMESPACE=true \ --setenv=WSLPATH="$(clean_wslpath)" \ - shell .host \ - /bin/sh -c "cd \"$PWD\"; $exportCmd; source /etc/set-environment; exec $command" + --working-directory="$PWD" \ + --machine=.host \ + "$(which runuser)" -u @username@ -- /bin/sh -c "$exportCmd; source /etc/set-environment; exec $command" } main "$@" -- cgit v1.2.3