Add tests from the old svn tree
We're losing the svn history (which we could probably keep if we tried hard enough) but don't consider that worthwhile. Note these tests are destructive, so run them only in a throwaway environment like a chroot, container, or vm. The tests/run.all script should be the one which launches all the tests. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
62
tests/cktools/01/run2
Executable file
62
tests/cktools/01/run2
Executable file
@@ -0,0 +1,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"
|
Reference in New Issue
Block a user