1#!/bin/sh 2# $FreeBSD: src/tools/regression/fstest/tests/rename/09.t,v 1.1 2007/01/17 01:42:10 pjd Exp $ 3 4desc="rename returns EACCES or EPERM if the directory containing 'from' is marked sticky, and neither the containing directory nor 'from' are owned by the effective user ID" 5 6n0=`namegen` 7n1=`namegen` 8n2=`namegen` 9n3=`namegen` 10n4=`namegen` 11 12expect 0 mkdir ${n4} 0755 13cdir=`pwd` 14cd ${n4} 15 16expect 0 mkdir ${n0} 0755 17expect 0 chown ${n0} 65534 65534 18expect 0 chmod ${n0} 01777 19 20expect 0 mkdir ${n1} 0755 21 22# User owns both: the sticky directory and the file to be renamed. 23expect 0 chown ${n1} 65534 65534 24expect 0 -u 65534 -g 65534 create ${n0}/${n2} 0644 25expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} 26expect 0 unlink ${n1}/${n3} 27# User owns the file to be renamed, but doesn't own the sticky directory. 28expect 0 chown ${n1} 65533 65533 29expect 0 -u 65533 -g 65533 create ${n0}/${n2} 0644 30expect 0 -u 65533 -g 65533 rename ${n0}/${n2} ${n1}/${n3} 31expect 0 unlink ${n1}/${n3} 32# User owns the sticky directory, but doesn't own the file to be renamed. 33expect 0 chown ${n1} 65534 65534 34expect 0 -u 65533 -g 65533 create ${n0}/${n2} 0644 35expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} 36expect 0 unlink ${n1}/${n3} 37# User doesn't own the sticky directory nor the file to be renamed. 38expect 0 chown ${n1} 65533 65533 39expect 0 -u 65534 -g 65534 create ${n0}/${n2} 0644 40expect "EACCES|EPERM" -u 65533 -g 65533 rename ${n0}/${n2} ${n1}/${n3} 41expect 0 unlink ${n0}/${n2} 42 43# User owns both: the sticky directory and the fifo to be renamed. 44expect 0 chown ${n1} 65534 65534 45expect 0 -u 65534 -g 65534 mkfifo ${n0}/${n2} 0644 46expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} 47expect 0 unlink ${n1}/${n3} 48# User owns the fifo to be renamed, but doesn't own the sticky directory. 49expect 0 chown ${n1} 65533 65533 50expect 0 -u 65533 -g 65533 mkfifo ${n0}/${n2} 0644 51expect 0 -u 65533 -g 65533 rename ${n0}/${n2} ${n1}/${n3} 52expect 0 unlink ${n1}/${n3} 53# User owns the sticky directory, but doesn't own the fifo to be renamed. 54expect 0 chown ${n1} 65534 65534 55expect 0 -u 65533 -g 65533 mkfifo ${n0}/${n2} 0644 56expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} 57expect 0 unlink ${n1}/${n3} 58# User doesn't own the sticky directory nor the fifo to be renamed. 59expect 0 chown ${n1} 65533 65533 60expect 0 -u 65534 -g 65534 mkfifo ${n0}/${n2} 0644 61expect "EACCES|EPERM" -u 65533 -g 65533 rename ${n0}/${n2} ${n1}/${n3} 62expect 0 unlink ${n0}/${n2} 63 64# User owns both: the sticky directory and the symlink to be renamed. 65expect 0 chown ${n1} 65534 65534 66expect 0 -u 65534 -g 65534 symlink test ${n0}/${n2} 67expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} 68expect 0 unlink ${n1}/${n3} 69# User owns the symlink to be renamed, but doesn't own the sticky directory. 70expect 0 chown ${n1} 65533 65533 71expect 0 -u 65533 -g 65533 symlink test ${n0}/${n2} 72expect 0 -u 65533 -g 65533 rename ${n0}/${n2} ${n1}/${n3} 73expect 0 unlink ${n1}/${n3} 74# User owns the sticky directory, but doesn't own the symlink to be renamed. 75expect 0 chown ${n1} 65534 65534 76expect 0 -u 65533 -g 65533 symlink test ${n0}/${n2} 77expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} 78expect 0 unlink ${n1}/${n3} 79# User doesn't own the sticky directory nor the symlink to be renamed. 80expect 0 chown ${n1} 65533 65533 81expect 0 -u 65534 -g 65534 symlink test ${n0}/${n2} 82expect "EACCES|EPERM" -u 65533 -g 65533 rename ${n0}/${n2} ${n1}/${n3} 83expect 0 unlink ${n0}/${n2} 84 85expect 0 rmdir ${n1} 86expect 0 rmdir ${n0} 87 88cd ${cdir} 89expect 0 rmdir ${n4} 90