Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Remove useless part of login command #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lucyllewy
Copy link
Contributor

@lucyllewy lucyllewy commented Jul 29, 2020

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

Daniel Llewellyn added 2 commits July 29, 2020 01:33
* VSCode WSL-remote fails: issue DamionGans#33
* `/bin/login` does not support environment variable setting via the command line when used with the `-f` flag that allows login to operate without requesting a password.

Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
This reduces the proliferation of recursion that can become difficult to understand or reason about. By using `/bin/sh` in as many places as possible we prevent the bash rcfile from kicking-in and performing the namespace stuff many times over.

Signed-off-by: Daniel Llewellyn <daniel@bowlhat.net>
@benjamincburns
Copy link

benjamincburns commented Aug 5, 2020

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VSCode terminal broken when using Remote WSL extension and scripts from this repo
3 participants