Find out how flame-proof my underwear really is.

This commit is contained in:
Dag-Erling Smørgrav 2004-10-04 11:26:01 +00:00
parent c335b1ecdb
commit 68ef5f71b0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=136113
2 changed files with 25 additions and 1 deletions

View File

@ -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 .. .

View File

@ -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)