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-2013 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 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
26 cleanup_
() { rm -rf "$other_partition_tmpdir"; }
27 .
"$abs_srcdir/tests/other-fs-tmpdir"
29 # Set up to run a test where non-root user tries to move a root-owned
30 # file from a sticky tmpdir to a directory owned by that user on
31 # a different partition.
33 mkdir t || framework_failure_
34 chmod a
=rwx
,o
+t t || framework_failure_
35 echo > t
/root-owned || framework_failure_
36 chmod a
+r t
/root-owned || framework_failure_
37 chown
"$NON_ROOT_USERNAME" "$other_partition_tmpdir" || framework_failure_
39 # We have to allow $NON_ROOT_USERNAME access to ".".
40 chmod go
+x . || framework_failure_
43 # Ensure that $NON_ROOT_USERNAME can access the required version of mv.
45 setuidgid
$NON_ROOT_USERNAME env PATH
="$PATH" mv --version |
50 *) skip_
"cannot access just-built mv as user $NON_ROOT_USERNAME";;
53 setuidgid
$NON_ROOT_USERNAME env PATH
="$PATH" \
54 mv t
/root-owned
"$other_partition_tmpdir" 2> out-t
&& fail
=1
56 # On some systems, we get 'Not owner'. Convert it.
57 # On other systems (HPUX), we get 'Permission denied'. Convert it, too.
58 onp
='Operation not permitted'
59 sed "s/Not owner/$onp/;s/Permission denied/$onp/" out-t
> out
62 mv: cannot remove
't/root-owned': Operation not permitted
65 compare exp out || fail
=1