]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/regression/pjdfstest/tests/chflags/07.t
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / regression / pjdfstest / tests / chflags / 07.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 desc="chflags returns EPERM when the effective user ID does not match the owner of the file and the effective user ID is not the super-user"
5
6 dir=`dirname $0`
7 . ${dir}/../misc.sh
8
9 require chflags
10
11 echo "1..93"
12
13 n0=`namegen`
14 n1=`namegen`
15 n2=`namegen`
16
17 expect 0 mkdir ${n0} 0755
18 cdir=`pwd`
19 cd ${n0}
20
21 for type in regular dir fifo block char socket symlink; do
22         if [ "${type}" != "symlink" ]; then
23                 create_file ${type} ${n1}
24                 expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
25                 expect none stat ${n1} flags
26                 expect 0 chown ${n1} 65534 65534
27                 expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
28                 expect none stat ${n1} flags
29                 if [ "${type}" = "dir" ]; then
30                         expect 0 rmdir ${n1}
31                 else
32                         expect 0 unlink ${n1}
33                 fi
34         fi
35
36         create_file ${type} ${n1}
37         expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP
38         expect none lstat ${n1} flags
39         expect 0 lchown ${n1} 65534 65534
40         expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP
41         expect none lstat ${n1} flags
42         if [ "${type}" = "dir" ]; then
43                 expect 0 rmdir ${n1}
44         else
45                 expect 0 unlink ${n1}
46         fi
47 done
48
49 cd ${cdir}
50 expect 0 rmdir ${n0}