findutils/findutils-4.5.11-perm-mode.patch

367 lines
12 KiB
Diff

From 8171b840e74641733d33af53664b811699eb7eab Mon Sep 17 00:00:00 2001
From: James Youngman <jay@gnu.org>
Date: Mon, 22 Apr 2013 21:49:40 +0100
Subject: [PATCH 1/3] Fix documentation typo.
* doc/find.texi (Mode Bits): Fix typo "it set" -> "is set".
[upstream commit 2957a7ae5581cf2e5b36f2c23781317a7bf2e901]
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
doc/find.texi | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/doc/find.texi b/doc/find.texi
index a44e5d5..94d0081 100644
--- a/doc/find.texi
+++ b/doc/find.texi
@@ -1183,7 +1183,7 @@ if @var{mode} exactly matches the file mode bits.
A @var{pmode} that starts with @samp{+} but which is not valid (for
example @samp{+a+x}) is an error if the POSIXLY_CORRECT environment
-variable it set. Otherwise this is treated as if the initial
+variable is set. Otherwise this is treated as if the initial
@samp{+} were a @samp{/}, for backward compatibility.
A @var{pmode} that starts with @samp{-} matches if
--
1.7.1
From cf50a86bea92033c42c1f3e539b666444cacb8eb Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 21 Apr 2013 00:14:18 -0700
Subject: [PATCH 2/3] Remove support for obsolete -perm +MODE syntax.
Also, do not reject -perm /MODE merely because of POSIXLY_CORRECT.
Problem reported in <https://savannah.gnu.org/bugs/?38474>.
* NEWS:
* doc/find.texi (Mode Bits): Document this.
(Environment Variables): POSIXLY_CORRECT does not affect -perm.
* find/parser.c (parse_help): Mention /MODE, not +MODE.
(non_posix_mode): Remove.
(parse_perm): Remove support for -perm +MODE.
Do not reject -perm /MODE merely because POSIXLY_CORRECT is set;
POSIXLY_CORRECT is not supposed to be for pedantic checking.
[upstream commit 90f0c5d24153ad3327edd6f2249fc95a5cfb72e0]
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
NEWS | 9 ++++++++
doc/find.texi | 11 +--------
find/find.1 | 38 ++++++++++++---------------------
find/parser.c | 63 ++++++++++----------------------------------------------
4 files changed, 37 insertions(+), 84 deletions(-)
diff --git a/NEWS b/NEWS
index 184722a..7de91e8 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,15 @@ GNU findutils NEWS - User visible changes. -*- outline -*- (allout)
* Major changes in release 4.5.11, 2013-02-02
+** Functional Changes to find
+
+The GNU extension "find ... -perm /MODE" is no longer disabled when
+the POSIXLY_CORRECT environment variable is set.
+
+The obsolete GNU extension "find ... -perm +MODE", which was withdrawn
+in release 4.2.21 in 2005 due to compatibility problems, has been
+completely removed. Use "find ... -perm /MODE" instead.
+
** Documentation Changes
The Texinfo manual and the find manual pafe now explain why two find
diff --git a/doc/find.texi b/doc/find.texi
index 94d0081..1ad3af5 100644
--- a/doc/find.texi
+++ b/doc/find.texi
@@ -1180,11 +1180,8 @@ optionally prefixed by @samp{-} or @samp{/}.
A @var{pmode} that starts with neither @samp{-} nor @samp{/} matches
if @var{mode} exactly matches the file mode bits.
-
-A @var{pmode} that starts with @samp{+} but which is not valid (for
-example @samp{+a+x}) is an error if the POSIXLY_CORRECT environment
-variable is set. Otherwise this is treated as if the initial
-@samp{+} were a @samp{/}, for backward compatibility.
+(To avoid confusion with an obsolete GNU extension, @var{mode}
+must not start with a @samp{+} immediately followed by an octal digit.)
A @var{pmode} that starts with @samp{-} matches if
@emph{all} the file mode bits set in @var{mode} are set for the file;
@@ -3944,10 +3941,6 @@ Setting this variable also turns off warning messages (that is, implies
the output for @samp{-ok}, all messages printed on stderr are
diagnostics and must result in a non-zero exit status.
-Arguments to @samp{-perm} beginning with @samp{+} are treated
-differently when POSIXLY_CORRECT is set. See
-@ref{Mode Bits,-perm,File Mode Bits}.
-
When POSIXLY_CORRECT is set, the response to the prompt made by the
@code{-ok} action is interpreted according to the system's message
catalogue, as opposed to according to @code{find}'s own message
diff --git a/find/find.1 b/find/find.1
index 34a4cba..071b7fe 100644
--- a/find/find.1
+++ b/find/find.1
@@ -804,25 +804,9 @@ with the behaviour of
.BR \-000 ).
.IP "\-perm +\fImode\fR"
-Deprecated, old way of searching for files with any of the permission
-bits in \fImode\fR set. You should use
-.B \-perm \fI/mode\fR
-instead. Trying to use the `+' syntax with symbolic modes will yield
-surprising results. For example, `+u+x' is a valid symbolic mode
-(equivalent to +u,+x, i.e. 0111) and will therefore not be evaluated
-as
-.B \-perm +\fImode\fR
-but instead as the exact mode specifier
-.B \-perm \fImode\fR
-and so it matches files with exact permissions 0111 instead of files with any
-execute bit set. If you found this paragraph confusing, you're not
-alone - just use
-.B \-perm /\fImode\fR.
-This form of the
-.B \-perm
-test is deprecated because the POSIX specification requires the
-interpretation of a leading `+' as being part of a symbolic mode, and
-so we switched to using `/' instead.
+This is no longer supported (and has been deprecated since 2005). Use
+.B "\-perm /\fImode\fR"
+instead.
.IP \-readable
Matches files which are readable. This takes into account access
@@ -2046,11 +2030,6 @@ As of findutils-4.2.2, shell metacharacters (`*', `?' or `[]' for
example) used in filename patterns will match a leading `.', because
IEEE POSIX interpretation 126 requires this.
.P
-The syntax
-\.B \-perm +MODE
-was deprecated in findutils-4.2.21, in favour of
-\.B \-perm
-.BR /MODE .
As of findutils-4.3.3,
.B \-perm /000
now matches all files instead of none.
@@ -2098,6 +2077,17 @@ Feature Added in Also occurs in
\-ipath 3.8
\-iregex 3.8
.TE
+.P
+The syntax
+\.B \-perm +MODE
+was removed in findutils-4.5.12, in favour of
+\.B \-perm
+.BR /MODE .
+The
+.B +MODE
+syntax had been deprecated since findutils-4.2.21
+which was released in 2005.
+.P
.SH "NON-BUGS"
.nf
.B $ find . \-name *.c \-print
diff --git a/find/parser.c b/find/parser.c
index d15c0e0..19747cd 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -1239,7 +1239,7 @@ tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N\n\
-ilname PATTERN -iname PATTERN -inum N -iwholename PATTERN -iregex PATTERN\n\
-links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE"));
puts (_("\
- -nouser -nogroup -path PATTERN -perm [+-]MODE -regex PATTERN\n\
+ -nouser -nogroup -path PATTERN -perm [-/]MODE -regex PATTERN\n\
-readable -writable -executable\n\
-wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N\n\
-used N -user NAME -xtype [bcdpfls]"));
@@ -1944,17 +1944,6 @@ parse_iwholename (const struct parser_table* entry, char **argv, int *arg_ptr)
return insert_path_check (entry, argv, arg_ptr, "iwholename", pred_ipath);
}
-static void
-non_posix_mode (const char *mode)
-{
- if (options.posixly_correct)
- {
- error (EXIT_FAILURE, 0,
- _("Mode %s is not valid when POSIXLY_CORRECT is on."),
- quotearg_n_style (0, options.err_quoting_style, mode));
- }
-}
-
static bool
parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
@@ -1964,7 +1953,7 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
int mode_start = 0;
bool havekind = false;
enum permissions_type kind = PERM_EXACT;
- struct mode_change *change = NULL;
+ struct mode_change *change;
struct predicate *our_pred;
const char *perm_expr;
@@ -1980,38 +1969,7 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
rate = 0.2;
break;
- case '+':
- change = mode_compile (perm_expr);
- 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.
- *
- * Example: POSIXLY_CORRECT=y find -perm +a+x
- */
- non_posix_mode (perm_expr);
-
- /* support the previous behaviour. */
- mode_start = 1;
- kind = PERM_ANY;
- rate = 0.3;
- }
- else
- {
- /* This is a POSIX-compatible usage */
- mode_start = 0;
- kind = PERM_EXACT;
- rate = 0.1;
- }
- havekind = true;
- break;
-
case '/': /* GNU extension */
- non_posix_mode (perm_expr);
mode_start = 1;
kind = PERM_ANY;
havekind = true;
@@ -2029,13 +1987,16 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
break;
}
- if (NULL == change)
- {
- change = mode_compile (perm_expr + mode_start);
- if (NULL == change)
- error (EXIT_FAILURE, 0, _("invalid mode %s"),
- quotearg_n_style (0, options.err_quoting_style, perm_expr));
- }
+ change = mode_compile (perm_expr + mode_start);
+
+ /* Reject invalid modes, or modes of the form +NUMERICMODE.
+ The latter were formerly accepted as a GNU extension, but that
+ extension was incompatible with how GNU 'chmod' treats these modes now,
+ and it would be confusing if 'find' continued to support it. */
+ if (NULL == change
+ || (perm_expr[0] == '+' && '0' <= perm_expr[1] && perm_expr[1] < '8'))
+ error (EXIT_FAILURE, 0, _("invalid mode %s"),
+ quotearg_n_style (0, options.err_quoting_style, perm_expr));
perm_val[0] = mode_adjust (0, false, 0, change, NULL);
perm_val[1] = mode_adjust (0, true, 0, change, NULL);
free (change);
--
1.7.1
From e9ebac18d364958f9872aa981a79ed97492a1b15 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 22 Apr 2013 15:15:53 -0700
Subject: [PATCH 3/3] More removal of support for -perm +MODE.
* find/parser.c (parse_perm): Remove no-longer-needed local var
and associated code. Reported by Eric Blake in
<http://savannah.gnu.org/bugs/?38474#comment9>.
[upstream commit 3d13be5654b42ef126cb19c84a9469634c005b7f]
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
find/parser.c | 26 +-------------------------
1 files changed, 1 insertions(+), 25 deletions(-)
diff --git a/find/parser.c b/find/parser.c
index 19747cd..3c2c771 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -1951,7 +1951,6 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
mode_t perm_val[2];
float rate;
int mode_start = 0;
- bool havekind = false;
enum permissions_type kind = PERM_EXACT;
struct mode_change *change;
struct predicate *our_pred;
@@ -1965,14 +1964,12 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
case '-':
mode_start = 1;
kind = PERM_AT_LEAST;
- havekind = true;
rate = 0.2;
break;
case '/': /* GNU extension */
mode_start = 1;
kind = PERM_ANY;
- havekind = true;
rate = 0.3;
break;
@@ -1982,7 +1979,6 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
*/
mode_start = 0;
kind = PERM_EXACT;
- havekind = true;
rate = 0.01;
break;
}
@@ -2020,7 +2016,6 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
perm_expr);
kind = PERM_AT_LEAST;
- havekind = true;
/* The "magic" number below is just the fraction of files on my
* own system that "-type l -xtype l" fails for (i.e. unbroken symlinks).
@@ -2031,26 +2026,7 @@ parse_perm (const struct parser_table* entry, char **argv, int *arg_ptr)
our_pred = insert_primary (entry, perm_expr);
our_pred->est_success_rate = rate;
- if (havekind)
- {
- our_pred->args.perm.kind = kind;
- }
- else
- {
-
- switch (perm_expr[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;
memcpy (our_pred->args.perm.val, perm_val, sizeof perm_val);
return true;
}
--
1.7.1