From 17f84b7cecf063c74c1b001ad000bb04a414b12a Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez-Fernandez Date: Wed, 30 Oct 2024 07:47:00 -0700 Subject: [PATCH] p_shadow-utils: use next guid for group tests There is a possibility that the guid 1010 is in used during the test and could make it fail. Picking the next available guid works around that possibility, while letting the test still test the same scenario. --- tests/p_shadow-utils/30-groupadd_tests | 3 ++- tests/p_shadow-utils/34-groupmod_tests | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/p_shadow-utils/30-groupadd_tests b/tests/p_shadow-utils/30-groupadd_tests index 79f4617f..d4aeff15 100755 --- a/tests/p_shadow-utils/30-groupadd_tests +++ b/tests/p_shadow-utils/30-groupadd_tests @@ -7,5 +7,6 @@ t_Log "Running $0 group add tests" sed -i /testgroup/d /etc/group echo "Create a new group" -groupadd -g 1010 testgroup +next_guid=$((10+$(awk -F: '{print $3}' /etc/group | sort | tail -1))) +groupadd -g $next_guid testgroup t_CheckExitStatus $? diff --git a/tests/p_shadow-utils/34-groupmod_tests b/tests/p_shadow-utils/34-groupmod_tests index 8bf80ab1..99affe0f 100755 --- a/tests/p_shadow-utils/34-groupmod_tests +++ b/tests/p_shadow-utils/34-groupmod_tests @@ -4,8 +4,9 @@ t_Log "Running $0" # Check that the testgroup exists with GID 1010 -grep -q "testgroup:x:1010:testshadow" /etc/group || { t_Log "FAIL Test group doesn't exist"; exit $FAIL; } +grep -q "^testgroup:" /etc/group || { t_Log "FAIL Test group doesn't exist"; exit $FAIL; } -echo "Changing GID for group testgroup to 1011" -groupmod -g 1011 testgroup +next_guid=$((10+$(awk -F: '{print $3}' /etc/group | sort | tail -1))) +echo "Changing GID for group testgroup to $next_guid" +groupmod -g $next_guid testgroup t_CheckExitStatus $?