]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
useradd: Correctly set subuid/subgid when using -F
authorndostert <crawax@cwxlab.fr>
Mon, 23 Feb 2026 20:50:16 +0000 (21:50 +0100)
committerSerge Hallyn <serge@hallyn.com>
Wed, 25 Feb 2026 15:43:53 +0000 (09:43 -0600)
The -F flag should bypass the -r flag and UID checks.

Closes: <shadow-maint#1255>
Signed-off-by: ndostert <crawax@cwxlab.fr>
Co-authored-by: Alejandro Colomar <alx@kernel.org>
Fixes: 3f7a72e9677b (2022-08-01; "useradd: add -F option for updating /etc/sub[ig]id for system accounts")
src/useradd.c

index 330b52f8d5720c6f80a85082aa83bfa77b452246..fbc7e7b25ae67aaace9533d687f41a78f02bda37 100644 (file)
@@ -2463,7 +2463,9 @@ should_assign_subuid(void)
                return false;
        if (!sub_uid_file_present())
                return false;
-       if (rflg && !Fflg)
+       if (Fflg)
+               return true;
+       if (rflg)
                return false;
        if (user_id == 0)
                return false;
@@ -2491,7 +2493,9 @@ should_assign_subgid(void)
                return false;
        if (!sub_gid_file_present())
                return false;
-       if (rflg && !Fflg)
+       if (Fflg)
+               return true;
+       if (rflg)
                return false;
        if (user_id == 0)
                return false;