blob: df1e27775a90746136e951d49383c3ec3b2b626e (
plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#!/bin/sh
set -e
cd $(dirname $0)
# Rational:
# Test that useradd can add an user and userdel removes it.
save()
{
[ ! -d tmp ] && mkdir tmp
for i in passwd group shadow gshadow
do
[ -f /etc/$i ] && cp /etc/$i tmp/$i
done
true
}
restore()
{
rm -f tmp/err tmp/out
for i in passwd group shadow gshadow
do
[ -f tmp/$i ] && cp tmp/$i /etc/$i && rm tmp/$i
done
rmdir tmp
}
save
# restore the files on exit
trap 'restore' 0
for i in passwd group shadow gshadow
do
cp data/$i /etc
done
lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ")
lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ")
lines_group=$(wc -l /etc/group | cut -f1 -d" ")
lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ")
echo -n "Add an user without an entry in shadow "
echo "test:x:10002:10002::/tmp:/bin/false" >> /etc/passwd
echo "OK"
echo "Check that pwck detects it "
pwck -r > tmp/out 2> tmp/err || true
diff -au data/run2.out tmp/out
diff -au data/run2.err tmp/err
echo " OK"
echo "grpck accepts valid password file "
msg=$(grpck -r)
test "$msg" = ""
echo " OK"
#echo -n "Make sure pwck can fix it "
#pwcd
#echo "OK"
|