From 2c6ecc3e02114bd51e5712e634beedd7ff4b7675 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Sun, 6 Jan 2008 19:58:46 +0000 Subject: [PATCH] Split run in 2 tests su to root and su to user. --- tests/su/01/{run => su_root.test} | 0 tests/su/01/su_user.test | 44 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) rename tests/su/01/{run => su_root.test} (100%) create mode 100755 tests/su/01/su_user.test 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 '$ ' +