DamionGans / ubuntu-wsl2-systemd-script

[Does not work anymore!] Script to enable systemd support on current Ubuntu WSL2 images
1.56k stars 383 forks source link

Remove useless part of login command #34

Open lucyllewy opened 4 years ago

lucyllewy commented 4 years ago

Signed-off-by: Daniel Llewellyn daniel@bowlhat.net

benjamincburns commented 4 years ago

This seems to break things on my system. I can't login when I run this patch.

I added a set -x to my /etc/bash.bashrc to try to troubleshoot. I think it's failing to find the systemd PID after entering into the namespace? The full output is below, I've only snipped out the interop path entries, as I didn't want to expose all those details about my system.

I'm running Ubuntu 20.04, updated from Ubuntu 18.04, if that helps any.

PS C:\Users\benja> wsl
++ source /usr/sbin/start-systemd-namespace
+++ SYSTEMD_EXE='/lib/systemd/systemd --system-unit=basic.target'
++++ ps -eo pid=,args=
++++ awk '$2" "$3=="/lib/systemd/systemd --system-unit=basic.target" {print $1}'
+++ SYSTEMD_PID=
+++ '[' bburns '!=' root ']'
+++ '[' -z '' ']'
+++ export
+++ sed -e 's/^declare -x //;/^IFS=".*[^"]$/{N;s/\n//}'
+++ grep -E -v '^(BASH|BASH_ENV|DIRSTACK|EUID|GROUPS|HOME|HOSTNAME|IFS|LANG|LOGNAME|MACHTYPE|MAIL|NAME|OLDPWD|OPTERR|OSTYPE|PATH|PIPESTATUS|POSIXLY_CORRECT|PPID|PS1|PS4|SHELL|SHELLOPTS|SHLVL|SYSTEMD_PID|UID|USER|_)(=|$)'
+++ export 'PRE_NAMESPACE_PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:<snipped interop path entries>'
+++ PRE_NAMESPACE_PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:<snipped interop path entries>'
++++ pwd
+++ export PRE_NAMESPACE_PWD=/mnt/c/Users/benja
+++ PRE_NAMESPACE_PWD=/mnt/c/Users/benja
+++ exec sudo /usr/sbin/enter-systemd-namespace ''
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 4.19.121-microsoft-standard x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue Aug  4 19:10:21 PDT 2020

  System load:  0.0                 Processes:             17
  Usage of /:   13.9% of 250.98GB   Users logged in:       0
  Memory usage: 4%                  IPv4 address for eth0: 172.19.153.129
  Swap usage:   0%

 * Are you ready for Kubernetes 1.19? It's nearly here! Try RC3 with
   sudo snap install microk8s --channel=1.19/candidate --classic

   https://www.microk8s.io/ has docs and details.

9 updates can be installed immediately.
9 of these updates are security updates.
To see these additional updates run: apt list --upgradable

Last login: Tue Aug  4 19:09:59 PDT 2020 on pts/1
++ source /usr/sbin/start-systemd-namespace
+++ SYSTEMD_EXE='/lib/systemd/systemd --system-unit=basic.target'
++++ ps -eo pid=,args=
++++ awk '$2" "$3=="/lib/systemd/systemd --system-unit=basic.target" {print $1}'
+++ SYSTEMD_PID=
+++ '[' bburns '!=' root ']'+++ '[' -z '' ']'
+++ export
+++ sed -e 's/^declare -x //;/^IFS=".*[^"]$/{N;s/\n//}'
+++ grep -E -v '^(BASH|BASH_ENV|DIRSTACK|EUID|GROUPS|HOME|HOSTNAME|IFS|LANG|LOGNAME|MACHTYPE|MAIL|NAME|OLDPWD|OPTERR|OSTYPE|PATH|PIPESTATUS|POSIXLY_CORRECT|PPID|PS1|PS4|SHELL|SHELLOPTS|SHLVL|SYSTEMD_PID|UID|USER|_)(=|$)'
+++ export PRE_NAMESPACE_PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
+++ PRE_NAMESPACE_PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
++++ pwd
+++ export PRE_NAMESPACE_PWD=/home/bburns
+++ PRE_NAMESPACE_PWD=/home/bburns
+++ exec sudo /usr/sbin/enter-systemd-namespace ''
benjamincburns commented 4 years ago

I don't fully understand how this all works, but perhaps it'd be more reliable to write out the PID to a pidfile in /var/run?

benjamincburns commented 4 years ago

It seems the breakage is related to the second commit. If I apply only the Remove useless part of login command commit on top of current master, things appear to work correctly, though I haven't tested exhaustively just yet.

benjamincburns commented 4 years ago

Also side note - while this change did get VSCode working for me, the interop path stuff didn't seem to find its way into the shell that VSCode gets - not sure why, however.

mikeseese commented 3 years ago

Fancy seeing you here @benjamincburns! Thanks for looking into this and thanks @diddledani for the fix.

@DamionGans, I can confirm that this fix still works and is necessary (a year later).