Package: busybox / 1:1.22.0-9+deb8u1

find:-support-perm-_BITS.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From: Denys Vlasenko <vda.linux@googlemail.com>
Date:   Fri Sep 5 12:16:15 2014 +0200
Subject: find: support -perm /BITS. Closes 7340
Bug-Debian: http://bugs.debian.org/760637
    
function                                             old     new   delta
parse_params                                        1487    1497     +10
func_perm                                             57      61      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 14/0)               Total: 14 bytes
    
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>

diff --git a/findutils/find.c b/findutils/find.c
index 56a7ed3..83aa63f 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -558,8 +558,8 @@ ACTF(type)
 #if ENABLE_FEATURE_FIND_PERM
 ACTF(perm)
 {
-	/* -perm +mode: at least one of perm_mask bits are set */
-	if (ap->perm_char == '+')
+	/* -perm [+/]mode: at least one of perm_mask bits are set */
+	if (ap->perm_char == '+' || ap->perm_char == '/')
 		return (statbuf->st_mode & ap->perm_mask) != 0;
 	/* -perm -mode: all of perm_mask are set */
 	if (ap->perm_char == '-')
@@ -1252,14 +1252,14 @@ static action*** parse_params(char **argv)
 /* -perm BITS   File's mode bits are exactly BITS (octal or symbolic).
  *              Symbolic modes use mode 0 as a point of departure.
  * -perm -BITS  All of the BITS are set in file's mode.
- * -perm +BITS  At least one of the BITS is set in file's mode.
+ * -perm [+/]BITS  At least one of the BITS is set in file's mode.
  */
 		else if (parm == PARM_perm) {
 			action_perm *ap;
 			dbg("%d", __LINE__);
 			ap = ALLOC_ACTION(perm);
 			ap->perm_char = arg1[0];
-			arg1 = plus_minus_num(arg1);
+			arg1 = (arg1[0] == '/' ? arg1+1 : plus_minus_num(arg1));
 			/*ap->perm_mask = 0; - ALLOC_ACTION did it */
 			if (!bb_parse_mode(arg1, &ap->perm_mask))
 				bb_error_msg_and_die("invalid mode '%s'", arg1);