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

fix: setup /bin/login for native systemd support #169

Merged
merged 1 commit into from
Nov 25, 2022

Conversation

psmf
Copy link
Contributor

@psmf psmf commented Nov 25, 2022

When native systemd integration is enabled in WSL, it looks for /bin/login to login the user.

It enables proper support for user session (dbus and systemd).

Resolves issue #165.

@psvo
Copy link
Contributor

psvo commented Nov 25, 2022

System processes with /bin/login symlink:

C:\> wsl --shutdown
C:\> wsl

bsh ❯ ps xafu
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  1.0  0.0  17608 10628 ?        Ss   17:28   0:00 /nix/var/nix/profiles/system/systemd/lib/systemd/systemd /sbin/init
root           2  0.0  0.0   2300  1188 ?        Sl   17:28   0:00 /init
root           3  0.0  0.0   2272     4 ?        Sl   17:28   0:00  \_ plan9 --control-socket 6 --log-level 4 --server-fd 7 --pipe-fd 9 --log-truncate
root         541  0.0  0.0   2308   132 ?        Ss   17:28   0:00  \_ /init
root         542  0.0  0.0   2324   140 ?        S    17:28   0:00  |   \_ /init
petr         543  0.1  0.0   9812  6440 pts/0    Ss   17:28   0:00  |       \_ -bash
petr         718  0.0  0.0 227464  3700 pts/0    R+   17:28   0:00  |           \_ ps xafu
root         544  0.0  0.0   5664  3208 pts/1    Ss   17:28   0:00  \_ /bin/login -f
petr         607  0.0  0.0 228124  7236 pts/1    S+   17:28   0:00      \_ -bash
root         165  0.5  0.0  39292 14472 ?        Ss   17:28   0:00 /nix/store/9xmrmm20hhil0yha82zh58wxpfy68gxh-systemd-250.8/lib/systemd/systemd-journald
root         193  1.1  0.4 2041968 77484 ?       Ssl  17:28   0:00 /nix/store/aibd0jvjbyi1rgg43wzsyqfij2ar9kxy-moby-20.10.18/libexec/docker/dockerd --config-file=/nix/store/rr17bi4wvjqplfzyy6arnllxazcys71z-daemon.json
root         245  0.4  0.3 1947788 58420 ?       Ssl  17:28   0:00  \_ containerd --config /var/run/docker/containerd/containerd.toml --log-level info
nscd         194  0.0  0.0 933660  3016 ?        Ssl  17:28   0:00 nscd
root         206  0.1  0.0  15260  7296 ?        Ss   17:28   0:00 /nix/store/9xmrmm20hhil0yha82zh58wxpfy68gxh-systemd-250.8/lib/systemd/systemd-logind
message+     214  0.0  0.0   8528  3836 ?        Ss   17:28   0:00 /nix/store/dqc3aq11bn9z1515mkb87hcsxvvqil47-dbus-1.14.4/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
root         244  0.1  0.1 538148 23472 ?        Ssl  17:28   0:00 nix-daemon --daemon
petr         552  0.1  0.0  16696  9908 ?        Ss   17:28   0:00 /nix/store/9xmrmm20hhil0yha82zh58wxpfy68gxh-systemd-250.8/lib/systemd/systemd --user
petr         555  0.0  0.0  19228  2396 ?        S    17:28   0:00  \_ (sd-pam)
petr         595  0.0  0.0 223740  3360 ?        Ss   17:28   0:00  \_ /nix/store/h3dwyhxyswzr8vkdchiqzdf7s8rlc4if-bash-5.1-p16/bin/bash /nix/store/wm1n86h1lqh605dzpg0j63dfa266nw0z-auto-fix-vscode-server.sh
petr         702  0.0  0.0 223740  1864 ?        S    17:28   0:00      \_ /nix/store/h3dwyhxyswzr8vkdchiqzdf7s8rlc4if-bash-5.1-p16/bin/bash /nix/store/wm1n86h1lqh605dzpg0j63dfa266nw0z-auto-fix-vscode-server.sh
petr         703  0.0  0.0   2788   280 ?        S    17:28   0:00          \_ inotifywait -q -m -e CREATE,ISDIR -e DELETE_SELF --format %w%f:%e /home/petr/.vscode-server/bin

bsh ❯ systemctl --user status
● nixos
    State: running
     Jobs: 0 queued
   Failed: 0 units
    Since: Fri 2022-11-25 17:28:19 CET; 28s ago
   CGroup: /user.slice/user-1000.slice/[email protected]
           ├─app.slice
           │ └─auto-fix-vscode-server.service
           │   ├─ 595 /nix/store/h3dwyhxyswzr8vkdchiqzdf7s8rlc4if-bash-5.1-p16/bin/bash /nix/store/wm1n86h1lqh605dzpg0j63dfa266nw0z-auto-fix-vscode-server.sh
           │   ├─ 702 /nix/store/h3dwyhxyswzr8vkdchiqzdf7s8rlc4if-bash-5.1-p16/bin/bash /nix/store/wm1n86h1lqh605dzpg0j63dfa266nw0z-auto-fix-vscode-server.sh
           │   └─ 703 inotifywait -q -m -e CREATE,ISDIR -e DELETE_SELF --format %w%f:%e /home/petr/.vscode-server/bin
           └─init.scope
             ├─ 552 /nix/store/9xmrmm20hhil0yha82zh58wxpfy68gxh-systemd-250.8/lib/systemd/systemd --user
             └─ 555 "(sd-pam)"

@psvo psvo force-pushed the setup-login-for-native-systemd branch from 55cf45b to c30c2b7 Compare November 25, 2022 16:35
@K900
Copy link
Contributor

K900 commented Nov 25, 2022

r+ from me, tested working on 11 too.

When native systemd integration is enabled in WSL, it looks for
/bin/login to login the user.

It enables proper support for user session (dbus and systemd).
@psvo psvo force-pushed the setup-login-for-native-systemd branch from c30c2b7 to 778d1b8 Compare November 25, 2022 18:23
@nzbr nzbr merged commit 08e2cf0 into nix-community:main Nov 25, 2022
@psvo psvo deleted the setup-login-for-native-systemd branch November 25, 2022 18:46
@nzbr nzbr added the bug Something isn't working label Dec 14, 2022
@nzbr nzbr changed the title Setup /bin/login for native systemd support fix: setup /bin/login for native systemd support Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants