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

Home directory mixup #3390

Closed
kinekt4 opened this issue Jul 19, 2018 · 17 comments
Closed

Home directory mixup #3390

kinekt4 opened this issue Jul 19, 2018 · 17 comments
Labels

Comments

@kinekt4
Copy link

kinekt4 commented Jul 19, 2018

Windows Version
10.0.17134 (Build 17134)

Summary
WSL gets home directory mixed up when more than one distro and user is created

How to replicate

  • Install Ubuntu from the Marketplace
  • On completion/launch create user: user01
  • Uninstalled Ubuntu
  • Install Ubuntu 18.04 from Marketplace
  • On completion/launch create user: user02
  • echo $HOME # /home/user02
  • Go to your local git repo; run git fetch
Could not create directory '/home/user01/.ssh'.
The authenticity of host 'host.demo (x.x.x.x)' can't be established.
RSA key fingerprint is SHA256:zz...1A.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/user01/.ssh/known_hosts).
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

On further investigation I found /etc/passwd was different when logged in as user02 and root

Logged in as user02:

user02@MY-MACHINE: cat /etc/passwd
user02:x:1000:1000:,,,:/home/user02:/bin

Logged in as root:

root@MY-MACHINE: cat /etc/passwd
user01:x:1000:1000:,,,:/home/user01:/bin

Further, and what is more perplexing, when logged in as user02, using tail will return a row for user01 (none for user02)

user02@MY-MACHINE: tail -n 1 /etc/passwd
user01:x:1000:1000:,,,:/home/user01:/bin

What I expect

  • /etc/passwd file to be static
@benhillis
Copy link
Member

benhillis commented Jul 19, 2018

Each distribution has its own /etc/passwd file. Think of each distribution you download as a completely separate environment with its own users, packages, and filesystem.

@kinekt4
Copy link
Author

kinekt4 commented Jul 19, 2018

@benhillis

  • Does that explain why cat /etc/passwd and tail /etc/password is not the same?
  • How do I know what distribution I'm currently in?
  • How do I completely remove the first distribution (Ubuntu)

@therealkenc
Copy link
Collaborator

How do I know what distribution I'm currently in?

Remains a good question. But as a practical matter, with the Distros currently shipping in the Store, you can get an idea with lsb_release -a.

@benhillis
Copy link
Member

benhillis commented Jul 19, 2018

How do I completely remove the first distribution (Ubuntu)

Uninstall the app. Alternitively you can use wslconfig.exe:

wslconfig.exe /list
wslconfig.exe /unregister <distro_you_wish_to_remove>

@kinekt4
Copy link
Author

kinekt4 commented Jul 19, 2018

It looks like Ubuntu has been uninstalled. So it seems some artifacts such as /etc/passwd are still lingering around

C:\Users\w_user01>wslconfig.exe /list
Windows Subsystem for Linux Distributions:
Ubuntu-18.04 (Default)

@therealkenc
Copy link
Collaborator

therealkenc commented Jul 20, 2018

so it seems some artifacts such as /etc/passwd are still lingering around

Precisely why I avoided your third question. wslconfig.exe lacks /cleanupturds. Someone will tell you to violate this blog and delete: [ed, path]

C:\Users\<you>\AppData\Local\Packages\CanonicalGroupLimited*

YRMV

@kinekt4
Copy link
Author

kinekt4 commented Jul 20, 2018

wslconfig.exe lacks /cleanupturds

Let me rename this issue to that :D

Will try deleting C:\Users<you>\AppData\Local\Packages\CanonicalGroupLimited* later.

@kinekt4
Copy link
Author

kinekt4 commented Jul 20, 2018

I've done the following and it still doesn't fix the issue:

  • Uninstalled Ubuntu 18.04
  • Deleted the dir: C:\Users\AppData\Local\Packages\CanonicalGroupLimited*
  • Restarted computer
  • Installed 18.04
  • Created user: user02

cat /etc/passwd displays user02
tail -n 1 /etc/passwd still displays user01

ie. Same issue as reported

This data must either be in /tmp or in registry

@onomatopellan
Copy link

Then uninstall everything and delete HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss

@benhillis
Copy link
Member

I don't understand what is happening here. /etc/passwd is a unique file in each distribution's filesystem which is located in their distinct app data directory. I can't reproduce this locally, so there must be some additional step that I'm missing.

@kinekt4
Copy link
Author

kinekt4 commented Jul 20, 2018

@onomatopellan I did the following:

  • Uninstalled Ubuntu 18.04
  • Removed primary key and all sub keys (if present): Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\{12345678-1234-5678-0123-456789abcdef}
  • Restarted computer
  • Also ran wsreset.exe (on another iteration)
  • Reinstalled 18.04

No change.

@kinekt4
Copy link
Author

kinekt4 commented Jul 20, 2018

@benhillis On the first distro install I may have hit escape while in the shell command. I can't remember exactly which step. It was waiting for user input (I think) rather than executing something. I may have accidentally hit escape. That is the only thing I can think of that is out of the ordinary.

@Brian-Perkins
Copy link

What is your process for logging in as a different user? Are you starting the same every time (clicking on an icon, running wsl.exe) and then running su? Does nano /etc/passwd look like cat or tail? Can you do a quick check of 'alias tail; alias cat; which tail; which cat' to make sure nothing looks out of the ordinary?

@0xbadfca11
Copy link

Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\{12345678-1234-5678-0123-456789abcdef}

Something strange.
{12345678-1234-5678-0123-456789abcdef} is GUID for Legacy instance (Ubuntu 16.04).
From the output of wslconfig.exe /list, you should not have installed it.

@kinekt4
Copy link
Author

kinekt4 commented Jul 21, 2018

@Brian-Perkins

What is your process for logging in as a different user

After install, I create a user, in this example, user02. To start WSL, i usually start cmd/powershell/conemu then type bash. I automatically get logged in as the created user. I don't try to change user manually. user01 was created when I installed the first distro, which I later uninstalled.
To run as root, I run sudo su and enter my password for my created user.

Does nano /etc/passwd look like cat or tail?

nano looks like cat. tail seems to be the only command I can see that is out of the ordinary

Can you do a quick check of 'alias tail; alias cat; which tail; which cat' to make sure nothing looks out of the ordinary?

$ alias tail
bash: alias: tail: not found
$ alias cat
bash: alias: cat: not found
$ which tail
/usr/bin/tail
$ which cat
/bin/cat

@kinekt4
Copy link
Author

kinekt4 commented Jul 21, 2018

@0xbadfca11

{12345678-1234-5678-0123-456789abcdef} is GUID for Legacy instance (Ubuntu 16.04).

Actually I copied that key from another machine just to show the string pattern. The actual key is different and as far as I could tell changed every install.

@kinekt4
Copy link
Author

kinekt4 commented Jul 25, 2018

@benhillis

I can't reproduce this locally, so there must be some additional step that I'm missing.

I don't think you will be able to reproduce simply by uninstalling then installing.

I think there is some significance that Ubuntu was installed first then Ubuntu 18.04.

If you installed 18.04 first, then uninstalled 18.04, then followed my steps, it is possible you won't be able to reproduce.

When I have time, I may be able to do a system refresh and try install Ubuntu 18.04 first then Ubuntu and see if there is difference.

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

No branches or pull requests

6 participants