14887Schin#!/bin/sh
24887Schin# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/11.t 211352 2010-08-15 21:24:17Z pjd $
34887Schin
44887Schindesc="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"
54887Schin
612068SRoger.Faulkner@Oracle.COMdir=`dirname $0`
74887Schin. ${dir}/../misc.sh
84887Schin
98462SApril.Chin@Sun.COMif supported lchmod; then
104887Schin	echo "1..173"
114887Schinelse
124887Schin	echo "1..109"
134887Schinfi
144887Schin
154887Schinn0=`namegen`
164887Schinn1=`namegen`
174887Schinn2=`namegen`
184887Schin
194887Schinexpect 0 mkdir ${n0} 0755
204887Schincdir=`pwd`
214887Schincd ${n0}
224887Schin
234887Schinfor type in regular dir fifo block char socket symlink; do
244887Schin	if [ "${type}" != "symlink" ]; then
254887Schin		create_file ${type} ${n1}
264887Schin		expect 0 chmod ${n1} 01621
274887Schin		expect 01621 stat ${n1} mode
284887Schin		expect 0 symlink ${n1} ${n2}
294887Schin		expect 0 chmod ${n2} 01700
304887Schin		expect 01700 stat ${n1} mode
314887Schin		expect 0 unlink ${n2}
324887Schin		if [ "${type}" = "dir" ]; then
334887Schin			expect 0 rmdir ${n1}
344887Schin		else
354887Schin			expect 0 unlink ${n1}
364887Schin		fi
374887Schin	fi
384887Schin
394887Schin	if supported lchmod; then
404887Schin		create_file ${type} ${n1}
414887Schin		expect 0 lchmod ${n1} 01621
424887Schin		expect 01621 lstat ${n1} mode
434887Schin		if [ "${type}" = "dir" ]; then
444887Schin			expect 0 rmdir ${n1}
454887Schin		else
464887Schin			expect 0 unlink ${n1}
474887Schin		fi
484887Schin	fi
494887Schindone
504887Schin
514887Schinexpect 0 mkdir ${n1} 0755
524887Schinexpect 0 chown ${n1} 65534 65534
534887Schinexpect 0 -u 65534 -g 65534 chmod ${n1} 01755
544887Schinexpect 01755 stat ${n1} mode
554887Schinexpect 0 symlink ${n1} ${n2}
564887Schinexpect 0 chmod ${n2} 01700
574887Schinexpect 01700 stat ${n1} mode
584887Schinexpect 0 unlink ${n2}
594887Schinexpect 0 rmdir ${n1}
604887Schin
614887Schinfor type in regular fifo block char socket symlink; do
624887Schin	if [ "${type}" != "symlink" ]; then
634887Schin		create_file ${type} ${n1} 0640 65534 65534
644887Schin		expect 0 symlink ${n1} ${n2}
654887Schin		case "${os}" in
664887Schin		FreeBSD)
674887Schin			expect EFTYPE -u 65534 -g 65534 chmod ${n1} 01644
684887Schin			expect 0640 stat ${n1} mode
694887Schin			expect EFTYPE -u 65534 -g 65534 chmod ${n2} 01644
704887Schin			expect 0640 stat ${n1} mode
714887Schin			;;
724887Schin		SunOS)
734887Schin			expect 0 -u 65534 -g 65534 chmod ${n1} 01644
744887Schin			expect 0644 stat ${n1} mode
754887Schin			expect 0 -u 65534 -g 65534 chmod ${n2} 01640
764887Schin			expect 0640 stat ${n1} mode
774887Schin			;;
784887Schin		Linux)
794887Schin			expect 0 -u 65534 -g 65534 chmod ${n1} 01644
804887Schin			expect 01644 stat ${n1} mode
814887Schin			expect 0 -u 65534 -g 65534 chmod ${n2} 01640
824887Schin			expect 01640 stat ${n1} mode
834887Schin			;;
844887Schin		esac
854887Schin		expect 0 unlink ${n2}
864887Schin		if [ "${type}" = "dir" ]; then
874887Schin			expect 0 rmdir ${n1}
884887Schin		else
894887Schin			expect 0 unlink ${n1}
904887Schin		fi
914887Schin	fi
924887Schin
934887Schin	if supported lchmod; then
944887Schin		create_file ${type} ${n1} 0640 65534 65534
954887Schin		case "${os}" in
964887Schin		FreeBSD)
974887Schin			expect EFTYPE -u 65534 -g 65534 lchmod ${n1} 01644
984887Schin			expect 0640 lstat ${n1} mode
994887Schin			;;
1004887Schin		SunOS)
1014887Schin			expect 0 -u 65534 -g 65534 lchmod ${n1} 01644
1024887Schin			expect 0644 lstat ${n1} mode
1034887Schin			;;
1044887Schin		Linux)
1054887Schin			expect 0 -u 65534 -g 65534 lchmod ${n1} 01644
1064887Schin			expect 01644 lstat ${n1} mode
1074887Schin			;;
1084887Schin		esac
1094887Schin		if [ "${type}" = "dir" ]; then
1104887Schin			expect 0 rmdir ${n1}
1114887Schin		else
1124887Schin			expect 0 unlink ${n1}
1134887Schin		fi
1144887Schin	fi
1154887Schindone
1164887Schin
1174887Schincd ${cdir}
1184887Schinexpect 0 rmdir ${n0}
1194887Schin