xref: /freebsd/contrib/pjdfstest/tests/link/07.t (revision 63a938566d524836885917d95bd491aa4400b181)
1#!/bin/sh
2# vim: filetype=sh noexpandtab ts=8 sw=8
3# $FreeBSD: head/tools/regression/pjdfstest/tests/link/07.t 211352 2010-08-15 21:24:17Z pjd $
4
5desc="link returns EACCES when the requested link requires writing in a directory with a mode that denies write permission"
6
7dir=`dirname $0`
8. ${dir}/../misc.sh
9
10echo "1..17"
11
12n0=`namegen`
13n1=`namegen`
14n2=`namegen`
15n3=`namegen`
16n4=`namegen`
17
18expect 0 mkdir ${n0} 0755
19cdir=`pwd`
20cd ${n0}
21
22expect 0 mkdir ${n1} 0755
23expect 0 chown ${n1} 65534 65534
24expect 0 mkdir ${n2} 0755
25expect 0 chown ${n2} 65534 65534
26expect 0 -u 65534 -g 65534 create ${n1}/${n3} 0644
27
28expect 0 -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4}
29expect 0 -u 65534 -g 65534 unlink ${n2}/${n4}
30
31expect 0 chmod ${n2} 0555
32expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4}
33expect 0 chmod ${n1} 0555
34expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n1}/${n4}
35expect 0 chmod ${n1} 0755
36
37expect 0 unlink ${n1}/${n3}
38expect 0 rmdir ${n1}
39expect 0 rmdir ${n2}
40
41cd ${cdir}
42expect 0 rmdir ${n0}
43