Deleted Added
full compact
07.t (211352) 07.t (211410)
1#!/bin/sh
1#!/bin/sh
2# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/07.t 185227 2008-11-23 20:07:00Z pjd $
2# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/07.t 211410 2010-08-17 06:08:09Z pjd $
3
4desc="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
6dir=`dirname $0`
7. ${dir}/../misc.sh
8
3
4desc="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
6dir=`dirname $0`
7. ${dir}/../misc.sh
8
9echo "1..11"
9echo "1..132"
10
11n0=`namegen`
12n1=`namegen`
13n2=`namegen`
10
11n0=`namegen`
12n1=`namegen`
13n2=`namegen`
14n3=`namegen`
14
15expect 0 mkdir ${n0} 0755
16cdir=`pwd`
17cd ${n0}
18expect 0 mkdir ${n1} 0755
19expect 0 chown ${n1} 65534 65534
15
16expect 0 mkdir ${n0} 0755
17cdir=`pwd`
18cd ${n0}
19expect 0 mkdir ${n1} 0755
20expect 0 chown ${n1} 65534 65534
20expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
21expect EPERM -u 65534 -g 65534 chown ${n1}/${n2} 65533 65533
22expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65534 65534
23expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65533 65533
24expect EPERM -u 65534 -g 65534 -- chown ${n1}/${n2} -1 65533
25expect 0 unlink ${n1}/${n2}
21for 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
50done
26expect 0 rmdir ${n1}
27cd ${cdir}
28expect 0 rmdir ${n0}
51expect 0 rmdir ${n1}
52cd ${cdir}
53expect 0 rmdir ${n0}