daandemeyer / rpms / systemd

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