From: Serge Hallyn Date: Fri, 17 Jul 2026 17:53:05 +0000 (-0500) Subject: tests/libsubid: fix the 03_add_remove tests so they pass X-Git-Tag: 4.20.0-rc3~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4416e5e3f05e02a4fda74738a15d762a4e410ea7;p=thirdparty%2Fshadow.git tests/libsubid: fix the 03_add_remove tests so they pass 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 --- diff --git a/src/new_subid_range.c b/src/new_subid_range.c index 978e4ef65..699014d1b 100644 --- a/src/new_subid_range.c +++ b/src/new_subid_range.c @@ -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) diff --git a/tests/libsubid/03_add_remove/add_remove_subids.test b/tests/libsubid/03_add_remove/add_remove_subids.test index a24a97525..32bb38b09 100755 --- a/tests/libsubid/03_add_remove/add_remove_subids.test +++ b/tests/libsubid/03_add_remove/add_remove_subids.test @@ -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" diff --git a/tests/libsubid/03_add_remove/config/etc/subgid b/tests/libsubid/03_add_remove/config/etc/subgid index b9495cfc2..3a4ccdb32 100644 --- a/tests/libsubid/03_add_remove/config/etc/subgid +++ b/tests/libsubid/03_add_remove/config/etc/subgid @@ -1,2 +1,2 @@ foo:200000:10000 -root:500000:1000 +root:100000:400000 diff --git a/tests/libsubid/03_add_remove/config/etc/subuid b/tests/libsubid/03_add_remove/config/etc/subuid index cf80c2f73..698522a21 100644 --- a/tests/libsubid/03_add_remove/config/etc/subuid +++ b/tests/libsubid/03_add_remove/config/etc/subuid @@ -1 +1,2 @@ foo:300000:10000 +bar:100000:200000