]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/pjdfstest/tests/chflags/07.t
Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
[FreeBSD/FreeBSD.git] / contrib / pjdfstest / tests / chflags / 07.t
1 #!/bin/sh
2 # vim: filetype=sh noexpandtab ts=8 sw=8
3 # $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/07.t 211352 2010-08-15 21:24:17Z pjd $
4
5 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"
6
7 dir=`dirname $0`
8 . ${dir}/../misc.sh
9
10 require chflags
11
12 echo "1..93"
13
14 n0=`namegen`
15 n1=`namegen`
16 n2=`namegen`
17
18 expect 0 mkdir ${n0} 0755
19 cdir=`pwd`
20 cd ${n0}
21
22 for type in regular dir fifo block char socket symlink; do
23         if [ "${type}" != "symlink" ]; then
24                 create_file ${type} ${n1}
25                 expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP
26                 expect none stat ${n1} flags
27                 expect 0 chown ${n1} 65534 65534
28                 expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP
29                 expect none stat ${n1} flags
30                 if [ "${type}" = "dir" ]; then
31                         expect 0 rmdir ${n1}
32                 else
33                         expect 0 unlink ${n1}
34                 fi
35         fi
36
37         create_file ${type} ${n1}
38         expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP
39         expect none lstat ${n1} flags
40         expect 0 lchown ${n1} 65534 65534
41         expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP
42         expect none lstat ${n1} flags
43         if [ "${type}" = "dir" ]; then
44                 expect 0 rmdir ${n1}
45         else
46                 expect 0 unlink ${n1}
47         fi
48 done
49
50 cd ${cdir}
51 expect 0 rmdir ${n0}