chiark / gitweb /
Classify processes from sessions into cgroups
[elogind.git] / src / libelogind / sd-bus / bus-creds.c
index cd1c5e232ad07a35301d1302623605a658801761..aea379d669b9c9e905b77ace228291457aa81401 100644 (file)
@@ -358,8 +358,6 @@ _public_ int sd_bus_creds_get_cgroup(sd_bus_creds *c, const char **ret) {
 }
 
 _public_ int sd_bus_creds_get_unit(sd_bus_creds *c, const char **ret) {
-        int r;
-
         assert_return(c, -EINVAL);
         assert_return(ret, -EINVAL);
 
@@ -368,25 +366,14 @@ _public_ int sd_bus_creds_get_unit(sd_bus_creds *c, const char **ret) {
 
         assert(c->cgroup);
 
-        if (!c->unit) {
-                const char *shifted;
-
-                r = cg_shift_path(c->cgroup, c->cgroup_root, &shifted);
-                if (r < 0)
-                        return r;
-
-                r = cg_path_get_unit(shifted, (char**) &c->unit);
-                if (r < 0)
-                        return r;
-        }
+        if (!c->unit)
+                return -ESRCH;
 
         *ret = c->unit;
         return 0;
 }
 
 _public_ int sd_bus_creds_get_user_unit(sd_bus_creds *c, const char **ret) {
-        int r;
-
         assert_return(c, -EINVAL);
         assert_return(ret, -EINVAL);
 
@@ -395,25 +382,14 @@ _public_ int sd_bus_creds_get_user_unit(sd_bus_creds *c, const char **ret) {
 
         assert(c->cgroup);
 
-        if (!c->user_unit) {
-                const char *shifted;
-
-                r = cg_shift_path(c->cgroup, c->cgroup_root, &shifted);
-                if (r < 0)
-                        return r;
-
-                r = cg_path_get_user_unit(shifted, (char**) &c->user_unit);
-                if (r < 0)
-                        return r;
-        }
+        if (!c->user_unit)
+                return -ESRCH;
 
         *ret = c->user_unit;
         return 0;
 }
 
 _public_ int sd_bus_creds_get_slice(sd_bus_creds *c, const char **ret) {
-        int r;
-
         assert_return(c, -EINVAL);
         assert_return(ret, -EINVAL);
 
@@ -422,17 +398,8 @@ _public_ int sd_bus_creds_get_slice(sd_bus_creds *c, const char **ret) {
 
         assert(c->cgroup);
 
-        if (!c->slice) {
-                const char *shifted;
-
-                r = cg_shift_path(c->cgroup, c->cgroup_root, &shifted);
-                if (r < 0)
-                        return r;
-
-                r = cg_path_get_slice(shifted, (char**) &c->slice);
-                if (r < 0)
-                        return r;
-        }
+        if (!c->slice)
+                return -ESRCH;
 
         *ret = c->slice;
         return 0;
@@ -481,7 +448,7 @@ _public_ int sd_bus_creds_get_owner_uid(sd_bus_creds *c, uid_t *uid) {
         if (r < 0)
                 return r;
 
-        return cg_path_get_owner_uid(shifted, uid);
+        return -ESRCH;
 }
 
 _public_ int sd_bus_creds_get_cmdline(sd_bus_creds *c, char ***cmdline) {