diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2004-10-04 11:26:01 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2004-10-04 11:26:01 +0000 |
commit | 68ef5f71b09d46f3815c7dd4b70df4fbda89b9fc (patch) | |
tree | 5f1e895df39cb1438436cf5893918146f2bd649f /bin | |
parent | c335b1ecdbe61c386ea210f13491f94244133d0a (diff) | |
download | src-68ef5f71b09d46f3815c7dd4b70df4fbda89b9fc.tar.gz src-68ef5f71b09d46f3815c7dd4b70df4fbda89b9fc.zip |
Find out how flame-proof my underwear really is.
Notes
Notes:
svn path=/head/; revision=136113
Diffstat (limited to 'bin')
-rw-r--r-- | bin/rm/rm.1 | 3 | ||||
-rw-r--r-- | bin/rm/rm.c | 23 |
2 files changed, 25 insertions, 1 deletions
diff --git a/bin/rm/rm.1 b/bin/rm/rm.1 index 7a7437a5d87e..327f8946435f 100644 --- a/bin/rm/rm.1 +++ b/bin/rm/rm.1 @@ -31,7 +31,7 @@ .\" @(#)rm.1 8.5 (Berkeley) 12/5/94 .\" $FreeBSD$ .\" -.Dd January 28, 1999 +.Dd October 04, 2004 .Dt RM 1 .Os .Sh NAME @@ -111,6 +111,7 @@ The utility removes symbolic links, not the files referenced by the links. .Pp It is an error to attempt to remove the files +.Dq / , .Dq .\& or .Dq .. . diff --git a/bin/rm/rm.c b/bin/rm/rm.c index 1d9f91f2d628..9c3f83904a9a 100644 --- a/bin/rm/rm.c +++ b/bin/rm/rm.c @@ -62,6 +62,7 @@ uid_t uid; int check(char *, char *, struct stat *); void checkdot(char **); +void checkslash(char **); void rm_file(char **); int rm_overwrite(char *, struct stat *); void rm_tree(char **); @@ -140,6 +141,7 @@ main(int argc, char *argv[]) } checkdot(argv); + checkslash(argv); uid = geteuid(); if (*argv) { @@ -465,6 +467,27 @@ check(char *path, char *name, struct stat *sp) return (first == 'y' || first == 'Y'); } +#define ISSLASH(a) ((a)[0] == '/' && (a)[1] == '\0') +void +checkslash(char **argv) +{ + char **t, **u; + int complained; + + complained = 0; + for (t = argv; *t;) { + if (ISSLASH(*t)) { + if (!complained++) + warnx("\"/\" may not be removed"); + eval = 1; + for (u = t; u[0] != NULL; ++u) + u[0] = u[1]; + } else { + ++t; + } + } +} + #define ISDOT(a) ((a)[0] == '.' && (!(a)[1] || ((a)[1] == '.' && !(a)[2]))) void checkdot(char **argv) |