audit: introduce audit_session_is_valid() and make use of it everywhere

Let's add a proper validation function, since validation isn't entirely
trivial. Make use of it where applicable. Also make use of
AUDIT_SESSION_INVALID where we need a marker for an invalid audit
session.
This commit is contained in:
Lennart Poettering
2017-07-31 18:01:42 +02:00
parent ab7e3ef561
commit 3a87a86e33
5 changed files with 14 additions and 10 deletions
+2 -2
View File
@@ -54,7 +54,7 @@ int audit_session_from_pid(pid_t pid, uint32_t *id) {
if (r < 0)
return r;
if (u == AUDIT_SESSION_INVALID || u <= 0)
if (!audit_session_is_valid(u))
return -ENODATA;
*id = u;
@@ -81,7 +81,7 @@ int audit_loginuid_from_pid(pid_t pid, uid_t *uid) {
if (r < 0)
return r;
*uid = (uid_t) u;
*uid = u;
return 0;
}
+4
View File
@@ -29,3 +29,7 @@ int audit_session_from_pid(pid_t pid, uint32_t *id);
int audit_loginuid_from_pid(pid_t pid, uid_t *uid);
bool use_audit(void);
static inline bool audit_session_is_valid(uint32_t id) {
return id > 0 && id != AUDIT_SESSION_INVALID;
}