return cg_path_get_session(cgroup, session);
}
-#if 0 /// UNNEEDED by elogind
int cg_path_get_owner_uid(const char *path, uid_t *uid) {
+#if 0 /// elogind does not support systemd slices
_cleanup_free_ char *slice = NULL;
char *start, *end;
int r;
return -ENXIO;
return 0;
+#else
+ _cleanup_free_ char *p = NULL, *s = NULL;
+ char *start;
+ int r;
+
+ assert(path);
+
+ /* Basically this is a simple session->uid mapping here.
+ The path argument will be something like "/<session id>"
+ and that is something we can map.
+ */
+
+ start = startswith(path, "/");
+ if (start)
+ p = strappend("/run/systemd/sessions/", start);
+ else
+ p = strappend("/run/systemd/sessions/", path);
+
+ r = parse_env_file(p, NEWLINE, "UID", &s, NULL);
+ if (r == -ENOENT)
+ return -ENXIO;
+ if (r < 0)
+ return r;
+ if (isempty(s))
+ return -EIO;
+
+ return parse_uid(s, uid);
+#endif // 0
}
int cg_pid_get_owner_uid(pid_t pid, uid_t *uid) {
return cg_path_get_owner_uid(cgroup, uid);
}
+#if 0 /// UNNEEDED by elogind
int cg_path_get_slice(const char *p, char **slice) {
const char *e = NULL;
int cg_get_root_path(char **path);
int cg_path_get_session(const char *path, char **session);
-#if 0 /// UNNEEDED by elogind
int cg_path_get_owner_uid(const char *path, uid_t *uid);
+#if 0 /// UNNEEDED by elogind
int cg_path_get_unit(const char *path, char **unit);
int cg_path_get_user_unit(const char *path, char **unit);
int cg_path_get_machine_name(const char *path, char **machine);
int cg_pid_get_path_shifted(pid_t pid, const char *cached_root, char **cgroup);
int cg_pid_get_session(pid_t pid, char **session);
-#if 0 /// UNNEEDED by elogind
int cg_pid_get_owner_uid(pid_t pid, uid_t *uid);
+#if 0 /// UNNEEDED by elogind
int cg_pid_get_unit(pid_t pid, char **unit);
int cg_pid_get_user_unit(pid_t pid, char **unit);
int cg_pid_get_machine_name(pid_t pid, char **machine);
}
_public_ int sd_pid_get_owner_uid(pid_t pid, uid_t *uid) {
-#if 0 /// UNNEEDED by elogind
int r;
-#endif // 0
assert_return(pid >= 0, -EINVAL);
assert_return(uid, -EINVAL);
-#if 0 /// elogind does not support systemd slices
r = cg_pid_get_owner_uid(pid, uid);
return IN_SET(r, -ENXIO, -ENOMEDIUM) ? -ENODATA : r;
-#else
- return -ESRCH;
-#endif // 0
}
_public_ int sd_pid_get_cgroup(pid_t pid, char **cgroup) {