diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-09-03 13:29:53 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-09-04 09:07:30 +0200 |
commit | a1f686daf55636f9446a4c017f2488a35595395e (patch) | |
tree | fed98d6c92f557097cb35a055dfca55dd573e8d5 /src/libsystemd/sd-login | |
parent | fea72cc0336f4d90875cdddc1aa9739dcbb174f5 (diff) |
util: add new uid_is_valid() call
This simply factors out the uid validation checks from parse_uid() and
uses them everywhere. This simply verifies that the passed UID is
neither 64bit -1 nor 32bit -1.
Diffstat (limited to 'src/libsystemd/sd-login')
-rw-r--r-- | src/libsystemd/sd-login/sd-login.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c index 7d6a4b78cf..6300162ebe 100644 --- a/src/libsystemd/sd-login/sd-login.c +++ b/src/libsystemd/sd-login/sd-login.c @@ -203,6 +203,7 @@ _public_ int sd_uid_get_state(uid_t uid, char**state) { char *s = NULL; int r; + assert_return(uid_is_valid(uid), -EINVAL); assert_return(state, -EINVAL); r = file_of_uid(uid, &p); @@ -230,6 +231,7 @@ _public_ int sd_uid_get_display(uid_t uid, char **session) { _cleanup_free_ char *p = NULL, *s = NULL; int r; + assert_return(uid_is_valid(uid), -EINVAL); assert_return(session, -EINVAL); r = file_of_uid(uid, &p); @@ -257,6 +259,7 @@ _public_ int sd_uid_is_on_seat(uid_t uid, int require_active, const char *seat) int r; const char *word, *variable, *state; + assert_return(uid_is_valid(uid), -EINVAL); assert_return(seat, -EINVAL); variable = require_active ? "ACTIVE_UID" : "UIDS"; @@ -289,6 +292,8 @@ static int uid_get_array(uid_t uid, const char *variable, char ***array) { char **a; int r; + assert_return(uid_is_valid(uid), -EINVAL); + r = file_of_uid(uid, &p); if (r < 0) return r; |