diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-08-22 18:48:03 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2020-08-24 19:48:26 +0200 |
commit | 73d3ac8e2440cda3b7f2310f329f0798de6c041c (patch) | |
tree | 2c0b703747602450361a5ded8916064f33a53364 /src/shared/bus-polkit.c | |
parent | 2b07ec316a0e25a3e10c270c7f6baee9e0187bf8 (diff) | |
download | systemd-73d3ac8e2440cda3b7f2310f329f0798de6c041c.tar.gz |
various: treat BUS_ERROR_NO_SUCH_UNIT the same as SD_BUS_ERROR_SERVICE_UNKNOWN
We return BUS_ERROR_NO_SUCH_UNIT a.k.a. org.freedesktop.systemd1.NoSuchUnit
in various places. In #16813:
Aug 22 06:14:48 core sudo[2769199]: pam_systemd_home(sudo:account): Failed to query user record: Unit dbus-org.freedesktop.home1.service not found.
Aug 22 06:14:48 core dbus-daemon[5311]: [system] Activation via systemd failed for unit 'dbus-org.freedesktop.home1.service': Unit dbus-org.freedesktop.home1.service not found.
Aug 22 06:14:48 core dbus-daemon[5311]: [system] Activating via systemd: service name='org.freedesktop.home1' unit='dbus-org.freedesktop.home1.service' requested by ':1.6564' (uid=0 pid=2769199 comm="sudo su ")
This particular error comes from bus_unit_validate_load_state() in pid1:
case UNIT_NOT_FOUND:
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not found.", u->id);
It seems possible that we should return a different error, but it doesn't really
matter: if we change pid1 to return a different error, we still need to handle
BUS_ERROR_NO_SUCH_UNIT as in this patch to handle pid1 with current code.
Diffstat (limited to 'src/shared/bus-polkit.c')
-rw-r--r-- | src/shared/bus-polkit.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/shared/bus-polkit.c b/src/shared/bus-polkit.c index 9b0a4552be..0722b1a118 100644 --- a/src/shared/bus-polkit.c +++ b/src/shared/bus-polkit.c @@ -3,6 +3,7 @@ #include "bus-internal.h" #include "bus-message.h" #include "bus-polkit.h" +#include "bus-util.h" #include "strv.h" #include "user-util.h" @@ -123,7 +124,7 @@ int bus_test_polkit( r = sd_bus_call(call->bus, request, 0, ret_error, &reply); if (r < 0) { /* Treat no PK available as access denied */ - if (sd_bus_error_has_name(ret_error, SD_BUS_ERROR_SERVICE_UNKNOWN)) { + if (bus_error_is_unknown_service(ret_error)) { sd_bus_error_free(ret_error); return -EACCES; } @@ -296,8 +297,7 @@ int bus_verify_polkit_async( e = sd_bus_message_get_error(q->reply); /* Treat no PK available as access denied */ - if (sd_bus_error_has_name(e, SD_BUS_ERROR_SERVICE_UNKNOWN) || - sd_bus_error_has_name(e, SD_BUS_ERROR_NAME_HAS_NO_OWNER)) + if (bus_error_is_unknown_service(e)) return -EACCES; /* Copy error from polkit reply */ |