Use numeric group ids, not symbolic group names, to avoid shell quoting issues.

This commit is contained in:
Paul Eggert 2005-01-17 22:40:57 +00:00
parent c994637901
commit b10a836fa0
6 changed files with 34 additions and 20 deletions

View File

@ -1,7 +1,17 @@
2005-01-15 Jim Meyering <jim@meyering.net>
2005-01-17 Paul Eggert <eggert@cs.ucla.edu>
* 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 <jim@meyering.net>
* 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.

View File

@ -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

View File

@ -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 <<EOF 1>&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

View File

@ -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

View File

@ -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

View File

@ -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 <<EOF 1>&2