-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #275 from hallyn/2020-08-27/test-su
Add tests on top of #254
- Loading branch information
Showing
11 changed files
with
434 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
root | ||
args: first second third |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
myuser | ||
args: first second third |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
cd $(dirname $0) | ||
|
||
. ../../common/config.sh | ||
. ../../common/log.sh | ||
|
||
cat > /tmp/shadow_test_wrap << "EOF" | ||
#!/bin/sh | ||
whoami | ||
echo args: "$@" | ||
EOF | ||
chmod 755 /tmp/shadow_test_wrap | ||
|
||
log_start "$0" "Running commands: su -c '/tmp/shadow_test_wrap \$1 \$2 \$3' testsuite -- first second third" | ||
|
||
save_config | ||
|
||
# restore the files on exit | ||
trap 'log_status "$0" "FAILURE"; restore_config' 0 | ||
|
||
change_config | ||
|
||
echo "/bin/su -c '/tmp/shadow_test_wrap \$1 \$2 \$3' testsuite -- first second third > tmp/out 2> tmp/err" | ||
/bin/su -c '/tmp/shadow_test_wrap $1 $2 $3' testsuite -- first second third > tmp/out 2> tmp/err | ||
|
||
echo "su reported:" | ||
echo "=== stdout ===" | ||
cat tmp/out | ||
echo "=== stderr ===" | ||
cat tmp/err | ||
echo "==============" | ||
|
||
echo -n "Checking tmp/out..." | ||
diff -au data/tsuser.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 | ||
|
Oops, something went wrong.