Open allisonkarlitskaya opened 1 year ago
This information actually is part of the polkit agent protocol. polkitd sends the agent a list of possible "admin" identities, e.g. like this on my system:
[('unix-user', {'uid': systemd_ctypes.Variant(1001, 'u')}), ('unix-user', {'uid': systemd_ctypes.Variant(1000, 'u')})]
The agent can use this to implement a selector, and let the user choose which admin user to authenticate as. Of course this requires quite some UI plumbing (including a possible fallback from sudo to polkit), but it seems possible in principle.
The problem
I am logged in to cockpit on a Silverblue machine with account (
lis
) that's not inwheel
. I see the "Limited access" button at the top. I know the password to theadmin
account (which is inwheel
) and I'm used to being prompted for this when I'm using GNOME.I press "Limited access" expecting that I will be asked for
admin
's password.Instead, I get asked for my own password in a futile attempt to use
sudo
.In some sense this is reasonable. Cockpit has no way to know that I'm not in the sudoers file. It could find out, however, that
pkexec
is possible for my situation.The desired solution
In a situation where it might be possible for a non-admin user to get admin access via entering the password of another user who does have the access (a common polkit configuration) then this should be presented as an option when clicking "Limited access".
This should not come at the cost of preventing access to sudo via the user's own password, unless we can definitively rule out sudo as being possible, given the right password (which I think isn't possible).
Feasibility research
Frustratingly, trying to execute
pkexec
in the Terminal tab fails:Doing this via SSH looks more promising, but gets a different failure:
In both places, this relatively contorted alternative seems to work:
And we could detect if maybe this might be possible:
...and for the record, not that it's really very useful, but this works:
and (easier) this too:
In terms of convincing Cockpit to do the right thing, I tried creating an override in
~/.config/cockpit/shell.override.json
containingThat got me:
which isn't so nice. Knowing a little bit about this stuff, I decided that maybe adding a
"label":
field would help. It did, but not much:Further considerations
I thought it might be useful to be able to show the name of the user that we'd be trying to authenticate as as part of a potential future interaction with the user:
but it's very difficult to discover whose password polkit is going to request.
I poked around the D-Bus API and available commandline tools to try to get polkit to tell me about the users it might select. The default config on Fedora does that via
/etc/polkit-1/rules.d/50-default.rules
:Frustratingly, this file is not accessible to normal users, and I couldn't find any other way to access the information. There is a
pkla-admin-identities
as a compatibility shim for old the old-style rules, but it returns nothing on Fedora, since the config is via Javascript. There's also no guarantee that this tool would even be used, anyway, as part of the JS config.One option would be to attempt to initiate a pkexec authentication, catch it with the agent to check the username, then immediately cancel the interaction without a password attempt. That might have logging implications, and we've gotten in trouble with stuff like that in the past, but it might be worth looking into.
Another UI option that doesn't involve knowing the name of the admin user ahead of time and preserves the same UI flow (and number of clicks) for existing users of sudo might be something like:
and a local storage item to remember if you elected "other options" (and possibly also remember if it actually worked).