As promised two missing patches for v4.6.0, no doubt
Rene will want to massage them, but they install now.

And yes one relates back to 4.4.2, but it's still has been awaiting 'absorbtion' until now and is still required.

Both are from the Findutils git against 4.6.0 and are suppose to be 'absorbed' when 4.7.0 arrives.

Please wait for Rene to release them before using.

regards
# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# 
# T2 SDE: package/.../findutils/findutils-4.4.2-xauto.patch
# Copyright (C) 2004 - 2019 The T2 SDE Project
# 
# More information can be found in the files COPYING and README.
# 
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- T2-COPYRIGHT-NOTE-END ---

---
 doc/find.texi  |    4 ++++
 find/defs.h    |    3 +++
 find/find.1    |    3 +++
 find/ftsfind.c |    6 ++++++
 find/parser.c  |   14 +++++++++++++-
 find/util.c    |    1 +
 6 files changed, 30 insertions(+), 1 deletion(-)

--- findutils-4.6.0/doc/find.texi.orig
+++ findutils-4.6.0/doc/find.texi
@@ -1448,6 +1448,10 @@ them.
 There are two ways to avoid searching certain filesystems.  One way is
 to tell @code{find} to only search one filesystem:
 
+@deffn Option -xautofs
+Don't descend directories on autofs filesystems.
+@end deffn
+
 @deffn Option -xdev
 @deffnx Option -mount
 Don't descend directories on other filesystems.  These options are
--- findutils-4.6.0/find/defs.h.orig
+++ findutils-4.6.0/find/defs.h
@@ -557,6 +557,9 @@ struct options
   /* If true, don't cross filesystem boundaries. */
   bool stay_on_filesystem;
 
+  /* If true, don't descend directores on autofs filesystems */
+  bool bypass_autofs;
+
   /* If true, we ignore the problem where we find that a directory entry
    * no longer exists by the time we get around to processing it.
    */
--- findutils-4.6.0/find/find.1.orig
+++ findutils-4.6.0/find/find.1
@@ -520,6 +520,9 @@ to stat them; this gives a significant i
 .IP "\-version, \-\-version"
 Print the \fBfind\fR version number and exit.
 
+.IP \-xautofs
+Don't descend directories on autofs filesystems.
+
 .IP \-xdev
 Don't descend directories on other filesystems.
 
--- findutils-4.6.0/find/ftsfind.c.orig
+++ findutils-4.6.0/find/ftsfind.c
@@ -485,6 +485,12 @@ consider_visiting (FTS *p, FTSENT *ent)
 	}
     }
 
