summaryrefslogtreecommitdiffstats
path: root/bin/rm/rm.c
Commit message (Collapse)AuthorAgeFilesLines
* Correct a security issue introduced in previous commit:delphij2006-10-311-2/+2
| | | | | | | | | | | | | | | | | | | | instead of removing the file and issue a warning about the removal, do not do any operation at all in case -P is specified when the dinode has hard links. With -f and -P specified together, we assume that the user wants rm to overwrite the contents of the file and remove it (destroy the contents of file but leave its hard links as is). The reason of doing it this way is that, in case where a hard link is created by a malicious user (currently this is permitted even if the user has no access to the file). Losing the link can potentially mean that the actual owner would lose control completely to the user who wants to obtain access in a future day. Discussed with: Peter Jermey
* Be more reasonable when overwrite mode is specified while theredelphij2006-10-301-0/+5
| | | | | | | | | is hard links. Overwritting when links > 1 would cause data loss, which is usually undesired. Inspired by: discussion on -hackers@ Suggested by: elessar at bsdforen de Obtained from: OpenBSD
* o Backout rev. 1.55. Don't waste cpu cycles for bzero(), do notmaxim2006-10-181-2/+1
| | | | | | call chflags() for whiteouted files. Prodded by: ru
* o Zero out struct stat before usage. lstat(2) can fail andmaxim2006-10-181-0/+1
| | | | | | | | leave garbage there which will break -W code path. PR: bin/84569 Submitted by: Igor MFC after: 2 weeks
* o Be pedantic and do fts_close() when done.maxim2006-04-151-0/+1
| | | | | | PR: bin/95292 Submitted by: Charles Hardin Obtained from: NetBSD via OpenBSD, PR
* Handle the case where the -P flag is specified for a read-only filedougb2005-09-291-4/+5
| | | | | | | | | | | | | | earlier, and more gracefully. Previously, this combination would be ignored early in the code where permissions are tested and fail later with a very unhelpful "permission denied" error. Instead, test for this flag in the same block that generates the "override?" messages for read-only files, but instead of trying to guess what the user has in mind, generate an error and exit. Update the man page to reflect this new behavior. Not objected to by: freebsd-hackers@
* UNIX conformance: If -r -f on non-existent directory, don't emit error.jkh2004-11-131-1/+4
|
* Add -I, an option that asks for confirmation once if recursivelydelphij2004-10-281-3/+62
| | | | | | | | | | | | | | | | | | | | | removing directories or if more than 3 files are listed in the command line. This feature is intended to provide a safe net but not being too annoying like having "rm -i" for every deleting operations, and is generally good for both newbies and power users, preventing them from being so easily run into ``rm -rf /'', ``rm -rf *'' and so forth. Originally implemented by Matthew Dillon for DragonFly, plus some improvements done by various DragonFly contributors. Approved by: murray (mentor; the original dillon's version) Discussed with: des Obtained from: DragonFly's bin/rm/ rm.c rev. 1.4 - 1.8 rm.1 rev. 1.3 - 1.4 MFC After: 1 month
* The previous commit added code to rm(1) to warn about and remove anydes2004-10-041-1/+2
| | | | | | | | | | | | | | | occurrences of "/" in the argument list. This corresponds to Enhancement Request Number 5 in the Austin Group TC2 Aardvark's XCU Defects Report (<URL:http://www.opengroup.org/austin/aardvark/finaltext/xcubug.txt>). Further discussion is available in the Austin Group mailing list archives (<URL:http://www.opengroup.org/austin/mailarchives/>, "Defect in XCU rm") and for Austin Group members, in the Austin Group Interpretations archive (<URL:http://www.opengroup.org/austin/interps/>, AI-019) This commit makes that check conditional on !POSIXLY_CORRECT, since it is not strictly correct according to the current version of the standard (but is expected to be correct according to the next version, and has already been adopted by Solaris).
* Find out how flame-proof my underwear really is.des2004-10-041-0/+23
|
* Whitespace cleanup.des2004-10-041-4/+4
|
* Remove clause 3 from the UCB licenses.markm2004-04-061-4/+0
| | | | OK'ed by: imp, core
* o Fix a style bug and poor wording in comment.kuriyama2004-01-011-2/+10
| | | | | | | | | o When fts_read() cannot stat the file, it can't be unlinked. At that case, don't display error message when -f flag is used. Obtained from: bde PR: kern/16815, bin/35842 Reported by: kuriyama, Aleksandr A. Babaylov <.@babolo.ru>
* When the P flag is set (i.e. Overwrite regular files before deleting them),guido2003-11-101-8/+14
| | | | | | | | | do only unlink the file if we could indeed overwrite the file. Old behaviour: rm -P /tmp/foo (foo mode 0444) would NOT overwrite foo, but still delete it (with a warning: rm: foo: Permission denied) New behaviour: Just the EPERM warning, but no deletion Reviewed by: bde
* 1. Fixed leakage of a file descriptor for every non-fatal failure inbde2003-11-081-1/+3
| | | | | | | | | | | | | | | rm_overwrite() (for rm -P). 2. Print the file name in the error message for (fatal) malloc() failures in rm_overwrite(). I first thought that malloc() failures should be non-fatal since they don't prevent proceeding the the next file, but making them non-fatal would normally give too much output for rm -Pr on a large tree in the unlikely event that even one occurs, since the malloc()ed amounts are usually the same. Just print the file name since the malloc()ed amounts are not always the same and it doesn't hurt to know where rm was when it quit. Submitted by: guido ((1) and original version of (2))
* Quiet warnings about copyright[].obrien2003-05-011-2/+2
|
* s/filesystem/file system/ as discussed on -developerstrhodes2002-08-211-2/+2
|
* Complain if more than one file argument is given to unlink(1) like we didtjr2002-07-121-1/+1
| | | | before I made unlink use getopt().
* err() is documented as allowing NULL for the format string but GCC isn'tdillon2002-07-101-2/+2
| | | | happy about it any more so change the usage to make buildworld work again.
* Consistently use FBSDIDobrien2002-06-301-3/+2
|
* Reject options, handle "--" correctly in unlink(1).tjr2002-05-301-4/+7
|
* Consistancy check s/file system/filesystem/trhodes2002-05-161-2/+2
| | | | Reviewed by: brian
* Move user_from_uid to pwd.himp2002-02-141-0/+2
| | | | | | | | | | | | | Move group_from_gid to grp.h Remove from stdlib.h Make the prototypes match the code Fix rm and mv to include new files. NetBSD has these defined in those files, and others too that I've not done. Approved by: terminal room kabal Reviewed by: jhb, phk
* o __P has been reovedimp2002-02-021-23/+13
| | | | | | | | | o Old-style K&R declarations have been converted to new C89 style o register has been removed o prototype for main() has been removed (gcc3 makes it an error) o int main(int argc, char *argv[]) is the preferred main definition. o Attempt to not break style(9) conformance for declarations more than they already are.
* Add prototypes for main() so that these programs compile with -Werrorluigi2001-12-141-0/+1
| | | | | | | | | | | | (which somehow now seems to be the default for compiling -current). This error popped up while doing a PicoBSD cross-compile on a 4.3-ish system, it may well be that there are other apps which have similar problems, but I did not spot them as they are not included in my picobsd config. Whether adding prototypes for main() is the correct solution or not I have no idea, a request to -current on the matter went basically unanswered. Those who have better ideas are welcome to back this out and replace it with the correct fix.
* Removed wrong cast for fts_open()'s third argument.ru2001-06-131-1/+1
|
* Display pathname of item being rm'ed.obrien2000-12-201-3/+3
| | | | Submitted by: Peter Pentchev <roam@orbitel.bg>
* Switch over to using the new fflagstostr and strtofflags library calls.joe2000-06-171-8/+6
|
* Remove unused #include.asmodai2000-05-011-1/+0
|
* Revert part of the last commit, remove {g|s}etflags from the libcjoe2000-02-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | interface, and statically link them to the programs using them. These functions, upon reflection and discussion, are too generically named for a library interface with such specific functionality. Also the api that they use, whilst ok for private use, isn't good enough for a libc function. Additionally there were complications with the build/install-world process. It depends heavily upon xinstall, which got broken by the change in api, and caused bootstrap problems and general mayhem. There is work in progress to address future problems that may be caused by changes in install-chain tools, and better names for {g|s}etflags can be derived when some future program requires them. For now the code has been left in src/lib/libc/gen (it started off in src/bin/ls). It's important to provide library functions for manipulating file flag strings if we ever want this interface to be adopted outside of the source tree, but now isn't necessarily the right moment with 4.0-release just around the corner. Approved: jkh
* Historically file flags (schg, uschg, etc) have been converted fromjoe2000-01-271-3/+1
| | | | | | | | | | | | | | | | | string to u_long and back using two functions, flags_to_string and string_to_flags, which co-existed with 'ls'. As time has progressed more and more other tools have used these private functions to manipulate the file flags. Recently I moved these functions from /usr/src/bin/ls to libutil, but after some discussion with bde it's been decided that they really ought to go in libc. There are two already existing libc functions for manipulating file modes: setmode and getmode. In keeping with these flags_to_string has been renamed getflags and string_to_flags to setflags. The manual page could probably be improved upon ;)
* Add link(1) and unlink(1) as special cases of ln(1) and rm(1)sheldonh1999-12-201-1/+21
| | | | | | | | | | | | respectively, in accordance with SUSv2. This differs from the approach taken in NetBSD, but provides less obscure error messages in at least the EISDIR case and does not take up additional disk space for new binaries. PR: 13071 PR: 13074 Requested by: James Howard <howardjp@wam.umd.edu>
* brucifymharo1999-11-281-13/+13
| | | | Reviewed by: obrien
* Fixed longstanding breakage of rm of deep directories in rev.1.2.bde1999-09-131-1/+1
| | | | | | | | | | rm must not use FTS_NOCHDIR, since chdir'ing is required for removing deep directory trees and the ability to remove such trees is required by POSIX.2 and POLA. The breakage didn't make much difference until recently, since fts(3) didn't work in deep directory trees. It isn't clear whether using FTS_NOCHDIR ever fixed anything (Net/2's rm.c is similar to Lite1's). Perhaps it was actually to limit the damage caused by the fts bug.
* brucify, `v' before `W', mention -v is non-standard in manpage andmharo1999-09-041-15/+19
| | | | | | make code slightly easier to read Reviewed by: obrien
* fix rm -rmharo1999-08-291-1/+2
| | | | Submitted by: John Hay -- John.Hay@mikom.csir.co.za
* add verbose flagmharo1999-08-291-9/+24
| | | | | | exit(1) --> exit(EX_USAGE) Reviewed by: obrien
* $Id$ -> $FreeBSD$peter1999-08-271-1/+1
|
* Use .Dq instead of ``'' in manpagekris1999-05-281-6/+18
| | | | | | | Use optimal blocksize for rm -P, instead of always using 8192-byte blocks to overwrite the file. Obtained from: OpenBSD
* Don't emit usage() message when no arguments given to -f. Thisjkh1999-02-251-2/+5
| | | | | | | appears to be consistent with other Unixen, like Solaris. PR: 10240 Submitted by: jun_sun@hlla.is.tsukuba.ac.jp
* Remove remaining Lite1 stuff from the man page and uphold thesteve1997-08-071-3/+8
| | | | | | | precedence in changing sccsid to rcsid as set by Phillippe Charnier in his previous 100 or so commits. pointed out by: Bruce Evans <bde@zeta.org.au>
* Remove #if(n)def BSD_4_4_LITE cruft and change sccsid to rcsid.steve1997-08-071-46/+5
|
* Enable whiteout code since we now have the lite2 support for them.dfr1997-04-291-2/+2
|
* compare return value from getopt against -1 rather than EOF, per the finalimp1997-03-281-3/+3
| | | | posix standard on the topic.
* Revert $FreeBSD$ to $Id$peter1997-02-221-1/+1
|
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Merge Lite2 mods, and -Wall cleaning. Unimplemented undelete(2)steve1996-12-141-34/+98
| | | | | cruft is protected by a #ifdef (BSD4_4_LITE) that should be removed when this is supported by the kernel.
* fix usage stringwosch1996-03-071-3/+3
| | | | | | respond `Y' is equal to `y' Add a note how to delete file name with beginning `-'
* Don't initialize udata, fix usage stringpst1996-02-191-4/+3
|
* delete my last commitwosch1996-02-191-5/+5
| | | | Submitted by: pst, ache
OpenPOWER on IntegriCloud