]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
user-util: switch order of checks in valid_user_group_name_or_id_full()
authorLennart Poettering <lennart@poettering.net>
Mon, 30 Mar 2020 19:46:01 +0000 (21:46 +0200)
committerThe Plumber <50238977+systemd-rhel-bot@users.noreply.github.com>
Mon, 2 Nov 2020 18:05:19 +0000 (19:05 +0100)
When we are supposed to accept numeric UIDs formatted as string, then
let's check that first, before passing things on to
valid_user_group_name_full(), since that might log about, and not the
other way round.

See: #15201
Follow-up for: 93c23c9297e48e594785e0bb9c51504aae5fbe3e

(cherry picked from commit a85daa0dfb3eb03be9845760e90e54b9af8fb00e)

Related: #1848373

src/basic/user-util.c

index 7dd2bb2c847c5c366eee8cf27ae7b09145b2d56e..68a924770b5b8286d2c06f9eada9f0250abcad1a 100644 (file)
@@ -656,10 +656,10 @@ bool valid_user_group_name_or_id_full(const char *u, bool strict) {
         if (isempty(u))
                 return false;
 
-        if (valid_user_group_name_full(u, strict))
+        if (parse_uid(u, NULL) >= 0)
                 return true;
 
-        return parse_uid(u, NULL) >= 0;
+        return valid_user_group_name_full(u, strict);
 }
 
 bool valid_gecos(const char *d) {