From aa56560dbbd485e61fb527214a5211d4b683b3e8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 21 Dec 2013 18:21:49 +0100 Subject: bus: when client asks driverd for credentials of a name, return a useful error if that name doesn't exist on the bus --- src/bus-driverd/bus-driverd.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/bus-driverd') diff --git a/src/bus-driverd/bus-driverd.c b/src/bus-driverd/bus-driverd.c index 61491a34d9..0fff698e95 100644 --- a/src/bus-driverd/bus-driverd.c +++ b/src/bus-driverd/bus-driverd.c @@ -377,6 +377,8 @@ static int driver_get_security_ctx(sd_bus *bus, sd_bus_message *m, void *userdat assert_return(service_name_is_valid(arg0), -EINVAL); r = sd_bus_get_owner(bus, arg0, SD_BUS_CREDS_SELINUX_CONTEXT, &creds); + if (r == -ENOENT) + return sd_bus_error_setf(error, SD_BUS_ERROR_NAME_HAS_NO_OWNER, "Name %s is currently not owned by anyone.", arg0); if (r < 0) return r; @@ -403,6 +405,8 @@ static int driver_get_pid(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus assert_return(service_name_is_valid(arg0), -EINVAL); r = sd_bus_get_owner(bus, arg0, SD_BUS_CREDS_PID, &creds); + if (r == -ENOENT) + return sd_bus_error_setf(error, SD_BUS_ERROR_NAME_HAS_NO_OWNER, "Name %s is currently not owned by anyone.", arg0); if (r < 0) return r; @@ -421,6 +425,8 @@ static int driver_get_user(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu assert_return(service_name_is_valid(arg0), -EINVAL); r = sd_bus_get_owner(bus, arg0, SD_BUS_CREDS_UID, &creds); + if (r == -ENOENT) + return sd_bus_error_setf(error, SD_BUS_ERROR_NAME_HAS_NO_OWNER, "Name %s is currently not owned by anyone.", arg0); if (r < 0) return r; @@ -451,6 +457,8 @@ static int driver_get_name_owner(sd_bus *bus, sd_bus_message *m, void *userdata, assert_return(service_name_is_valid(arg0), -EINVAL); r = sd_bus_get_owner(bus, arg0, SD_BUS_CREDS_UNIQUE_NAME, &creds); + if (r == -ENOENT) + return sd_bus_error_setf(error, SD_BUS_ERROR_NAME_HAS_NO_OWNER, "Name %s is currently not owned by anyone.", arg0); if (r < 0) return r; -- cgit v1.2.3-54-g00ecf