diff options
author | des <des@FreeBSD.org> | 2004-10-04 11:26:01 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2004-10-04 11:26:01 +0000 |
commit | b6f24c61ed1ddb2ecf829be756bd85a703378fa8 (patch) | |
tree | 5f1e895df39cb1438436cf5893918146f2bd649f /bin/rm | |
parent | 9ccc4fa11b9cb72eb8ee05bdfa59dcc0411a82cb (diff) | |
download | FreeBSD-src-b6f24c61ed1ddb2ecf829be756bd85a703378fa8.zip FreeBSD-src-b6f24c61ed1ddb2ecf829be756bd85a703378fa8.tar.gz |
Find out how flame-proof my underwear really is.
Diffstat (limited to 'bin/rm')
-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 7a7437a5..327f894 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 1d9f91f..9c3f839 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) |