11 Commits

Author SHA1 Message Date
Dmitry V. Levin
f4d77401d0 Fix save_cwd/restore_cwd error diagnostics.
Before this change, a pointer to struct saved_cwd was used in place
of char*, leading to incorrect error diagnostics, e.g.:
$ chmod a-x . && find / -maxdepth 0 -exec true \;
find: Failed to change directory: ÿÿÿÿ: Permission denied
find: failed to restore initial working directory: ÿÿÿÿ: Permission denied

* find/exec.c (prep_child_for_exec): Fix error diagnostics.
* find/util.c (record_initial_cwd, cleanup_initial_cwd): Likewise.
2015-12-23 21:44:33 +00:00
Sami Kerola
7f3af09ef1 When reporting failure to change/save directory, mention its name.
* find/exec.c (prep_child_for_exec): When issuing an error message
about a failure to change directory, mention the directory.
* find/util.c (record_initial_cwd): Do the same when saving the
initial working directory.
(cleanup_initial_cwd): Also when restoring the initial working
directory.
2014-08-21 06:05:57 +01:00
James Youngman
d5234fe96a Standardize on "initialize".
* find/exec.c (initialise_wd_for_exec): rename to
initialize_wd_for_exec, since "initialize" is the preferred form
even in UK spelling (the OED says "initialise" is a variant).
Update callers (it's a static function).  Update spelling in
comments.
* find/find.c (main): Fix missing "to" in error message and update
"initialise" to "initialize".  Update comment too.
* find/ftsfind.c (main): Update spelling in error message.
* lib/listfile.c (print_name_with_quoting): spelling change in
comment.
* find/tree.c (init_pred_perf): Likewise.
* lib/extendbuf.c (extendbuf): Likewise.
* lib/splitstring.h: Likewise.
* find/print.c (format_date): Likewise.
* doc/find-maint.texi (Tools): Update spelling.
2014-07-19 11:17:52 +01:00
James Youngman
9b0079c1d3 Fix typo "sturct".
* find/exec.c (impl_pred_exec): Typo fix: struct/struct.
* ChangeLog (2007-03-28): Likewise.
2013-09-21 00:06:04 +01:00
183115d048 find: fix fd leak with --execdir option (bug#34976)
Prevent "Failed to save working dir[...]: Too many open files"
error by closing the file descriptor of the working directory.

* find/exec.c (impl_pred_exec): Free the working directory if find
executes the command in the local dir, i.e. if it has been saved
by record_exec_dir().  Re-indent code.
* find/testsuite/sv-34976-execdir-fd-leak.sh: Add test.
* find/testsuite/Makefile.am (test_shell_progs): Mention the test.
* NEWS: Mention the fix.
2013-09-20 22:14:05 +01:00
James Youngman
5f7a605f5e Reduce needless calls to complete_pending_execdirs.
* find/exec.c (impl_pred_exec): Once pushing an argument for
-exec{,dir} ... +, Only set state.execdirs_outstanding if
there were previously no todo items on ths command line.
This avoids spurious calls to complete_pending_execdirs().
2013-02-02 12:21:14 +00:00
James Youngman
8becd09bb9 Use a consistent order for header-file inclusion.
* find/exec.c: Include config.h, then system headers followed by
gnulib headers and last, find-specific headers.
* find/find.c: Likewise.
* find/finddata.c: Likewise.
* find/fstype.c: Likewise.
* find/ftsfind.c: Likewise.
* find/parser.c: Likewise.
* find/pred.c: Likewise.
* find/tree.c: Likewise.
* find/util.c: Likewise.
* lib/buildcmd.c: Likewise.
* lib/dircallback.c: Likewise.
* lib/extendbuf.c: Likewise.
* lib/fdleak.c: Likewise.
* lib/findutils-version.c: Likewise.
* lib/listfile.c: Likewise.
* lib/printquoted.c: Likewise.
* lib/qmark.c: Likewise.
* lib/regexprops.c: Likewise.
* lib/regextype.c: Likewise.
* lib/safe-atoi.c: Likewise.
* lib/savedirinfo.c: Likewise.
* lib/splitstring.c: Likewise.
* lib/test_splitstring.c: Likewise.
* lib/waitpid.c: Likewise.
* locate/bigram.c: Likewise.
* locate/code.c: Likewise.
* locate/frcode.c: Likewise.
* locate/locate.c: Likewise.
* locate/word_io.c: Likewise.
* xargs/xargs.c: Likewise.
2011-06-20 10:26:24 +01:00
James Youngman
0caac6fe3d Take gnulib-tool's advice about which header files to include.
* locate/locate.c: Include <regex.h> instead of "regex.h".
Include "fnmatch.h" instead of <fnmatch.h> (because we use
fnmatch-gnu).  Include "gettext.h".
* lib/regexprops.c: Include <regex.h> instead of "regex.h".
* find/tree.c: Include "gettext.h".  Include "fnmatch.h" instead
of <fnmatch.h> (because we use fnmatch-gnu).
* find/parser.c: Include "gettext.h" and <regex.h>.  Include
"fnmatch.h" instead of <fnmatch.h> (because we use fnmatch-gnu).
* find/pred.c: Likewise.
* find/exec.c: Include "gettext.h".
* find/find.c: Likewise.
* find/fstype.c: Likewise.
* find/ftsfind.c: Likewise.
* find/print.c: Likewise.
* lib/buildcmd.c: Likewise.
* lib/fdleak.c: Likewise.
* lib/findutils-version.c: Likewise.
* lib/regextype.c: Likewise.
* lib/safe-atoi.c: Likewise.
* find/util.c: Likewise.
* locate/bigram.c: Likewise.
* locate/code.c: Likewise.
* locate/frcode.c: Likewise.
* locate/word_io.c: Likewise.
* xargs/xargs.c: Likewise.
* find/Makefile.am: Add a comment explaining why gnulib-tool
advised us to use each library.
2011-06-20 00:39:20 +01:00
James Youngman
edb481e9d2 Fix further compiler warnings.
* find/ftsfind.c (show_outstanding_execdirs): Now that
execp->state.cmd_argc is a size_t, we can't print it with %d.  So
print it with PRIuMAX (and include <inttypes.h> to define that).
* find/tree.c (prec_name): change return type to const char*.
(type_name): Likewise.
* find/exec.c (impl_pred_exec): use a separate variable (buf) to
point the memory allocated/freed with malloc/free, so that the
existing variable target can then be const (and so we can assign
pathname to it without a compiler warning).
2011-06-14 23:44:57 +01:00
James Youngman
4f1a351a23 Assume SIGCHLD and O_NOFOLLOW are defined by gnulib.
* find/find.c: Since gnulib defines O_NOFOLLOW, don't check to see
if the macro is defined.  Check instead to see if it is 0.
(safely_chdir_nofollow): Point this out.
(safely_chdir): Check O_NOFOLLOW for zeroness.
* find/exec.c: Don't #define SIGCHLD.
* xargs/xargs.c: Likewise.
2011-06-14 00:22:44 +01:00
James Youngman
9044591cab Split exec-related code into a new file, exec.c
* find/exec.c: New file.
(initialise_wd_for_exec): Move out of pred.c
(record_exec_dir): Likewise.
(impl_pred_exec): Likewise.
(prep_child_for_exec): Likewise.
(launch): Likewise.
* find/pred.c: These functions are moved out of this file.
* find/defs.h: impl_pred_exec is no longer static in pred.c, do
add an external declaration for it.  Move the declaration of
launch to here also.
* find/Makefile.am (libfindtools_a_SOURCES): Add exec.c.
* po/POTFILES.in: Add find/exec.c.

Signed-off-by: James Youngman <jay@gnu.org>
2011-06-12 20:28:41 +01:00