-
Notifications
You must be signed in to change notification settings - Fork 822
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 login nukes systemd/dbus user session / contents of /run/user/1000 #10205
Comments
@OneBlue - another one related to your /run/usr/ change. |
Thank you for reporting this @sarim. Interestingly, I can't reproduce the issue. Can you share the output of WSL does mount an overlayfs on /run/user/X when the session is created, but happens regardless of whether GUI apps are enabled or not so I wonder if there's something else happening here. |
.wslconfig
/etc/wsl.conf
/etc/fstab
After wsl --shutdown, log into wsl via root user with diff mount-before.txt mount-after.txt
mount-after.txt Btw if I run |
Also this might also be relevant. root@GITTUW11WSL:~# ls /run/user/1000/rw
ls: cannot access '/run/user/1000/rw': No such file or directory
root@GITTUW11WSL:~# ls /mnt/wslg/run/user/1000/rw
ls: cannot access '/mnt/wslg/run/user/1000/rw': No such file or directory
root@GITTUW11WSL:~# ls /mnt/wslg/run/user/1000
dbus-1 pulse wayland-0 wayland-0.lock Edit:
Umm I don't understand, when guiApplications=false, the "system"/"wslg" distro doesn't get launched. This "/mnt/wslg" directory is shared with that system distro right? So the behavior is definitely changing from how much I understand. Below outputs are when guiApplications=false. Notice the output of mount is absent of any /mnt/wslg related entry. Though I don't understand how /mnt/wslg directory is created now as there's no such entry in mount output.
|
For those that need
or
|
I just wrote and add this to my bashrc to restart user session. the command is allowed in sudoers file. function check_and_restart_session {
# Check if "/run/user/1000/bus" exists
if [ -e "/run/user/1000/bus" ]; then
return 0
fi
# Try to avoid race condition
sleep 0.$(( ( RANDOM % 300 ) + 50 ))
# Check if "/tmp/gittuRestartSession" exists
if [ -e "/tmp/gittuRestartSession" ]; then
echo "/tmp/gittuRestartSession exists"
return 0
fi
# If neither condition is true, restart the session
touch /tmp/gittuRestartSession
sudo /usr/bin/systemctl restart [email protected]
echo "Restart User Session"
} |
This just started happening to me today, where I actually have a working system for a bit but then it breaks. In
I'm running Running I thought this might be due to 2.0.0.0, but I don't have it yet:
Perhaps this is a different issue than this thread; apologies if it is, but this is perfectly reproducible for me so I'm totally happy to try things out. |
Not sure if it is the same issue I see. Right after startup is finished WSL seems to stop the User Manager.
After this, when running
|
Just found another interesting article: https://serverfault.com/questions/1139283/systemd-stops-user-manager-and-kills-all-user-processes In my case I am running Ubuntu 22.04. After enabling lingering for my user it does not seem to be stopped anymore. So my workaround: |
This solved to me a |
Workaround for WSL2 Ubuntu 22.04 Systemd IssueFor anyone running WSL2 Ubuntu 22.04 using systemd and encountering this issue, I found a very simple workaround.
Note that I had enabled systemd while running 20.04 and it was working fine. This issue only surfaced when I did an in-place upgrade to 22.04. I'll note that before I figured this out, running I guess "Have you tried turning it off and on again?" never stops being sage advice. |
For me this started occurring after disabling GUI application support via the WSL Settings app. Enabling linger for the user seems to have resolved the issue. Edit: I also disabled Hyper-V Firewall at the same time, but based on the comments in this thread, I figure that's unrelated. |
Also see #8879 for more systemd issues |
Hi |
I've just run across this myself in a newly installed Ubuntu 22.04 setup. It's a pretty big out-of-the-box flaw for anyone who actually wants to use user systemd. Is anyone working on it on the WSL team? |
|
WSL systemd doesn't reliably provide a user session; that is, `systemctl --user status` may fail. This commit provides a workaround based on: microsoft/WSL#10205 (comment)
Windows Version
Microsoft Windows [Version 10.0.22621.1778]
WSL Version
1.3.10.0
Are you using WSL 1 or WSL 2?
Kernel Version
5.15.90.2-microsoft-standard-WSL2
Distro Version
Ubuntu 22.04
Other Software
No response
Repro Steps
Make sure
guiApplications=true
in wslconfig.systemctl --user status
ls /run/user/1000
Expected Behavior
Excepts systemd user session to be present and systemctl --user to be able connect to it.
This kinda relates to #8842 , but not the same issue. This not the race condition issue, rather WSL login is nuking bus and other sockets in /run/user/1000 directory. Check the attached video demonstration.
If we follow the Following steps:
wsl -u root -e /bin/bash
this makes wsl login to root. So wsl doesn't touch 1000 user (named gittu). this user has linger enabled, so systemd naturally creates the user session.ls /run/user/1000
shows proper bus, systemd etc.. sockets created.[ 29.574698] WSL (2): Creating login session for gittu
line appears in dmesg output, confirming that WSL indeed created a user session for gittu, nuking previously good user session created by systemd.ls /run/user/1000/
doesn't have bus, systemd etc.. sockets.Now If I disable wslg, so guiApplications=false. The issue is solved, wsl doesn't nuke contents of /run/user/1000. So from this observation my conclusion is wslg is nuking the contents of /run/user/1000, and only manually putting wslg's files there.
Screenshot.2023-06-16.00.24.23.mp4
Actual Behavior
Diagnostic Logs
No response
The text was updated successfully, but these errors were encountered: