GNU bug report logs - #8292
COREUTILS-8.9: Potential bug in tests/cp/preserve-gid

Previous Next

Package: coreutils;

Reported by: gmail <arbogast.cedric <at> gmail.com>

Date: Sat, 19 Mar 2011 17:54:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8292 in the body.
You can then email your comments to 8292 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#8292; Package coreutils. (Sat, 19 Mar 2011 17:54:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to gmail <arbogast.cedric <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sat, 19 Mar 2011 17:54:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: gmail <arbogast.cedric <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: COREUTILS-8.9: Potential bug in tests/cp/preserve-gid
Date: Sat, 19 Mar 2011 17:21:59 +0100
Hi all,

This is my first contact and mail with this mailing list, to summarize 
i'm a coder maintening a personnal home server using several GNU tools 
since the late 90's.


I build COREUTILS-8.9 in a chroot jail (gcc 4.5.2/libc 2.13/binutils 
2.21/make 3.82) with an athlon architecture on ext3 FS and, as root,  
got one failed test on  tests/cp/preserve-gid :

    [root <at> pompomgalli] mkdir coreutils-8.9_build && cd coreutils-8.9_build

    [root <at> pompomgalli] ../coreutils-8.9/configure && make

    ...

    [root <at> pompomgalli] NON_ROOT_USERNAME=cedric make -k check 
TESTS=cp/preserve-gid VERBOSE=yes

    [root <at> pompomgalli] less tests/cp/preserve-gid.log

    FAIL: cp/preserve-gid (exit: 1)
    ===============================

    ++ initial_cwd_=/usr/src/coreutils-8.9_build/tests
    ++ fail=0
    +++ testdir_prefix_
    +++ printf gt
    ++ pfx_=gt
    +++ mktempd_ /usr/src/coreutils-8.9_build/tests gt-preserve-gid.XXXX
    +++ destdir_=/usr/src/coreutils-8.9_build/tests
    +++ template_=gt-preserve-gid.XXXX
    +++ MAX_TRIES_=4
    ++++ unset TMPDIR
    ++++ mktemp -d -t -p /usr/src/coreutils-8.9_build/tests 
gt-preserve-gid.XXXX
    +++ d=/usr/src/coreutils-8.9_build/tests/gt-preserve-gid.jLiF
    +++ test -d /usr/src/coreutils-8.9_build/tests/gt-preserve-gid.jLiF
    ++++ tr S -
    ++++ ls -dgo /usr/src/coreutils-8.9_build/tests/gt-preserve-gid.jLiF
    +++ perms=drwx------ 2 4096 Mar 19 15:18 
/usr/src/coreutils-8.9_build/tests/gt-preserve-gid.jLiF
    +++ test 0 = 0
    +++ echo /usr/src/coreutils-8.9_build/tests/gt-preserve-gid.jLiF
    +++ return
    ++ test_dir_=/usr/src/coreutils-8.9_build/tests/gt-preserve-gid.jLiF
    ++ cd /usr/src/coreutils-8.9_build/tests/gt-preserve-gid.jLiF
    ++ gl_init_sh_nl_=

    ++ IFS=

    +++ expr 1 + 128
    ++ eval 'trap '\''Exit 129'\'' 1'
    +++ trap 'Exit 129' 1
    +++ expr 2 + 128
    ++ eval 'trap '\''Exit 130'\'' 2'
    +++ trap 'Exit 130' 2
    +++ expr 3 + 128
    ++ eval 'trap '\''Exit 131'\'' 3'
    +++ trap 'Exit 131' 3
    +++ expr 13 + 128
    ++ eval 'trap '\''Exit 141'\'' 13'
    +++ trap 'Exit 141' 13
    +++ expr 15 + 128
    ++ eval 'trap '\''Exit 143'\'' 15'
    +++ trap 'Exit 143' 15
    ++ trap remove_tmp_ 0
    + path_prepend_ ../src
    + test 1 '!=' 0
    + path_dir_=../src
    ++ cd /usr/src/coreutils-8.9_build/tests/../src
    ++ echo /usr/src/coreutils-8.9_build/src
    + abs_path_dir_=/usr/src/coreutils-8.9_build/src
    + 
