]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/regression/pjdfstest/tests/chmod/07.t
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / regression / pjdfstest / tests / chmod / 07.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 desc="chmod returns EPERM if the operation would change the ownership, but the effective user ID is not the super-user"
5
6 dir=`dirname $0`
7 . ${dir}/../misc.sh
8
9 if supported lchmod; then
10         echo "1..34"
11 else
12         echo "1..25"
13 fi
14
15 n0=`namegen`
16 n1=`namegen`
17 n2=`namegen`
18 n3=`namegen`
19
20 expect 0 mkdir ${n0} 0755
21 cdir=`pwd`
22 cd ${n0}
23 expect 0 mkdir ${n1} 0755
24 expect 0 chown ${n1} 65534 65534
25
26 expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
27 expect 0 -u 65534 -g 65534 chmod ${n1}/${n2} 0642
28 expect 0642 stat ${n1}/${n2} mode
29 expect EPERM -u 65533 -g 65533 chmod ${n1}/${n2} 0641
30 expect 0642 stat ${n1}/${n2} mode
31 expect 0 chown ${n1}/${n2} 0 0
32 expect EPERM -u 65534 -g 65534 chmod ${n1}/${n2} 0641
33 expect 0642 stat ${n1}/${n2} mode
34 expect 0 unlink ${n1}/${n2}
35
36 expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
37 expect 0 -u 65534 -g 65534 symlink ${n2} ${n1}/${n3}
38 expect 0 -u 65534 -g 65534 chmod ${n1}/${n3} 0642
39 expect 0642,65534,65534 stat ${n1}/${n2} mode,uid,gid
40 expect EPERM -u 65533 -g 65533 chmod ${n1}/${n3} 0641
41 expect 0642,65534,65534 stat ${n1}/${n2} mode,uid,gid
42 expect 0 chown ${n1}/${n3} 0 0
43 expect EPERM -u 65534 -g 65534 chmod ${n1}/${n3} 0641
44 expect 0642,0,0 stat ${n1}/${n2} mode,uid,gid
45 expect 0 unlink ${n1}/${n2}
46 expect 0 unlink ${n1}/${n3}
47
48 if supported lchmod; then
49         expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
50         expect 0 -u 65534 -g 65534 lchmod ${n1}/${n2} 0642
51         expect 0642 stat ${n1}/${n2} mode
52         expect EPERM -u 65533 -g 65533 lchmod ${n1}/${n2} 0641
53         expect 0642 stat ${n1}/${n2} mode
54         expect 0 chown ${n1}/${n2} 0 0
55         expect EPERM -u 65534 -g 65534 lchmod ${n1}/${n2} 0641
56         expect 0642 stat ${n1}/${n2} mode
57         expect 0 unlink ${n1}/${n2}
58 fi
59
60 expect 0 rmdir ${n1}
61 cd ${cdir}
62 expect 0 rmdir ${n0}