chiark / gitweb /
man: document a batch of bus functions
[elogind.git] / src / libsystemd-bus / bus-control.c
index 1eed7b9e320952036e3f78899cd65d635381717d..e7e9ba07b0a4f5bab1681f1036624cf9ee5415f0 100644 (file)
@@ -33,6 +33,7 @@
 #include "bus-control.h"
 #include "bus-bloom.h"
 #include "bus-util.h"
+#include "cgroup-util.h"
 
 _public_ int sd_bus_get_unique_name(sd_bus *bus, const char **unique) {
         int r;
@@ -407,17 +408,25 @@ static int bus_get_owner_kdbus(
                 switch (item->type) {
 
                 case KDBUS_ITEM_CREDS:
-                        m = (SD_BUS_CREDS_UID | SD_BUS_CREDS_GID | SD_BUS_CREDS_PID |
-                             SD_BUS_CREDS_TID | SD_BUS_CREDS_PID_STARTTIME) & mask;
+                        m = (SD_BUS_CREDS_UID | SD_BUS_CREDS_GID | SD_BUS_CREDS_PID) & mask;
 
                         if (m) {
-                                c->uid = item->creds.uid;
-                                c->pid = item->creds.pid;
-                                c->gid = item->creds.gid;
-                                c->tid = item->creds.tid;
-                                c->pid_starttime = item->creds.starttime;
+                                c->uid = (uid_t) item->creds.uid;
+                                c->pid = (pid_t) item->creds.pid;
+                                c->gid = (gid_t) item->creds.gid;
                                 c->mask |= m;
                         }
+
+                        if (mask & SD_BUS_CREDS_TID && item->creds.tid > 0) {
+                                c->tid = (pid_t) item->creds.tid;
+                                c->mask |= SD_BUS_CREDS_TID;
+                        }
+
+                        if (mask & SD_BUS_CREDS_PID_STARTTIME && item->creds.starttime > 0) {
+                                c->pid_starttime = item->creds.starttime;
+                                c->mask |= SD_BUS_CREDS_PID_STARTTIME;
+                        }
+
                         break;
 
                 case KDBUS_ITEM_PID_COMM:
@@ -481,6 +490,18 @@ static int bus_get_owner_kdbus(
                                         goto fail;
                                 }
 
+                                if (!bus->cgroup_root) {
+                                        r = cg_get_root_path(&bus->cgroup_root);
+                                        if (r < 0)
+                                                goto fail;
+                                }
+
+                                c->cgroup_root = strdup(bus->cgroup_root);
+                                if (!c->cgroup_root) {
+                                        r = -ENOMEM;
+                                        goto fail;
+                                }
+
                                 c->mask |= m;
                         }
                         break;