4 desc="rename returns EACCES or EPERM if the file pointed at by the 'to' argument exists, the directory containing 'to' is marked sticky, and neither the containing directory nor 'to' are owned by the effective user ID"
17 expect 0 mkdir ${n4} 0755
21 expect 0 mkdir ${n0} 0755
22 expect 0 chown ${n0} 65534 65534
24 expect 0 mkdir ${n1} 0755
25 expect 0 chmod ${n1} 01777
27 for type in regular fifo block char socket symlink; do
28 # User owns both: the sticky directory and the destination file.
29 expect 0 chown ${n1} 65534 65534
30 create_file ${type} ${n0}/${n2} 65534 65534
31 inode=`${fstest} lstat ${n0}/${n2} inode`
33 for type in regular fifo block char socket symlink; do
34 create_file ${type} ${n1}/${n3} 65534 65534
35 expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3}
36 expect ENOENT lstat ${n0}/${n2} inode
37 expect ${inode} lstat ${n1}/${n3} inode
38 expect 0 -u 65534 -g 65534 rename ${n1}/${n3} ${n0}/${n2}
39 expect ${inode} lstat ${n0}/${n2} inode
40 expect ENOENT lstat ${n1}/${n3} inode
43 expect 0 unlink ${n0}/${n2}
45 # User owns the sticky directory, but doesn't own the destination file.
47 expect 0 chown ${n1} 65534 65534
48 create_file ${type} ${n0}/${n2} 65534 65534
49 inode=`${fstest} lstat ${n0}/${n2} inode`
51 for type in regular fifo block char socket symlink; do
52 create_file ${type} ${n1}/${n3} ${id} ${id}
53 expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3}
54 expect ENOENT lstat ${n0}/${n2} inode
55 expect ${inode} lstat ${n1}/${n3} inode
56 expect 0 -u 65534 -g 65534 rename ${n1}/${n3} ${n0}/${n2}
57 expect ${inode} lstat ${n0}/${n2} inode
58 expect ENOENT lstat ${n1}/${n3} inode
61 expect 0 unlink ${n0}/${n2}
64 # User owns the destination file, but doesn't own the sticky directory.
66 expect 0 chown ${n1} ${id} ${id}
67 create_file ${type} ${n0}/${n2} 65534 65534
68 inode=`${fstest} lstat ${n0}/${n2} inode`
70 for type in regular fifo block char socket symlink; do
71 create_file ${type} ${n1}/${n3} 65534 65534
72 expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3}
73 expect ENOENT lstat ${n0}/${n2} inode
74 expect ${inode} lstat ${n1}/${n3} inode
75 expect 0 -u 65534 -g 65534 rename ${n1}/${n3} ${n0}/${n2}
76 expect ${inode} lstat ${n0}/${n2} inode
77 expect ENOENT lstat ${n1}/${n3} inode
80 expect 0 unlink ${n0}/${n2}
83 # User doesn't own the sticky directory nor the destination file.
85 expect 0 chown ${n1} ${id} ${id}
86 create_file ${type} ${n0}/${n2} 65534 65534
87 inode=`${fstest} lstat ${n0}/${n2} inode`
89 for type in regular fifo block char socket symlink; do
90 create_file ${type} ${n1}/${n3} ${id} ${id}
91 expect "EACCES|EPERM" -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3}
92 expect ${inode} lstat ${n0}/${n2} inode
93 expect ${id},${id} lstat ${n1}/${n3} uid,gid
94 expect 0 unlink ${n1}/${n3}
97 expect 0 unlink ${n0}/${n2}
101 # User owns both: the sticky directory and the destination directory.
102 expect 0 chown ${n1} 65534 65534
103 expect 0 -u 65534 -g 65534 mkdir ${n0}/${n2} 0755
104 inode=`${fstest} lstat ${n0}/${n2} inode`
106 expect 0 -u 65534 -g 65534 mkdir ${n1}/${n3} 0755
107 expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3}
108 expect ENOENT lstat ${n0}/${n2} type
109 expect ${inode} lstat ${n1}/${n3} inode
110 expect 0 rmdir ${n1}/${n3}
112 # User owns the sticky directory, but doesn't own the destination directory.
113 for id in 0 65533; do
114 expect 0 chown ${n1} 65534 65534
115 expect 0 -u 65534 -g 65534 mkdir ${n0}/${n2} 0755
116 inode=`${fstest} lstat ${n0}/${n2} inode`
118 expect 0 -u ${id} -g ${id} mkdir ${n1}/${n3} 0755
119 expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3}
120 expect ENOENT lstat ${n0}/${n2} type
121 expect ${inode} lstat ${n1}/${n3} inode
122 expect 0 rmdir ${n1}/${n3}
125 # User owns the destination directory, but doesn't own the sticky directory.
126 for id in 0 65533; do
127 expect 0 chown ${n1} ${id} ${id}
128 expect 0 -u 65534 -g 65534 mkdir ${n0}/${n2} 0755
129 inode=`${fstest} lstat ${n0}/${n2} inode`
131 expect 0 -u 65534 -g 65534 mkdir ${n1}/${n3} 0755
132 expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3}
133 expect ENOENT lstat ${n0}/${n2} type
134 expect ${inode} lstat ${n1}/${n3} inode
135 expect 0 rmdir ${n1}/${n3}
138 # User doesn't own the sticky directory nor the destination directory.
139 for id in 0 65533; do
140 expect 0 chown ${n1} ${id} ${id}
141 expect 0 -u 65534 -g 65534 mkdir ${n0}/${n2} 0755
142 inode=`${fstest} lstat ${n0}/${n2} inode`
144 expect 0 -u ${id} -g ${id} mkdir ${n1}/${n3} 0755
145 expect "EACCES|EPERM" -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3}
146 expect ${inode} lstat ${n0}/${n2} inode
147 expect ${id},${id} lstat ${n1}/${n3} uid,gid
148 expect 0 rmdir ${n0}/${n2}
149 expect 0 rmdir ${n1}/${n3}