From: Paul Eggert Date: Mon, 17 Jan 2005 22:40:57 +0000 (+0000) Subject: Use numeric group ids, not symbolic group names, to avoid shell quoting issues. X-Git-Tag: CPPI-1_12~1591 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b10a836fa0f27b5f2ef1491c3226681a97ea4072;p=platform%2Fupstream%2Fcoreutils.git Use numeric group ids, not symbolic group names, to avoid shell quoting issues. --- diff --git a/ChangeLog b/ChangeLog index 1e27636..97b00d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,17 @@ -2005-01-15 Jim Meyering +2005-01-17 Paul Eggert * Version 5.3.1. + * tests/group-names: Use numeric group ids, not symbolic group names, + since the latter can have shell metacharacters in them (e.g., spaces). + Problem reported by Eric Blake. + * tests/chgrp/basic: Assume groups are numeric, not symbolic. + * tests/chgrp/deref: Likewise. + * tests/chgrp/posix-H: Likewise. + * tests/chgrp/recurse: Likewise. + +2005-01-15 Jim Meyering + * src/shred.c (isaac_seed) [HAVE_GETHRTIME]: #if-0 this block, because just calling gethrtime evokes an `illegal instruction' failure when compiled with Sun's c89 on Solaris 8 and 9. diff --git a/tests/chgrp/basic b/tests/chgrp/basic index de3d1ae..de43573 100755 --- a/tests/chgrp/basic +++ b/tests/chgrp/basic @@ -84,7 +84,11 @@ test "$VERBOSE" = yes && set +x chgrp '' f ls -c -t f g -) 2>&1 | sed "s/\([ :]\)$g1$/\1G1/;s/\([ :]\)$g2$/\1G2/" > actual +) 2>&1 | sed " + s/' to .*[^0-9:].*/' to SOMENAME/ + s/\([ :]\)$g1$/\1G1/ + s/\([ :]\)$g2$/\1G2/ +" > actual cat <<\EOF > expected changed group of `f' to G1 @@ -92,7 +96,7 @@ changed group of `f' to G2 ownership of `f' retained changed group of `f' to G1 group of `f' retained as G1 -changed group of `f' to G2 +changed group of `f' to SOMENAME changed group of `d/f3' to G2 changed group of `d' to G2 changed group of `d/f3' to G1 diff --git a/tests/chgrp/deref b/tests/chgrp/deref index 5e605bf..ff21512 100755 --- a/tests/chgrp/deref +++ b/tests/chgrp/deref @@ -30,7 +30,7 @@ touch f ln -s f symlink chgrp -h $g2 symlink 2> /dev/null -set _ `ls -l symlink` +set _ `ls -ln symlink` g=$5 test "$g" = $g2 || { cat <&2 @@ -43,25 +43,25 @@ EOF fail=0 chgrp $g1 f -set _ `ls -l f`; g=$5; test "$g" = $g1 || fail=1 +set _ `ls -ln f`; g=$5; test "$g" = $g1 || fail=1 chgrp -h $g2 symlink || fail=1 -set _ `ls -l f`; g=$5; test "$g" = $g1 || fail=1 -set _ `ls -l symlink`; g=$5; test "$g" = $g2 || fail=1 +set _ `ls -ln f`; g=$5; test "$g" = $g1 || fail=1 +set _ `ls -ln symlink`; g=$5; test "$g" = $g2 || fail=1 # This should not change the group of f. chgrp -h $g2 symlink || fail=1 -set _ `ls -l f`; g=$5; test "$g" = $g1 || fail=1 -set _ `ls -l symlink`; g=$5; test "$g" = $g2 || fail=1 +set _ `ls -ln f`; g=$5; test "$g" = $g1 || fail=1 +set _ `ls -ln symlink`; g=$5; test "$g" = $g2 || fail=1 chgrp $g2 f -set _ `ls -l f`; g=$5; test "$g" = $g2 || fail=1 +set _ `ls -ln f`; g=$5; test "$g" = $g2 || fail=1 # This *should* change the group of f. # Though note that the diagnostic you'd get with -c is misleading in that # it says the `group of `symlink'' has been changed. chgrp --dereference $g1 symlink -set _ `ls -l f`; g=$5; test "$g" = $g1 || fail=1 -set _ `ls -l symlink`; g=$5; test "$g" = $g2 || fail=1 +set _ `ls -ln f`; g=$5; test "$g" = $g1 || fail=1 +set _ `ls -ln symlink`; g=$5; test "$g" = $g2 || fail=1 (exit $fail); exit $fail diff --git a/tests/chgrp/posix-H b/tests/chgrp/posix-H index 92a2cd0..e973696 100755 --- a/tests/chgrp/posix-H +++ b/tests/chgrp/posix-H @@ -48,7 +48,7 @@ for i in $changed; do # Filter out symlinks (entries that end in `s'), since it's not # possible to change their group/owner information on some systems. case $i in *s) continue;; esac - set _ `ls -dg $i`; shift + set _ `ls -dgn $i`; shift group=$3 test $group = $g2 || fail=1 done @@ -64,7 +64,7 @@ for i in $not_changed; do # Filter out symlinks (entries that end in `s'), since it's not # possible to change their group/owner information on some systems. case $i in *s) continue;; esac - set _ `ls -dg $i`; shift + set _ `ls -dgn $i`; shift group=$3 test $group = $g1 || fail=1 done diff --git a/tests/chgrp/recurse b/tests/chgrp/recurse index 05aaa08..7cd1648 100755 --- a/tests/chgrp/recurse +++ b/tests/chgrp/recurse @@ -35,22 +35,22 @@ ln -s ../e d/s chgrp -R $g1 e/ee || fail=1 # This should not should change the group of e/ee chgrp -R $g2 d -set _ `ls -l e/ee`; g=$5; test "$g" = $g1 || fail=1 +set _ `ls -ln e/ee`; g=$5; test "$g" = $g1 || fail=1 # This must change the group of e/ee, since -L makes # chgrp traverse the symlink from d/s into e. chgrp -L -R $g2 d -set _ `ls -l e/ee`; g=$5; test "$g" = $g2 || fail=1 +set _ `ls -ln e/ee`; g=$5; test "$g" = $g2 || fail=1 # This must *not* change the group of e/ee chgrp -H -R $g1 d -set _ `ls -l e/ee`; g=$5; test "$g" = $g2 || fail=1 +set _ `ls -ln e/ee`; g=$5; test "$g" = $g2 || fail=1 ln -s d link # This shouldn't change the group of e/ee either. chgrp -H -R $g1 link || fail=1 -set _ `ls -l e/ee`; g=$5; test "$g" = $g2 || fail=1 +set _ `ls -ln e/ee`; g=$5; test "$g" = $g2 || fail=1 # But it *should* change d/dd. -set _ `ls -l d/dd`; g=$5; test "$g" = $g1 || fail=1 +set _ `ls -ln d/dd`; g=$5; test "$g" = $g1 || fail=1 (exit $fail); exit $fail diff --git a/tests/group-names b/tests/group-names index 5dae794..2bd22b4 100644 --- a/tests/group-names +++ b/tests/group-names @@ -2,7 +2,7 @@ # Set `groups' to a space-separated list of at least two groups of which # the user is a member. -groups=${FETISH_GROUPS-`(id -nG || /usr/xpg4/bin/id -nG) 2>/dev/null`} +groups=${FETISH_GROUPS-`(id -G || /usr/xpg4/bin/id -G) 2>/dev/null`} case "$groups" in *' '*) ;; *) cat <&2