[Pkg-shadow-devel] [Git][debian/adduser][master] 12 commits: repeat all --system test to check idempocy and identical result
Marc Haber (@zugschlus)
gitlab at salsa.debian.org
Thu Mar 6 18:19:33 GMT 2025
Marc Haber pushed to branch master at Debian / adduser
Commits:
9826551e by Marc Haber at 2025-03-06T11:55:52+01:00
repeat all --system test to check idempocy and identical result
Git-Dch: ignore
- - - - -
7a4dfc08 by Marc Haber at 2025-03-06T17:34:14+01:00
add assert_command_result_silent
Git-Dch: ignore
- - - - -
5b20cd56 by Marc Haber at 2025-03-06T17:34:34+01:00
fix a mismatch check in existing_user_status [Matt Barry]
- - - - -
55ff6bf3 by Marc Haber at 2025-03-06T17:35:11+01:00
add some return values to check against
Git-Dch: ignore
- - - - -
c1238bdd by Marc Haber at 2025-03-06T18:22:40+01:00
reformat otherwise unchanged tests
Git-Dch: ignore
- - - - -
1ff7cf17 by Marc Haber at 2025-03-06T18:22:40+01:00
define my $nextid
Git-Dch: ignore
- - - - -
7782fd4c by Marc Haber at 2025-03-06T18:22:40+01:00
double non-system user tests
the second instance should fail but don't change anything with the user
Git-Dch: ignore
- - - - -
aeee5b04 by Marc Haber at 2025-03-06T18:22:40+01:00
re-work explicit --uid tests
reformat system calls
double test, second instance should fail (Object Exists)
- - - - -
e1808761 by Marc Haber at 2025-03-06T18:22:40+01:00
re-work expclit --uid tests (3)
reformat system calls
triple test, second instance should fail (Object exits)
third instance with different uid should fail as well (Object exists)
Git-Dch: ignore
- - - - -
22b7a697 by Marc Haber at 2025-03-06T18:54:58+01:00
re-work explicit --uid tests (4)
reformat system calls
double test, second instance should fail (Object exists)
third instance with different uid should fail as well (Object exists)
fourth instance with another different uid should fail as well (Object exists)
Git-Dch: ignore
- - - - -
42b39fab by Marc Haber at 2025-03-06T18:54:58+01:00
re-work system user explicit --uuid tests
triple test
first repeat should succeed and change nothing
second repeat with differen uid should fail (Wrong Object Parameters)
and change nothing
Git-Dch: ignore
- - - - -
67358f78 by Marc Haber at 2025-03-06T18:54:58+01:00
re-work system user explicit --uid tests (2)
double test
first repeat should succeed
Git-Dch: ignore
- - - - -
3 changed files:
- adduser
- debian/tests/f/user_group.t
- debian/tests/lib/AdduserTestsCommon.pm
Changes:
=====================================
adduser
=====================================
@@ -1153,7 +1153,8 @@ sub existing_user_status {
$ret |= EXISTING_ID_MISMATCH if (defined($new_uid) && $uid != $new_uid);
$ret |= EXISTING_SYSTEM if \
($uid >= $config{"first_system_uid"} && $uid <= $config{"last_system_uid"});
- $ret |= EXISTING_ID_MISMATCH if ($new_uid && getpwuid($new_uid));
+ } elsif ($new_uid && getpwuid($new_uid)) {
+ $ret |= EXISTING_ID_MISMATCH;
}
log_trace( "existing_user_status( %s, %s ) returns %s", $new_name, $new_uid, $ret );
return $ret;
=====================================
debian/tests/f/user_group.t
=====================================
@@ -8,23 +8,43 @@ use warnings;
use AdduserTestsCommon;
+# how do I use a module from the package in question?
+#use AdduserRetvalues;
+
+use constant RET_OK => 0;
+use constant RET_OBJECT_EXISTS => 11;
+use constant RET_WRONG_OBJECT_PROPERTIES => 13;
+
+
my @quiet=("--stdoutmsglevel=error", '--stderrmsglevel=error');
# create custom user groups
my $cusergroup="myusers";
-assert_command_success('/usr/sbin/addgroup', '--system', $cusergroup);
+assert_command_success(
+ '/usr/sbin/addgroup',
+ '--system',
+ $cusergroup
+);
my @group_info = getgrnam($cusergroup);
my $cusergid = $group_info[2];
my %confhash;
my $dusergroup="manusers";
-assert_command_success('/usr/sbin/addgroup', '--system', $dusergroup);
+assert_command_success(
+ '/usr/sbin/addgroup',
+ '--system',
+ $dusergroup
+);
@group_info = getgrnam($dusergroup);
my $dusergid = $group_info[2];
my @extragroups=('extra1', 'extra2', 'extra3');
foreach ( @extragroups ) {
- assert_command_success('/usr/sbin/addgroup', '--system', $_);
+ assert_command_success(
+ '/usr/sbin/addgroup',
+ '--system',
+ $_
+ );
}
# USERS_GROUP and USERS_GID both set => failure
@@ -33,14 +53,20 @@ my $test_name="test1";
$confhash{"USERS_GROUP"}='users';
$confhash{"USERS_GID"}='100';
apply_config_hash(\%confhash);
-assert_command_failure_silent('/usr/sbin/adduser', @quiet,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_failure_silent(0,
+ '/usr/sbin/adduser', @quiet,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name
+);
my $homedir;
my $usergroup="users";
my $usergid="100";
my $useruid=40000;
+my $nextid;
my $sysuuid=400;
# USERGROUPS=yes USERS_GROUP="" USERS_GID=""
@@ -52,9 +78,13 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--home', "$homedir",
- '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name
+);
assert_user_exists($test_name);
assert_group_exists($test_name);
my $test_uid=getpwnam($test_name);
@@ -65,6 +95,23 @@ assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
assert_path_is_a_directory($homedir);
assert_user_has_home_directory($test_name, $homedir);
assert_dir_group_owner($homedir, $test_name);
+assert_command_failure_silent(
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name
+);
+assert_user_exists($test_name);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $test_name);
# USERGROUPS=yes USERS_GROUP="" USERS_GID=""
# this test also creates and checks a home directory
@@ -77,10 +124,51 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--home', "$homedir",
- '--uid', "$useruid",
- '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--uid', "$useruid",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name
+);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--uid', "$useruid",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name
+);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $test_name);
+$nextid=$useruid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--uid', "$nextid",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name
+);
assert_user_uid_exists($test_name,$useruid);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -102,10 +190,27 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--ingroup', $dusergroup,
- '--home', "$homedir",
- '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $dusergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -126,10 +231,27 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--ingroup', $dusergroup,
- '--home', "$homedir",
- '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $dusergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -148,10 +270,42 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--gid', $dusergid,
- '--home', "$homedir",
- '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $dusergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $dusergroup);
+$nextid=$dusergid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -172,11 +326,61 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--gid', $dusergid,
- '--uid', "$useruid",
- '--home', "$homedir",
- '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$useruid",
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $dusergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$useruid",
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $dusergroup);
+$nextid=$dusergid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--uid', "$useruid",
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $dusergroup);
+$nextid=$useruid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$nextid",
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -194,8 +398,28 @@ $confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
$confhash{"EXTRA_GROUPS"}=join(' ', @extragroups);
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+foreach ( @extragroups ) {
+ assert_supplementary_group_membership_does_not_exist($test_name, $_);
+}
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -218,9 +442,30 @@ $confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
$confhash{"EXTRA_GROUPS"}=join(' ', @extragroups);
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+foreach ( @extragroups ) {
+ assert_supplementary_group_membership_does_not_exist($test_name, $_);
+}
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -241,9 +486,30 @@ $confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
$confhash{"EXTRA_GROUPS"}=join(' ', @extragroups);
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--add-extra-groups',
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--add-extra-groups',
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+foreach ( @extragroups ) {
+ assert_supplementary_group_membership_exists($test_name, $_);
+}
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--add-extra-groups',
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -266,10 +532,32 @@ $confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
$confhash{"EXTRA_GROUPS"}=join(' ', @extragroups);
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--add-extra-groups',
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--add-extra-groups',
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+foreach ( @extragroups ) {
+ assert_supplementary_group_membership_exists($test_name, $_);
+}
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--add-extra-groups',
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -290,9 +578,30 @@ $confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
$confhash{"EXTRA_GROUPS"}=join(' ', @extragroups);
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--add_extra_groups',
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--add_extra_groups',
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+foreach ( @extragroups ) {
+ assert_supplementary_group_membership_exists($test_name, $_);
+}
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--add_extra_groups',
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -315,10 +624,32 @@ $confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
$confhash{"EXTRA_GROUPS"}=join(' ', @extragroups);
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--add_extra_groups',
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--add_extra_groups',
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+foreach ( @extragroups ) {
+ assert_supplementary_group_membership_exists($test_name, $_);
+}
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--add_extra_groups',
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -340,8 +671,28 @@ $confhash{"USERS_GID"}='';
$confhash{"EXTRA_GROUPS"}=join(' ', @extragroups);
$confhash{"ADD_EXTRA_GROUPS"}='1';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+foreach ( @extragroups ) {
+ assert_supplementary_group_membership_exists($test_name, $_);
+}
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -365,9 +716,30 @@ $confhash{"USERS_GID"}='';
$confhash{"EXTRA_GROUPS"}=join(' ', @extragroups);
$confhash{"ADD_EXTRA_GROUPS"}='1';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $usergroup);
+foreach ( @extragroups ) {
+ assert_supplementary_group_membership_exists($test_name, $_);
+}
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -386,8 +758,26 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}=$cusergroup;
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -406,9 +796,28 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}=$cusergroup;
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -426,9 +835,24 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}=$cusergroup;
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--ingroup', $dusergroup,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -444,10 +868,39 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}=$cusergroup;
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--ingroup', $dusergroup,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$useruid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--uid', "$nextid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -461,9 +914,36 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}=$cusergroup;
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--gid', $dusergid,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$dusergid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -479,10 +959,52 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}=$cusergroup;
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--gid', $dusergid,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$dusergid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$useruid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$nextid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -495,8 +1017,26 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=$cusergid;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -515,9 +1055,44 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=$cusergid;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+$nextid=$useruid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--uid', "$nextid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -535,9 +1110,24 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=$cusergid;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--ingroup', $dusergroup,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -553,10 +1143,39 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=$cusergid;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--ingroup', $dusergroup,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$useruid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--uid', "$nextid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -570,9 +1189,36 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=$cusergid;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--gid', $dusergid,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$dusergid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -588,16 +1234,58 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=$cusergid;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--gid', $dusergid,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
-
-# USERGROUPS=yes USERS_GROUP="" USERS_GID=-1
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$dusergid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$useruid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$nextid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+
+# USERGROUPS=yes USERS_GROUP="" USERS_GID=-1
# this test also creates and checks a home directory
$test_name="test5";
$homedir="/home/$test_name";
@@ -606,9 +1294,29 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=-1;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--home', "$homedir",
- '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -632,10 +1340,50 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=-1;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--home', "$homedir",
- '--uid', "$useruid",
- '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--uid', "$useruid",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--uid', "$useruid",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_exists($test_name);
+$test_uid=getpwnam($test_name);
+assert_group_has_gid($test_name, $test_uid);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $test_name);
+$nextid=$useruid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--uid', "$nextid",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_exists($test_name);
$test_uid=getpwnam($test_name);
@@ -658,10 +1406,28 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=-1;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--ingroup', $dusergroup,
- '--home', "$homedir",
- '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $dusergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -683,11 +1449,47 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=-1;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--ingroup', $dusergroup,
- '--home', "$homedir",
- '--uid', "$useruid",
- '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--home', "$homedir",
+ '--uid', "$useruid",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $dusergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--home', "$homedir",
+ '--uid', "$useruid",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $dusergroup);
+$nextid=$useruid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--home', "$homedir",
+ '--uid', "$nextid",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -705,9 +1507,38 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=-1;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--gid', $dusergid,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$dusergid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -724,10 +1555,55 @@ $confhash{"USERGROUPS"}='yes';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=-1;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--gid', $dusergid,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$dusergid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$useruid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$nextid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -743,9 +1619,27 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}=$cusergroup;
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--home', "$homedir",
- '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $cusergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $cusergroup);
@@ -767,10 +1661,29 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}=$cusergroup;
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--home', "$homedir",
- '--uid', "$useruid",
- '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--uid', "$useruid",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $cusergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--uid', "$useruid",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $cusergroup);
@@ -789,9 +1702,25 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}=$cusergroup;
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--ingroup', $dusergroup,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -808,10 +1737,27 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}=$cusergroup;
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--ingroup', $dusergroup,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -826,9 +1772,38 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}=$cusergroup;
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--gid', $dusergid,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$dusergid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -845,10 +1820,55 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}=$cusergroup;
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--gid', $dusergid,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$dusergid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$useruid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$nextid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -862,8 +1882,24 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=$cusergid;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $cusergroup);
@@ -880,9 +1916,26 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=$cusergid;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $cusergroup);
@@ -898,9 +1951,25 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=$cusergid;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--ingroup', $dusergroup,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -917,10 +1986,41 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=$cusergid;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--ingroup', $dusergroup,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$useruid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--uid', "$nextid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -935,9 +2035,38 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=$cusergid;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--gid', $dusergid,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$dusergid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -954,10 +2083,55 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=$cusergid;
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--gid', $dusergid,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $usergid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$dusergid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$useruid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$nextid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -973,9 +2147,27 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--home', "$homedir",
- '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $usergroup);
@@ -997,10 +2189,29 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--home', "$homedir",
- '--uid', "$useruid",
- '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--uid', "$useruid",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_path_is_a_directory($homedir);
+assert_user_has_home_directory($test_name, $homedir);
+assert_dir_group_owner($homedir, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--home', "$homedir",
+ '--uid', "$useruid",
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $usergroup);
@@ -1019,9 +2230,25 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--ingroup', $dusergroup,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -1038,10 +2265,27 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--ingroup', $dusergroup,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--ingroup', $dusergroup,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -1056,9 +2300,38 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--gid', $dusergid,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$dusergid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -1075,10 +2348,55 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}='';
apply_config_hash(\%confhash);
-assert_command_success('/usr/sbin/adduser', @quiet,
- '--gid', $dusergid,
- '--uid', "$useruid",
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$dusergid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $nextid,
+ '--uid', "$useruid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
+assert_user_uid_exists($test_name,$useruid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $dusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $usergroup);
+$nextid=$useruid+1000;
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--gid', $dusergid,
+ '--uid', "$nextid",
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
assert_user_uid_exists($test_name,$useruid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $dusergroup);
@@ -1093,8 +2411,12 @@ $confhash{"USERGROUPS"}='no';
$confhash{"USERS_GROUP"}='';
$confhash{"USERS_GID"}=-1;
apply_config_hash(\%confhash);
-assert_command_failure_silent('/usr/sbin/adduser', @quiet,
- '--no-create-home', '--comment', '""', '--disabled-password', $test_name);
+assert_command_result_silent(RET_OBJECT_EXISTS,
+ '/usr/sbin/adduser', @quiet,
+ '--no-create-home',
+ '--comment', '""',
+ '--disabled-password',
+ $test_name);
##+# TODO: write tests with loops
@@ -1104,8 +2426,20 @@ apply_config_hash(\%confhash);
# system user, default, should be in nogroup
$test_name="systest1";
-assert_command_success('/usr/sbin/adduser', @quiet, '--system',
- '--no-create-home', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--no-create-home',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, 'nogroup');
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--no-create-home',
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, 'nogroup');
@@ -1115,9 +2449,33 @@ assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
# with explicit --uid
$test_name="systest1-a";
$sysuuid++;
-assert_command_success('/usr/sbin/adduser', @quiet, '--system',
- '--uid', "$sysuuid",
- '--no-create-home', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--uid', "$sysuuid",
+ '--no-create-home',
+ $test_name);
+assert_user_uid_exists($test_name,$sysuuid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, 'nogroup');
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--uid', "$sysuuid",
+ '--no-create-home',
+ $test_name);
+assert_user_uid_exists($test_name,$sysuuid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, 'nogroup');
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+$nextid=$sysuuid+1000;
+assert_command_result_silent(RET_WRONG_OBJECT_PROPERTIES,
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--uid', "$nextid",
+ '--no-create-home',
+ $test_name);
assert_user_uid_exists($test_name,$sysuuid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, 'nogroup');
@@ -1125,8 +2483,22 @@ assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
# system user, with --gid
$test_name="systest2";
-assert_command_success('/usr/sbin/adduser', @quiet, '--system',
- '--no-create-home', '--gid', $cusergid, $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--no-create-home',
+ '--gid', $cusergid,
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--no-create-home',
+ '--gid', $cusergid,
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $cusergroup);
@@ -1136,9 +2508,36 @@ assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
# with explicit --uid
$test_name="systest2-a";
$sysuuid++;
-assert_command_success('/usr/sbin/adduser', @quiet, '--system',
- '--uid', "$sysuuid",
- '--no-create-home', '--gid', $cusergid, $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--uid', "$sysuuid",
+ '--no-create-home',
+ '--gid', $cusergid,
+ $test_name);
+assert_user_uid_exists($test_name,$sysuuid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--uid', "$sysuuid",
+ '--no-create-home',
+ '--gid', $cusergid,
+ $test_name);
+assert_user_uid_exists($test_name,$sysuuid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+$nextid=$sysuuid+1000;
+assert_command_result_silent(RET_WRONG_OBJECT_PROPERTIES,
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--uid', "$nextid",
+ '--no-create-home',
+ '--gid', $cusergid,
+ $test_name);
assert_user_uid_exists($test_name,$sysuuid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $cusergroup);
@@ -1146,8 +2545,22 @@ assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
# system user, with --ingroup
$test_name="systest3";
-assert_command_success('/usr/sbin/adduser', @quiet, '--system',
- '--no-create-home', '--ingroup', $cusergroup, $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--no-create-home',
+ '--ingroup', $cusergroup,
+ $test_name);
+assert_user_exists($test_name);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--no-create-home',
+ '--ingroup', $cusergroup,
+ $test_name);
assert_user_exists($test_name);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $cusergroup);
@@ -1158,9 +2571,36 @@ assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
# with explicit --uid
$test_name="systest3-a";
$sysuuid++;
-assert_command_success('/usr/sbin/adduser', @quiet, '--system',
- '--uid', "$sysuuid",
- '--no-create-home', '--ingroup', $cusergroup, $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--uid', "$sysuuid",
+ '--no-create-home',
+ '--ingroup', $cusergroup,
+ $test_name);
+assert_user_uid_exists($test_name,$sysuuid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--uid', "$sysuuid",
+ '--no-create-home',
+ '--ingroup', $cusergroup,
+ $test_name);
+assert_user_uid_exists($test_name,$sysuuid);
+assert_group_does_not_exist($test_name);
+assert_primary_group_membership_exists($test_name, $cusergroup);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+$nextid=$sysuuid+1000;
+assert_command_result_silent(RET_WRONG_OBJECT_PROPERTIES,
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--uid', "$nextid",
+ '--no-create-home',
+ '--ingroup', $cusergroup,
+ $test_name);
assert_user_uid_exists($test_name,$sysuuid);
assert_group_does_not_exist($test_name);
assert_primary_group_membership_exists($test_name, $cusergroup);
@@ -1168,8 +2608,23 @@ assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
# system user, with --group
$test_name="systest4";
-assert_command_success('/usr/sbin/adduser', @quiet, '--system',
- '--no-create-home', '--group', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--no-create-home',
+ '--group',
+ $test_name);
+assert_user_exists($test_name);
+assert_group_exists($test_name);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--no-create-home',
+ '--group',
+ $test_name);
assert_user_exists($test_name);
assert_group_exists($test_name);
assert_primary_group_membership_exists($test_name, $test_name);
@@ -1181,9 +2636,38 @@ assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
# with explicit --uid
$test_name="systest4-a";
$sysuuid++;
-assert_command_success('/usr/sbin/adduser', @quiet, '--system',
- '--uid', "$sysuuid",
- '--no-create-home', '--group', $test_name);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--uid', "$sysuuid",
+ '--no-create-home',
+ '--group',
+ $test_name);
+assert_user_uid_exists($test_name,$sysuuid);
+assert_group_exists($test_name);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+assert_command_success(
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--uid', "$sysuuid",
+ '--no-create-home',
+ '--group',
+ $test_name);
+assert_user_uid_exists($test_name,$sysuuid);
+assert_group_exists($test_name);
+assert_primary_group_membership_exists($test_name, $test_name);
+assert_supplementary_group_membership_does_not_exist($test_name, $test_name);
+assert_supplementary_group_membership_does_not_exist($test_name, $cusergroup);
+$nextid=$sysuuid+1000;
+assert_command_result_silent(RET_WRONG_OBJECT_PROPERTIES,
+ '/usr/sbin/adduser', @quiet,
+ '--system',
+ '--uid', "$nextid",
+ '--no-create-home',
+ '--group',
+ $test_name);
assert_user_uid_exists($test_name,$sysuuid);
assert_group_exists($test_name);
assert_primary_group_membership_exists($test_name, $test_name);
=====================================
debian/tests/lib/AdduserTestsCommon.pm
=====================================
@@ -64,6 +64,14 @@ sub assert_command_failure {
isnt($? >> 8, 0, "command failure (expected): @_");
}
+sub assert_command_result_silent {
+ my $expected = shift;
+ my $cmd = join(' ', @_);
+ my $output = `$cmd >/dev/null 2>&1`;
+ my $ret = $? >> 8;
+ isnt($ret != $expected, 0, "command result $ret (expected $expected): @_");
+}
+
sub assert_command_failure_silent {
my $cmd = join(' ', @_);
my $output = `$cmd >/dev/null 2>&1`;
View it on GitLab: https://salsa.debian.org/debian/adduser/-/compare/dc561b330b6f2a80245105ce79660286a2ecf014...67358f788014bfc59f6f4f2df7af1d5736857037
--
View it on GitLab: https://salsa.debian.org/debian/adduser/-/compare/dc561b330b6f2a80245105ce79660286a2ecf014...67358f788014bfc59f6f4f2df7af1d5736857037
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-shadow-devel/attachments/20250306/3d4f1882/attachment-0001.htm>
More information about the Pkg-shadow-devel
mailing list