return NULL;
}
+/// UNNEEDED by elogind
+#if 0
_public_ uint64_t sd_bus_creds_get_mask(const sd_bus_creds *c) {
assert_return(c, 0);
return c->mask;
}
+#endif // 0
_public_ uint64_t sd_bus_creds_get_augmented_mask(const sd_bus_creds *c) {
assert_return(c, 0);
return c;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_new_from_pid(sd_bus_creds **ret, pid_t pid, uint64_t mask) {
sd_bus_creds *c;
int r;
*ret = c;
return 0;
}
+#endif // 0
_public_ int sd_bus_creds_get_uid(sd_bus_creds *c, uid_t *uid) {
assert_return(c, -EINVAL);
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_get_suid(sd_bus_creds *c, uid_t *suid) {
assert_return(c, -EINVAL);
assert_return(suid, -EINVAL);
*gid = c->gid;
return 0;
}
+#endif // 0
_public_ int sd_bus_creds_get_egid(sd_bus_creds *c, gid_t *egid) {
assert_return(c, -EINVAL);
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_get_sgid(sd_bus_creds *c, gid_t *sgid) {
assert_return(c, -EINVAL);
assert_return(sgid, -EINVAL);
*gids = c->supplementary_gids;
return (int) c->n_supplementary_gids;
}
+#endif // 0
_public_ int sd_bus_creds_get_pid(sd_bus_creds *c, pid_t *pid) {
assert_return(c, -EINVAL);
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_get_ppid(sd_bus_creds *c, pid_t *ppid) {
assert_return(c, -EINVAL);
assert_return(ppid, -EINVAL);
if (!(c->mask & SD_BUS_CREDS_PPID))
return -ENODATA;
- /* PID 1 has no parent process. Let's distuingish the case of
+ /* PID 1 has no parent process. Let's distinguish the case of
* not knowing and not having a parent process by the returned
* error code. */
if (c->ppid == 0)
*ppid = c->ppid;
return 0;
}
+#endif // 0
_public_ int sd_bus_creds_get_tid(sd_bus_creds *c, pid_t *tid) {
assert_return(c, -EINVAL);
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_get_comm(sd_bus_creds *c, const char **ret) {
assert_return(c, -EINVAL);
assert_return(ret, -EINVAL);
}
_public_ int sd_bus_creds_get_unit(sd_bus_creds *c, const char **ret) {
+ int r;
+
assert_return(c, -EINVAL);
assert_return(ret, -EINVAL);
assert(c->cgroup);
- if (!c->unit)
- return -ESRCH;
+ 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;
+ }
*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);
assert(c->cgroup);
- if (!c->user_unit)
- return -ESRCH;
+ 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;
+ }
*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);
assert(c->cgroup);
- if (!c->slice)
- return -ESRCH;
+ 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;
+ }
*ret = c->slice;
return 0;
*ret = c->user_slice;
return 0;
}
+#endif // 0
_public_ int sd_bus_creds_get_session(sd_bus_creds *c, const char **ret) {
int r;
if (r < 0)
return r;
- return -ESRCH;
+ return cg_path_get_owner_uid(shifted, uid);
}
_public_ int sd_bus_creds_get_cmdline(sd_bus_creds *c, char ***cmdline) {
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_get_audit_session_id(sd_bus_creds *c, uint32_t *sessionid) {
assert_return(c, -EINVAL);
assert_return(sessionid, -EINVAL);
*sessionid = c->audit_session_id;
return 0;
}
+#endif // 0
_public_ int sd_bus_creds_get_audit_login_uid(sd_bus_creds *c, uid_t *uid) {
assert_return(c, -EINVAL);
return 0;
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_get_unique_name(sd_bus_creds *c, const char **unique_name) {
assert_return(c, -EINVAL);
assert_return(unique_name, -EINVAL);
*ret = c->unescaped_description;
return 0;
}
+#endif // 0
static int has_cap(sd_bus_creds *c, unsigned offset, int capability) {
size_t sz;
return has_cap(c, CAP_OFFSET_EFFECTIVE, capability);
}
+/// UNNEEDED by elogind
+#if 0
_public_ int sd_bus_creds_has_permitted_cap(sd_bus_creds *c, int capability) {
assert_return(c, -EINVAL);
assert_return(capability >= 0, -EINVAL);
return has_cap(c, CAP_OFFSET_BOUNDING, capability);
}
+#endif // 0
static int parse_caps(sd_bus_creds *c, unsigned offset, const char *p) {
size_t sz, max;
return 0;
/* Try to retrieve PID from creds if it wasn't passed to us */
- if (pid <= 0 && (c->mask & SD_BUS_CREDS_PID))
+ if (pid > 0) {
+ c->pid = pid;
+ c->mask |= SD_BUS_CREDS_PID;
+ } else if (c->mask & SD_BUS_CREDS_PID)
pid = c->pid;
-
- /* Without pid we cannot do much... */
- if (pid <= 0)
+ else
+ /* Without pid we cannot do much... */
return 0;
/* Try to retrieve TID from creds if it wasn't passed to us */
if (missing == 0)
return 0;
- c->pid = pid;
- c->mask |= SD_BUS_CREDS_PID;
-
if (tid > 0) {
c->tid = tid;
c->mask |= SD_BUS_CREDS_TID;
if (missing & SD_BUS_CREDS_EXE) {
r = get_process_exe(pid, &c->exe);
if (r == -ESRCH) {
- /* Unfortunately we cannot really distuingish
+ /* Unfortunately we cannot really distinguish
* the case here where the process does not
* exist, and /proc/$PID/exe being unreadable
* because $PID is a kernel thread. Hence,
}
/* In case only the exe path was to be read we cannot
- * distuingish the case where the exe path was unreadable
+ * distinguish the case where the exe path was unreadable
* because the process was a kernel thread, or when the
* process didn't exist at all. Hence, let's do a final check,
* to be sure. */