Skip to content

WSL login nukes systemd/dbus user session / contents of /run/user/1000 #10205

@sarim

Description

@sarim

Windows Version

Microsoft Windows [Version 10.0.22621.1778]

WSL Version

1.3.10.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

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.

  1. Open WSL from Windows Terminal.
  2. Run systemctl --user status
  3. Or Run 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:

  1. In Powershell, wsl --shutdown few times to be sure.
  2. 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.
  3. Here logged in via root, ls /run/user/1000 shows proper bus, systemd etc.. sockets created.
  4. Now open wsl to user gittu (which is default user) by opening a new tab in Windows Terminal.
  5. Observe that [ 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.
  6. Now output of 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

↪ ~ ➤ systemctl --user status
Failed to connect to bus: No such file or directory
↪ ~ ➤ ls /run/user/1000 -l
total 0
drwx------ 3 gittu gittu 60 Jun 16 00:24 dbus-1
drwx------ 2 gittu gittu 80 Jun 16 00:24 pulse
lrwxrwxrwx 1 root  root  31 Jun 16 00:25 wayland-0 -> /mnt/wslg/runtime-dir/wayland-0
-rw-rw---- 1 gittu gittu  0 Jun 16 00:24 wayland-0.lock

Diagnostic Logs

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions