Split run in 2 tests su to root and su to user.
This commit is contained in:
44
tests/su/01/su_user.test
Executable file
44
tests/su/01/su_user.test
Executable 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 '$ '
|
||||
|
||||
Reference in New Issue
Block a user