From fc92148eac1cd2f8a5e99b3facc21e630e815bef Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 7 Dec 2006 08:10:35 +0100 Subject: cp -p now clears special bits if it fails to preserve owner or group * NEWS: Document the cp -p fix for special bits. * src/copy.c (set_owner): Now returns a three-way result, so that the caller can clear the special bits. All callers changed. (copy_reg): Don't set the special bits if chown failed. (copy_internal): Likewise. * tests/cp/special-bits: Test this fix. Signed-off-by: Jim Meyering --- tests/cp/special-bits | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests/cp/special-bits') diff --git a/tests/cp/special-bits b/tests/cp/special-bits index 6a9b0949d..96dbf3d92 100755 --- a/tests/cp/special-bits +++ b/tests/cp/special-bits @@ -38,9 +38,12 @@ framework_failure=0 mkdir -p $tmp || framework_failure=1 cd $tmp || framework_failure=1 -touch a b || framework_failure=1 +touch a b c || framework_failure=1 chmod u+sx,go= a || framework_failure=1 chmod u=rwx,g=sx,o= b || framework_failure=1 +chmod a=r,ug+sx c || framework_failure=1 +chown $NON_ROOT_USERNAME . || framework_failure=1 +chmod u=rwx,g=rx,o=rx . || framework_failure=1 if test $framework_failure = 1; then echo 'failure in testing framework' @@ -59,4 +62,9 @@ set _ `ls -l b`; shift; p1=$1 set _ `ls -l b2`; shift; p2=$1 test $p1 = $p2 || fail=1 +setuidgid $NON_ROOT_USERNAME env PATH="$PATH" cp -p c c2 || fail=1 +set _ `ls -l c`; shift; p1=$1 +set _ `ls -l c2`; shift; p2=$1 +test $p1 = $p2 && fail=1 + (exit $fail); exit $fail -- cgit v1.2.3-54-g00ecf