diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-04-29 21:40:54 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-04-29 21:45:58 +0200 |
commit | cfeaa44a09756a93a881f786678973d9b1e382db (patch) | |
tree | c86172a848d4ca1716e1b2b82427e819f025e51c /src/shared/cgroup-util.c | |
parent | cfa9677bd164574600d29a9bf99f9d1f28a7a170 (diff) |
sd-bus: properly handle creds that are known but undefined for a process
A number of fields do not apply to all processes, including: there a
processes without a controlling tty, without parent process, without
service, user services or session. To distuingish these cases from the
case where we simply don't have the data, always return ENXIO for them,
while returning ENODATA for the case where we really lack the
information.
Also update the credentials dumping code to show this properly. Fields
that are known but do not apply are now shown as "n/a".
Note that this also changes some of the calls in process-util.c and
cgroup-util.c to return ENXIO for these cases.
Diffstat (limited to 'src/shared/cgroup-util.c')
-rw-r--r-- | src/shared/cgroup-util.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c index 5b04702ac2..7521b8b5f9 100644 --- a/src/shared/cgroup-util.c +++ b/src/shared/cgroup-util.c @@ -1150,7 +1150,7 @@ int cg_path_decode_unit(const char *cgroup, char **unit){ c = cg_unescape(c); if (!unit_name_is_valid(c, TEMPLATE_INVALID)) - return -EINVAL; + return -ENXIO; s = strdup(c); if (!s) @@ -1258,7 +1258,7 @@ int cg_path_get_user_unit(const char *path, char **unit) { if (!t) t = skip_user_manager(e); if (!t) - return -ENOENT; + return -ENXIO; /* ... and skip more slices if there are any */ e = skip_slices(t); @@ -1318,17 +1318,17 @@ int cg_path_get_session(const char *path, char **session) { n = strchrnul(e, '/'); if (e == n) - return -ENOENT; + return -ENXIO; s = strndupa(e, n - e); s = cg_unescape(s); x = startswith(s, "session-"); if (!x) - return -ENOENT; + return -ENXIO; y = endswith(x, ".scope"); if (!y || x == y) - return -ENOENT; + return -ENXIO; if (session) { char *r; @@ -1369,17 +1369,17 @@ int cg_path_get_owner_uid(const char *path, uid_t *uid) { start = startswith(slice, "user-"); if (!start) - return -ENOENT; + return -ENXIO; end = endswith(slice, ".slice"); if (!end) - return -ENOENT; + return -ENXIO; s = strndupa(start, end - start); if (!s) - return -ENOENT; + return -ENXIO; if (parse_uid(s, &u) < 0) - return -EIO; + return -ENXIO; if (uid) *uid = u; @@ -1415,7 +1415,7 @@ int cg_path_get_slice(const char *p, char **slice) { char *s; if (!e) - return -ENOENT; + return -ENXIO; s = strndup(e, m); if (!s) |