diff --git a/tests/su/01/run b/tests/su/01/su_root.test similarity index 100% rename from tests/su/01/run rename to tests/su/01/su_root.test diff --git a/tests/su/01/su_user.test b/tests/su/01/su_user.test new file mode 100755 index 00000000..9338555c --- /dev/null +++ b/tests/su/01/su_user.test @@ -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 '$ ' +