diff options
author | Lennart Poettering <lennart@poettering.net> | 2024-03-11 12:57:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-11 12:57:45 +0100 |
commit | 29556b75d8025580eebe160a1fa1459965912ee2 (patch) | |
tree | 9fe24bd2d823ce1f0e33ccbbbb7d8c76270a9649 /src/shared/bus-polkit.h | |
parent | basic: add PIDFS magic (#31709) (diff) | |
download | systemd-29556b75d8025580eebe160a1fa1459965912ee2.tar.xz systemd-29556b75d8025580eebe160a1fa1459965912ee2.zip |
polkit: turn "interactive" flag to polkit APIs into a proper flags field (#31715)
This adds for both the D-Bus and the Varlink flavours of our polkit
client api a flags parameter. And then folds the "bool interactive" flag
that the D-Bus version so far had, into a flag, and also adds support
for it in the Varlink API.
Since this means the Varlink API gained another parameter, let's do what
we already did for the D-Bus API and add a _full() version of the API
that has the flags and the good_uid parameter, and one without both.
Diffstat (limited to '')
-rw-r--r-- | src/shared/bus-polkit.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/shared/bus-polkit.h b/src/shared/bus-polkit.h index 0fe3a4ca0e..4e2c1d3551 100644 --- a/src/shared/bus-polkit.h +++ b/src/shared/bus-polkit.h @@ -7,14 +7,21 @@ #include "user-util.h" #include "varlink.h" +typedef enum PolkitFLags { + POLKIT_ALLOW_INTERACTIVE = 1 << 0, /* Allow interactive auth (typically not required, because can be derived from bus message/link automatically) */ +} PolkitFlags; + int bus_test_polkit(sd_bus_message *call, const char *action, const char **details, uid_t good_user, bool *_challenge, sd_bus_error *e); -int bus_verify_polkit_async_full(sd_bus_message *call, const char *action, const char **details, bool interactive, uid_t good_user, Hashmap **registry, sd_bus_error *error); +int bus_verify_polkit_async_full(sd_bus_message *call, const char *action, const char **details, uid_t good_user, PolkitFlags flags, Hashmap **registry, sd_bus_error *error); static inline int bus_verify_polkit_async(sd_bus_message *call, const char *action, const char **details, Hashmap **registry, sd_bus_error *ret_error) { - return bus_verify_polkit_async_full(call, action, details, false, UID_INVALID, registry, ret_error); + return bus_verify_polkit_async_full(call, action, details, UID_INVALID, 0, registry, ret_error); } -int varlink_verify_polkit_async(Varlink *link, sd_bus *bus, const char *action, const char **details, uid_t good_user, Hashmap **registry); +int varlink_verify_polkit_async_full(Varlink *link, sd_bus *bus, const char *action, const char **details, uid_t good_user, PolkitFlags flags, Hashmap **registry); +static inline int varlink_verify_polkit_async(Varlink *link, sd_bus *bus, const char *action, const char **details, Hashmap **registry) { + return varlink_verify_polkit_async_full(link, bus, action, details, UID_INVALID, 0, registry); +} /* A JsonDispatch initializer that makes sure the allowInteractiveAuthentication boolean field we want for * polkit support in Varlink calls is ignored while regular dispatching (and does not result in errors |