Find out how flame-proof my underwear really is.
This commit is contained in:
parent
c335b1ecdb
commit
68ef5f71b0
@ -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 .. .
|
||||
|
23
bin/rm/rm.c
23
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user