From 2a38f30b6c3b629e4d49efa3edb3838c7f8d204d Mon Sep 17 00:00:00 2001 From: "Jason T. Greene" Date: Wed, 4 Oct 2023 16:20:59 -0500 Subject: [PATCH] Revert "Fix WSL systemd detection" This reverts commit 5b990c3835ac167cc7f5b51fae3f719edf031965. PR #19994 Causes wsl nsenter script to infinitely loop in standard operation [NO NEW TESTS NEEDED] Signed-off-by: Jason T. Greene --- pkg/machine/wsl/machine.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/machine/wsl/machine.go b/pkg/machine/wsl/machine.go index 38219a799f..80ae9f3da0 100644 --- a/pkg/machine/wsl/machine.go +++ b/pkg/machine/wsl/machine.go @@ -69,6 +69,12 @@ chown [USER]:[USER] /home/[USER]/.config const sudoers = `%wheel ALL=(ALL) NOPASSWD: ALL ` +const bootstrap = `#!/bin/bash +ps -ef | grep -v grep | grep -q systemd && exit 0 +nohup unshare --kill-child --fork --pid --mount --mount-proc --propagation shared /lib/systemd/systemd >/dev/null 2>&1 & +sleep 0.1 +` + const wslmotd = ` You will be automatically entered into a nested process namespace where systemd is running. If you need to access the parent namespace, hit ctrl-d @@ -76,13 +82,7 @@ or type exit. This also means to log out you need to exit twice. ` -const sysdpid = "SYSDPID=`ps --no-headers -C systemd --format exe,pid | grep -m 1 ^/usr/lib/systemd/systemd | awk '{print $2}'`" - -const bootstrap = "#!/bin/bash\n" + sysdpid + ` -[ -n "$SYSDPID" ] && exit 0 -nohup unshare --kill-child --fork --pid --mount --mount-proc --propagation shared /usr/lib/systemd/systemd >/dev/null 2>&1 & -sleep 0.1 -` +const sysdpid = "SYSDPID=`ps -eo cmd,pid | grep -m 1 ^/lib/systemd/systemd | awk '{print $2}'`" const profile = sysdpid + ` if [ ! -z "$SYSDPID" ] && [ "$SYSDPID" != "1" ]; then