+  if (options.bypass_autofs &&
+      0 == strcmp ("autofs", filesystem_type (&statbuf, ent->fts_name)))
+    {
+      fts_set(p, ent, FTS_SKIP); /* descend no further */
+    }
+
   if ( (ent->fts_info == FTS_D) && !options.do_dir_first )
     {
       /* this is the preorder visit, but user said -depth */
--- findutils-4.6.0/find/parser.c.orig
+++ findutils-4.6.0/find/parser.c
@@ -146,6 +146,7 @@ static bool parse_user          (const s
 static bool parse_version       (const struct parser_table*, char *argv[], int *arg_ptr);
 static bool parse_wholename     (const struct parser_table*, char *argv[], int *arg_ptr);
 static bool parse_xdev          (const struct parser_table*, char *argv[], int *arg_ptr);
+static bool parse_xautofs       (const struct parser_table*, char *argv[], int *arg_ptr);
 static bool parse_ignore_race   (const struct parser_table*, char *argv[], int *arg_ptr);
 static bool parse_noignore_race (const struct parser_table*, char *argv[], int *arg_ptr);
 static bool parse_warn          (const struct parser_table*, char *argv[], int *arg_ptr);
@@ -306,6 +307,7 @@ static struct parser_table const parse_t
   PARSE_TEST_NP    ("wholename",             wholename), /* GNU, replaced -path, but anyway -path will soon be in POSIX */
   {ARG_TEST,       "writable",               parse_accesscheck, pred_writable}, /* GNU, 4.3.0+ */
   PARSE_OPTION     ("xdev",                  xdev), /* POSIX */
+  PARSE_OPTION     ("xautofs",               xautofs),
   PARSE_TEST       ("xtype",                 xtype),	     /* GNU */
 #ifdef UNIMPLEMENTED_UNIX
   /* It's pretty ugly for find to know about archive formats.
@@ -1239,7 +1241,7 @@ operators (decreasing precedence; -and i
 positional options (always true): -daystart -follow -regextype\n\n\
 normal options (always true, specified before other expressions):\n\
       -depth --help -maxdepth LEVELS -mindepth LEVELS -mount -noleaf\n\
-      --version -xdev -ignore_readdir_race -noignore_readdir_race\n"));
+      --version -xdev -xautofs -ignore_readdir_race -noignore_readdir_race\n"));
   puts (_("\
 tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N\n\
       -cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME\n\
@@ -2683,6 +2685,16 @@ parse_xdev (const struct parser_table* e
 }
 
 static bool
+parse_xautofs(const struct parser_table* entry, char **argv, int *arg_ptr)
+{
+  (void) argv;
+  (void) arg_ptr;
+  (void) entry;
+  options.bypass_autofs = true;
+  return true;
+}
+
+static bool
 parse_ignore_race (const struct parser_table* entry, char **argv, int *arg_ptr)
 {
   options.ignore_readdir_race = true;
--- findutils-4.6.0/find/util.c.orig
+++ findutils-4.6.0/find/util.c
@@ -1017,6 +1017,7 @@ set_option_defaults (struct options *p)
 
   p->full_days = false;
   p->stay_on_filesystem = false;
+  p->bypass_autofs = false;
   p->ignore_readdir_race = false;
 
   if (p->posixly_correct)
# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# 
# T2 SDE: package/.../findutils/sv-bug-48030-find-exec-plus-does-not-pass-all-arguments.patch
# Copyright (C) 2004 - 2019 The T2 SDE Project
# 
# More information can be found in the files COPYING and README.
# 
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- T2-COPYRIGHT-NOTE-END ---

---
Fix bug #48030: find: -exec + does not pass all arguments in certain cases
When the -exec arguments buffer (usually 128k) is full and the given
command has been executed with all that arguments, find(1) missed to
execute the command yet another time if only 1 another file would have
to be processed.
Both find(1), i.e., nowadays FTS-version, and oldfind are affected.
This bug was present since the implementation of '-exec +' in 2005,
see commit FINDUTILS_4_2_11-1-25-gf0a6ac6.

* lib/buildcmd.c (bc_push_arg): Move the assignment to set 'state->todo'
* to 1 down after the immediate execution which resets that flag.
* find/testsuite/sv-48030-exec-plus-bug.sh: Add a test.
* find/testsuite/Makefile.am (test_shell_progs): Reference the test.
* NEWS (Bug Fixes): Mention the fix.

Reported by Joe Philip Ninan <[email protected]> in
https://savannah.gnu.org/bugs/?48030
Diffstat
-rw-r--r--	NEWS	6	
		
-rw-r--r--	find/testsuite/Makefile.am	3	
		
-rwxr-xr-x	find/testsuite/sv-48030-exec-plus-bug.sh	143	
		
-rw-r--r--	lib/buildcmd.c	10	
		
4 files changed, 156 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index 59f6cb9..2070f0e 100644
--- findutils-4.6.0/NEWS
+++ findutils-4.6.0/NEWS
@@ -43,6 +43,12 @@ of the - yet more portable - '( -type l -o -type d )'.
 
 ** Bug Fixes
 
+#48030: find -exec + does not pass all arguments for certain specific filename
+        lengths.  After the internal (usually 128k) buffer is full and find(1)
+        executed the given command with these arguments, it would miss to run
+        the command yet another time if only one other file argument has to be
+        processed.  Bug introduced in FINDUTILS-4.2.12.
+
 Applied patch #8688: Spelling fixes.
 
 * Major changes in release 4.5.18, 2015-12-27
diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am
index 65d5d32..cb34830 100644
--- findutils-4.6.0/find/testsuite/Makefile.am
+++ findutils-4.6.0/find/testsuite/Makefile.am
@@ -259,7 +259,8 @@ test_escape_c.sh \
 test_inode.sh \
 test_type-list.sh \
 sv-34079.sh \
-sv-34976-execdir-fd-leak.sh
+sv-34976-execdir-fd-leak.sh \
+sv-48030-exec-plus-bug.sh
 
 EXTRA_DIST = $(EXTRA_DIST_EXP) $(EXTRA_DIST_XO) $(EXTRA_DIST_GOLDEN) \
 	$(test_shell_progs) binary_locations.sh checklists.py
diff --git a/find/testsuite/sv-48030-exec-plus-bug.sh b/find/testsuite/sv-48030-exec-plus-bug.sh
new file mode 100755
index 0000000..4dbf149
--- /dev/null
+++ findutils-4.6.0/find/testsuite/sv-48030-exec-plus-bug.sh
@@ -0,0 +1,143 @@
+#! /bin/sh
+# Copyright (C) 2016 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+# This test verifies that find invokes the given command for the
+# multiple-argument sytax '-exec CMD {} +'.  Between FINDUTILS-4.2.12
+# and v4.6.0, find(1) would have failed to execute CMD another time
+# if there was only one last single file argument.
+
+testname="$(basename $0)"
+
+. "${srcdir}"/binary_locations.sh
+
+die() {
+  echo "$@" >&2
+  exit 1
+}
+
+# This is used to simplify checking of the return value
+# which is useful when ensuring a command fails as desired.
+# I.e., just doing `command ... &&fail=1` will not catch
+# a segfault in command for example.  With this helper you
+# instead check an explicit exit code like
+#   returns_ 1 command ... || fail
+returns_ () {
+  # Disable tracing so it doesn't interfere with stderr of the wrapped command
+  { set +x; } 2>/dev/null
+
+  local exp_exit="$1"
+  shift
+  "$@"
+  test $? -eq $exp_exit && ret_=0 || ret_=1
+
+  set -x
+  { return $ret_; } 2>/dev/null
+}
+
+# Define the nicest compare available (borrowed from gnulib).
+if diff_out_=`exec 2>/dev/null; diff -u "$0" "$0" < /dev/null` \
+   && diff -u Makefile "$0" 2>/dev/null | grep '^[+]#!' >/dev/null; then
+  # diff accepts the -u option and does not (like AIX 7 'diff') produce an
+  # extra space on column 1 of every content line.
+  if test -z "$diff_out_"; then
+    compare () { diff -u "$@"; }
+  else
+    compare ()
+    {
+      if diff -u "$@" > diff.out; then
+        # No differences were found, but Solaris 'diff' produces output
+        # "No differences encountered". Hide this output.
+        rm -f diff.out
+        true
+      else
+        cat diff.out
+        rm -f diff.out
+        false
+      fi
+    }
+  fi
+elif diff_out_=`exec 2>/dev/null; diff -c "$0" "$0" < /dev/null`; then
+  if test -z "$diff_out_"; then
+    compare () { diff -c "$@"; }
+  else
+    compare ()
+    {
+      if diff -c "$@" > diff.out; then
+        # No differences were found, but AIX and HP-UX 'diff' produce output
+        # "No differences encountered" or "There are no differences between the
+        # files.". Hide this output.
+        rm -f diff.out
+        true
+      else
+        cat diff.out
+        rm -f diff.out
+        false
+      fi
+    }
+  fi
+elif cmp -s /dev/null /dev/null 2>/dev/null; then
+  compare () { cmp -s "$@"; }
+else
+  compare () { cmp "$@"; }
+fi
+
+DIR='RashuBug'
+# Name of the CMD to execute: the file name must be 6 characters long
+# (to trigger the bug in combination with the test files).
+CMD='tstcmd'
+
+# Create test files.
+make_test_data() {
+  # Create the CMD script and check that it works.
+  mkdir "$DIR" 'bin' \
+    && echo 'printf "%s\n" "$@"' > "bin/$CMD" \
+    && chmod +x "bin/$CMD" \
+    && PATH="$PWD/bin:$PATH" \
+    && [ $( "${ftsfind}" bin -maxdepth 0 -exec "$CMD" '{}' + ) = 'bin' ] \
+    || return 1
+
+  # Create expected output file - also used for creating the test data.
+  { seq -f "${DIR}/abcdefghijklmnopqrstuv%04g" 901 &&
+    seq -f "${DIR}/abcdefghijklmnopqrstu%04g" 902 3719
+  } > exp2 \
+    && LC_ALL=C sort exp2 > exp \
+    && rm exp2 \
+    || return 1
+
+  # Create test files, and check if test data has been created correctly.
+  xargs touch < exp \
+    && [ -f "${DIR}/abcdefghijklmnopqrstu3719" ] \
+    && [ 3719 = $( "${ftsfind}" "$DIR" -type f | wc -l ) ] \
+    || return 1
+}
+
+set -x
+tmpdir="$(mktemp -d)" \
+  && cd "$tmpdir" \
+  && make_test_data "${tmpdir}" \
+  || die "FAIL: failed to set up the test in ${tmpdir}"
+
+fail=0
+for exe in "${ftsfind}" "${oldfind}"; do
+  "$exe" "$DIR" -type f -exec "$CMD" '{}' + > out || fail=1
+  LC_ALL=C sort out > out2 || fail=1
+  compare exp out2 || fail=1
+done
+
+cd ..
+rm -rf "${tmpdir}" || exit 1
+exit $fail
diff --git a/lib/buildcmd.c b/lib/buildcmd.c
index 73d3187..b0677d7 100644
--- findutils-4.6.0/lib/buildcmd.c
+++ findutils-4.6.0/lib/buildcmd.c
@@ -350,11 +350,6 @@ bc_push_arg (struct buildcmd_control *ctl,
 
   assert (arg != NULL);
 
-  if (!initial_args)
-    {
-      state->todo = 1;
-    }
-
   if (!terminate)
     {
       if (state->cmd_argv_chars + len + pfxlen > ctl->arg_max)
@@ -374,6 +369,11 @@ bc_push_arg (struct buildcmd_control *ctl,
             bc_do_exec (ctl, state);
     }
 
+  if (!initial_args)
+    {
+      state->todo = 1;
+    }
+
   if (state->cmd_argc >= state->cmd_argv_alloc)
     {
       /* XXX: we could use extendbuf() here. */
----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[email protected] with a subject of: unsubscribe t2

Reply via email to