2 # Verify that cp -p preserves GID when it is possible.
4 # Copyright (C) 2007, 2008 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 .
"$srcdir/../lang-default"
20 PRIV_CHECK_ARG
=require-root .
"$srcdir/../priv-check"
21 .
"$srcdir/../test-lib.sh"
24 echo "$1" > "$1" ||
exit 1
25 chown
"+$2:+$3" "$1" ||
exit 1
35 if test "x$s" != "x$u $g"; then
36 # Allow the actual group to match that of the parent directory
37 # (it was set to 0 above).
38 if test "x$s" = "x$u 0"; then
41 echo "$0: $* $f b: $u $g != $s" 1>&2
51 t0
"$f" "$u" "$g" setuidgid
-g "$nameless_gid1,$nameless_gid2" \
55 if test "x$VERBOSE" = xyes
; then
60 nameless_uid
=`$PERL -le 'foreach my $i (1000..16*1024-1) { getpwuid $i or (print $i), exit }'`
61 nameless_gid1
=`$PERL -le 'foreach my $i (1000..16*1024) { getgrgid $i or (print $i), exit }'`
62 nameless_gid2
=`$PERL -le 'foreach my $i ('"$nameless_gid1"'+1..16*1024) { getgrgid $i or (print $i), exit }'`
64 if test -z "$nameless_uid" \
65 ||
test -z "$nameless_gid1" \
66 ||
test -z "$nameless_gid2"; then
67 skip_test_
"couldn't find a nameless UID or GID"
70 chown
"+$nameless_uid:+0" .
73 create b0
"$nameless_uid" "$nameless_gid1"
74 create b1
"$nameless_uid" "$nameless_gid2"
75 create c0
0 "$nameless_gid1"
76 create c1
0 "$nameless_gid2"
85 t0 b0
"$nameless_uid" "$nameless_gid1" cp -p
86 t0 b1
"$nameless_uid" "$nameless_gid2" cp -p
87 t0 c0
0 "$nameless_gid1" cp -p
88 t0 c1
0 "$nameless_gid2" cp -p
90 t1 a0
"$nameless_uid" "$nameless_gid1" cp
91 t1 b0
"$nameless_uid" "$nameless_gid1" cp
92 t1 b1
"$nameless_uid" "$nameless_gid1" cp
93 t1 c0
"$nameless_uid" "$nameless_gid1" cp
94 t1 c1
"$nameless_uid" "$nameless_gid1" cp
96 t1 a0
"$nameless_uid" "$nameless_gid1" cp -p
97 t1 b0
"$nameless_uid" "$nameless_gid1" cp -p
98 t1 b1
"$nameless_uid" "$nameless_gid2" cp -p
99 t1 c0
"$nameless_uid" "$nameless_gid1" cp -p
100 t1 c1
"$nameless_uid" "$nameless_gid2" cp -p