Applied Paul Eggert's patch which corrects a POSIX non-conformance for '-perm ++r'

This commit is contained in:
James Youngman 2005-05-25 19:57:43 +00:00
parent 645ad71e56
commit de2a4f4dd1
6 changed files with 75 additions and 25 deletions

View File

@ -21,7 +21,7 @@ David J. MacKenzie
Jim Meyering
Tim Wood
Kevin Dalley <kevind@rahul.net>
Paul Eggert <eggert@twinsun.com>
Paul Eggert <eggert@cs.ucla.edu>
James Youngman <jay@gnu.org>
Jay Plett
Paul Sheer

View File

@ -1,3 +1,11 @@
2005-05-23 Paul Eggert <eggert@cs.ucla.edu>
Adjust to recent gnulib changes.
* import-gnulib.sh: Get config.rpath from gnulib/build-aux,
not gnulib/config.
* find/parser.c (parse_perm): Ignore umask when parsing
symbolic permissions. Adjust to new modechange API.
2005-05-16 James Youngman <jay@gnu.org>
* find/find.c, find/parser.c, find/pred.c, find/tree.c:

7
NEWS
View File

@ -1,5 +1,12 @@
GNU findutils NEWS - User visible changes. -*- outline -*- (allout)
* Major changes in release 4.2.21-CVS
** Functional Changes
The GNU extension "find ... -perm +MODE" has been withdrawn because it
is incompatible with POSIX in obscure cases like "find ... -perm ++r".
Use the new syntax "find ... -perm /MODE" instead. Old usages will
still continue to work, so long as they don't conflict with POSIX.
** Bug Fixes
find /blah/blah/blah -depth -empty now works once again.

View File

@ -907,16 +907,16 @@ numeric or symbolic).
If @var{mode} starts with @samp{-}, true if
@emph{all} of the permissions set in @var{mode} are set for the file;
permissions not set in @var{mode} are ignored.
If @var{mode} starts with @samp{+}, true if
If @var{mode} starts with @samp{/}, true if
@emph{any} of the permissions set in @var{mode} are set for the file;
permissions not set in @var{mode} are ignored.
This is a GNU extension.
If you don't use the @samp{+} or @samp{-} form with a symbolic mode
If you don't use the @samp{/} or @samp{-} form with a symbolic mode
string, you may have to specify a rather complex mode string. For
example @samp{-perm g=w} will only match files which have mode 0020
(that is, ones for which group write permission is the only permission
set). It is more likely that you will want to use the @samp{+} or
set). It is more likely that you will want to use the @samp{/} or
@samp{-} forms, for example @samp{-perm -g=w}, which matches any file
with group write permission.
@ -935,19 +935,19 @@ without regard to the presence of any extra permission bits (for
example the executable bit). This will match a file which has mode
0777, for example.
@item -perm +222
@item -perm /222
Match files which are writeable by somebody (their owner, or
their group, or anybody else).
@item -perm +022
@item -perm /022
Match files which are writeable by either their owner or their
group. The files don't have to be writeable by both the owner and
group to be matched; either will do.
@item -perm +g+w,o+w
@item -perm /g+w,o+w
As above.
@item -perm +g=w,o=w
@item -perm /g=w,o=w
As above
@item -perm -022
@ -1994,7 +1994,7 @@ running @code{file} on files that are not regular files or are not
executable.
@example
find /usr/local -type f -perm +a=x | xargs file |
find /usr/local -type f -perm /a=x | xargs file |
grep 'not stripped' | cut -d: -f1
@end example
@ -2037,7 +2037,7 @@ scripts) in the file @file{sbins} and the unstripped ones in
@file{ubins}.
@example
find /usr/local -type f -perm +a=x \
find /usr/local -type f -perm /a=x \
\( -execdir unstripped '@{@}' \; -fprint ubins -o -fprint sbins \)
@end example

View File

@ -1,5 +1,5 @@
/* parser.c -- convert the command line args into an expression tree.
Copyright (C) 1990, 91, 92, 93, 94, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
Copyright (C) 1990, 91, 92, 93, 94, 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -1214,7 +1214,8 @@ parse_perm (char **argv, int *arg_ptr)
{
mode_t perm_val;
int mode_start = 0;
struct mode_change *change;
enum permissions_type kind = PERM_EXACT;
struct mode_change *change = NULL;
struct predicate *our_pred;
if ((argv == NULL) || (argv[*arg_ptr] == NULL))
@ -1223,22 +1224,56 @@ parse_perm (char **argv, int *arg_ptr)
switch (argv[*arg_ptr][0])
{
case '-':
case '+':
mode_start = 1;
kind = PERM_AT_LEAST;
break;
case '+':
change = mode_compile (argv[*arg_ptr]);
if (NULL == change)
{
/* Most likely the caller is an old script that is still
* using the obsolete GNU syntax '-perm +MODE'. This old
* syntax was withdrawn in favor of '-perm /MODE' because
* it is incompatible with POSIX in some cases, but we
* still support uses of it that are not incompatible with
* POSIX.
*/
mode_start = 1;
kind = PERM_ANY;
}
else
{
/* This is a POSIX-compatible usage */
mode_start = 0;
kind = PERM_EXACT;
}
break;
case '/': /* GNU extension */
mode_start = 1;
kind = PERM_ANY;
break;
default:
/* empty */
/* For example, '-perm 0644', which is valid and matches
* only files whose mode is exactly 0644.
*
* We do nothing here, because mode_start and kind are already
* correctly set.
*/
break;
}
change = mode_compile (argv[*arg_ptr] + mode_start, MODE_MASK_PLUS);
if (change == MODE_INVALID)
error (1, 0, _("invalid mode `%s'"), argv[*arg_ptr]);
else if (change == MODE_MEMORY_EXHAUSTED)
error (1, 0, _("virtual memory exhausted"));
perm_val = mode_adjust (0, change);
mode_free (change);
if (NULL == change)
{
change = mode_compile (argv[*arg_ptr] + mode_start);
if (NULL == change)
error (1, 0, _("invalid mode `%s'"), argv[*arg_ptr]);
}
perm_val = mode_adjust (0, change, 0);
free (change);
our_pred = insert_primary (pred_perm);
switch (argv[*arg_ptr][0])

View File

@ -1,7 +1,7 @@
#! /bin/sh
#
# import-gnulib.sh -- imports a copy of gnulib into findutils
# Copyright (C) 2003,2004 Free Software Foundation, Inc.
# Copyright (C) 2003,2004,2005 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -144,5 +144,5 @@ EOF
# some reason, "autoreconf -i" doesn't fetch it.
for f in config.rpath
do
(set -x; cp "$1"/config/"$f" . )
(set -x; cp "$1"/build-aux/"$f" . )
done