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

guiApplications=false causes broken systemd environment #10818

Closed
1 of 2 tasks
fknittel opened this issue Nov 23, 2023 · 6 comments
Closed
1 of 2 tasks

guiApplications=false causes broken systemd environment #10818

fknittel opened this issue Nov 23, 2023 · 6 comments
Assignees
Labels

Comments

@fknittel
Copy link

Windows Version

Microsoft Windows [Version 10.0.22621.2715]

WSL Version

2.0.9.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.133.1-1

Distro Version

Ubuntu-22.04

Other Software

No response

Repro Steps

  1. Disable wslg in .wslconfig:
    [wsl2]
    guiApplications=false
    
  2. Install a distribution using systemd, e.g. Ubuntu-22.04:
    wsl.exe --install Ubuntu-22.04
    
  3. Shutdown wsl:
    wsl.exe --shutdown
    
  4. Enter distribution again:
    wsl.exe -d Ubuntu-22.04
    

Expected Behavior

The system should have a working XDG runtime directory:

$ ls -lnd $XDG_RUNTIME_DIR
drwx------ 4 1000 1000 120 Nov 23 16:30 /run/user/1000/

Additionally, the system should have a proper X11-unix socket dir:

$ ls -la /tmp/.X11-unix
total 8
drwxrwxrwt  2 root root 4096 Nov 23 17:01 .
drwxrwxrwt 11 root root 4096 Nov 23 17:01 ..

Actual Behavior

The system has a broken XDG runtime directory:

$ ls -ldn $XDG_RUNTIME_DIR
drwx------ 2 root root 4096 Nov 23 13:42 /run/user/1000/

Additionally, the system has a missing /tmp/X11-unix direcotry:

$ ls -l /tmp/.X11-unix
ls: cannot access '/tmp/.X11-unix': No such file or directory

Diagnostic Logs

The directory /run/user appears to be bind mounted from the distributions root filesystem:

$ grep /run/user /proc/mounts
none /run/user tmpfs rw,nosuid,nodev,noexec,noatime,mode=755 0 0
/dev/sdc /run/user ext4 rw,relatime,discard,errors=remount-ro,data=ordered 0 0
$ ls -lid /mnt/wslg/run/user /run/user
29471 drwxr-xr-x 3 root root 4096 Nov 23 16:30 /mnt/wslg/run/user
29471 drwxr-xr-x 3 root root 4096 Nov 23 16:30 /run/user

Moving /mnt/wslg out of the way, running wsl --shutdown and then re-entering wsl fixes this once. Without moving /mnt/wslg away, the issue returns on the next cycle.

The missing X11-unix directory is caused by the presence of /run/tmpfiles.d/x11.conf, which might be a good idea for wslg mode, but not when that is disabled.

Generally, it seems that at least some wslg-specific actions/mounts/system overrides are still active despite of the "guiApplications=false" setting.

Copy link

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@benhillis
Copy link
Member

You're right, we shouldn't be doing this sytemd fixup logic if gui applications are disabled. I'll work on a fix.

@benhillis benhillis self-assigned this Nov 27, 2023
@benhillis benhillis added the bug label Nov 27, 2023
@benhillis
Copy link
Member

@fknittel
Copy link
Author

@benhillis I can confirm that /run/tmpfiles.d/x11.conf is no longer generated.

Unfortunately, the problem with XDG_RUNTIME_DIR persists: /mnt/wslg/run/user still appears to be bind-mounted to /run/user, which breaks the next wsl boot unless I move that directory out of the way. In other words: To successfully boot the distro a second time, I do:

PS> wsl -d Ubuntu-22.04
$ sudo mv /mnt/wslg /mnt/wslg.old
$ exit
PS> wsl --shutdown
PS> wsl -d Ubuntu-22.04

Some more details:

PS> wsl --version
WSL-Version: 2.0.12.0
Kernelversion: 5.15.133.1-1
WSLg-Version: 1.0.59
MSRDC-Version: 1.2.4677
Direct3D-Version: 1.611.1-81528511
DXCore-Version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows-Version: 10.0.22621.2715
PS> wsl -d Ubuntu-22.04
$ id -u
1000
$ sudo lsof /mnt/wslg/run/user/1000/
$ sudo rm -rf /mnt/wslg/run/user/1000/
rm: cannot remove '/mnt/wslg/run/user/1000/': Device or resource busy
$ grep /run/user /proc/mounts
none /run/user tmpfs rw,nosuid,nodev,noexec,noatime,mode=755 0 0
/dev/sdc /run/user ext4 rw,relatime,discard,errors=remount-ro,data=ordered 0 0
ls -lid /mnt/wslg/run/user /run/user
125882 drwxr-xr-x 3 root root 4096 30. Nov 15:59 /mnt/wslg/run/user
125882 drwxr-xr-x 3 root root 4096 30. Nov 15:59 /run/user
$ sudo mv /mnt/wslg /mnt/wslg.old
$ exit
PS> wsl --shutdown
PS> wsl -d Ubuntu-22.04
$ grep /run/user /proc/mounts
none /run/user tmpfs rw,nosuid,nodev,noexec,noatime,mode=755 0 0
/dev/sdc /run/user ext4 rw,relatime,discard,errors=remount-ro,data=ordered 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=1638104k,nr_inodes=409526,mode=700,uid=1000,gid=1000 0 0

