1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-06-06 01:36:28 +02:00
Files
coreutils/tests/priv-check
T

39 lines
941 B
Bash
Raw Normal View History

2001-08-05 08:42:53 +00:00
# -*- sh -*-
# Source this file at the beginning of a test that works
# only when run as root or as non-root.
2001-09-02 15:21:33 +00:00
case "$PRIV_CHECK_ARG" in
2001-08-05 08:42:53 +00:00
require-root) who='as root';;
require-non-root) who='by an unprivileged user';;
2001-09-02 15:21:33 +00:00
*) echo "Usage: PRIV_CHECK_ARG={require-root|require-non-root} . priv-check"\
1>&2; exit 1;;
2001-08-05 08:42:53 +00:00
esac
2001-08-05 08:58:52 +00:00
priv_check_temp=priv-check.$$
touch $priv_check_temp || framework_failure=1
chmod a-w $priv_check_temp || framework_failure=1
2001-08-05 08:42:53 +00:00
2001-08-06 09:50:05 +00:00
(echo foo >> $priv_check_temp) >/dev/null 2>&1
overwrite_status=$?
give_msg=no
2001-09-02 15:21:33 +00:00
case $PRIV_CHECK_ARG:$overwrite_status in
2001-08-06 09:50:05 +00:00
require-root:0) ;;
require-root:*) give_msg=yes ;;
require-non-root:0) give_msg=yes ;;
require-non-root:*) ;;
esac
test $give_msg = yes && {
2001-08-05 08:42:53 +00:00
cat <<EOF
***************************
NOTICE:
$0: This test is being skipped, since it works only
when run $who.
***************************
EOF
2001-08-05 08:58:52 +00:00
rm -f $priv_check_temp
2001-08-05 08:42:53 +00:00
(exit 77); exit
}
2001-08-05 08:58:52 +00:00
rm -f $priv_check_temp