* find/testsuite/Makefile.am (EXTRA_DIST_EXP):
find.gnu/sv-bug-25359-execdir.exp should in fact be
find.gnu/sv-bug-27563-execdir.exp and
find.posix/sv-bug-25359-exec.exp should be
find.posix/sv-bug-27563-exec.exp.
Signed-off-by: James Youngman <jay@gnu.org>
* lib/fdleak.c (get_max_fd): Don't use RLIM_SAVED_MAX or
RLIM_SAVED_CUR. Not only are they non-portable, they aren't
useful.
* NEWS: Mention this bugfix.
Signed-off-by: James Youngman <jay@gnu.org>
* find/util.c (hook_fstatat): This has been disabled and unused
for a long time, delete it.
* find/find.c (process_dir): Remove some unused debug code.
* find/tree.c (predlist_insert): Remove some dead code.
* lib/fdleak.c (complain_about_leaky_fds): Remove some unused
debug code.
Signed-off-by: James Youngman <jay@gnu.org>
* .x-sc_prohibit_empty_lines_at_EOF: New file; exceptions for the
sc_prohibit_empty_lines_at_EOF syntax check.
Signed-off-by: James Youngman <jay@gnu.org>
* find/pred.c (initialise_wd_for_exec): New function, factoring
out part of the body of record_exec_dir.
(record_exec_dir): If state.rel_pathname contains a /, extract the
directory part and initialise execp->wd_for_exec to point at that
directory.
(impl_pred_exec): Rename new_impl_pred_exec to impl_pred_exec.
Drop the prefix and pfxlen parameters. Compute the base name of
the target and pass that to the bc_push_arg function instead of
state.rel_pathname. Deal with state.rel_pathname being an
absolute path (e.g. find / -execdir...). Introduce a new
variable, result, allowing us to free the buffer used for the base
name in the return path.
(pred_exec): Don't pass the prefix and the prefix length any more.
(pred_execdir): Likewise.
(pred_ok): Likewise.
(pred_okdir): Likewise.
Signed-off-by: James Youngman <jay@gnu.org>
* find/ftsfind.c (consider_visiting): Don't call
complete_pending_execdirs for every file we visit.
(find): Instead, call complete_pending_execdirs every time we
see a file which isn't at the same nesting level as the previous
file we saw. This is an improvement but not optimal (since
descending into a subdirectory will cause us to issue an exec
before we've finished with the current directory).
* NEWS: Mention this change.
Signed-off-by: James Youngman <jay@gnu.org>
* lib/dircallback.c (run_in_dirfd): New name for old run_in_dir
function.
(run_in_dir): Like the old funciton of the same name, but now
takes an argument const struct saved_cwd *.
* lib/dircallback.h: Update declarations of run_in_dirfd and
run_in_dir.
* find/util.c: Include dircallback.h, xalloc.h, save-cwd.h.
(do_complete_pending_execdirs): Remove dir_fd parameter, since the
per-predicate data structures now indicate what directory they
need to be run in. Instead of calling bc_do_exec directly, use a
callback 'exec_cb' that uses run_in_dir (which now takes a
saved_cwd* parameter instead of a file descriptor).
(do_exec): Called by do_complete_pending_execdirs, and simply uses
run_in_dir to call exec_cb, restoring the working directory
afterward.
(record_initial_cwd): New function, initialises the global
variable initial_wd.
(cleanup_initial_cwd): New function, cleans up the global variable
initial_wd.
(cleanup): Call cleanup_initial_cwd.
(get_start_dirfd): Remove.
(is_exec_in_local_dir): New funciton; true for predicates -execdir
and -okdir.
* find/pred.c: Include cloexec.h and save-cwd.h.
(record_exec_dir): New function, sets the value of
execp->wd_for_exec if needed.
(new_impl_pred_exec): Remove the obsolete dir_fd parameter. Call
record_exec_dir.
(pred_exec): Don't pass the dir_fd parameter.
(pred_execdir): Likewise.
(pred_ok): Likewise.
(pred_okdir): Likewise.
(can_access): Call run_in_dirfd rather than run_in_dir (the
function was renamed).
(prep_child_for_exec): Remove dir_fd parameter; don't fchdir to
that. Call restore_cwd instead (passing a saved_cwd* parameter
which replaced dir_fd).
(launch): Remove references to execp->use_current_dir.
(launch): Change references to execp->dir_fd to execp->wd_for_exec.
* find/parser.c: Correct indentiation of declaration of
insert_exec_ok and remove the obsolete dir_fd parameter.
(parse_exec): Don't pass the dir_fd parameter to insert_exec_ok.
(parse_execdir): Likewise.
(parse_ok): Likewise.
(parse_okdir): Likewise.
(insert_exec_ok): Remove obsolete dir_fd paramter. Initialise
execp->wd_for_exec, either to NULL (for -*dir) or to the
initial_wd.
* find/ftsfind.c: Remove get_current_dirfd. Remove
complete_execdirs_cb.
(consider_visiting): Call complete_pending_execdirs directly.
(main): Call record_initial_cwd to record the initial working
directory, early on. Don't initialise starting_dir or
starting_desc, they have been removed.
* find/finddata.c: Include save-cwd.h. Remove starting_dir and
starting_desc. Add new global variable initial_wd. It is a struct
saved_wd* and represents find's initial working directory.
* find/find.c: Include save-cwd.h.
(main): Call record_initial_cwd in order to initialise the
global variable initial_wd Don't set starting_desc and
starting_dir, since those variables have been removed.
(safely_chdir): Don't pass an fd to complete_pending_execdirs.
(chdir_back): Remove the safety check (since we are using fchdir
and in any case no longer have all the data that the existing
wd_sanity_check function wants).
(do_process_top_dir): Don't pass an fd to
complete_pending_execdirs.
(process_dir): Likewise.
* find/defs.h (struct exec_val): Remove use_current_dir and
dir_fd. Replace with wd_for_exec, which is a struct saved_wd*.
(get_start_dirfd): Remove prototype.
(get_current_dirfd): Remove prototype.
(complete_pending_execdirs): No longer takes dir_fd parameter.
(record_initial_cwd): Add prototype.
(is_exec_in_local_dir): Add prototype.
(options): Declare.
(initial_wd): Add declaration. It is a struct saved_wd* and
represents find's initial working directory.
(starting_dir): Remove devlaration of global variable.
(starting_desc): Remove devlaration of global variable.
* import-gnulib.config (modules): Import module save-cwd.
Signed-off-by: James Youngman <jay@gnu.org>
* find/testsuite/find.gnu/execdir-multiple.exp: New test; verifies
that for -execdir +, all the execs occur with the correct workikng
directory.
* find/testsuite/find.gnu/execdir-multiple.xo: Expected output for
this test.
* find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add the new test.
(EXTRA_DIST_XO): Add the expected output file.
* find/testsuite/config/unix.exp (mkdir): Create proc "mkdir"
which creates a directory.
* find/testsuite/find.gnu/execdir-pwd1.exp: New test.
* find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add
execdir-pwd1.exp.
Signed-off-by: James Youngman <jay@gnu.org>
* .x-sc_prohibit_test_minus_ao: Add all the DejaGnu scripts to the
list of exceptions to the 'test C1 -a C2' syntax check, since they
are not actually shell scripts.
Signed-off-by: James Youngman <jay@gnu.org>
* NEWS: Mention that release 4.5.8 also fixed bug #27221
(symlink_loop check broken by FTS_CWDFD), though the NEWS file in
that release omitted to say so.
Signed-off-by: James Youngman <jay@gnu.org>
* import-gnulib.config (modules): Add dirent-safer; we were
previously transitively importing this module, but we are now
importing it directly.
* lib/savedirinfo.c: Include opendir-safer.h.
(xsavedir): Call opendir_safer instead of opendir.
Signed-off-by: James Youngman <jay@gnu.org>
* import-gnulib.config (modules): Import the d-type module.
* configure.ac: Remove old struct dirent.d_type detection logic
(since we now use the gnulib macro from the d-type module for
this).
* find/parser.c (parse_version): Use HAVE_STRUCT_DIRENT_D_TYPE
(since the d-ino module still defines it) but remove references to
the macro USE_STRUCT_DIRENT_D_TYPE, since it's not defined and not
needed.
* lib/savedirinfo.c: Use HAVE_STRUCT_DIRENT_D_TYPE but ignore
USE_STRUCT_DIRENT_D_TYPE.
(xsavedir): Unconditionally initialise
internal[result->size].type_info so that we don't have untested
code (HAVE_STRUCT_DIRENT_D_TYPE is defined on my system).
Signed-off-by: James Youngman <jay@gnu.org>
* NEWS: Mention that release 4.5.8 also fixed bug #27974 (Use
gnulib's xreadlinkat support), though the NEWS file in that
release omitted to say so.
Signed-off-by: James Youngman <jay@gnu.org>
* find/parser.c (parse_samefile): Since collect_arg_stat_info
increments *arg_ptr, argv[*arg_ptr] is often NULL. Use filename
instead, as that's the variable in which we store the name of our
file. The purpose of the fd was only to attempt to keep the inode
number stable on systems that don't really have inode numbers, so
this change should have no functional effect on POSIX systems.
* find/parser.c (parse_samefile): Use open_cloexec to open the
reference file, so that we don't leak a file descriptor.
Signed-off-by: James Youngman <jay@gnu.org>
* import-gnulib.config (modules): Add c-casestr, errno, fdopendir,
fflush, getdelim, gettimeofday, locale, modf, perror, snprintf,
stat, stdarg, stddef, stdio, stdlib, string, strpbrk, sys_time,
sys_wait.
Also add comments about other modules we may also want to use
which would require other code changes (for example dirent-safer).
* find/Makefile.am (LDADD): Add $(LIB_EACCESS) $(LIB_SELINUX)
$(MODF_LIBM) which are needed by gnulib modules we now depend on.
Signed-off-by: James Youngman <jay@gnu.org>
* find/parser.c (estimate_fstype_success_rate): Change the name of
the variable "dir" to "the_root_dir" to emphasise that it doesn't
matter that we're calling stat rather than options.xstat.
* find/ftsfind.c (symlink_loop): Call options.xstat instead of
stat/lstat, because options.xstat takes account of
state.cwd_dir_fd.
Signed-off-by: James Youngman <jay@gnu.org>
* find/pred.c (do_fprintf): Use optionl_stat and optionp_stat
instead of stat and lstat, because the first two functions are
aware of state.cwd_dir_fd.
* find/testsuite/find.gnu/printf-nonlocal-symlink.exp: A new test
case for this bug.
* find/testsuite/find.gnu/printf-nonlocal-symlink.xo: Expected
output for this test.
* find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add the new test
case.
(EXTRA_DIST_XO): Add the expected-output file.
Signed-off-by: James Youngman <jay@gnu.org>
* doc/find-maint.texi: Update the maintenance manual to take into
account the fact that we uniformly use git rather than CVS. Point
out the new version tag format. Mention "make coverage".
README-CVS is now called README-hacking. Update the URL for the
Translation Project.
Signed-off-by: James Youngman <jay@gnu.org>
* lib/extendbuf.c (xextendbuf): New function; extends the buffer,
but calls xalloc_die on failure. On the the other hand, extendbuf
returns NULL on failure.
(decide_size): If wanted>SIZE_MAX/2, return wanted. This means
that for very large buffers, performance on repeated extension
degrades from linear to quadratic (instead of just failing at that
point, as before).
* lib/savedirinfo.c (xsavedir): Use xextendbuf rather than
extendbuf, now that there is a difference in semantics.
* find/fstype.c (get_mounted_filesystems): If extendbuf returns
NULL, fail (by returning NULL ourselves).
(get_mounted_devices): Likewise.
Signed-off-by: James Youngman <jay@gnu.org>