run0: implement -k/-K to revoke temporary auth

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 commit is contained in:
Ronan Pigott
2026-06-20 09:55:02 +01:00
committed by Luca Boccassi
parent 075036f205
commit 78b53d0132
4 changed files with 340 additions and 1 deletions
+1
View File
@@ -38,6 +38,7 @@ _run0() {
--setenv --background
)
local OPTS="${opts_with_values[*]} -h --help -V --version --no-ask-password --slice-inherit --empower"
OPTS="$OPTS -k --reset-timestamp -K --remove-timestamp"
local i
for (( i=1; i <= COMP_CWORD; i++ )); do