]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - tools/regression/pjdfstest/tests/chflags/11.t
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / tools / regression / pjdfstest / tests / chflags / 11.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 desc="chflags returns EPERM if a user tries to set or remove the SF_SNAPSHOT flag"
5
6 dir=`dirname $0`
7 . ${dir}/../misc.sh
8
9 require chflags_SF_SNAPSHOT
10
11 echo "1..145"
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} SF_SNAPSHOT
25                 expect none stat ${n1} flags
26                 expect EPERM chflags ${n1} SF_SNAPSHOT
27                 expect none stat ${n1} flags
28                 expect 0 chown ${n1} 65534 65534
29                 expect EPERM -u 65534 -g 65534 chflags ${n1} SF_SNAPSHOT
30                 expect none stat ${n1} flags
31                 expect EPERM chflags ${n1} SF_SNAPSHOT
32                 expect none stat ${n1} flags
33                 if [ "${type}" = "dir" ]; then
34                         expect 0 rmdir ${n1}
35                 else
36                         expect 0 unlink ${n1}
37                 fi
38         fi
39
40         create_file ${type} ${n1}
41         expect EPERM -u 65534 -g 65534 lchflags ${n1} SF_SNAPSHOT
42         expect none lstat ${n1} flags
43         expect EPERM lchflags ${n1} SF_SNAPSHOT
44         expect none lstat ${n1} flags
45         expect 0 lchown ${n1} 65534 65534
46         expect EPERM -u 65534 -g 65534 lchflags ${n1} SF_SNAPSHOT
47         expect none lstat ${n1} flags
48         expect EPERM lchflags ${n1} SF_SNAPSHOT
49         expect none lstat ${n1} flags
50         if [ "${type}" = "dir" ]; then
51                 expect 0 rmdir ${n1}
52         else
53                 expect 0 unlink ${n1}
54         fi
55 done
56
57 cd ${cdir}
58 expect 0 rmdir ${n0}