PATH=/usr/src/coreutils-8.9_build/src:/usr/src/coreutils-8.9_build/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
    + create_exe_shims_ /usr/src/coreutils-8.9_build/src
    + return 0
    + shift
    + test 0 '!=' 0
    + export PATH
    + print_ver_ cp
    + test yes = yes
    + local i
    + env cp --version
    cp (GNU coreutils) 8.9
    Copyright (C) 2011 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>.
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    [Written by Torbj"orn Granlund, David MacKenzie, and Jim Meyering.
    + require_root_
    + uid_is_privileged_
    ++ id -u
    + my_uid=0
    + NON_ROOT_USERNAME=cedric
    ++ id -g cedric
    + NON_ROOT_GROUP=2003
    + working_umask_or_skip_
    + umask 022
    + touch file1 file2
    + chmod 644 file2
    ++ uniq
    ++ sed 's/ .*//'
    ++ ls -l file1 file2
    + perms=-rw-r--r--
    + rm -f file1 file2
    ++ id -g
    + primary_group_num=0
    ++ perl -le '
      foreach my $i (1000..16*1024-1)
        {
          getpwuid $i or (print $i), exit
        }
    '
    + nameless_uid=1000
    ++ perl -le '
      foreach my $i (1000..16*1024)
        {
          getgrgid $i or (print $i), exit
        }
    '
    + nameless_gid1=1000
    ++ perl -le '
      foreach my $i (1000+1..16*1024)
        {
          getgrgid $i or (print $i), exit
        }
    '
    + nameless_gid2=1001
    + test -z 1000
    + test -z 1000
    + test -z 1001
    + chown +1000:+0 .
    + create a0 0 0
    + echo a0
    + chown +0:+0 a0
    + create b0 1000 1000
    + echo b0
    + chown +1000:+1000 b0
    + create b1 1000 1001
    + echo b1
    + chown +1000:+1001 b1
    + create c0 0 1000
    + echo c0
    + chown +0:+1000 c0
    + create c1 0 1001
    + echo c1
    + chown +0:+1001 c1
    + t0 a0 0 0 cp
    + f=a0
    + shift
    + u=0
    + shift
    + g=0
    + shift
    + rm -f b
    + cp a0 b
    ++ stat -c '%u %g' b
    + s=0 0
    + test 'x0 0' '!=' 'x0 0'
    + t0 b0 0 0 cp
    + f=b0
    + shift
    + u=0
    + shift
    + g=0
    + shift
    + rm -f b
    + cp b0 b
    ++ stat -c '%u %g' b
    + s=0 0
    + test 'x0 0' '!=' 'x0 0'
    + t0 b1 0 0 cp
    + f=b1
    + shift
    + u=0
    + shift
    + g=0
    + shift
    + rm -f b
    + cp b1 b
    ++ stat -c '%u %g' b
    + s=0 0
    + test 'x0 0' '!=' 'x0 0'
    + t0 c0 0 0 cp
    + f=c0
    + shift
    + u=0
    + shift
    + g=0
    + shift
    + rm -f b
    + cp c0 b
    ++ stat -c '%u %g' b
    + s=0 0
    + test 'x0 0' '!=' 'x0 0'
    + t0 c1 0 0 cp
    + f=c1
    + shift
    + u=0
    + shift
    + g=0
    + shift
    + rm -f b
    + cp c1 b
    ++ stat -c '%u %g' b
    + s=0 0
    + test 'x0 0' '!=' 'x0 0'
    + t0 a0 0 0 cp -p
    + f=a0
    + shift
    + u=0
    + shift
    + g=0
    + shift
    + rm -f b
    + cp -p a0 b
    ++ stat -c '%u %g' b
    + s=0 0
    + test 'x0 0' '!=' 'x0 0'
    + t0 b0 1000 1000 cp -p
    + f=b0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + cp -p b0 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t0 b1 1000 1001 cp -p
    + f=b1
    + shift
    + u=1000
    + shift
    + g=1001
    + shift
    + rm -f b
    + cp -p b1 b
    ++ stat -c '%u %g' b
    + s=1000 1001
    + test 'x1000 1001' '!=' 'x1000 1001'
    + t0 c0 0 1000 cp -p
    + f=c0
    + shift
    + u=0
    + shift
    + g=1000
    + shift
    + rm -f b
    + cp -p c0 b
    ++ stat -c '%u %g' b
    + s=0 1000
    + test 'x0 1000' '!=' 'x0 1000'
    + t0 c1 0 1001 cp -p
    + f=c1
    + shift
    + u=0
    + shift
    + g=1001
    + shift
    + rm -f b
    + cp -p c1 b
    ++ stat -c '%u %g' b
    + s=0 1001
    + test 'x0 1001' '!=' 'x0 1001'
    + t1 a0 1000 1000 cp
    + f=a0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 a0 1000 1000 setuidgid -g 1000,1001 1000 cp
    + f=a0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + setuidgid -g 1000,1001 1000 cp a0 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 b0 1000 1000 cp
    + f=b0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 b0 1000 1000 setuidgid -g 1000,1001 1000 cp
    + f=b0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + setuidgid -g 1000,1001 1000 cp b0 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 b1 1000 1000 cp
    + f=b1
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 b1 1000 1000 setuidgid -g 1000,1001 1000 cp
    + f=b1
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + setuidgid -g 1000,1001 1000 cp b1 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 c0 1000 1000 cp
    + f=c0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 c0 1000 1000 setuidgid -g 1000,1001 1000 cp
    + f=c0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + setuidgid -g 1000,1001 1000 cp c0 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 c1 1000 1000 cp
    + f=c1
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 c1 1000 1000 setuidgid -g 1000,1001 1000 cp
    + f=c1
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + setuidgid -g 1000,1001 1000 cp c1 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 a0 1000 1000 cp -p
    + f=a0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 a0 1000 1000 setuidgid -g 1000,1001 1000 cp -p
    + f=a0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + setuidgid -g 1000,1001 1000 cp -p a0 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 b0 1000 1000 cp -p
    + f=b0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 b0 1000 1000 setuidgid -g 1000,1001 1000 cp -p
    + f=b0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + setuidgid -g 1000,1001 1000 cp -p b0 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 b1 1000 1001 cp -p
    + f=b1
    + shift
    + u=1000
    + shift
    + g=1001
    + shift
    + t0 b1 1000 1001 setuidgid -g 1000,1001 1000 cp -p
    + f=b1
    + shift
    + u=1000
    + shift
    + f=b1
    + shift
    + u=1000
    + shift
    + g=1001
    + shift
    + t0 b1 1000 1001 setuidgid -g 1000,1001 1000 cp -p
    + f=b1
    + shift
    + u=1000
    + shift
    + g=1001
    + shift
    + rm -f b
    + setuidgid -g 1000,1001 1000 cp -p b1 b
    ++ stat -c '%u %g' b
    + s=1000 1001
    + test 'x1000 1001' '!=' 'x1000 1001'
    + t1 c0 1000 1000 cp -p
    + f=c0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 c0 1000 1000 setuidgid -g 1000,1001 1000 cp -p
    + f=c0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + setuidgid -g 1000,1001 1000 cp -p c0 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 c1 1000 1001 cp -p
    + f=c1
    + shift
    + u=1000
    + shift
    + g=1001
    + shift
    + t0 c1 1000 1001 setuidgid -g 1000,1001 1000 cp -p
    + f=c1
    + shift
    + u=1000
    + shift
    + g=1001
    + shift
    + rm -f b
    + setuidgid -g 1000,1001 1000 cp -p c1 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1001'
    + test 'x1000 1000' = 'x1000 0'
    + echo '../../coreutils-8.9/tests/cp/preserve-gid: setuidgid -g 
1000,1001 1000 cp -p c1 b: 1000 1001 != 1000 1000'
    ../../coreutils-8.9/tests/cp/preserve-gid: setuidgid -g 1000,1001 
1000 cp -p c1 b: 1000 1001 != 1000 1000
    + Exit 1
    + set +e
    + exit 1
    + exit 1
    + remove_tmp_


To investigate, i disable  the remove_tmp_ function and take a look at 
the temporary folder :


    [root <at> pompomgalli] cd tests/gt-preserve-gid.jLiF/

    [root <at> pompomgalli] ls -ld *

    -rw-r--r--    1 root     root            3 Mar 19 15:18 a0
    -rw-r--r--    1 1000     1000            3 Mar 19 15:18 b
    -rw-r--r--    1 1000     1000            3 Mar 19 15:18 b0
    -rw-r--r--    1 1000     1001            3 Mar 19 15:18 b1
    -rw-r--r--    1 root     1000            3 Mar 19 15:18 c0
    -rw-r--r--    1 root     1001            3 Mar 19 15:18 c1

    [root <at> pompomgalli] ../../src/setuidgid -g 1000,1001 1000 
../../src/cp -p c1 ww

    [root <at> pompomgalli] ls -ld c1 ww

    -rw-r--r--    1 root     1001            3 Mar 19 15:18 c1
    -rw-r--r--    1 1000     1001            3 Mar 19 15:18 ww


The gid has been correctly preserved, so this is an environment issue :

    [root <at> pompomgalli] ../../src/setuidgid -g 1000,1001 1000 cp -p c1 ww2

    -rw-r--r--    1 root     1001            3 Mar 19 15:18 c1
    -rw-r--r--    1 1000     1001            3 Mar 19 15:18 ww
    -rw-r--r--    1 1000     1000            3 Mar 19 15:18 ww2


The PATH variables was :

    + 
PATH=/usr/src/coreutils-8.9_build/src:/usr/src/coreutils-8.9_build/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin

But the cp call ( "$@" "$f" b  ) in preserve-gid give :

    setuidgid -g 1000,1001 1000 cp -p c1 b

So the setuidgid used is the /usr/src/coreutils-8.9_build/src/setuidgid 
command, but, as the PATH variable isn't an exported variable, the 
setuigid command look for /bin/cp instead of 
/usr/src/coreutils-8.9_build/src/cp.
The local /bin/cp command used for the build was not intented to support 
that kind of operation, and i guess the test should concern the 
coreutils's cp command in the coreutils's build tree ^^.

Consequently, i make and apply this patch :


--- coreutils-8.9/tests/cp/preserve-gid.orig    2011-01-01 
22:19:23.000000000 +0100
+++ coreutils-8.9/tests/cp/preserve-gid 2011-03-19 16:04:59.000000000 +0100
@@ -93,28 +93,28 @@
 create c0 0 "$nameless_gid1"
 create c1 0 "$nameless_gid2"

-t0 a0 0 0 cp
-t0 b0 0 0 cp
-t0 b1 0 0 cp
-t0 c0 0 0 cp
-t0 c1 0 0 cp
+t0 a0 0 0 "${abs_path_dir_}/cp"
+t0 b0 0 0 "${abs_path_dir_}/cp"
+t0 b1 0 0 "${abs_path_dir_}/cp"
+t0 c0 0 0 "${abs_path_dir_}/cp"
+t0 c1 0 0 "${abs_path_dir_}/cp"

-t0 a0 0 0 cp -p
-t0 b0 "$nameless_uid" "$nameless_gid1" cp -p
-t0 b1 "$nameless_uid" "$nameless_gid2" cp -p
-t0 c0 0 "$nameless_gid1" cp -p
-t0 c1 0 "$nameless_gid2" cp -p
+t0 a0 0 0 "${abs_path_dir_}/cp" -p
+t0 b0 "$nameless_uid" "$nameless_gid1" "${abs_path_dir_}/cp" -p
+t0 b1 "$nameless_uid" "$nameless_gid2" "${abs_path_dir_}/cp" -p
+t0 c0 0 "$nameless_gid1" "${abs_path_dir_}/cp" -p
+t0 c1 0 "$nameless_gid2" "${abs_path_dir_}/cp" -p

-t1 a0 "$nameless_uid" "$nameless_gid1" cp
-t1 b0 "$nameless_uid" "$nameless_gid1" cp
-t1 b1 "$nameless_uid" "$nameless_gid1" cp
-t1 c0 "$nameless_uid" "$nameless_gid1" cp
-t1 c1 "$nameless_uid" "$nameless_gid1" cp
+t1 a0 "$nameless_uid" "$nameless_gid1" "${abs_path_dir_}/cp"
+t1 b0 "$nameless_uid" "$nameless_gid1" "${abs_path_dir_}/cp"
+t1 b1 "$nameless_uid" "$nameless_gid1" "${abs_path_dir_}/cp"
+t1 c0 "$nameless_uid" "$nameless_gid1" "${abs_path_dir_}/cp"
+t1 c1 "$nameless_uid" "$nameless_gid1" "${abs_path_dir_}/cp"

-t1 a0 "$nameless_uid" "$nameless_gid1" cp -p
-t1 b0 "$nameless_uid" "$nameless_gid1" cp -p
-t1 b1 "$nameless_uid" "$nameless_gid2" cp -p
-t1 c0 "$nameless_uid" "$nameless_gid1" cp -p
-t1 c1 "$nameless_uid" "$nameless_gid2" cp -p
+t1 a0 "$nameless_uid" "$nameless_gid1" "${abs_path_dir_}/cp" -p
+t1 b0 "$nameless_uid" "$nameless_gid1" "${abs_path_dir_}/cp" -p
+t1 b1 "$nameless_uid" "$nameless_gid2" "${abs_path_dir_}/cp" -p
+t1 c0 "$nameless_uid" "$nameless_gid1" "${abs_path_dir_}/cp" -p
+t1 c1 "$nameless_uid" "$nameless_gid2" "${abs_path_dir_}/cp" -p

 Exit $fail



But absolute path imply path traversal which can fail due to 
permissions, so here is the patch i my final choice :


--- coreutils-8.9/tests/cp/preserve-gid.orig    2011-01-01 
22:19:23.000000000 +0100
+++ coreutils-8.9/tests/cp/preserve-gid 2011-03-19 16:37:11.000000000 +0100
@@ -93,28 +93,28 @@
 create c0 0 "$nameless_gid1"
 create c1 0 "$nameless_gid2"

-t0 a0 0 0 cp
-t0 b0 0 0 cp
-t0 b1 0 0 cp
-t0 c0 0 0 cp
-t0 c1 0 0 cp
+t0 a0 0 0 "../${path_dir_}/cp"
+t0 b0 0 0 "../${path_dir_}/cp"
+t0 b1 0 0 "../${path_dir_}/cp"
+t0 c0 0 0 "../${path_dir_}/cp"
+t0 c1 0 0 "../${path_dir_}/cp"

-t0 a0 0 0 cp -p
-t0 b0 "$nameless_uid" "$nameless_gid1" cp -p
-t0 b1 "$nameless_uid" "$nameless_gid2" cp -p
-t0 c0 0 "$nameless_gid1" cp -p
-t0 c1 0 "$nameless_gid2" cp -p
+t0 a0 0 0 "../${path_dir_}/cp" -p
+t0 b0 "$nameless_uid" "$nameless_gid1" "../${path_dir_}/cp" -p
+t0 b1 "$nameless_uid" "$nameless_gid2" "../${path_dir_}/cp" -p
+t0 c0 0 "$nameless_gid1" "../${path_dir_}/cp" -p
+t0 c1 0 "$nameless_gid2" "../${path_dir_}/cp" -p

-t1 a0 "$nameless_uid" "$nameless_gid1" cp
-t1 b0 "$nameless_uid" "$nameless_gid1" cp
-t1 b1 "$nameless_uid" "$nameless_gid1" cp
-t1 c0 "$nameless_uid" "$nameless_gid1" cp
-t1 c1 "$nameless_uid" "$nameless_gid1" cp
+t1 a0 "$nameless_uid" "$nameless_gid1" "../${path_dir_}/cp"
+t1 b0 "$nameless_uid" "$nameless_gid1" "../${path_dir_}/cp"
+t1 b1 "$nameless_uid" "$nameless_gid1" "../${path_dir_}/cp"
+t1 c0 "$nameless_uid" "$nameless_gid1" "../${path_dir_}/cp"
+t1 c1 "$nameless_uid" "$nameless_gid1" "../${path_dir_}/cp"

-t1 a0 "$nameless_uid" "$nameless_gid1" cp -p
-t1 b0 "$nameless_uid" "$nameless_gid1" cp -p
-t1 b1 "$nameless_uid" "$nameless_gid2" cp -p
-t1 c0 "$nameless_uid" "$nameless_gid1" cp -p
-t1 c1 "$nameless_uid" "$nameless_gid2" cp -p
+t1 a0 "$nameless_uid" "$nameless_gid1" "../${path_dir_}/cp" -p
+t1 b0 "$nameless_uid" "$nameless_gid1" "../${path_dir_}/cp" -p
+t1 b1 "$nameless_uid" "$nameless_gid2" "../${path_dir_}/cp" -p
+t1 c0 "$nameless_uid" "$nameless_gid1" "../${path_dir_}/cp" -p
+t1 c1 "$nameless_uid" "$nameless_gid2" "../${path_dir_}/cp" -p

 Exit $fail

The checks are now all succesfull on my platform.

    ...
    =======================
    All 213 tests passed
    (16 tests were not run)
    =======================
    make[6]: Leaving directory `/usr/src/coreutils-8.9_build/gnulib-tests'
    make[5]: Leaving directory `/usr/src/coreutils-8.9_build/gnulib-tests'
    make[4]: Leaving directory `/usr/src/coreutils-8.9_build/gnulib-tests'
    make[3]: Leaving directory `/usr/src/coreutils-8.9_build/gnulib-tests'
    make[2]: Leaving directory `/usr/src/coreutils-8.9_build/gnulib-tests'
    make[2]: Entering directory `/usr/src/coreutils-8.9_build'
    make[2]: Nothing to be done for `check-am'.
    make[2]: Leaving directory `/usr/src/coreutils-8.9_build'
    make[1]: Leaving directory `/usr/src/coreutils-8.9_build'


The cp call ( "$@" "$f" b  ) in preserve-gid with arguments with quote 
could be a problem for some old fahsioned shells, even if i don't see 
any concerned shells.

Some commands in other test scripts could have the same problem and 
should be then enforced in the same way, i'll do this if this is the 
right solution.


Regards, Cedric.










Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#8292; Package coreutils. (Sun, 20 Mar 2011 08:16:02 GMT) Full text and rfc822 format available.

Message #8 received at 8292 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: arbogast.cedric <at> gmail.com
Cc: 8292 <at> debbugs.gnu.org
Subject: Re: bug#8292: COREUTILS-8.9: Potential bug in tests/cp/preserve-gid
Date: Sun, 20 Mar 2011 09:15:37 +0100
gmail wrote:
> This is my first contact and mail with this mailing list, to summarize
> i'm a coder maintening a personnal home server using several GNU tools
> since the late 90's.
>
> I build COREUTILS-8.9 in a chroot jail (gcc 4.5.2/libc 2.13/binutils
> 2.21/make 3.82) with an athlon architecture on ext3 FS and, as root,
> got one failed test on  tests/cp/preserve-gid :
...
> -t1 a0 "$nameless_uid" "$nameless_gid1" cp -p
> -t1 b0 "$nameless_uid" "$nameless_gid1" cp -p
> -t1 b1 "$nameless_uid" "$nameless_gid2" cp -p
> -t1 c0 "$nameless_uid" "$nameless_gid1" cp -p
> -t1 c1 "$nameless_uid" "$nameless_gid2" cp -p
> +t1 a0 "$nameless_uid" "$nameless_gid1" "../${path_dir_}/cp" -p
> +t1 b0 "$nameless_uid" "$nameless_gid1" "../${path_dir_}/cp" -p
> +t1 b1 "$nameless_uid" "$nameless_gid2" "../${path_dir_}/cp" -p
> +t1 c0 "$nameless_uid" "$nameless_gid1" "../${path_dir_}/cp" -p
> +t1 c1 "$nameless_uid" "$nameless_gid2" "../${path_dir_}/cp" -p
>
>  Exit $fail
>
> The checks are now all succesfull on my platform.
...
> The cp call ( "$@" "$f" b  ) in preserve-gid with arguments with quote
> could be a problem for some old fahsioned shells, even if i don't see
> any concerned shells.

If you find a problem, please let us know,
but due to the way init.sh selects a usable shell,
I think we don't have to worry about old shells.

> Some commands in other test scripts could have the same problem and
> should be then enforced in the same way, i'll do this if this is the
> right solution.

Nice analysis.  Thanks for reporting that.
That's a particularly convoluted part of the test suite.
I think the patch below solves the problem, too, while
continuing to invoke tools solely by their name
(i.e., with no relative or absolute prefix)
Can you confirm?

BTW, coreutils-8.10 is the latest stable release.

From 7a3eca37167590a0cc245dc4ea7cb23815d81665 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering <at> redhat.com>
Date: Sun, 20 Mar 2011 08:56:06 +0100
Subject: [PATCH] tests: fix a bug in cp/preserve-gid

* tests/cp/preserve-gid (t1): Export PATH into the environment used
by setuidgid, so that it runs the just-built "cp", rather than whatever
happens to be in $PATH.  Otherwise, we would see a test failure
whenever there is a less-functional cp in PATH.
Analysis by arbogast.cedric <at> gmail.com in http://debbugs.gnu.org/8292.
---
 tests/cp/preserve-gid |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/tests/cp/preserve-gid b/tests/cp/preserve-gid
index ac6d221..41b993c 100755
--- a/tests/cp/preserve-gid
+++ b/tests/cp/preserve-gid
@@ -56,7 +56,8 @@ t1() {
   f=$1; shift
   u=$1; shift
   g=$1; shift
-  t0 "$f" "$u" "$g" setuidgid -g "$nameless_gid1,$nameless_gid2" \
+  t0 "$f" "$u" "$g" env PATH="$PATH" \
+      setuidgid -g "$nameless_gid1,$nameless_gid2" \
       "$nameless_uid" "$@"
 }

--
1.7.4.1.499.g53f9




Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#8292; Package coreutils. (Sun, 20 Mar 2011 13:13:02 GMT) Full text and rfc822 format available.

Message #11 received at 8292 <at> debbugs.gnu.org (full text, mbox):

From: gmail <arbogast.cedric <at> gmail.com>
To: Jim Meyering <jim <at> meyering.net>
Cc: 8292 <at> debbugs.gnu.org
Subject: Re: bug#8292: COREUTILS-8.9: Potential bug in tests/cp/preserve-gid
Date: Sun, 20 Mar 2011 14:33:32 +0100
Jim Meyering wrote :
> gmail wrote:
>
>> Some commands in other test scripts could have the same problem and
>> should be then enforced in the same way, i'll do this if this is the
>> right solution.
> Nice analysis.  Thanks for reporting that.
> That's a particularly convoluted part of the test suite.
> I think the patch below solves the problem, too, while
> continuing to invoke tools solely by their name
> (i.e., with no relative or absolute prefix)
> Can you confirm?
>
> BTW, coreutils-8.10 is the latest stable release.
>
>  From 7a3eca37167590a0cc245dc4ea7cb23815d81665 Mon Sep 17 00:00:00 2001
> From: Jim Meyering<meyering <at> redhat.com>
> Date: Sun, 20 Mar 2011 08:56:06 +0100
> Subject: [PATCH] tests: fix a bug in cp/preserve-gid
>
> * tests/cp/preserve-gid (t1): Export PATH into the environment used
> by setuidgid, so that it runs the just-built "cp", rather than whatever
> happens to be in $PATH.  Otherwise, we would see a test failure
> whenever there is a less-functional cp in PATH.
> Analysis by arbogast.cedric <at> gmail.com in http://debbugs.gnu.org/8292.
> ---
>   tests/cp/preserve-gid |    3 ++-
>   1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/tests/cp/preserve-gid b/tests/cp/preserve-gid
> index ac6d221..41b993c 100755
> --- a/tests/cp/preserve-gid
> +++ b/tests/cp/preserve-gid
> @@ -56,7 +56,8 @@ t1() {
>     f=$1; shift
>     u=$1; shift
>     g=$1; shift
> -  t0 "$f" "$u" "$g" setuidgid -g "$nameless_gid1,$nameless_gid2" \
> +  t0 "$f" "$u" "$g" env PATH="$PATH" \
> +      setuidgid -g "$nameless_gid1,$nameless_gid2" \
>         "$nameless_uid" "$@"
>   }
>
> --
> 1.7.4.1.499.g53f9

It's a far better way to solve this, imho. I was reluctant to alter the 
environment, fearing side effects due to my lack of knownledge regarding 
coreutils test chain, but  your approach, a local change, is elegant, 
efficient and riskless.
Alas, i was wrong thinking it was due to an unexported PATH variable, 
the PATH variable was already exporterd, the problem was elsewhere   :

   (adding <typeset -p PATH> in the test) :

+ typeset -p PATH
declare -x 
PATH="/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"

But the setuigid command does not use this path, so the test fail :

[root <at> pompomgalli]# cd coreutils-8.9_build3

[root <at> pompomgalli]# cd tests/gt-preserve-gid.o3Qn

[root <at> zeus gt-preserve-gid.o3Qn]# ../../src/setuidgid -g 1000,1001 1000 
../../src/cp -p c1 ww

[root <at> zeus gt-preserve-gid.o3Qn]# ../../src/setuidgid -g 1000,1001 1000 
cp -p c1 ww2

[root <at> zeus gt-preserve-gid.o3Qn]# ls -l

total 32
-rw-r--r-- 1 root root 3 Mar 20 12:51 a0
-rw-r--r-- 1 1000 1000 3 Mar 20 12:51 b
-rw-r--r-- 1 1000 1000 3 Mar 20 12:51 b0
-rw-r--r-- 1 1000 1001 3 Mar 20 12:51 b1
-rw-r--r-- 1 root 1000 3 Mar 20 12:51 c0
-rw-r--r-- 1 root 1001 3 Mar 20 12:51 c1
-rw-r--r-- 1 1000 1001 3 Mar 20 12:51 ww
-rw-r--r-- 1 1000 1000 3 Mar 20 12:51 ww2

[root <at> zeus gt-preserve-gid.o3Qn]# cd ../..

[root <at> pompomgalli] NON_ROOT_USERNAME=cedric make -k check 
TESTS=cp/preserve-gid VERBOSE=yes

    FAIL: cp/preserve-gid (exit: 1)
    ===============================

    ++ initial_cwd_=/usr/src/coreutils-8.9_build3/tests
    ++ fail=0
    +++ testdir_prefix_
    +++ printf gt
    ++ pfx_=gt
    +++ mktempd_ /usr/src/coreutils-8.9_build3/tests gt-preserve-gid.XXXX
    +++ destdir_=/usr/src/coreutils-8.9_build3/tests
    +++ template_=gt-preserve-gid.XXXX
    +++ MAX_TRIES_=4
    ++++ unset TMPDIR
    ++++ mktemp -d -t -p /usr/src/coreutils-8.9_build3/tests 
gt-preserve-gid.XXXX
    +++ d=/usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.bDee
    +++ test -d /usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.bDee
    ++++ tr S -
    ++++ ls -dgo /usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.bDee
    +++ perms=drwx------ 2 4096 Mar 20 12:40 
/usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.bDee
    +++ test 0 = 0
    +++ echo /usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.bDee
    +++ return
    ++ test_dir_=/usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.bDee
    ++ cd /usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.bDee
    ++ gl_init_sh_nl_=

    ++ IFS=

    +++ expr 1 + 128
    ++ eval 'trap '\''Exit 129'\'' 1'
    +++ trap 'Exit 129' 1
    +++ expr 2 + 128
    ++ eval 'trap '\''Exit 130'\'' 2'
    +++ trap 'Exit 130' 2
    +++ expr 3 + 128
    ++ eval 'trap '\''Exit 131'\'' 3'
    +++ trap 'Exit 131' 3
    +++ expr 13 + 128
    ++ eval 'trap '\''Exit 141'\'' 13'
    +++ trap 'Exit 141' 13
    +++ expr 15 + 128
    ++ eval 'trap '\''Exit 143'\'' 15'
    +++ trap 'Exit 143' 15
    ++ trap remove_tmp_ 0
    + path_prepend_ ../src
    + test 1 '!=' 0
    + path_dir_=../src
    ++ cd /usr/src/coreutils-8.9_build3/tests/../src
    ++ echo /usr/src/coreutils-8.9_build3/src
    + abs_path_dir_=/usr/src/coreutils-8.9_build3/src
    + 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
    + create_exe_shims_ /usr/src/coreutils-8.9_build3/src
    + return 0
    + shift
    + test 0 '!=' 0
    + export PATH
    + print_ver_ cp
    + test yes = yes
    + local i
    + env cp --version
    cp (GNU coreutils) 8.9
    Copyright (C) 2011 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>.
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.

    Written by Torbj"orn Granlund, David MacKenzie, and Jim Meyering.
    + require_root_
    + uid_is_privileged_
    ++ id -u
    + my_uid=0
    + NON_ROOT_USERNAME=cedric
    ++ id -g cedric
    + NON_ROOT_GROUP=2003
    + working_umask_or_skip_
    + umask 022
    + touch file1 file2
    + chmod 644 file2
    ++ uniq
    ++ sed 's/ .*//'
    ++ ls -l file1 file2
    + perms=-rw-r--r--
    + rm -f file1 file2
    ++ id -g
    + primary_group_num=0
    ++ perl -le '
      foreach my $i (1000..16*1024-1)
        {
          getpwuid $i or (print $i), exit
        }
    '
    + nameless_uid=1000
    ++ perl -le '
      foreach my $i (1000..16*1024)
        {
          getgrgid $i or (print $i), exit
        }
    '
    + nameless_gid1=1000
    ++ perl -le '
      foreach my $i (1000+1..16*1024)
        {
          getgrgid $i or (print $i), exit
        }
    '
    + nameless_gid2=1001
    + test -z 1000
    + test -z 1000
    + test -z 1001
    + chown +1000:+0 .
    + create a0 0 0
    + echo a0
    + chown +0:+0 a0
    + create b0 1000 1000
    + echo b0
    + chown +1000:+1000 b0
    + create b1 1000 1001
    + echo b1
    + chown +1000:+1001 b1
    + create c0 0 1000
    + echo c0
    + chown +0:+1000 c0
    + create c1 0 1001
    + echo c1
    + chown +0:+1001 c1
    + t0 a0 0 0 cp
    + f=a0
    + shift
    + u=0
    + shift
    + g=0
    + shift
    + rm -f b
    + cp a0 b
    ++ stat -c '%u %g' b
    + s=0 0
    + test 'x0 0' '!=' 'x0 0'
    + t0 b0 0 0 cp
    + f=b0
    + shift
    + u=0
    + shift
    + g=0
    + shift
    + rm -f b
    + cp b0 b
    ++ stat -c '%u %g' b
    + s=0 0
    + test 'x0 0' '!=' 'x0 0'
    + t0 b1 0 0 cp
    + f=b1
    + shift
    + u=0
    + shift
    + g=0
    + shift
    + rm -f b
    + cp b1 b
    ++ stat -c '%u %g' b
    + s=0 0
    + test 'x0 0' '!=' 'x0 0'
    + t0 c0 0 0 cp
    + f=c0
    + shift
    + u=0
    + shift
    + g=0
    + shift
    + rm -f b
    + cp c0 b
    ++ stat -c '%u %g' b
    + s=0 0
    + test 'x0 0' '!=' 'x0 0'
    + t0 c1 0 0 cp
    + f=c1
    + shift
    + u=0
    + shift
    + g=0
    + shift
    + rm -f b
    + cp c1 b
    ++ stat -c '%u %g' b
    + s=0 0
    + test 'x0 0' '!=' 'x0 0'
    + t0 a0 0 0 cp -p
    + f=a0
    + shift
    + u=0
    + shift
    + g=0
    + shift
    + rm -f b
    + cp -p a0 b
    ++ stat -c '%u %g' b
    + s=0 0
    + test 'x0 0' '!=' 'x0 0'
    + t0 b0 1000 1000 cp -p
    + f=b0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + cp -p b0 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t0 b1 1000 1001 cp -p
    + f=b1
    + shift
    + u=1000
    + shift
    + g=1001
    + shift
    + rm -f b
    + cp -p b1 b
    ++ stat -c '%u %g' b
    + s=1000 1001
    + test 'x1000 1001' '!=' 'x1000 1001'
    + t0 c0 0 1000 cp -p
    + f=c0
    + shift
    + u=0
    + shift
    + g=1000
    + shift
    + rm -f b
    + cp -p c0 b
    ++ stat -c '%u %g' b
    + s=0 1000
    + test 'x0 1000' '!=' 'x0 1000'
    + t0 c1 0 1001 cp -p
    + f=c1
    + shift
    + u=0
    + shift
    + g=1001
    + shift
    + rm -f b
    + cp -p c1 b
    ++ stat -c '%u %g' b
    + s=0 1001
    + test 'x0 1001' '!=' 'x0 1001'
    + t1 a0 1000 1000 cp
    + f=a0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 a0 1000 1000 env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp
    + f=a0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp a0 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 b0 1000 1000 cp
    + f=b0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 b0 1000 1000 env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp
    + f=b0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp b0 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 b1 1000 1000 cp
    + f=b1
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 b1 1000 1000 env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp
    + f=b1
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp b1 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 c0 1000 1000 cp
    + f=c0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 c0 1000 1000 env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp
    + f=c0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp c0 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 c1 1000 1000 cp
    + f=c1
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 c1 1000 1000 env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp
    + f=c1
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp c1 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 a0 1000 1000 cp -p
    + f=a0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 a0 1000 1000 env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp -p
    + f=a0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp -p a0 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 b0 1000 1000 cp -p
    + f=b0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 b0 1000 1000 env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp -p
    + f=b0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp -p b0 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 b1 1000 1001 cp -p
    + f=b1
    + shift
    + u=1000
    + shift
    + g=1001
    + shift
    + t0 b1 1000 1001 env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp -p
    + f=b1
    + shift
    + u=1000
    + shift
    + shift
    + u=1000
    + shift
    + g=1001
    + shift
    + rm -f b
    + env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp -p b1 b
    ++ stat -c '%u %g' b
    + s=1000 1001
    + test 'x1000 1001' '!=' 'x1000 1001'
    + t1 c0 1000 1000 cp -p
    + f=c0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + t0 c0 1000 1000 env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp -p
    + f=c0
    + shift
    + u=1000
    + shift
    + g=1000
    + shift
    + rm -f b
    + env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp -p c0 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1000'
    + t1 c1 1000 1001 cp -p
    + f=c1
    + shift
    + u=1000
    + shift
    + g=1001
    + shift
    + t0 c1 1000 1001 env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp -p
    + f=c1
    + shift
    + u=1000
    + shift
    + g=1001
    + shift
    + rm -f b
    + env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp -p c1 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1001'
    + test 'x1000 1000' = 'x1000 0'
    + echo '../../coreutils-8.9/tests/cp/preserve-gid: env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp -
    p c1 b: 1000 1001 != 1000 1000'
    ../../coreutils-8.9/tests/cp/preserve-gid: env 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
setuidgid -g 1000,1001 1000 cp -p c1 b:
    1000 1001 != 1000 1000
    + Exit 1
    + set +e
    + exit 1
    + exit 1
    + remove_tmp_
    + __st=1
    + cleanup_
    + :
    + cd /usr/src/coreutils-8.9_build3/tests
    + chmod -R u+rwx 
/usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.bDee
    + rm -rf /usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.bDee
    + exit 1



Normally setuidgid MUST take the parent shell environment, so i finally 
add a strace in the test to the original source :


--- tests/cp/preserve-gid       2011-03-20 13:34:52.000000000 +0100
+++ tests/cp/preserve-gid.orig  2011-01-01 22:19:23.000000000 +0100
@@ -38,7 +38,7 @@
   u=$1; shift
   g=$1; shift
   rm -f b || exit 1
-  strace -o ../../trace.txt "$@" "$f" b || exit 1
+  "$@" "$f" b || exit 1
   s=`stat -c '%u %g' b`
   if test "x$s" != "x$u $g"; then
     # Allow the actual group to match that of the parent directory


And got this .... :


    execve("/usr/src/coreutils-8.9_build3/src/setuidgid", ["setuidgid", 
"-g", "1000,1001", "1000", "cp", "-p", "c1", "b"], [/* 72 vars */]) = 0
    brk(0)                                  = 0x804f000
    mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 
-1, 0) = 0xb77c0000
    access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file 
or directory)
    open("/lib/tls/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file 
or directory)
    stat64("/lib/tls/i686", 0xbf916d80)     = -1 ENOENT (No such file 
or directory)
    open("/lib/tls/libc.so.6", O_RDONLY)    = -1 ENOENT (No such file 
or directory)
    stat64("/lib/tls", 0xbf916d80)          = -1 ENOENT (No such file 
or directory)
    open("/lib/i686/libc.so.6", O_RDONLY)   = 3
    read(3, 
"\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0`o\1\000"..., 512) = 512
    fstat64(3, {st_mode=S_IFREG|0755, st_size=9034904, ...}) = 0
    mmap2(NULL, 1427976, PROT_READ|PROT_EXEC, 
MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7663000
    mprotect(0xb77b9000, 4096, PROT_NONE)   = 0
    mmap2(0xb77ba000, 12288, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x156) = 0xb77ba000
    mmap2(0xb77bd000, 10760, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb77bd000
    close(3)                                = 0
    mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 
-1, 0) = 0xb7662000
    set_thread_area({entry_number:-1 -> 6, base_addr:0xb76626c0, 
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, 
limit_in_pages:1, seg_not_present:0, useable:1}) = 0
    mprotect(0xb77ba000, 8192, PROT_READ)   = 0
    mprotect(0xb77dd000, 4096, PROT_READ)   = 0
    brk(0)                                  = 0x804f000
    brk(0x8070000)                          = 0x8070000
    setgroups32(0x2, 0x804f038)             = 0
    setgid32(0x3e8)                         = 0
    setuid32(0x3e8)                         = 0
>>  execve("/usr/src/coreutils-8.9_build3/src/cp", ["cp", "-p", "c1", 
"b"], [/* 72 vars */]) = -1 EACCES (Permission denied)
>>  execve("/usr/src/coreutils-8.9_build3/src/cp", ["cp", "-p", "c1", 
"b"], [/* 72 vars */]) = -1 EACCES (Permission denied)
    execve("./cp", ["cp", "-p", "c1", "b"], [/* 72 vars */]) = -1 
ENOENT (No such file or directory)
    execve("/bin/cp", ["cp", "-p", "c1", "b"], [/* 72 vars */]) = 0
    brk(0)                                  = 0x8055000


The setuidgid has the PATH, but this is an absolute PATH and PATH 
traversal with the test uid/gid  fail. The command then fall on the 
first available cp command on the remaining PATH...

So i have lightly modified your patch in the following way :

--- tests/cp/preserve-gid.jme   2011-03-20 12:57:53.000000000 +0100
+++ tests/cp/preserve-gid       2011-03-20 14:05:19.000000000 +0100
@@ -56,7 +56,7 @@
   f=$1; shift
   u=$1; shift
   g=$1; shift
-  t0 "$f" "$u" "$g" env PATH="$PATH" \
+  t0 "$f" "$u" "$g" env PATH="../../src:$PATH" \
       setuidgid -g "$nameless_gid1,$nameless_gid2" \
       "$nameless_uid" "$@"
 }



And the test was then succesfull.

Perhaps the use of absolute paths with test uid/gid  is the real problem 
that should be addressed ?

Regards, Cédric.














Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#8292; Package coreutils. (Sun, 20 Mar 2011 14:38:03 GMT) Full text and rfc822 format available.

Message #14 received at 8292 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: gmail <arbogast.cedric <at> gmail.com>
Cc: 8292 <at> debbugs.gnu.org
Subject: Re: bug#8292: COREUTILS-8.9: Potential bug in tests/cp/preserve-gid
Date: Sun, 20 Mar 2011 15:37:16 +0100
gmail wrote:
...
> Normally setuidgid MUST take the parent shell environment, so i
> finally add a strace in the test to the original source :

Thanks for investigating.

> --- tests/cp/preserve-gid       2011-03-20 13:34:52.000000000 +0100
> +++ tests/cp/preserve-gid.orig  2011-01-01 22:19:23.000000000 +0100
> @@ -38,7 +38,7 @@
>    u=$1; shift
>    g=$1; shift
>    rm -f b || exit 1
> -  strace -o ../../trace.txt "$@" "$f" b || exit 1
> +  "$@" "$f" b || exit 1
>    s=`stat -c '%u %g' b`
>    if test "x$s" != "x$u $g"; then
>      # Allow the actual group to match that of the parent directory
>
> And got this .... :
...
>>>  execve("/usr/src/coreutils-8.9_build3/src/cp", ["cp", "-p", "c1",
> "b"], [/* 72 vars */]) = -1 EACCES (Permission denied)
...
> The setuidgid has the PATH, but this is an absolute PATH and PATH
> traversal with the test uid/gid  fail.

But why is that?  I.e., it implies that NON_ROOT_USERNAME (your
"cedric" user) cannot run that program, yet the README instructions
regarding how to run root tests suggest that NON_ROOT_USERNAME must
have access to the sources and built programs.

Can you reproduce the failure if you follow these guidelines from
the README file?

    I find that it is best to unpack and build as a non-privileged
    user, and then to run the following command as that user in order
    to run the privilege-requiring tests:

      sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k check-root




Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#8292; Package coreutils. (Sun, 20 Mar 2011 16:50:03 GMT) Full text and rfc822 format available.

Message #17 received at 8292 <at> debbugs.gnu.org (full text, mbox):

From: gmail <arbogast.cedric <at> gmail.com>
To: Jim Meyering <jim <at> meyering.net>
Cc: 8292 <at> debbugs.gnu.org
Subject: Re: bug#8292: COREUTILS-8.9: Potential bug in tests/cp/preserve-gid
Date: Sun, 20 Mar 2011 18:10:48 +0100
Le 20/03/2011 15:37, Jim Meyering a écrit :
> gmail wrote:
> ...
>> Normally setuidgid MUST take the parent shell environment, so i
>> finally add a strace in the test to the original source :
> Thanks for investigating.
>
>> --- tests/cp/preserve-gid       2011-03-20 13:34:52.000000000 +0100
>> +++ tests/cp/preserve-gid.orig  2011-01-01 22:19:23.000000000 +0100
>> @@ -38,7 +38,7 @@
>>     u=$1; shift
>>     g=$1; shift
>>     rm -f b || exit 1
>> -  strace -o ../../trace.txt "$@" "$f" b || exit 1
>> +  "$@" "$f" b || exit 1
>>     s=`stat -c '%u %g' b`
>>     if test "x$s" != "x$u $g"; then
>>       # Allow the actual group to match that of the parent directory
>>
>> And got this .... :
> ...
>>>>   execve("/usr/src/coreutils-8.9_build3/src/cp", ["cp", "-p", "c1",
>> "b"], [/* 72 vars */]) = -1 EACCES (Permission denied)
> ...
>> The setuidgid has the PATH, but this is an absolute PATH and PATH
>> traversal with the test uid/gid  fail.
> But why is that?  I.e., it implies that NON_ROOT_USERNAME (your
> "cedric" user) cannot run that program, yet the README instructions
> regarding how to run root tests suggest that NON_ROOT_USERNAME must
> have access to the sources and built programs.
>
> Can you reproduce the failure if you follow these guidelines from
> the README file?
>
>      I find that it is best to unpack and build as a non-privileged
>      user, and then to run the following command as that user in order
>      to run the privilege-requiring tests:
>
>        sudo env PATH="$PATH" NON_ROOT_USERNAME=$USER make -k check-root

it seems i have not been enough precise, to be clear, "cedric" user HAS 
full read/write access to the source and the build :


[root <at> pompomgalli] # su cedric

[root <at> pompomgalli]$ find /usr/src/coreutils-8.9 -name preserve-gid

/usr/src/coreutils-8.9/tests/cp/preserve-gid

[root <at> pompomgalli]$ find /usr/src/coreutils-8.9_build -name preserve-gid.log

/usr/src/coreutils-8.9_build/tests/cp/preserve-gid.log

[root <at> pompomgalli]$ touch /usr/src/coreutils-8.9_build3/writing

[root <at> pompomgalli]$ touch /usr/src/coreutils-8.9/writing

[root <at> pompomgalli]$



And the test fail anyway as root :


    FAIL: cp/preserve-gid (exit: 1)
    ===============================

    ++ initial_cwd_=/usr/src/coreutils-8.9_build3/tests
    ++ fail=0
    +++ testdir_prefix_
    +++ printf gt
    ++ pfx_=gt
    +++ mktempd_ /usr/src/coreutils-8.9_build3/tests gt-preserve-gid.XXXX
    +++ destdir_=/usr/src/coreutils-8.9_build3/tests
    +++ template_=gt-preserve-gid.XXXX
    +++ MAX_TRIES_=4
    ++++ unset TMPDIR
    ++++ mktemp -d -t -p /usr/src/coreutils-8.9_build3/tests 
gt-preserve-gid.XXXX
    +++ d=/usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.l7ug
    +++ test -d /usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.l7ug
    ++++ tr S -
    ++++ ls -dgo /usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.l7ug
    +++ perms=drwx------ 2 4096 Mar 20 17:31 
/usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.l7ug
    +++ test 0 = 0
    +++ echo /usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.l7ug
    +++ return
    ++ test_dir_=/usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.l7ug
    ++ cd /usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.l7ug
    ++ gl_init_sh_nl_=

    ++ IFS=

    +++ expr 1 + 128
    ++ eval 'trap '\''Exit 129'\'' 1'
    +++ trap 'Exit 129' 1
    +++ expr 2 + 128
    ++ eval 'trap '\''Exit 130'\'' 2'
    +++ trap 'Exit 130' 2

    ....

    + t0 c1 1000 1001 setuidgid -g 1000,1001 1000 cp -p
    + f=c1
    + shift
    + u=1000
    + shift
    + g=1001
    + shift
    + rm -f b
    + setuidgid -g 1000,1001 1000 cp -p c1 b
    ++ stat -c '%u %g' b
    + s=1000 1000
    + test 'x1000 1000' '!=' 'x1000 1001'
    + test 'x1000 1000' = 'x1000 0'
    + echo '../../coreutils-8.9/tests/cp/preserve-gid: setuidgid -g 
1000,1001 1000 cp -p c1 b: 1000 1001 != 1000 1000'
    ../../coreutils-8.9/tests/cp/preserve-gid: setuidgid -g 1000,1001 
1000 cp -p c1 b: 1000 1001 != 1000 1000
    + Exit 1
    + set +e
    + exit 1
    + exit 1
    + remove_tmp_
    + __st=1
    + cleanup_
    + :
    + cd /usr/src/coreutils-8.9_build3/tests
    + chmod -R u+rwx 
/usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.l7ug
    + rm -rf /usr/src/coreutils-8.9_build3/tests/gt-preserve-gid.l7ug
    + exit 1

The user '1000', gid '1001' used for the gt-preserve-gid test  no access 
to the /usr/src root, and i see nothing in the guideline requiring to 
give unrestricted source and build access to anyone.
This is under this uid account that the setuigid try to launch the 
builded cp and fail, due to the fact that the PATH variable has a full 
path refering to /usr/src/coreutils-8.9_build3/src, implying a path 
traversal with uid 1000  :

    + 
PATH=/usr/src/coreutils-8.9_build3/src:/usr/src/coreutils-8.9_build3/src:.:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin


This patch is a way to solve  this problem :

--- tests/cp/preserve-gid.orig  2011-01-01 22:19:23.000000000 +0100
+++ tests/cp/preserve-gid.cea   2011-03-20 14:05:19.000000000 +0100
@@ -56,7 +56,8 @@
   f=$1; shift
   u=$1; shift
   g=$1; shift
-  t0 "$f" "$u" "$g" setuidgid -g "$nameless_gid1,$nameless_gid2" \
+  t0 "$f" "$u" "$g" env PATH="../../src:$PATH" \
+      setuidgid -g "$nameless_gid1,$nameless_gid2" \
       "$nameless_uid" "$@"
 }


