Repository navigation
Closed
Labels
Description
systemd version the issue has been seen with
systend-258.devel.r80793.5d902cc21f8-1
Used distribution
Archlinux (WSL)
Linux kernel version used
6.6.84.1-microsoft-standard-WSL2
CPU architectures issue was seen on
x86_64
Component
systemd-run
Expected behaviour you didn't see
When running inside WSL run0 should bring up a shell as the root user. run0 echo hello should run the specified command as root user.
Unexpected behaviour you saw
Both run0 and run0 echo hello fail to run and exit with the error message (similar message for systemctl enable as non-root):
[nekko@wsl ~]$ run0
Failed to start transient service unit: Interactive authentication required.
Testing both commands with pkexec instead of run0 the results are as expected (root shell and run command as root, tested by installing packages).
[nekko@wsl ~]$ pkexec
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ====
Authentication is needed to run `/usr/bin/bash' as the super user
Authenticating as: nekko
Password:
==== AUTHENTICATION COMPLETE ====
[root@wsl ~]# exit
Steps to reproduce the problem
- Install a WSL distro with new enough systemd for
run0(confirmed this appears on both Arch and Fedora installs) - Run
run0 echo helloas an unpriviledged user in thewheelgroup
Additional program output to the terminal or log subsystem illustrating the issue
[nekko@wsl ~]$ SYSTEMD_LOG_LEVEL=debug run0
Using pty stdio mode.
Setting XDG_SESSION_CLASS to 'user-early-light'.
Bus n/a: changing state UNSET → OPENING
sd-bus: starting bus by connecting to /run/dbus/system_bus_socket...
Bus n/a: changing state OPENING → AUTHENTICATING
Successfully forked off '(polkit-agent)' as PID 891.
Skipping PR_SET_MM, as we don't have privileges.
Successfully forked off '(sd-askpwagent)' as PID 896.
Failed to acquire pidfd ID of myself, defaulting to randomized unit name: Operation not supported
Skipping PR_SET_MM, as we don't have privileges.
Bus n/a: changing state AUTHENTICATING → HELLO
Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=Hello cookie=1 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a
Got message type=method_return sender=org.freedesktop.DBus destination=:1.64 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=1 signature=s error-name=n/a error-message=n/a
Bus n/a: changing state HELLO → RUNNING
Sent message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=StartTransientUnit cookie=2 reply_cookie=0 signature=ssa(sv)a(sa(sv)) error-name=n/a error-message=n/a
Failed to open /run/systemd/ask-password-block/136:0: Permission denied
Got message type=error sender=:1.2 destination=:1.64 path=n/a interface=n/a member=n/a cookie=3390 reply_cookie=2 signature=s error-name=org.freedesktop.DBus.Error.InteractiveAuthorizationRequired error-message=Interactive authentication required.
Failed to start transient service unit: Interactive authentication required.
Bus n/a: changing state RUNNING → CLOSED
Activity
poettering commentedon Apr 16, 2025
my educated guess is that wsl doesn't register a pam session properly, hence pk's agent logic cannot work.
please contact wsl for help about this, systemd cannot do anything about it.
septatrix commentedon Apr 16, 2025
A quick
loginctlcould confirm that.My question then would be why
pkexecdoes work?NekkoDroid commentedon Apr 16, 2025
For completeness sake here is
loginctls output:(
ttygives me/dev/pts/2)arvidjaar commentedon Apr 16, 2025
Which does not change with additional terminals logons or even if I close everything and open new terminal session. So, the listed sessions really do not have anything to do with your actual terminal session.
NekkoDroid commentedon Apr 16, 2025
Yea, I didn't exactly think it did, hense for completeness sake. To my knowledge WSL actually doesn't actually do full logins for the shells, but instead just spawns them as the user :/
Looking at the process tree I get roughtly the following:
So it seems the actual logon is just somewhere lost in the aether
(Seems there is already an open ticket for the login shell on the WSL repo microsoft/WSL#9213)
arvidjaar commentedon Apr 16, 2025
Using example from this issue:
NekkoDroid commentedon Apr 16, 2025
Weird, since those same steps also just fail with the same problem I originally encountered when run on Arch, but not when I run it on Fedora.
When looking into the differences for the PAM config I noticed that
pam_systemd.sois part of Fedora's, while it isn't for Arch onlypam_systemd_home.so(insystem-auth). Manually adding it seems to allow the workaround to function.I'll bring this up on the Arch bug tracker. Thanks for getting me (at least partially) on the right track.
YHNdnzj commentedon Apr 16, 2025
pam_systemd.sois intentionally left out there IIUC. It was a deliberate choice that only actual "login" stacks get a session, but not sudo ones (unlike run0 that's forked off from pid1, sudo acquires privilege via suid, so IMO that behavior makes more sense)And as you noted already, it's a workaround that involves a new session, which doesn't resolve the original problem about the startup session not being set up properly in WSL. I don't think there's anything actionable for Arch.
greyltc commentedon Jun 18, 2025
@poettering @YHNdnzj
$ pkexec --user rootworks as expected though:So wouldn't that suggest that polkit (via PAM) is not the issue here?
arvidjaar commentedon Jun 18, 2025
pkexecregisters internal polkit agent which directly gets authentication request.run0invokespkttyagent --fallback. In this casepolkitattempts first to find "better" agent registered for the user session. If it cannot get session it bails out.To have valid session user needs to go via PAM
pam_systemd.I suppose
run0could mimicpkexecwhich first attempts to start the given program and ifpolkitresponds with "authentication required" (meaning - no other agent was found) thenpkexecregisters its own internal agent and repeats request.greyltc commentedon Jun 19, 2025
Why should it bail out? It clearly has the capability to authenticate the user in this environment (see pkexec). Is this a polkit bug then? Of course in addition to microsoft's PAM bug, microsoft/WSL#9213, but that bug is now several years old with seemingly zero attention from microsoft, who knows if it's ever going to be addressed.
polkit's job here is to authenticate the user. If something is screwed up with PAM that stops it from working normally, shouldn't it then try the approach it uses in the
pkexeccase?By the way, I see what you mean with pkexec's internal agent:
arvidjaar commentedon Jun 19, 2025
Whether it is intentional or not needs to be discussed with
polkitfolks. I believe it is not and should be fixed to actually fall back to--fallbackagent.https://github.com/polkit-org/polkit/blob/f506138c71a17ac99bfaa9c3414dad698f93428b/src/polkitbackend/polkitbackendinteractiveauthority.c#L1775-L1779
I think so. Care to open
polkitissue?greyltc commentedon Jun 19, 2025
Could it be that in this case polkit won't have/know the details needed to actually read and write to the same terminal that run0 was invoked from to do the authentication?
(in which case, maybe what you said before is true: systemd could then set up an internal polkit agent to do the auth in the local terminal in the case when the first try, asking polkit over dbus, fails due to screwed up/missing PAM environment)