chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bus: add generator that turns old dbus1 activation files into .busname + .service...
[elogind.git]
/
src
/
shared
/
cgroup-util.c
diff --git
a/src/shared/cgroup-util.c
b/src/shared/cgroup-util.c
index 4e0211a7a04758c12c292064020c476972b81509..88bc33e3d55c21e6da797a1ec30c77476ecc852e 100644
(file)
--- a/
src/shared/cgroup-util.c
+++ b/
src/shared/cgroup-util.c
@@
-1337,36
+1337,41
@@
int cg_pid_get_session(pid_t pid, char **session) {
int cg_path_get_owner_uid(const char *path, uid_t *uid) {
_cleanup_free_ char *slice = NULL;
int cg_path_get_owner_uid(const char *path, uid_t *uid) {
_cleanup_free_ char *slice = NULL;
- const char *
e
;
+ const char *
start, *end
;
char *s;
char *s;
+ uid_t u;
int r;
assert(path);
int r;
assert(path);
- assert(uid);
r = cg_path_get_slice(path, &slice);
if (r < 0)
return r;
r = cg_path_get_slice(path, &slice);
if (r < 0)
return r;
-
e
= startswith(slice, "user-");
- if (!
e
)
+
start
= startswith(slice, "user-");
+ if (!
start
)
return -ENOENT;
return -ENOENT;
- if (!endswith(slice, ".slice"))
+ end = endswith(slice, ".slice");
+ if (!end)
return -ENOENT;
return -ENOENT;
- s = strndupa(
e, strlen(e) - 6
);
+ s = strndupa(
start, end - start
);
if (!s)
if (!s)
- return -ENO
MEM
;
+ return -ENO
ENT
;
- return parse_uid(s, uid);
+ if (parse_uid(s, &u) < 0)
+ return -EIO;
+
+ if (uid)
+ *uid = u;
+
+ return 0;
}
int cg_pid_get_owner_uid(pid_t pid, uid_t *uid) {
_cleanup_free_ char *cgroup = NULL;
int r;
}
int cg_pid_get_owner_uid(pid_t pid, uid_t *uid) {
_cleanup_free_ char *cgroup = NULL;
int r;
- assert(uid);
-
r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
if (r < 0)
return r;
r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
if (r < 0)
return r;