diff options
| author | nzbr <mail@nzbr.de> | 2022-11-14 00:47:49 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-14 00:47:49 +0100 |
| commit | e9e8d01c5a2f57d330d42c9a772cf67d89b43650 (patch) | |
| tree | 9e61d75f44211ddfd6df9cde5ad4d1e8f99edcd2 /scripts | |
| parent | a4bbcf329a98a7faf79d10370278f87e836e1d7c (diff) | |
Fix syschdemd exit code (#140)
* use systemd-run instead of machinectl
* fix systemd user sessions by launching through runuser
* fix: add which to path
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/syschdemd.nix | 5 | ||||
| -rw-r--r-- | scripts/syschdemd.sh | 14 |
2 files changed, 12 insertions, 7 deletions
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 "$@" |
