e0bc27
From f5a43df0bd6481b407a6ec00a24679f521584e20 Mon Sep 17 00:00:00 2001
e0bc27
From: Paul Eggert <eggert@cs.ucla.edu>
e0bc27
Date: Mon, 22 Apr 2013 21:49:40 +0100
e0bc27
Subject: [PATCH] Resolves: #1116237 - find -perm +numeric does not work as
e0bc27
 expected
e0bc27
e0bc27
Also, do not reject -perm /MODE merely because of POSIXLY_CORRECT.
e0bc27
Problem reported in <https://savannah.gnu.org/bugs/?38474>.
e0bc27
* doc/find.texi (Mode Bits): Document this.
e0bc27
* find/parser.c (parse_help): Mention /MODE, not +MODE.
e0bc27
Do not reject -perm /MODE merely because POSIXLY_CORRECT is set;
e0bc27
POSIXLY_CORRECT is not supposed to be for pedantic checking.
e0bc27
e0bc27
[upstream commit 90f0c5d24153ad3327edd6f2249fc95a5cfb72e0]
e0bc27
e0bc27
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
e0bc27
---
e0bc27
 doc/find.texi | 11 ++---------
e0bc27
 find/find.1   | 17 ++++++++++++-----
e0bc27
 find/parser.c | 10 ++++++++--
e0bc27
 3 files changed, 22 insertions(+), 16 deletions(-)
e0bc27
e0bc27
diff --git a/doc/find.texi b/doc/find.texi
e0bc27
index a44e5d5..1ad3af5 100644
e0bc27
--- a/doc/find.texi
e0bc27
+++ b/doc/find.texi
e0bc27
@@ -1180,11 +1180,8 @@ optionally prefixed by @samp{-} or @samp{/}.
e0bc27
 
e0bc27
 A @var{pmode} that starts with neither @samp{-} nor @samp{/} matches
e0bc27
 if @var{mode} exactly matches the file mode bits.
e0bc27
-
e0bc27
-A @var{pmode} that starts with @samp{+} but which is not valid (for
e0bc27
-example @samp{+a+x}) is an error if the POSIXLY_CORRECT environment
e0bc27
-variable it set.  Otherwise this is treated as if the initial
e0bc27
-@samp{+} were a @samp{/}, for backward compatibility.
e0bc27
+(To avoid confusion with an obsolete GNU extension, @var{mode}
e0bc27
+must not start with a @samp{+} immediately followed by an octal digit.)
e0bc27
 
e0bc27
 A @var{pmode} that starts with @samp{-} matches if
e0bc27
 @emph{all} the file mode bits set in @var{mode} are set for the file;
e0bc27
@@ -3944,10 +3941,6 @@ Setting this variable also turns off warning messages (that is, implies
e0bc27
 the output for @samp{-ok}, all messages printed on stderr are
e0bc27
 diagnostics and must result in a non-zero exit status.
e0bc27
 
e0bc27
-Arguments to @samp{-perm} beginning with @samp{+} are treated
e0bc27
-differently when POSIXLY_CORRECT is set. See
e0bc27
-@ref{Mode Bits,-perm,File Mode Bits}.
e0bc27
-
e0bc27
 When POSIXLY_CORRECT is set, the response to the prompt made by the
e0bc27
 @code{-ok} action is interpreted according to the system's message
e0bc27
 catalogue, as opposed to according to @code{find}'s own message
e0bc27
diff --git a/find/find.1 b/find/find.1
e0bc27
index 34a4cba..00e45e6 100644
e0bc27
--- a/find/find.1
e0bc27
+++ b/find/find.1
e0bc27
@@ -2046,11 +2046,6 @@ As of findutils-4.2.2, shell metacharacters (`*', `?' or `[]' for
e0bc27
 example) used in filename patterns will match a leading `.', because
e0bc27
 IEEE POSIX interpretation 126 requires this.
e0bc27
 .P
e0bc27
-The syntax
e0bc27
-\.B \-perm +MODE
e0bc27
-was deprecated in findutils-4.2.21, in favour of
e0bc27
-\.B \-perm
e0bc27
-.BR /MODE .
e0bc27
 As of findutils-4.3.3,
e0bc27
 .B \-perm /000
e0bc27
 now matches all files instead of none.
e0bc27
@@ -2098,6 +2093,18 @@ Feature	Added in	Also occurs in
e0bc27
 \-ipath	3.8
e0bc27
 \-iregex	3.8
e0bc27
 .TE
e0bc27
+.P
e0bc27
+The syntax
e0bc27
+\.B \-perm +MODE
e0bc27
+does not work as expected in findutils-4.5.11 and it
e0bc27
+was removed in findutils-4.5.12, in favour of
e0bc27
+\.B \-perm
e0bc27
+.BR /MODE .
e0bc27
+The
e0bc27
+.B +MODE
e0bc27
+syntax had been deprecated since findutils-4.2.21
e0bc27
+which was released in 2005.
e0bc27
+.P
e0bc27
 .SH "NON-BUGS"
e0bc27
 .nf
e0bc27
 .B $ find . \-name *.c \-print
e0bc27
diff --git a/find/parser.c b/find/parser.c
e0bc27
index d15c0e0..e5f02b3 100644
e0bc27
--- a/find/parser.c
e0bc27
+++ b/find/parser.c
e0bc27
@@ -1239,7 +1239,7 @@ tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N\n\
e0bc27
       -ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN\n\
e0bc27
       -links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE"));
e0bc27
   puts (_("\
e0bc27
-      -nouser -nogroup -path PATTERN -perm [+-]MODE -regex PATTERN\n\
e0bc27
+      -nouser -nogroup -path PATTERN -perm [-/]MODE -regex PATTERN\n\
e0bc27
       -readable -writable -executable\n\
e0bc27
       -wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N\n\
e0bc27
       -used N -user NAME -xtype [bcdpfls]"));
e0bc27
@@ -1981,6 +1981,13 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
e0bc27
       break;
e0bc27
 
e0bc27
      case '+':
e0bc27
+       if ('0' <= perm_expr[1] && perm_expr[1] < '8')
e0bc27
+	 /* warn about using obsolete syntax (with unexpected behavior) */
e0bc27
+	 error(0, 0, "warning: you are using `-perm +MODE'.  The "
e0bc27
+	     "interpretation of `-perm +omode' changed in findutils-4.5.11.  "
e0bc27
+	     "The syntax `-perm +omode' was removed in findutils-4.5.12, in "
e0bc27
+	     "favour of `-perm /omode'.");
e0bc27
+
e0bc27
        change = mode_compile (perm_expr);
e0bc27
        if (NULL == change)
e0bc27
 	 {
e0bc27
@@ -2011,7 +2018,6 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
e0bc27
        break;
e0bc27
 
e0bc27
     case '/':			/* GNU extension */
e0bc27
-      non_posix_mode (perm_expr);
e0bc27
       mode_start = 1;
e0bc27
       kind = PERM_ANY;
e0bc27
       havekind = true;
e0bc27
-- 
e0bc27
1.9.3
e0bc27