[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
find -perm /MODE implementation incomplete
From: |
sw . l . klswlff |
Subject: |
find -perm /MODE implementation incomplete |
Date: |
Mon, 12 Sep 2005 18:18:47 +0200 |
User-agent: |
Mozilla Thunderbird 1.0 (X11/20041206) |
To be compatible with POSIX the syntax
'-perm +MODE'
has been obsoleted and replaced by
'-perm /MODE'
In the parser (findutils-4.2.23/find/parser.c, function parse_perm)
the argument is processed by two switch-statements.
The first switch handles the case '/' and stores the kind of check
in the local variable 'kind' as PERM_ANY (ok).
The second switch lacks case '/'. Thus '/' is handled as default kind PERM_EXACT
and the permission test will be done as '-perm MODE'.
As the kind of test has been stored alredy in the first switch in variable
'kind'
the second switch is not needed at all and can be replaced by
our_pred->args.perm.kind = kind;
I'm attaching a patch for this change.
BTW: The problem behind bug#14507 is the POSIX syntax. The submitter wrote
find . -perm -022
find . -perm +g+w,o+w
...
Both these commands do the same thing;
search for files which are
writeable by both their owner and their group.
...
Both of these should refer to group and other,
not the owner.
I think, the submitter has been misled by the obsoleted use '-perm +MODE'.
In POSIX-syntax, which takes priority over the old GNU-syntax,
the first clause of '+g+w,o+w' is actionlist '+g+w', applying group permissions
to all (+g) and write permissions to all (+w).
'+g+w,o+w' will accept all files with write access to any of user, group or
other.
I can see only one case, where a mode starting with '+' is not a POSIX mode
and will be handled in the old GNU way:
If the leading '+' is followed by more than one 'who' character,
e.g. '+go+w', function 'mode_compile' in modechange.c will look for an operator
between 'g' and 'o', reject the expression and parse.c will split off the
leading '+',
handle it as kind PERM_ANY and take 'go+w' as mode string.
diff -Naur old/parser.c new/parser.c
--- old/parser.c 2005-09-12 15:06:26.306827145 +0000
+++ new/parser.c 2005-09-12 15:10:54.647907481 +0000
@@ -1289,18 +1289,7 @@
our_pred = insert_primary (pred_perm);
- 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.kind = kind;
our_pred->args.perm.val = perm_val & MODE_ALL;
(*arg_ptr)++;
return (true);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- find -perm /MODE implementation incomplete,
sw . l . klswlff <=