File: test6.pl

package info (click to toggle)
adduser 3.153
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,560 kB
  • sloc: perl: 9,407; sh: 189; makefile: 22
file content (31 lines) | stat: -rw-r--r-- 711 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl -w

# expect:
#  - a new user $USER with uid $want_uid and gid 0
#  - added to group nogroup
#  - no home directory /home/$USER

use strict;
use lib_test;

my $username = find_unused_name();
my $want_uid = find_unused_uid("system");
my $want_gid = 0;

my $cmd = "adduser --system --uid $want_uid --gid $want_gid $username";

if (!defined (getpwnam($username))) {
	print "Testing $cmd... ";
	`$cmd`;
	my $error = ($?>>8);
	if ($error) {
	  print "failed\n  adduser returned an errorcode != 0 ($error)\n";
	  exit $error;
	}

	assert(check_user_exist ($username, $want_uid));
	assert(check_user_homedir_not_exist ($username));
	assert(check_user_has_gid($username,$want_gid));
	print "ok\n";
}