Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$WSL_DISTRO_NAME does not exists after sudo -i #5914

Closed
herbert256 opened this issue Sep 13, 2020 · 3 comments
Closed

$WSL_DISTRO_NAME does not exists after sudo -i #5914

herbert256 opened this issue Sep 13, 2020 · 3 comments

Comments

@herbert256
Copy link

Environment

Windows build number: 10.0.19041.0
Your Distribution version: 1 Debian GNU/Linux 10 (buster) / imported from https://salsa.debian.org/debian/WSL/-/raw/master/x64/install.tar.gz
Whether the issue is on WSL 2 and/or WSL 1: WSL 2, Linux version 4.19.104-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Wed Feb 19 06:37:35 UTC 2020

Description

When I enter the distro with user root the environment variabele $WSL_DISTRO_NAME does exists

When I enter the distro with the default user and then go to the root user with sudo -i or sudo su - root the environment variabele $WSL_DISTRO_NAME does not exists

Steps to reproduce

wsl -d distro -u root
echo $WSL_DISTRO_NAME
*distro name here*
wsl -d distro
sudo -i
echo $WSL_DISTRO_NAME
*no distro name here*
@0xbadfca11
Copy link

0xbadfca11 commented Sep 13, 2020

This is the correct behavior of sudo.
See man of sudoers(5).

@herbert256
Copy link
Author

herbert256 commented Sep 15, 2020

sudo -i is supose to work as a new login, imho that means the result should be the same as directly login as root with 'wsl -d distro -u root'

wsl -d distro -u root  # $WSL_DISTRO_NAME does exists

wsl -d distro -u user
sudo -i                # $WSL_DISTRO_NAME does not exists

@therealkenc
Copy link
Collaborator

How sudo(1) is "supposed to work" is not dictated by WSL, your h.o. notwithstanding.

You probably want Defaults env_keep=WSL_DISTRO_NAME in your sudoers(5), as 0xbadfca11 was implying.

image

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

No branches or pull requests

3 participants