Fixed bug which caused find -perm /440 to be treated the same as find -perm 440

This commit is contained in:
James Youngman 2005-07-31 21:12:43 +00:00
parent 7f0082feaf
commit 872c7615dc
5 changed files with 58 additions and 11 deletions

12
NEWS
View File

@ -1,4 +1,16 @@
GNU findutils NEWS - User visible changes. -*- outline -*- (allout)
* Major changes in release 4.2.25-CVS
** Bug Fixes
find -perm /440 (which should succeed if a file is readable by its
owner or group) now works. Previously there was a bug which
caused this to be treated as "find -perm 440".
** Other Changes
The test suite for find is now much more extensive.
* Major changes in release 4.2.24
** Documentation Changes

View File

@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT([GNU findutils], 4.2.24, [bug-findutils@gnu.org])
AC_INIT([GNU findutils], 4.2.25-CVS, [bug-findutils@gnu.org])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([find/pred.c])

View File

@ -1278,6 +1278,7 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
{
mode_t perm_val;
int mode_start = 0;
boolean havekind = false;
enum permissions_type kind = PERM_EXACT;
struct mode_change *change = NULL;
struct predicate *our_pred;
@ -1290,6 +1291,7 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
case '-':
mode_start = 1;
kind = PERM_AT_LEAST;
havekind = true;
break;
case '+':
@ -1312,11 +1314,13 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
mode_start = 0;
kind = PERM_EXACT;
}
havekind = true;
break;
case '/': /* GNU extension */
mode_start = 1;
kind = PERM_ANY;
havekind = true;
break;
default:
@ -1340,17 +1344,25 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
our_pred = insert_primary (entry);
switch (argv[*arg_ptr][0])
if (havekind)
{
case '-':
our_pred->args.perm.kind = PERM_AT_LEAST;
break;
case '+':
our_pred->args.perm.kind = PERM_ANY;
break;
default:
our_pred->args.perm.kind = PERM_EXACT;
break;
our_pred->args.perm.kind = kind;
}
else
{
switch (argv[*arg_ptr][0])
{
case '-':
our_pred->args.perm.kind = PERM_AT_LEAST;
break;
case '+':
our_pred->args.perm.kind = PERM_ANY;
break;
default:
our_pred->args.perm.kind = PERM_EXACT;
break;
}
}
our_pred->args.perm.val = perm_val & MODE_ALL;
(*arg_ptr)++;

View File

@ -0,0 +1,19 @@
# tests for -perm /nnn
# The slash is a GNU extension
exec rm -rf tmp
exec mkdir tmp
## set up a selection of test files
foreach perm { 400 200 555 700 000 050 } {
exec touch "tmp/$perm"
exec chmod $perm "tmp/$perm"
}
#
# The -o operator normally has a short-circuit effect,
# so we have to use "-exec false \;" to make sure that
# all the parenthesised expression actually fail.
#
find_start p {tmp -mindepth 1 -perm /555 -printf "p/555 %p\n" }
# exec rm -rf tmp tmp2

View File

@ -0,0 +1,4 @@
p/555 tmp/050
p/555 tmp/555
p/555 tmp/400
p/555 tmp/700