]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - tools/regression/pjdfstest/tests/chown/07.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 / chown / 07.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 desc="chown returns EPERM if the operation would change the ownership, but the effective user ID is not the super-user and the process is not an owner of the file"
5
6 dir=`dirname $0`
7 . ${dir}/../misc.sh
8
9 echo "1..132"
10
11 n0=`namegen`
12 n1=`namegen`
13 n2=`namegen`
14 n3=`namegen`
15
16 expect 0 mkdir ${n0} 0755
17 cdir=`pwd`
18 cd ${n0}
19 expect 0 mkdir ${n1} 0755
20 expect 0 chown ${n1} 65534 65534
21 for type in regular dir fifo block char socket symlink; do
22         if [ "${type}" != "symlink" ]; then
23                 create_file ${type} ${n1}/${n2} 65534 65534
24                 expect EPERM -u 65534 -g 65534 chown ${n1}/${n2} 65533 65533
25                 expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65534 65534
26                 expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65533 65533
27                 expect EPERM -u 65534 -g 65534 -- chown ${n1}/${n2} -1 65533
28                 expect 0 -u 65534 -g 65534 symlink ${n2} ${n1}/${n3}
29                 expect EPERM -u 65534 -g 65534 chown ${n1}/${n3} 65533 65533
30                 expect EPERM -u 65533 -g 65533 chown ${n1}/${n3} 65534 65534
31                 expect EPERM -u 65533 -g 65533 chown ${n1}/${n3} 65533 65533
32                 expect EPERM -u 65534 -g 65534 -- chown ${n1}/${n3} -1 65533
33                 expect 0 unlink ${n1}/${n3}
34                 if [ "${type}" = "dir" ]; then
35                         expect 0 rmdir ${n1}/${n2}
36                 else
37                         expect 0 unlink ${n1}/${n2}
38                 fi
39         fi
40         create_file ${type} ${n1}/${n2} 65534 65534
41         expect EPERM -u 65534 -g 65534 lchown ${n1}/${n2} 65533 65533
42         expect EPERM -u 65533 -g 65533 lchown ${n1}/${n2} 65534 65534
43         expect EPERM -u 65533 -g 65533 lchown ${n1}/${n2} 65533 65533
44         expect EPERM -u 65534 -g 65534 -- lchown ${n1}/${n2} -1 65533
45         if [ "${type}" = "dir" ]; then
46                 expect 0 rmdir ${n1}/${n2}
47         else
48                 expect 0 unlink ${n1}/${n2}
49         fi
50 done
51 expect 0 rmdir ${n1}
52 cd ${cdir}
53 expect 0 rmdir ${n0}