21255d
From 7569168bea3d7e11cd3afe6167fcf4a3ac65a1a6 Mon Sep 17 00:00:00 2001
21255d
From: Lennart Poettering <lennart@poettering.net>
21255d
Date: Mon, 30 Mar 2020 21:46:01 +0200
21255d
Subject: [PATCH] user-util: switch order of checks in
21255d
 valid_user_group_name_or_id_full()
21255d
21255d
When we are supposed to accept numeric UIDs formatted as string, then
21255d
let's check that first, before passing things on to
21255d
valid_user_group_name_full(), since that might log about, and not the
21255d
other way round.
21255d
21255d
See: #15201
21255d
Follow-up for: 93c23c9297e48e594785e0bb9c51504aae5fbe3e
21255d
21255d
(cherry picked from commit a85daa0dfb3eb03be9845760e90e54b9af8fb00e)
21255d
21255d
Related: #1848373
21255d
---
21255d
 src/basic/user-util.c | 4 ++--
21255d
 1 file changed, 2 insertions(+), 2 deletions(-)
21255d
21255d
diff --git a/src/basic/user-util.c b/src/basic/user-util.c
21255d
index 7dd2bb2c84..68a924770b 100644
21255d
--- a/src/basic/user-util.c
21255d
+++ b/src/basic/user-util.c
21255d
@@ -656,10 +656,10 @@ bool valid_user_group_name_or_id_full(const char *u, bool strict) {
21255d
         if (isempty(u))
21255d
                 return false;
21255d
 
21255d
-        if (valid_user_group_name_full(u, strict))
21255d
+        if (parse_uid(u, NULL) >= 0)
21255d
                 return true;
21255d
 
21255d
-        return parse_uid(u, NULL) >= 0;
21255d
+        return valid_user_group_name_full(u, strict);
21255d
 }
21255d
 
21255d
 bool valid_gecos(const char *d) {