summaryrefslogtreecommitdiff
path: root/src/remove.c
AgeCommit message (Collapse)Author
2002-09-06(prompt): Change comment to give a better note to translators.Jim Meyering
2002-08-29(is_empty_dir): Detect and diagnose readdir failures.Jim Meyering
Always close directory handle.
2002-08-29(remove_cwd_entries): Use closedir (not CLOSEDIR) when ignoring any return ↵Jim Meyering
value.
2002-08-29(remove_cwd_entries): Detect and diagnose readdirJim Meyering
failures. On some systems (at least EMC Celerra and Solaris5.8), this appears to be necessary.
2002-08-28(remove_cwd_entries): Use CLOSEDIR, not closedir.Jim Meyering
Give a diagnostic and fail if closedir fails.
2002-07-22rm would prompt for non-dangling symlinksJim Meyering
(prompt): When not interactive, don't prompt for a symlink.
2002-07-14Under some circumstances, rm would fail due to a lack ofJim Meyering
permissions, but give a misleading diagnostic like this: rm: cannot chdir from `.' to `foo': Not a directory (remove_dir): Detect the case in which unlinking a non-directory fails with EPERM, and give an appropriate diagnostic.
2002-07-04(prompt): Fix test for write-protectedness to alsoJim Meyering
check errno == EACCES. Otherwise, `rm dangling-symlink' would mistakenly prompt.
2002-06-29(AD_mark_current_as_unremovable): Replace dead code with an assertion.Jim Meyering
2002-06-25(prompt): Add a comment to help translators workJim Meyering
around the problem of making the translations of the adjective `write-protected' and the corresponding run-time-variable noun (e.g., file, directory, symlink, etc.) consistent. From Paul Eggert.
2002-06-12(rm): Fix typo in assertion.Jim Meyering
2002-06-07(remove_entry): Use DT_IS_DIR only ifJim Meyering
HAVE_STRUCT_DIRENT_D_TYPE is defined.
2002-06-02Merge in all changes from no-recursion branch.Jim Meyering
* src/remove.c (enum Ternary): Define type. (prompt): Add a parameter. Adjust callers. (remove_entry): Attempt rmdir here, only if a directory is `known' to be empty. Significant rework. (remove_dir): Propagate failure `up' also when rmdir fails. In interactive mode, prompt only once about an empty directory. * src/remove.c (enum Prompt_action): Define. (prompt): Two new parameters. Adjust all callers. Performance. * src/remove.c (remove_entry) [!ROOT_CAN_UNLINK_DIRS]: Don't call rmdir here. * src/remove.c (AD_pop_and_chdir): Don't use errno (it's not valid) in diagnostic for changed dev/ino. (remove_entry): Tweak diagnostic. * src/remove.c (ROOT_CAN_UNLINK_DIRS): Define. (AD_pop_and_chdir): Propagate status as we traverse back `up' the tree. (DO_UNLINK, DO_RMDIR): Define. (remove_entry) [ROOT_CAN_UNLINK_DIRS]: Add code so this works also on systems where root can use `unlink' to remove directories. * src/remove.c: Include file-type.h. Include file type in prompt when asking whether to remove file. Based on a patch from Paul Eggert. * src/remove.c (prompt): Add comment. * src/remove.c (remove_dir): Fix another (known) leak. * src/remove.c (hash_freer): New function. (AD_mark_helper): Use it. (AD_mark_as_unremovable): xstrdup the filename argument. (remove_dir): Free directory name. * src/remove.c (remove_entry): Fail also when trying to remove a directory without the --recursive option. Change a diagnostic, s/unlink/remove/, now that it can apply also to a directory. * src/remove.c (is_empty_dir): New function. (prompt): New function, factored out of... (remove_entry): ...here. Call it. (remove_dir): Call prompt before rmdir. * src/remove.c (remove_entry): Add support for prompting (e.g., -i). * src/remove.h (UPDATE_STATUS): New macro. * src/remove.c [AD_ent] (status): New member. This lets us propagate the status from a subdirectory to its parent via AD_pop_and_chdir. (AD_push_initial): Set it. (AD_push): Likewise. (remove_cwd_entries): Change return type to enum RM_status, and adjust all callers. (rm): Use UPDATE_STATUS rather than open-coding it. * src/remove.c (remove_entry): New function, factored out of... (remove_cwd_entries): ...here, and... (rm_1): ...here. * src/remove.c (remove_cwd_entries): Add support for --verbose. (remove_dir): Likewise. (rm_1): Likewise. * src/remove.c (rm): Free cwd_state, if necessary. * src/remove.c (rm_1): Remove now useless (always true) user_specified_name parameter. Adjust sole caller. * src/remove.c (rm): New function. This interface allows one to remove multiple arguments at a time. This is important in that it allows us to hide the remove_init/remove_fini functions and the cwd_state parameter. (rm_1): Renamed from rm. (remove_init, remove_fini): Remove functions. Each body is now part of `rm'.
2002-05-03Add FIXME comment.Jim Meyering
2002-04-27(cycle_check): Add a comment.Jim Meyering
2002-04-27(cycle_check): New function containing code factoredJim Meyering
out of remove_dir. The sole difference is that upon detecting a cycle, rm now dies unconditionally. Before, in interactive mode, it would ask the user whether to continue. (remove_dir): Call cycle_check.
2002-04-25Remove hash table, active_dir_map, used to detect directory cycles.Jim Meyering
Instead, detect them lazily with just O(1) memory. Suggestion from Andi Kleen. (is_power_of_two): New function. (print_nth_dir, make_active_dir_ent): Remove functions. (hash_active_dir_ent, hash_compare_active_dir_ents): Likewise. (remove_dir): Check for cycles here, ... (rm): ... and don't check for cycles here. (rm): Call fspec_get_full_mode here, rather than fspec_get_filetype_mode. We want to get the dev/ino earlier, and at the same time as when we get the file type, to avoid the risk that an attacker would change e.g. a directory to a symlink before we record its dev/ino.
2002-04-22(rm): Call exit with EXIT_FAILURE, not `1'.Jim Meyering
2002-04-22(rm, remove_init, remove_fini): Don't use or evenJim Meyering
initialize the active_dir_map unless --recursive (-r) is specified.
2002-03-10* src/copy.c (copy_reg): Use a more concise diagnostic forJim Meyering
reporting replaced files. This avoids a bug in the code, which mishandled ino_t wider than long. * src/remove.c (remove_dir): Likewise, twice.
2002-03-09(rm) Add comment on new parameter.Jim Meyering
2002-03-08Don't allow a malicious user to trick another user's rm process intoJim Meyering
removing unintended files. In one scenario, if root is removing a hierarchy that is writable by the malicious user, that user may trick root into removing all of `/'. Reported by Wojciech Purczynski. (remove_dir): After chdir `..', call lstat to get the dev/inode of "." and fail if they aren't the same as the old numbers. (remove_cwd_entries): New parameter, `cwd_dev_ino'. (remove_dir): Likewise. (rm): Likewise. Adjust all callers.
2002-02-01(rm): Add a comment.Jim Meyering
2001-11-23Use opaque type, Hash_table, not `struct hash_table'.Jim Meyering
2001-10-05Include hash-pjw.h and remove definition of hash_pjw.Jim Meyering
2001-08-31* src/remove.c: Move true/false definitions and include from here...Jim Meyering
* src/system.h: ...to here.
2001-05-13(dir_name, dir_len): Define to different namesJim Meyering
to avoid shadowing warnings due to new declarations from dirname.h.
2001-05-12Include dirname.h, to get base_nameJim Meyering
2001-02-18`chmod 0 file; rm file' would no longer prompt before removal.Jim Meyering
(remove_file): Revert last change.
2001-01-22(remove_file): Correct an expression to avoid makingJim Meyering
an unnecessary call to euidaccess for each file.
2000-12-25(hash_compare_active_dir_ents): Return explicit `true'Jim Meyering
or `false', rather than relying on implicit int-to-enum cast.
2000-08-08(remove_cwd_entries, rm): Invoke xalloc_die instead of printing our own message.Jim Meyering
2000-07-30(remove_file): Quote the file names that are displayed with --verbose.Jim Meyering
2000-07-30(remove_cwd_entries): Quote one more file name.Jim Meyering
2000-07-23(ASSIGN_STRDUPA): Remove macro definition.Jim Meyering
2000-07-15Convert "`%s'" in format strings to "%s", and wrap eachJim Meyering
corresponding argument in a `quote (...)' call -- if there's only one. If there are more than one, then use `quote_n (0, ...), quote_n (1, ...), ...'.
2000-05-20add format args to match new %lu directivesJim Meyering
2000-05-20tweak warning diagnosticJim Meyering
2000-05-20Save device number as well as inode number for each directory.Jim Meyering
(struct active_dir_ent) [st_dev]: New member. [st_ino]: Rename from `inum'. (make_active_dir_ent) [device]: New parameter. (hash_compare_active_dir_ents): Compare using SAME_INODE macro. (fspec_init_common): New function, factored out. (fspec_init_file): Initialize have_device member. (fspec_get_full_mode): Remove parameter. Update caller. Set have_device and st_dev members.
2000-05-18(rm): Combine adjacent fputc and fprintf.Jim Meyering
2000-05-18remove some parens from some cpp linesJim Meyering
2000-05-18(remove_dir): Detect (and fail upon) attempt to subvert a running `rm -r'.Jim Meyering
Reported by Morten Welinder.
1999-11-12(print_nth_dir): Write one fewer byte so we don't print a trailing slash.Jim Meyering
(rm): Fix bugs in (and test, this time) the very-rarely-used code to warn about directory cycles.
1999-05-13(pop_dir): Cast length to `int' to avoid a warning onJim Meyering
64-bit systems. From Ulrich Drepper.
1999-03-31Don't include closeout.h or version-etc.h explicitly. Now, they're included ↵Jim Meyering
via sys2.h.
1999-03-18(remove_cwd_entries): Reflect changes in hash_insert.Jim Meyering
(remove_init): Call hash_initialize with one more argument.
1999-02-16update copyright datesJim Meyering
1999-01-16Don't declare base_name.Jim Meyering
1998-11-30(DOT_OR_DOTDOT): Move definition from this file...Jim Meyering
1998-11-08[HAVE_LSTAT_EMPTY_STRING_BUG]: Define lstat to rpl_lstat and declare the latter.Jim Meyering