Deleted Added
full compact
10.t (211180) 10.t (211186)
1#!/bin/sh
1#!/bin/sh
2# $FreeBSD: head/tools/regression/fstest/tests/chflags/10.t 211180 2010-08-11 16:34:44Z pjd $
2# $FreeBSD: head/tools/regression/fstest/tests/chflags/10.t 211186 2010-08-11 17:34:58Z pjd $
3
4desc="chflags returns EPERM if non-super-user tries to set one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK"
5
6dir=`dirname $0`
7. ${dir}/../misc.sh
8
9require chflags
10
3
4desc="chflags returns EPERM if non-super-user tries to set one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK"
5
6dir=`dirname $0`
7. ${dir}/../misc.sh
8
9require chflags
10
11echo "1..210"
11echo "1..197"
12
13n0=`namegen`
14n1=`namegen`
15n2=`namegen`
16
17expect 0 mkdir ${n0} 0755
18cdir=`pwd`
19cd ${n0}
20
21for type in regular dir fifo block char socket symlink; do
22 if [ "${type}" != "symlink" ]; then
12
13n0=`namegen`
14n1=`namegen`
15n2=`namegen`
16
17expect 0 mkdir ${n0} 0755
18cdir=`pwd`
19cd ${n0}
20
21for type in regular dir fifo block char socket symlink; do
22 if [ "${type}" != "symlink" ]; then
23 create_file ${type} ${n1} 0 0
23 create_file ${type} ${n1}
24 expect 0 chown ${n1} 65534 65534
25 for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
26 expect EPERM -u 65533 -g 65533 chflags ${n1} ${flag}
27 expect none stat ${n1} flags
28 expect EPERM -u 65534 -g 65534 chflags ${n1} ${flag}
29 expect none stat ${n1} flags
30 done
31 if [ "${type}" = "dir" ]; then
32 expect 0 rmdir ${n1}
33 else
34 expect 0 unlink ${n1}
35 fi
36 fi
37
24 expect 0 chown ${n1} 65534 65534
25 for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
26 expect EPERM -u 65533 -g 65533 chflags ${n1} ${flag}
27 expect none stat ${n1} flags
28 expect EPERM -u 65534 -g 65534 chflags ${n1} ${flag}
29 expect none stat ${n1} flags
30 done
31 if [ "${type}" = "dir" ]; then
32 expect 0 rmdir ${n1}
33 else
34 expect 0 unlink ${n1}
35 fi
36 fi
37
38 create_file ${type} ${n1} 0 0
38 create_file ${type} ${n1}
39 expect 0 lchown ${n1} 65534 65534
40 for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
41 expect EPERM -u 65533 -g 65533 lchflags ${n1} ${flag}
42 expect none lstat ${n1} flags
43 expect EPERM -u 65534 -g 65534 lchflags ${n1} ${flag}
44 expect none lstat ${n1} flags
45 done
46 if [ "${type}" = "dir" ]; then
47 expect 0 rmdir ${n1}
48 else
49 expect 0 unlink ${n1}
50 fi
51done
52
53cd ${cdir}
54expect 0 rmdir ${n0}
39 expect 0 lchown ${n1} 65534 65534
40 for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do
41 expect EPERM -u 65533 -g 65533 lchflags ${n1} ${flag}
42 expect none lstat ${n1} flags
43 expect EPERM -u 65534 -g 65534 lchflags ${n1} ${flag}
44 expect none lstat ${n1} flags
45 done
46 if [ "${type}" = "dir" ]; then
47 expect 0 rmdir ${n1}
48 else
49 expect 0 unlink ${n1}
50 fi
51done
52
53cd ${cdir}
54expect 0 rmdir ${n0}