]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
tests/libsubid: fix the 03_add_remove tests so they pass
authorSerge Hallyn <serge@hallyn.com>
Fri, 17 Jul 2026 17:53:05 +0000 (12:53 -0500)
committerSerge Hallyn <serge@hallyn.com>
Sat, 18 Jul 2026 17:52:48 +0000 (12:52 -0500)
Fix src/new_subid_range.c, which is only used by this test case.  It
was not honoring the SUB_UID_MIN in login.defs.  Then fix the testcase's
expected end results.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
src/new_subid_range.c
tests/libsubid/03_add_remove/add_remove_subids.test
tests/libsubid/03_add_remove/config/etc/subgid
tests/libsubid/03_add_remove/config/etc/subuid

index 978e4ef6585e37b366f4d152dbb1bba84aed7ed9..699014d1be617909f02338a503165bdada704fb6 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "atoi/a2i.h"
 #include "io/fprintf.h"
+#include "getdef.h"
 #include "subid.h"
 #include "stdlib.h"
 
@@ -44,8 +45,8 @@ int main(int argc, char *argv[])
        if (argc == 0)
                usage();
        range.owner = argv[0];
-       range.start = 0;
-       range.count = 65536;
+       range.start = getdef_ulong ("SUB_UID_MIN", 100000UL);
+       range.count = getdef_ulong ("SUB_UID_COUNT", 65536);
        if (argc > 1)
                str2ul(&range.count, argv[1]);
        if (group)
index a24a97525b9a5c33baf7410f8260f56fc03f2f21..32bb38b092df2b3d0a5154328853da593355fbad 100755 (executable)
@@ -28,6 +28,10 @@ echo "OK"
 
 echo -n "New range returned if requested..."
 res=$(${build_path}/src/new_subid_range foo 500 -n)
+echo "debug"
+echo "res is $res"
+echo "wanted Subuid range 310000:500"
+echo "end debug"
 [ "$res" = "Subuid range 310000:500" ]
 [ $(grep -c foo /etc/subuid) -eq 2 ]
 echo "OK"
@@ -39,8 +43,11 @@ echo "OK"
 
 echo -n "Subgids work too..."
 res=$(${build_path}/src/new_subid_range -g foo 100000)
-echo "DEBUG: res is ${res}"
-[ "$res" = "Subuid range 501000:100000" ]
+echo "debug"
+echo "res is $res"
+echo "wanted Subuid range 500000:100000"
+echo "end debug"
+[ "$res" = "Subuid range 500000:100000" ]
 echo "DEBUG: subgid is:"
 cat /etc/subgid
 [ $(grep -c foo /etc/subgid) -eq 2 ]
@@ -50,7 +57,8 @@ res=$(${build_path}/src/free_subid_range -g foo 501000 100000)
 echo "DEBUG: res is ${res}"
 echo "DEBUG: subgid is:"
 cat /etc/subgid
-[ $(grep -c foo /etc/subgid) -eq 1 ]
+# we had a pre-existing foo line, and added 1, so make sure there are 2 lines
+[ $(grep -c foo /etc/subgid) -eq 2 ]
 echo "OK"
 
 log_status "$0" "SUCCESS"
index b9495cfc2943825571b54e3a66e1553ae93f14c2..3a4ccdb32758439e6e4abf0a676e4c1f9eb9efcd 100644 (file)
@@ -1,2 +1,2 @@
 foo:200000:10000
-root:500000:1000
+root:100000:400000
index cf80c2f73db28e6e8c31301a093ddec92a20f891..698522a2128f4f32b6739f1474315797acc96ae0 100644 (file)
@@ -1 +1,2 @@
 foo:300000:10000
+bar:100000:200000