polkit: simplify bus_verify_polkit_async() + drop auth-by-cap dbus feature
This simplifies bus_verify_polkit_async() and related calls quite a bit: 1. This removes any support for authentication-by-Linux-capability. This is ultimately a kdbus leftover: with classic AF_UNIX transports we cannot authenticate by capabilities securely (because we cannot acquire it from the peer without races), hence we never actually did. Since the necessary kernel work didn't materialize in the last 10y, and is unlikely to be added, let's just kill this context. We cannot quite remove the caps stuff from sd-bus for API compat, but for our polkit logic let's kill it. 2. The "good_uid" and "interactive" params are only necessary in very few cases, hence let's move them to a new call bus_verify_polkit_async_full() and make bus_verify_polkit_async() a wrapper around it without those two parameters. This also fixes a bunch of wrong uses of the "interactive" bool. The bool makes no sense today as the ALLOW_INTERACTIVE_AUTHORIZATION field in the D-Bus message header replaces it fully. We only need it to implement method calls we introduced prior to that header field becoming available in D-Bus. And it should only be used on such old method calls, and otherwise always be set to false. This does not change behaviour in any way. Just simplifies stuff. Fixes: #21586
This commit is contained in:
committed by
Yu Watanabe
parent
207aafe7e1
commit
7b36fb9f96
@@ -102,7 +102,6 @@ static int bus_message_new_polkit_auth_call(
|
||||
|
||||
int bus_test_polkit(
|
||||
sd_bus_message *call,
|
||||
int capability,
|
||||
const char *action,
|
||||
const char **details,
|
||||
uid_t good_user,
|
||||
@@ -120,7 +119,7 @@ int bus_test_polkit(
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = sd_bus_query_sender_privilege(call, capability);
|
||||
r = sd_bus_query_sender_privilege(call, -1);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0)
|
||||
@@ -465,12 +464,11 @@ static int async_polkit_query_check_action(
|
||||
* <- async_polkit_defer(q)
|
||||
*/
|
||||
|
||||
int bus_verify_polkit_async(
|
||||
int bus_verify_polkit_async_full(
|
||||
sd_bus_message *call,
|
||||
int capability,
|
||||
const char *action,
|
||||
const char **details,
|
||||
bool interactive,
|
||||
bool interactive, /* Use only for legacy method calls that have a separate "allow_interactive_authentication" field */
|
||||
uid_t good_user,
|
||||
Hashmap **registry,
|
||||
sd_bus_error *ret_error) {
|
||||
@@ -499,7 +497,7 @@ int bus_verify_polkit_async(
|
||||
}
|
||||
#endif
|
||||
|
||||
r = sd_bus_query_sender_privilege(call, capability);
|
||||
r = sd_bus_query_sender_privilege(call, -1);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0)
|
||||
|
||||
@@ -4,8 +4,13 @@
|
||||
#include "sd-bus.h"
|
||||
|
||||
#include "hashmap.h"
|
||||
#include "user-util.h"
|
||||
|
||||
int bus_test_polkit(sd_bus_message *call, int capability, const char *action, const char **details, uid_t good_user, bool *_challenge, sd_bus_error *e);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
int bus_verify_polkit_async(sd_bus_message *call, int capability, const char *action, const char **details, bool interactive, uid_t good_user, Hashmap **registry, sd_bus_error *error);
|
||||
Hashmap *bus_verify_polkit_async_registry_free(Hashmap *registry);
|
||||
|
||||
Reference in New Issue
Block a user