An other way could be to check if the PATH variable could have a 
relative path instead of a full path, which need far more work.

There could be other problems of this kind in other tests using uid/gid 
change too, but the gt-preserve-gid was the only test that fail in my build.

Regards, Cedric.






Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#8292; Package coreutils. (Sun, 20 Mar 2011 18:59:01 GMT) Full text and rfc822 format available.

Message #20 received at 8292 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: gmail <arbogast.cedric <at> gmail.com>
Cc: 8292 <at> debbugs.gnu.org
Subject: Re: bug#8292: COREUTILS-8.9: Potential bug in tests/cp/preserve-gid
Date: Sun, 20 Mar 2011 19:58:30 +0100
gmail wrote:
> This patch is a way to solve  this problem :
>
> --- tests/cp/preserve-gid.orig  2011-01-01 22:19:23.000000000 +0100
> +++ tests/cp/preserve-gid.cea   2011-03-20 14:05:19.000000000 +0100
> @@ -56,7 +56,8 @@
>    f=$1; shift
>    u=$1; shift
>    g=$1; shift
> -  t0 "$f" "$u" "$g" setuidgid -g "$nameless_gid1,$nameless_gid2" \
> +  t0 "$f" "$u" "$g" env PATH="../../src:$PATH" \
> +      setuidgid -g "$nameless_gid1,$nameless_gid2" \