Logs during a failing log-in / boot:

[...]
Nov 30 16:43:25 my-hostname systemd[1]: Reached target multi-user.target - Multi-User System.
Nov 30 16:43:25 my-hostname systemd[1]: Reached target graphical.target - Graphical Interface.
Nov 30 16:43:25 my-hostname systemd[1]: Starting systemd-update-utmp-runlevel.service - Record Runlevel Change in UTMP...
Nov 30 16:43:25 my-hostname systemd[1]: systemd-update-utmp-runlevel.service: Deactivated successfully.
Nov 30 16:43:25 my-hostname systemd[1]: Finished systemd-update-utmp-runlevel.service - Record Runlevel Change in UTMP.
Nov 30 16:43:25 my-hostname systemd[1]: Startup finished in 760ms.
Nov 30 16:43:25 my-hostname unknown: WSL (2): Creating login session for my-wsl-user
Nov 30 16:43:25 my-hostname unknown: WSL (2) ERROR: ConfigHandleInteropMessage:595: getenv(XDG_RUNTIME_DIR) failed
Nov 30 16:43:25 my-hostname unknown: 0
Nov 30 16:43:25 my-hostname login[286]: pam_unix(login:session): session opened for user my-wsl-user(uid=1000) by (uid=0)
Nov 30 16:43:25 my-hostname systemd[1]: Created slice user-1000.slice - User Slice of UID 1000.
Nov 30 16:43:25 my-hostname systemd[1]: Starting [email protected] - User Runtime Directory /run/user/1000...
Nov 30 16:43:25 my-hostname systemd-logind[105]: New session 1 of user my-wsl-user.
Nov 30 16:43:25 my-hostname systemd[1]: Finished [email protected] - User Runtime Directory /run/user/1000.
Nov 30 16:43:25 my-hostname systemd[1]: Starting [email protected] - User Manager for UID 1000...
Nov 30 16:43:25 my-hostname (systemd)[299]: pam_unix(systemd-user:session): session opened for user my-wsl-user(uid=1000) by (uid=0)
Nov 30 16:43:25 my-hostname (systemd)[299]: pam_systemd(systemd-user:session): Runtime directory '/run/user/1000' is not owned by UID 1000, as it should.
Nov 30 16:43:25 my-hostname (systemd)[299]: pam_systemd(systemd-user:session): Not setting $XDG_RUNTIME_DIR, as the directory is not in order.
Nov 30 16:43:25 my-hostname systemd[299]: Trying to run as user instance, but $XDG_RUNTIME_DIR is not set.
Nov 30 16:43:25 my-hostname systemd[1]: [email protected]: Main process exited, code=exited, status=1/FAILURE
Nov 30 16:43:25 my-hostname systemd[1]: [email protected]: Failed with result 'exit-code'.
Nov 30 16:43:25 my-hostname systemd[1]: Failed to start [email protected] - User Manager for UID 1000.
Nov 30 16:43:25 my-hostname systemd[1]: Started session-1.scope - Session 1 of User my-wsl-user.
Nov 30 16:43:25 my-hostname login[286]: pam_systemd(login:session): Runtime directory '/run/user/1000' is not owned by UID 1000, as it should.
Nov 30 16:43:25 my-hostname login[286]: pam_systemd(login:session): Not setting $XDG_RUNTIME_DIR, as the directory is not in order.

Based on the WSL (2) ERROR: ConfigHandleInteropMessage:595: getenv(XDG_RUNTIME_DIR) failed error message I found #10846, which looks to be the same issue.

@fknittel
Copy link
Author

@benhillis Can you please re-open? Or should I create a new issue?

@jeffrson
Copy link

Even with WSL 2.0.14 (current stable) or 2.1.3.0 (current pre-release) /run/user/ is not created with

[wsl2]
guiApplications=false

guiApplications=true is no option, unfortunately, since Windows Terminal still/again loses focus after start.

So will this issue be reopened or should we report another one?

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

3 participants