summaryrefslogtreecommitdiff
path: root/src/basic/audit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-09-03 18:24:57 +0200
committerLennart Poettering <lennart@poettering.net>2015-09-04 09:07:31 +0200
commitd7e46e01aca53017cffb659115665be621264b8f (patch)
tree9db4600736b83e27c2a6238c76755d8048c9c4e2 /src/basic/audit.c
parentef5c570edfd8afb20e3b04d3711e111a1dea0548 (diff)
audit: audit calls should return ENODATA when process are not in an audit session
ENODATA is how we usually indicate such "missing info" cases, so we should do this here, too.
Diffstat (limited to 'src/basic/audit.c')
-rw-r--r--src/basic/audit.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/basic/audit.c b/src/basic/audit.c
index 54148fcf18..1f593aa813 100644
--- a/src/basic/audit.c
+++ b/src/basic/audit.c
@@ -36,6 +36,11 @@ int audit_session_from_pid(pid_t pid, uint32_t *id) {
assert(id);
+ /* We don't convert ENOENT to ESRCH here, since we can't
+ * really distuingish between "audit is not available in the
+ * kernel" and "the process does not exist", both which will
+ * result in ENOENT. */
+
p = procfs_file_alloca(pid, "sessionid");
r = read_one_line_file(p, &s);
@@ -47,7 +52,7 @@ int audit_session_from_pid(pid_t pid, uint32_t *id) {
return r;
if (u == AUDIT_SESSION_INVALID || u <= 0)
- return -ENXIO;
+ return -ENODATA;
*id = u;
return 0;
@@ -68,6 +73,8 @@ int audit_loginuid_from_pid(pid_t pid, uid_t *uid) {
return r;
r = parse_uid(s, &u);
+ if (r == -ENXIO) /* the UID was -1 */
+ return -ENODATA;
if (r < 0)
return r;