2 # A cross-partition move of a file in a sticky tmpdir and owned by
3 # someone else would evoke an invalid diagnostic:
4 # mv: cannot remove `x': Operation not permitted
5 # Affects coreutils-6.0-6.9.
7 # Copyright (C) 2007-2009 Free Software Foundation, Inc.
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 if test "$VERBOSE" = yes; then
30 cleanup_
() { rm -rf "$other_partition_tmpdir"; }
31 .
"$abs_srcdir/other-fs-tmpdir"
33 # Set up to run a test where non-root user tries to move a root-owned
34 # file from a sticky tmpdir to a directory owned by that user on
35 # a different partition.
37 mkdir t || framework_failure
38 chmod a
=rwx
,o
+t t || framework_failure
39 echo > t
/root-owned || framework_failure
40 chmod a
+r t
/root-owned || framework_failure
41 chown
"$NON_ROOT_USERNAME" "$other_partition_tmpdir" || framework_failure
43 # We have to allow $NON_ROOT_USERNAME access to ".".
44 chmod go
+x . || framework_failure
46 # Ensure that $NON_ROOT_USERNAME can access the required version of mv.
47 version
=`setuidgid $NON_ROOT_USERNAME env PATH="$PATH" mv --version|sed -n '1s/.* //p'`
50 *) echo "$0: cannot access just-built mv as user $NON_ROOT_USERNAME" 1>&2
54 setuidgid
$NON_ROOT_USERNAME env PATH
="$PATH" \
55 mv t
/root-owned
$other_partition_tmpdir 2> out-t
&& fail
=1
57 # On some systems, we get `Not owner'. Convert it.
58 # On other systems (HPUX), we get `Permission denied'. Convert it, too.
59 onp
='Operation not permitted'
60 sed "s/Not owner/$onp/;s/Permission denied/$onp/" out-t
> out
63 mv: cannot remove
`t/root-owned': Operation not permitted
66 compare out exp || fail=1