Split the test script in more atomic tests.
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
#!/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.exp
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
set timeout 2
|
||||
expect_after default {puts "\nFAIL"; exit 1}
|
||||
|
||||
spawn /bin/bash
|
||||
expect "# "
|
||||
|
||||
#=============================================================================
|
||||
#
|
||||
# Test the -c option
|
||||
#
|
||||
#=============================================================================
|
||||
send "/bin/su myuser -c ls\r"
|
||||
expect "data run run.exp tmp\r\n"
|
||||
expect "# "
|
||||
|
||||
send "/bin/su -- myuser -c ls\r"
|
||||
expect "data run run.exp tmp\r\n"
|
||||
expect "# "
|
||||
|
||||
send "/bin/su myuser -- -c ls\r"
|
||||
expect "data run run.exp tmp\r\n"
|
||||
expect "# "
|
||||
|
||||
# This is Debian specific. Use su's -c option
|
||||
send "/bin/su -c ls myuser\r"
|
||||
expect "data run run.exp tmp\r\n"
|
||||
expect "# "
|
||||
|
||||
send "/bin/su -c ls -- myuser\r"
|
||||
expect "data run run.exp tmp\r\n"
|
||||
expect "# "
|
||||
|
||||
# non login su should not change the working directory
|
||||
send "/bin/su myuser -c pwd\r"
|
||||
expect "/su/03\r\n"
|
||||
expect "# "
|
||||
|
||||
# Same tests with login su
|
||||
send "/bin/su - myuser -c pwd\r"
|
||||
expect "/home\r\n"
|
||||
expect "# "
|
||||
|
||||
send "/bin/su - -- myuser -c pwd\r"
|
||||
expect "/home\r\n"
|
||||
expect "# "
|
||||
|
||||
send "/bin/su - myuser -- -c pwd\r"
|
||||
expect "/home\r\n"
|
||||
expect "# "
|
||||
|
||||
# The same with -l/--login
|
||||
send "/bin/su -l myuser -c pwd\r"
|
||||
expect "/home\r\n"
|
||||
expect "# "
|
||||
|
||||
send "/bin/su --login -- myuser -c pwd\r"
|
||||
expect "/home\r\n"
|
||||
expect "# "
|
||||
|
||||
send "/bin/su -l myuser -- -c pwd\r"
|
||||
expect "/home\r\n"
|
||||
expect "# "
|
||||
|
||||
# make sure -c is an su option
|
||||
send "/bin/su -c pwd - myuser\r"
|
||||
expect "/home\r\n"
|
||||
expect "# "
|
||||
|
||||
send "/bin/su -c pwd -- - myuser\r"
|
||||
expect "/home\r\n"
|
||||
expect "# "
|
||||
|
||||
# getopt must reorder the options/non-options
|
||||
send "/bin/su -p -c pwd -- - myuser\r"
|
||||
expect "/su/03\r\n"
|
||||
expect "# "
|
||||
send "/bin/su -p -c pwd - myuser\r"
|
||||
expect "/su/03\r\n"
|
||||
expect "# "
|
||||
send "/bin/su -c pwd -p - myuser\r"
|
||||
expect "/su/03\r\n"
|
||||
expect "# "
|
||||
send "/bin/su -c pwd - -p myuser\r"
|
||||
expect "/su/03\r\n"
|
||||
expect "# "
|
||||
send "/bin/su -c pwd - myuser -p\r"
|
||||
expect "/su/03\r\n"
|
||||
expect "# "
|
||||
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
36
tests/su/03/su_run_command01.test
Executable file
36
tests/su/03/su_run_command01.test
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands: su myuser -c 'ls config'"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su myuser -c 'ls config'> tmp/out 2> tmp/err"
|
||||
/bin/su myuser -c 'ls config'> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
diff -au data/ls.out tmp/out
|
||||
rm -f tmp/out
|
||||
echo "OK"
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
36
tests/su/03/su_run_command02.test
Executable file
36
tests/su/03/su_run_command02.test
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands: su -- myuser -c 'ls config'"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su -- myuser -c 'ls config'> tmp/out 2> tmp/err"
|
||||
/bin/su -- myuser -c 'ls config'> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
diff -au data/ls.out tmp/out
|
||||
rm -f tmp/out
|
||||
echo "OK"
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
36
tests/su/03/su_run_command03.test
Executable file
36
tests/su/03/su_run_command03.test
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands: su myuser -- -c 'ls config'"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su myuser -- -c 'ls config'> tmp/out 2> tmp/err"
|
||||
/bin/su myuser -- -c 'ls config'> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
diff -au data/ls.out tmp/out
|
||||
rm -f tmp/out
|
||||
echo "OK"
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
36
tests/su/03/su_run_command04.test
Executable file
36
tests/su/03/su_run_command04.test
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands: su -c 'ls config' myuser"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su -c 'ls config' myuser> tmp/out 2> tmp/err"
|
||||
/bin/su -c 'ls config' myuser> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
diff -au data/ls.out tmp/out
|
||||
rm -f tmp/out
|
||||
echo "OK"
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
36
tests/su/03/su_run_command05.test
Executable file
36
tests/su/03/su_run_command05.test
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands: su -c 'ls config' -- myuser"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su -c 'ls config' -- myuser> tmp/out 2> tmp/err"
|
||||
/bin/su -c 'ls config' -- myuser> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
diff -au data/ls.out tmp/out
|
||||
rm -f tmp/out
|
||||
echo "OK"
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
45
tests/su/03/su_run_command06.test
Executable file
45
tests/su/03/su_run_command06.test
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands (check working directory): su myuser -c pwd"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su myuser -c pwd> tmp/out 2> tmp/err"
|
||||
/bin/su myuser -c pwd> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
case "$(cat tmp/out)" in
|
||||
*/su/03)
|
||||
echo "OK"
|
||||
;;
|
||||
*)
|
||||
echo "FAIL"
|
||||
echo "working directory: '$(cat tmp/out)' instead of '.../su/03'"
|
||||
rm -f tmp/out
|
||||
false
|
||||
;;
|
||||
esac
|
||||
rm -f tmp/out
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
45
tests/su/03/su_run_command07.test
Executable file
45
tests/su/03/su_run_command07.test
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands (check working directory): su - myuser -c pwd"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su - myuser -c pwd> tmp/out 2> tmp/err"
|
||||
/bin/su - myuser -c pwd> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
case "$(cat tmp/out)" in
|
||||
/home)
|
||||
echo "OK"
|
||||
;;
|
||||
*)
|
||||
echo "FAIL"
|
||||
echo "working directory: '$(cat tmp/out)' instead of '/home'"
|
||||
rm -f tmp/out
|
||||
false
|
||||
;;
|
||||
esac
|
||||
rm -f tmp/out
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
45
tests/su/03/su_run_command08.test
Executable file
45
tests/su/03/su_run_command08.test
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands (check working directory): su - -- myuser -c pwd"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su - -- myuser -c pwd> tmp/out 2> tmp/err"
|
||||
/bin/su - -- myuser -c pwd> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
case "$(cat tmp/out)" in
|
||||
/home)
|
||||
echo "OK"
|
||||
;;
|
||||
*)
|
||||
echo "FAIL"
|
||||
echo "working directory: '$(cat tmp/out)' instead of '/home'"
|
||||
rm -f tmp/out
|
||||
false
|
||||
;;
|
||||
esac
|
||||
rm -f tmp/out
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
45
tests/su/03/su_run_command09.test
Executable file
45
tests/su/03/su_run_command09.test
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands (check working directory): su - myuser -- -c pwd"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su - myuser -- -c pwd> tmp/out 2> tmp/err"
|
||||
/bin/su - myuser -- -c pwd> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
case "$(cat tmp/out)" in
|
||||
/home)
|
||||
echo "OK"
|
||||
;;
|
||||
*)
|
||||
echo "FAIL"
|
||||
echo "working directory: '$(cat tmp/out)' instead of '/home'"
|
||||
rm -f tmp/out
|
||||
false
|
||||
;;
|
||||
esac
|
||||
rm -f tmp/out
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
45
tests/su/03/su_run_command10.test
Executable file
45
tests/su/03/su_run_command10.test
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands (check working directory): su -l myuser -c pwd"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su -l myuser -c pwd> tmp/out 2> tmp/err"
|
||||
/bin/su -l myuser -c pwd> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
case "$(cat tmp/out)" in
|
||||
/home)
|
||||
echo "OK"
|
||||
;;
|
||||
*)
|
||||
echo "FAIL"
|
||||
echo "working directory: '$(cat tmp/out)' instead of '/home'"
|
||||
rm -f tmp/out
|
||||
false
|
||||
;;
|
||||
esac
|
||||
rm -f tmp/out
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
45
tests/su/03/su_run_command11.test
Executable file
45
tests/su/03/su_run_command11.test
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands (check working directory): su --login -- myuser -c pwd"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su --login -- myuser -c pwd> tmp/out 2> tmp/err"
|
||||
/bin/su --login -- myuser -c pwd> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
case "$(cat tmp/out)" in
|
||||
/home)
|
||||
echo "OK"
|
||||
;;
|
||||
*)
|
||||
echo "FAIL"
|
||||
echo "working directory: '$(cat tmp/out)' instead of '/home'"
|
||||
rm -f tmp/out
|
||||
false
|
||||
;;
|
||||
esac
|
||||
rm -f tmp/out
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
45
tests/su/03/su_run_command12.test
Executable file
45
tests/su/03/su_run_command12.test
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands (check working directory): su -l myuser -- -c pwd"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su -l myuser -- -c pwd> tmp/out 2> tmp/err"
|
||||
/bin/su -l myuser -- -c pwd> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
case "$(cat tmp/out)" in
|
||||
/home)
|
||||
echo "OK"
|
||||
;;
|
||||
*)
|
||||
echo "FAIL"
|
||||
echo "working directory: '$(cat tmp/out)' instead of '/home'"
|
||||
rm -f tmp/out
|
||||
false
|
||||
;;
|
||||
esac
|
||||
rm -f tmp/out
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
50
tests/su/03/su_run_command13.test
Executable file
50
tests/su/03/su_run_command13.test
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands (check working directory): su -p -c pwd -- - myuser"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su -p -c pwd -- - myuser> tmp/out 2> tmp/err"
|
||||
/bin/su -p -c pwd -- - myuser> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
case "$(cat tmp/out)" in
|
||||
*/su/03)
|
||||
echo "OK"
|
||||
;;
|
||||
*)
|
||||
echo "FAIL"
|
||||
echo "working directory: '$(cat tmp/out)' instead of '.../su/03'"
|
||||
rm -f tmp/out
|
||||
false
|
||||
;;
|
||||
esac
|
||||
rm -f tmp/out
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || {
|
||||
echo "FAIL"
|
||||
echo "tmp/err is not empty:"
|
||||
cat tmp/err
|
||||
false
|
||||
}
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
45
tests/su/03/su_run_command14.test
Executable file
45
tests/su/03/su_run_command14.test
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands (check working directory): su -p -c pwd - myuser"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su -p -c pwd - myuser> tmp/out 2> tmp/err"
|
||||
/bin/su -p -c pwd - myuser> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
case "$(cat tmp/out)" in
|
||||
*/su/03)
|
||||
echo "OK"
|
||||
;;
|
||||
*)
|
||||
echo "FAIL"
|
||||
echo "working directory: '$(cat tmp/out)' instead of '.../su/03'"
|
||||
rm -f tmp/out
|
||||
false
|
||||
;;
|
||||
esac
|
||||
rm -f tmp/out
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
45
tests/su/03/su_run_command15.test
Executable file
45
tests/su/03/su_run_command15.test
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands (check working directory): su -c pwd -p - myuser"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su -c pwd -p - myuser> tmp/out 2> tmp/err"
|
||||
/bin/su -c pwd -p - myuser> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
case "$(cat tmp/out)" in
|
||||
*/su/03)
|
||||
echo "OK"
|
||||
;;
|
||||
*)
|
||||
echo "FAIL"
|
||||
echo "working directory: '$(cat tmp/out)' instead of '.../su/03'"
|
||||
rm -f tmp/out
|
||||
false
|
||||
;;
|
||||
esac
|
||||
rm -f tmp/out
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
45
tests/su/03/su_run_command16.test
Executable file
45
tests/su/03/su_run_command16.test
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands (check working directory): su -c pwd - -p myuser"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su -c pwd - -p myuser> tmp/out 2> tmp/err"
|
||||
/bin/su -c pwd - -p myuser> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
case "$(cat tmp/out)" in
|
||||
*/su/03)
|
||||
echo "OK"
|
||||
;;
|
||||
*)
|
||||
echo "FAIL"
|
||||
echo "working directory: '$(cat tmp/out)' instead of '.../su/03'"
|
||||
rm -f tmp/out
|
||||
false
|
||||
;;
|
||||
esac
|
||||
rm -f tmp/out
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
45
tests/su/03/su_run_command17.test
Executable file
45
tests/su/03/su_run_command17.test
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
. ../../common/config.sh
|
||||
. ../../common/log.sh
|
||||
|
||||
|
||||
log_start "$0" "Running commands (check working directory): su -c pwd - myuser -p"
|
||||
|
||||
save_config
|
||||
|
||||
# restore the files on exit
|
||||
trap 'log_status "$0" "FAILURE"; restore_config' 0
|
||||
|
||||
change_config
|
||||
|
||||
echo "/bin/su -c pwd - myuser -p> tmp/out 2> tmp/err"
|
||||
/bin/su -c pwd - myuser -p> tmp/out 2> tmp/err
|
||||
|
||||
echo -n "Checking tmp/out..."
|
||||
case "$(cat tmp/out)" in
|
||||
*/su/03)
|
||||
echo "OK"
|
||||
;;
|
||||
*)
|
||||
echo "FAIL"
|
||||
echo "working directory: '$(cat tmp/out)' instead of '.../su/03'"
|
||||
rm -f tmp/out
|
||||
false
|
||||
;;
|
||||
esac
|
||||
rm -f tmp/out
|
||||
|
||||
echo -n "Checking tmp/err..."
|
||||
[ "$(wc -c tmp/err)" = "0 tmp/err" ] || false
|
||||
rm -f tmp/err
|
||||
echo "OK"
|
||||
|
||||
log_status "$0" "SUCCESS"
|
||||
restore_config
|
||||
trap '' 0
|
||||
|
||||
Reference in New Issue
Block a user