]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/regression/pjdfstest/tests/chmod/11.t
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / regression / pjdfstest / tests / chmod / 11.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 desc="chmod returns EFTYPE if the effective user ID is not the super-user, the mode includes the sticky bit (S_ISVTX), and path does not refer to a directory"
5
6 dir=`dirname $0`
7 . ${dir}/../misc.sh
8
9 if supported lchmod; then
10         echo "1..173"
11 else
12         echo "1..109"
13 fi
14
15 n0=`namegen`
16 n1=`namegen`
17 n2=`namegen`
18
19 expect 0 mkdir ${n0} 0755
20 cdir=`pwd`
21 cd ${n0}
22
23 for type in regular dir fifo block char socket symlink; do
24         if [ "${type}" != "symlink" ]; then
25                 create_file ${type} ${n1}
26                 expect 0 chmod ${n1} 01621
27                 expect 01621 stat ${n1} mode
28                 expect 0 symlink ${n1} ${n2}
29                 expect 0 chmod ${n2} 01700
30                 expect 01700 stat ${n1} mode
31                 expect 0 unlink ${n2}
32                 if [ "${type}" = "dir" ]; then
33                         expect 0 rmdir ${n1}
34                 else
35                         expect 0 unlink ${n1}
36                 fi
37         fi
38
39         if supported lchmod; then
40                 create_file ${type} ${n1}
41                 expect 0 lchmod ${n1} 01621
42                 expect 01621 lstat ${n1} mode
43                 if [ "${type}" = "dir" ]; then
44                         expect 0 rmdir ${n1}
45                 else
46                         expect 0 unlink ${n1}
47                 fi
48         fi
49 done
50
51 expect 0 mkdir ${n1} 0755
52 expect 0 chown ${n1} 65534 65534
53 expect 0 -u 65534 -g 65534 chmod ${n1} 01755
54 expect 01755 stat ${n1} mode
55 expect 0 symlink ${n1} ${n2}
56 expect 0 chmod ${n2} 01700
57 expect 01700 stat ${n1} mode
58 expect 0 unlink ${n2}
59 expect 0 rmdir ${n1}
60
61 for type in regular fifo block char socket symlink; do
62         if [ "${type}" != "symlink" ]; then
63                 create_file ${type} ${n1} 0640 65534 65534
64                 expect 0 symlink ${n1} ${n2}
65                 case "${os}" in
66                 FreeBSD)
67                         expect EFTYPE -u 65534 -g 65534 chmod ${n1} 01644
68                         expect 0640 stat ${n1} mode
69                         expect EFTYPE -u 65534 -g 65534 chmod ${n2} 01644
70                         expect 0640 stat ${n1} mode
71                         ;;
72                 SunOS)
73                         expect 0 -u 65534 -g 65534 chmod ${n1} 01644
74                         expect 0644 stat ${n1} mode
75                         expect 0 -u 65534 -g 65534 chmod ${n2} 01640
76                         expect 0640 stat ${n1} mode
77                         ;;
78                 Linux)
79                         expect 0 -u 65534 -g 65534 chmod ${n1} 01644
80                         expect 01644 stat ${n1} mode
81                         expect 0 -u 65534 -g 65534 chmod ${n2} 01640
82                         expect 01640 stat ${n1} mode
83                         ;;
84                 esac
85                 expect 0 unlink ${n2}
86                 if [ "${type}" = "dir" ]; then
87                         expect 0 rmdir ${n1}
88                 else
89                         expect 0 unlink ${n1}
90                 fi
91         fi
92
93         if supported lchmod; then
94                 create_file ${type} ${n1} 0640 65534 65534
95                 case "${os}" in
96                 FreeBSD)
97                         expect EFTYPE -u 65534 -g 65534 lchmod ${n1} 01644
98                         expect 0640 lstat ${n1} mode
99                         ;;
100                 SunOS)
101                         expect 0 -u 65534 -g 65534 lchmod ${n1} 01644
102                         expect 0644 lstat ${n1} mode
103                         ;;
104                 Linux)
105                         expect 0 -u 65534 -g 65534 lchmod ${n1} 01644
106                         expect 01644 lstat ${n1} mode
107                         ;;
108                 esac
109                 if [ "${type}" = "dir" ]; then
110                         expect 0 rmdir ${n1}
111                 else
112                         expect 0 unlink ${n1}
113                 fi
114         fi
115 done
116
117 cd ${cdir}
118 expect 0 rmdir ${n0}