Split run in 2 tests su to root and su to user.

This commit is contained in:
nekral-guest
2008-01-06 19:58:46 +00:00
parent 06f7f0d87f
commit 2c6ecc3e02
2 changed files with 44 additions and 0 deletions

44
tests/su/01/su_user.test Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/sh
set -e
cd $(dirname $0)
# Rational:
# Test that su can be used to switch to root and to a normal account
# no testsuite password
# root password: rootF00barbaz
# myuser password: myuserF00barbaz
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
cp data/{passwd,shadow,group,gshadow} /etc/
./run_su root rootF00barbaz '# '
./run_su myuser myuserF00barbaz '$ '