Files
shadow/tests/su/01/su_root.test
T

45 lines
640 B
Bash
Executable File

#!/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 '$ '