Thanks for the suggestion, but that doesn't work when using a umask of 077.
In that case, the cp executable is not usable by $nameless_uid, period,
regardless of directory permissions.

Here is a proposed patch that should do the trick:

From 3ed2bb6975f08597ab5ea216378ef27561309135 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering <at> redhat.com>
Date: Sun, 20 Mar 2011 08:56:06 +0100
Subject: [PATCH] tests: fix a bug in the cp/preserve-gid test

* tests/cp/preserve-gid: Ensure that every process under test uses
the cp binary we've just built.  Before this fix, the UID-changing
tests would end up using whatever cp happened to be available through
$PATH when umask or build-dir permissions were restrictive.
Analysis by arbogast.cedric <at> gmail.com in http://debbugs.gnu.org/8292.
---
 tests/cp/preserve-gid |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/tests/cp/preserve-gid b/tests/cp/preserve-gid
index ac6d221..552032a 100755
--- a/tests/cp/preserve-gid
+++ b/tests/cp/preserve-gid
@@ -52,14 +52,6 @@ t0() {
   fi
 }

-t1() {
-  f=$1; shift
-  u=$1; shift
-  g=$1; shift
-  t0 "$f" "$u" "$g" setuidgid -g "$nameless_gid1,$nameless_gid2" \
-      "$nameless_uid" "$@"
-}
-
 nameless_uid=`$PERL -le '
   foreach my $i (1000..16*1024-1)
     {
@@ -105,6 +97,25 @@ t0 b1 "$nameless_uid" "$nameless_gid2" cp -p
 t0 c0 0 "$nameless_gid1" cp -p
 t0 c1 0 "$nameless_gid2" cp -p

+# For the remaining tests, we need a cp binary that is accessible to a user
+# with UID of $nameless_uid.  The build directory may not be accessible,
+# so create a temporary directory and copy cp into it, ensure that
+# $nameless_uid can access it and then make that directory the search path.
+tmp_path=
+cleanup_() { rm -rf "$tmp_path"; }
+tmp_path=$(mktemp -d) || fail_ "failed to create temporary directory"
+cp "$abs_path_dir_/cp" "$tmp_path"
+chown -R $nameless_uid "$tmp_path"
+
+t1() {
+  f=$1; shift
+  u=$1; shift
+  g=$1; shift
+  t0 "$f" "$u" "$g" env \
+      setuidgid -g "$nameless_gid1,$nameless_gid2" \
+      "$nameless_uid" env PATH="$tmp_path" "$@"
+}
+
 t1 a0 "$nameless_uid" "$nameless_gid1" cp
 t1 b0 "$nameless_uid" "$nameless_gid1" cp
 t1 b1 "$nameless_uid" "$nameless_gid1" cp
--
1.7.4.1.499.g53f9




Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#8292; Package coreutils. (Sun, 20 Mar 2011 22:18:01 GMT) Full text and rfc822 format available.

Message #23 received at 8292 <at> debbugs.gnu.org (full text, mbox):

From: gmail <arbogast.cedric <at> gmail.com>
To: Jim Meyering <jim <at> meyering.net>
Cc: 8292 <at> debbugs.gnu.org
Subject: Re: bug#8292: COREUTILS-8.9: Potential bug in tests/cp/preserve-gid
Date: Sun, 20 Mar 2011 23:38:59 +0100
Le 20/03/2011 19:58, Jim Meyering a écrit :
> gmail wrote:
>> This patch is a way to solve  this problem :
>>
>> --- tests/cp/preserve-gid.orig  2011-01-01 22:19:23.000000000 +0100
>> +++ tests/cp/preserve-gid.cea   2011-03-20 14:05:19.000000000 +0100
>> @@ -56,7 +56,8 @@
>>     f=$1; shift
>>     u=$1; shift
>>     g=$1; shift
>> -  t0 "$f" "$u" "$g" setuidgid -g "$nameless_gid1,$nameless_gid2" \
>> +  t0 "$f" "$u" "$g" env PATH="../../src:$PATH" \
>> +      setuidgid -g "$nameless_gid1,$nameless_gid2" \
> Thanks for the suggestion, but that doesn't work when using a umask of 077.
> In that case, the cp executable is not usable by $nameless_uid, period,
> regardless of directory permissions.
>
> Here is a proposed patch that should do the trick:
>
>  From 3ed2bb6975f08597ab5ea216378ef27561309135 Mon Sep 17 00:00:00 2001
> From: Jim Meyering<meyering <at> redhat.com>
> Date: Sun, 20 Mar 2011 08:56:06 +0100
> Subject: [PATCH] tests: fix a bug in the cp/preserve-gid test
>
> * tests/cp/preserve-gid: Ensure that every process under test uses
> the cp binary we've just built.  Before this fix, the UID-changing
> tests would end up using whatever cp happened to be available through
> $PATH when umask or build-dir permissions were restrictive.
> Analysis by arbogast.cedric <at> gmail.com in http://debbugs.gnu.org/8292.
> ---
>   tests/cp/preserve-gid |   27 +++++++++++++++++++--------
>   1 files changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/tests/cp/preserve-gid b/tests/cp/preserve-gid
> index ac6d221..552032a 100755
> --- a/tests/cp/preserve-gid
> +++ b/tests/cp/preserve-gid
> @@ -52,14 +52,6 @@ t0() {
>     fi
>   }
>
> -t1() {
> -  f=$1; shift
> -  u=$1; shift
> -  g=$1; shift
> -  t0 "$f" "$u" "$g" setuidgid -g "$nameless_gid1,$nameless_gid2" \
> -      "$nameless_uid" "$@"
> -}
> -
>   nameless_uid=`$PERL -le '
>     foreach my $i (1000..16*1024-1)
>       {
> @@ -105,6 +97,25 @@ t0 b1 "$nameless_uid" "$nameless_gid2" cp -p
>   t0 c0 0 "$nameless_gid1" cp -p
>   t0 c1 0 "$nameless_gid2" cp -p
>
> +# For the remaining tests, we need a cp binary that is accessible to a user
> +# with UID of $nameless_uid.  The build directory may not be accessible,
> +# so create a temporary directory and copy cp into it, ensure that
> +# $nameless_uid can access it and then make that directory the search path.
> +tmp_path=
> +cleanup_() { rm -rf "$tmp_path"; }
> +tmp_path=$(mktemp -d) || fail_ "failed to create temporary directory"
> +cp "$abs_path_dir_/cp" "$tmp_path"
> +chown -R $nameless_uid "$tmp_path"
> +
> +t1() {
> +  f=$1; shift
> +  u=$1; shift
> +  g=$1; shift
> +  t0 "$f" "$u" "$g" env \
> +      setuidgid -g "$nameless_gid1,$nameless_gid2" \
> +      "$nameless_uid" env PATH="$tmp_path" "$@"
> +}
> +
>   t1 a0 "$nameless_uid" "$nameless_gid1" cp
>   t1 b0 "$nameless_uid" "$nameless_gid1" cp
>   t1 b1 "$nameless_uid" "$nameless_gid1" cp
> --
> 1.7.4.1.499.g53f9

The patch is efficient, the test is successfull on my build.
Thanks for considering my mail, sorry for the work overhead due to my 
lack of precision and my first wrong analysis.

Request me if needed for further tests/works/etc. relating to 
core-utils, i could get availability for.

Regards, Cedric.






Reply sent to Jim Meyering <jim <at> meyering.net>:
You have taken responsibility. (Mon, 21 Mar 2011 06:41:02 GMT) Full text and rfc822 format available.

Notification sent to gmail <arbogast.cedric <at> gmail.com>:
bug acknowledged by developer. (Mon, 21 Mar 2011 06:41:02 GMT) Full text and rfc822 format available.

Message #28 received at 8292-done <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: gmail <arbogast.cedric <at> gmail.com>
Cc: 8292-done <at> debbugs.gnu.org
Subject: Re: bug#8292: COREUTILS-8.9: Potential bug in tests/cp/preserve-gid
Date: Mon, 21 Mar 2011 07:40:29 +0100
> The patch is efficient, the test is successfull on my build.

Thanks again for the report and the prompt replies.
I've pushed that.
I'm closing this ticket.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 18 Apr 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 18 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.