summaryrefslogtreecommitdiff
path: root/tests/chmod/c-option
blob: ff5d16e2cc75606d7122344133807a4bfdd0d2bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
# Verify that chmod's --changes (-c) option works.

if test "$VERBOSE" = yes; then
  set -x
  chmod --version
fi

. $srcdir/../lang-default

pwd=`pwd`
tmp=c-option.$$
trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
trap '(exit $?); exit' 1 2 13 15

framework_failure=0

# Record absolute path of srcdir.
cd $srcdir || framework_failure=1
abs_srcdir=`pwd`

cd $pwd || framework_failure=1
mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1

umask 0
file=f
touch $file || framework_failure=1
chmod 444 $file || framework_failure=1

if test $framework_failure = 1; then
  echo 'failure in testing framework'
  (exit 1); exit 1
fi

. $abs_srcdir/../setgid-check

fail=0

chmod u=rwx $file || fail=1
chmod -c g=rwx $file > out || fail=1
chmod -c g=rwx $file > empty || fail=1

test -s empty && fail=1
case "`cat out`" in
  "mode of \`f' changed to 0774 "?rwxrwxr--?) ;;
  *) fail=1 ;;
esac

(exit $fail); exit $fail