teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0473-user-util-switch-order-of-checks-in-valid_user_group.patch

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