summaryrefslogtreecommitdiffstats
path: root/usr.bin/find/find.h
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-10-04 12:54:07 +0000
committerpeter <peter@FreeBSD.org>1996-10-04 12:54:07 +0000
commit342c1e079401a7b0174ba0bb6b4c4cbc9839e9e3 (patch)
tree6a961baf6e584072dd782aa7ea6833a44a7bc50b /usr.bin/find/find.h
parent76b116d2fd0e0fd77244ae0eeeedb0d944ecf0ee (diff)
downloadFreeBSD-src-342c1e079401a7b0174ba0bb6b4c4cbc9839e9e3.zip
FreeBSD-src-342c1e079401a7b0174ba0bb6b4c4cbc9839e9e3.tar.gz
Implement a -delete option to find. The code is extremely paranoid and
goes to a fair degree of trouble to enable something like this to be safe: cd /tmp && find . -mtime +7 -delete It removes both files and directories. It does not attempt to remove immutable files (an earlier version I showed to a few people did a chflags and tried to blow away even immutable files. Too risky..) It is thought to be safe because it forces the fts(3) driven descent to only do "minimal risk" stuff. specifically, -follow is disabled, it does checking to see that it chdir'ed to the directory it thought it was going to, it will *not* pass a pathname with a '/' character in it to unlink(), so it should be totally immune to symlink tree races. If it runs into something "fishy", it bails out rather than blunder ahead.. It's better to do that if somebody is trying to compromise security rather than risk giving them an opportunity. Since the unlink()/rmdir() is being called from within the current working directory during the tree descent, there are no fork/exec overheads or races. As a side effect of this paranoia, you cannot do a "find /somewhere/dir -delete", as the last argument to rmdir() is "/somewhere/dir", and the checking won't allow it. Besides, one would use rm -rf for that case anyway. :-) Reviewed by: pst (some time ago, but I've removed the immutable file deletion code that he complained about since he last saw it)
Diffstat (limited to 'usr.bin/find/find.h')
-rw-r--r--usr.bin/find/find.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.bin/find/find.h b/usr.bin/find/find.h
index 8066d37..ff007e7 100644
--- a/usr.bin/find/find.h
+++ b/usr.bin/find/find.h
@@ -43,7 +43,7 @@ enum ntype {
N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MTIME, N_NAME, N_NEWER,
N_NOGROUP, N_NOT, N_NOUSER, N_OK, N_OPENPAREN, N_OR, N_PATH,
N_PERM, N_PRINT, N_PRUNE, N_SIZE, N_TYPE, N_USER, N_XDEV,
- N_PRINT0
+ N_PRINT0, N_DELETE
};
/* node definition */
OpenPOWER on IntegriCloud