summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/sd-bus.c
diff options
context:
space:
mode:
authorDaniel Mack <daniel@zonque.org>2014-10-22 19:43:09 +0200
committerDaniel Mack <daniel@zonque.org>2014-10-22 19:45:07 +0200
commit8f44e3ea3e0821625e584938e54623e7fb381bb8 (patch)
tree1a91bf18cf0d57760d0d1a71be46ff287cfc60cc /src/libsystemd/sd-bus/sd-bus.c
parent056f95d0a70413e10e4a4ea9966baabb5a1450ed (diff)
sd-bus: implement sd_bus_get_owner_creds() for kdbus
kdbus learned a new ioctl to tell userspace about a bus creator's credentials, which is what we need to implement sd_bus_get_owner_creds() for kdbus. Move the function from sd-bus.c to bus-control.c to be able to reuse the bus_populate_creds_from_items() helper.
Diffstat (limited to 'src/libsystemd/sd-bus/sd-bus.c')
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c51
1 files changed, 0 insertions, 51 deletions
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 9ec15658df..f3796175cc 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -3300,57 +3300,6 @@ _public_ int sd_bus_path_decode(const char *path, const char *prefix, char **ext
return 1;
}
-_public_ int sd_bus_get_owner_creds(sd_bus *bus, uint64_t mask, sd_bus_creds **ret) {
- sd_bus_creds *c;
- pid_t pid = 0;
- int r;
-
- assert_return(bus, -EINVAL);
- assert_return(mask <= _SD_BUS_CREDS_ALL, -ENOTSUP);
- assert_return(ret, -EINVAL);
- assert_return(!bus_pid_changed(bus), -ECHILD);
-
- if (bus->is_kernel)
- return -ENOTSUP;
-
- if (!BUS_IS_OPEN(bus->state))
- return -ENOTCONN;
-
- if (!bus->ucred_valid && !isempty(bus->label))
- return -ENODATA;
-
- c = bus_creds_new();
- if (!c)
- return -ENOMEM;
-
- if (bus->ucred_valid) {
- pid = c->pid = bus->ucred.pid;
- c->uid = bus->ucred.uid;
- c->gid = bus->ucred.gid;
-
- c->mask |= (SD_BUS_CREDS_UID | SD_BUS_CREDS_PID | SD_BUS_CREDS_GID) & mask;
- }
-
- if (!isempty(bus->label) && (mask & SD_BUS_CREDS_SELINUX_CONTEXT)) {
- c->label = strdup(bus->label);
- if (!c->label) {
- sd_bus_creds_unref(c);
- return -ENOMEM;
- }
-
- c->mask |= SD_BUS_CREDS_SELINUX_CONTEXT;
- }
-
- r = bus_creds_add_more(c, mask, pid, 0);
- if (r < 0) {
- sd_bus_creds_unref(c);
- return r;
- }
-
- *ret = c;
- return 0;
-}
-
_public_ int sd_bus_try_close(sd_bus *bus) {
int r;