assert_return(pid >= 0, -EINVAL);
assert_return(unit, -EINVAL);
+/// elogind does not support systemd units
+#if 0
return cg_pid_get_unit(pid, unit);
+#else
+ return -ESRCH;
+#endif // 0
}
_public_ int sd_pid_get_user_unit(pid_t pid, char **unit) {
assert_return(pid >= 0, -EINVAL);
assert_return(unit, -EINVAL);
+/// elogind does not support systemd units
+#if 0
return cg_pid_get_user_unit(pid, unit);
+#else
+ return -ESRCH;
+#endif // 0
}
_public_ int sd_pid_get_machine_name(pid_t pid, char **name) {
assert_return(pid >= 0, -EINVAL);
assert_return(name, -EINVAL);
+/// elogind does not support systemd units
+#if 0
return cg_pid_get_machine_name(pid, name);
+#else
+ return -ESRCH;
+#endif // 0
}
_public_ int sd_pid_get_slice(pid_t pid, char **slice) {
assert_return(pid >= 0, -EINVAL);
assert_return(slice, -EINVAL);
+/// elogind does not support systemd slices
+#if 0
return cg_pid_get_slice(pid, slice);
+#else
+ return -ESRCH;
+#endif // 0
}
_public_ int sd_pid_get_user_slice(pid_t pid, char **slice) {
assert_return(pid >= 0, -EINVAL);
assert_return(slice, -EINVAL);
+/// elogind does not support systemd slices
+#if 0
return cg_pid_get_user_slice(pid, slice);
+#else
+ return -ESRCH;
+#endif // 0
}
_public_ int sd_pid_get_owner_uid(pid_t pid, uid_t *uid) {
assert_return(pid >= 0, -EINVAL);
assert_return(uid, -EINVAL);
+/// elogind does not support systemd slices
+#if 0
return cg_pid_get_owner_uid(pid, uid);
+#else
+ return -ESRCH;
+#endif // 0
+}
+
+_public_ int sd_pid_get_cgroup(pid_t pid, char **cgroup) {
+ char *c;
+ int r;
+
+ assert_return(pid >= 0, -EINVAL);
+ assert_return(cgroup, -EINVAL);
+
+ r = cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, pid, &c);
+ if (r < 0)
+ return r;
+
+ /* The internal APIs return the empty string for the root
+ * cgroup, let's return the "/" in the public APIs instead, as
+ * that's easier and less ambigious for people to grok. */
+ if (isempty(c)) {
+ free(c);
+ c = strdup("/");
+ if (!c)
+ return -ENOMEM;
+
+ }
+
+ *cgroup = c;
+ return 0;
}
_public_ int sd_peer_get_session(int fd, char **session) {
if (r < 0)
return r;
+/// elogind does not support systemd scopes
+#if 0
return cg_pid_get_session(ucred.pid, session);
+#else
+ return -ESRCH;
+#endif // 0
}
_public_ int sd_peer_get_owner_uid(int fd, uid_t *uid) {
if (r < 0)
return r;
+/// elogind does not support systemd units
+#if 0
return cg_pid_get_owner_uid(ucred.pid, uid);
+#else
+ return -ESRCH;
+#endif // 0
}
_public_ int sd_peer_get_unit(int fd, char **unit) {
if (r < 0)
return r;
+/// elogind does not support systemd units
+#if 0
return cg_pid_get_unit(ucred.pid, unit);
+#else
+ return -ESRCH;
+#endif // 0
}
_public_ int sd_peer_get_user_unit(int fd, char **unit) {
if (r < 0)
return r;
+/// elogind does not support systemd units
+#if 0
return cg_pid_get_user_unit(ucred.pid, unit);
+#else
+ return -ESRCH;
+#endif // 0
}
_public_ int sd_peer_get_machine_name(int fd, char **machine) {
if (r < 0)
return r;
+/// elogind does not support systemd units
+#if 0
return cg_pid_get_machine_name(ucred.pid, machine);
+#else
+ return -ESRCH;
+#endif // 0
}
_public_ int sd_peer_get_slice(int fd, char **slice) {
if (r < 0)
return r;
+/// elogind does not support systemd slices
+#if 0
return cg_pid_get_slice(ucred.pid, slice);
+#else
+ return -ESRCH;
+#endif // 0
}
_public_ int sd_peer_get_user_slice(int fd, char **slice) {
if (r < 0)
return r;
+/// elogind does not support systemd slices
+#if 0
return cg_pid_get_user_slice(ucred.pid, slice);
+#else
+ return -ESRCH;
+#endif // 0
+}
+
+_public_ int sd_peer_get_cgroup(int fd, char **cgroup) {
+ struct ucred ucred;
+ int r;
+
+ assert_return(fd >= 0, -EBADF);
+ assert_return(cgroup, -EINVAL);
+
+ r = getpeercred(fd, &ucred);
+ if (r < 0)
+ return r;
+
+ return sd_pid_get_cgroup(ucred.pid, cgroup);
}
static int file_of_uid(uid_t uid, char **p) {
if (!filename_is_valid(seat))
return -EINVAL;
- p = strappend("/run/systemd/seats/", seat);
+ p = strappend("/run/systemd/seats/", seat);
} else {
_cleanup_free_ char *buf = NULL;
r = parse_env_file(p, NEWLINE, variable, &s, NULL);
if (r == -ENOENT || (r >= 0 && isempty(s))) {
- if (array)
- *array = NULL;
- return 0;
- }
+ if (array)
+ *array = NULL;
+ return 0;
+ }
if (r < 0)
return r;
return r;
if (session && !s)
- return -ENOENT;
+ return -ENODATA;
if (uid && !t)
- return -ENOENT;
+ return -ENODATA;
if (uid && t) {
r = parse_uid(t, uid);