Skip to content

run0: implement sudo options -k/-K/-v#42465

Open
rpigott wants to merge 3 commits into
systemd:mainfrom
rpigott:run-revoke-tmp
Open

run0: implement sudo options -k/-K/-v#42465
rpigott wants to merge 3 commits into
systemd:mainfrom
rpigott:run-revoke-tmp

Conversation

@rpigott
Copy link
Copy Markdown
Contributor

@rpigott rpigott commented Jun 4, 2026

This implements a close facsimile of sudo's -k/-K/-v options, which manipulate the temporary authorizations used by sudo. Use like run0 -k whoami to always re-auth, or just run0 -k to revoke a prior temporary authorization.

Depends on polkit-org/polkit#662 due to a bug in polkit. Now it should work ok despite the bug.

@github-actions github-actions Bot added run please-review PR is ready for (re-)review by a maintainer labels Jun 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

Claude review: no issues found 🎉

Workflow run

Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
@github-actions github-actions Bot added documentation shell completion please-review PR is ready for (re-)review by a maintainer and removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Jun 4, 2026
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
@rpigott rpigott force-pushed the run-revoke-tmp branch 2 times, most recently from 11aa7d0 to 9076174 Compare June 4, 2026 20:48
@rpigott
Copy link
Copy Markdown
Contributor Author

rpigott commented Jun 4, 2026

Now -v doesn't accept subsequent commands and will exit with a failure status if the user fails to auth successfully. That's more like sudo.

Also added a new commit introducing -n/--non-interactive that are just aliases for --no-ask-password. Those are the flags sudo uses, and now -v respects the ask_password flag, so you can do run0 -nv to check if you're already authorized without a prompt, similar to sudo -nv.

There is a bit of an odd behavior if there is no polkit agent running — polkit refuses to revoke the surrogate temporary authorization from the old unix-process subject granted using pkttyagent. I'm not sure if there's anything too interesting to do about that from our side and in fact maybe polkit really should just allow this to be revoked. I think I'll take the discussion there.

E.g. w/ pkttyagent:

$ ARGV0=run0 ./build/systemd-run -v
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to manage system services or other units.
Authenticating as: rpigott
Password: 
==== AUTHENTICATION COMPLETE ====
$ ARGV0=run0 ./build/systemd-run -k
Failed to revoke temporary authorization tmpauthz19: Cannot remove a temporary authorization belonging to another subject.

Comment thread src/run/run.c Outdated
Comment thread src/run/run.c
Comment thread src/run/run.c Outdated
Comment thread src/run/run.c Outdated
Comment thread man/run0.xml Outdated
Comment thread src/run/run.c
Comment thread src/run/run.c Outdated
@rpigott rpigott force-pushed the run-revoke-tmp branch 2 times, most recently from 4bb1968 to a82db28 Compare June 4, 2026 22:55
Comment thread man/run0.xml Outdated
Comment thread src/run/run.c
Comment thread shell-completion/bash/run0 Outdated
rpigott added 3 commits June 4, 2026 16:25
This is meant to mirror sudo's -k/--reset-timestamp and
-K/--remove-timestamp options, which revoke the temporary authorization
provided by the timestamp files in /var/run/sudo/ts.

To achieve the same effect in run0, we ask polkit to revoke our
temporary authorization. If used with a command, run0 will revoke the
temporary auth and then immediately authorize the user again, just like
sudo -k. All the bus calls are completed synchronously, as they need to
complete before authorizing the user anyway.

Like sudo, the effect of -k/--reset-timestamp is to revoke only the
tmpauthz that polkit would have used to authorize the command, if
available. The -K/--remove-timestamp option will revoke all temporary
authorizations across all ttys.
This is meant to mirror sudo's -v/--validate options, which autohrize
the user without running a command.
These are the flag names used by sudo with similar effect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants