diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 02:22:06 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 02:22:06 +0000 |
commit | 741c1ef7a4f2ac316ad6e557ddbe03023413478d (patch) | |
tree | 38890f681daa26c57e865b4feca10d0ca53e1046 /tests/cptools/01/run3 | |
parent | Initial commit. (diff) | |
download | shadow-741c1ef7a4f2ac316ad6e557ddbe03023413478d.tar.xz shadow-741c1ef7a4f2ac316ad6e557ddbe03023413478d.zip |
Adding upstream version 1:4.5.upstream/1%4.5upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/cptools/01/run3')
-rwxr-xr-x | tests/cptools/01/run3 | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/cptools/01/run3 b/tests/cptools/01/run3 new file mode 100755 index 0000000..d213e47 --- /dev/null +++ b/tests/cptools/01/run3 @@ -0,0 +1,57 @@ +#!/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() +{ + 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 "Copy shadow.new " +cppw -s data/shadow.new +echo "OK" + +echo -n "test if the password file was copied" +diff -au /etc/shadow data/shadow.new +echo " OK" + +echo -n "check that the other files were not modified" +diff -au /etc/group data/group +diff -au /etc/gshadow data/gshadow +diff -au /etc/passwd data/passwd +echo " OK" |