summaryrefslogtreecommitdiffstats
path: root/bin/rm/rm.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2004-10-04 11:26:01 +0000
committerdes <des@FreeBSD.org>2004-10-04 11:26:01 +0000
commitb6f24c61ed1ddb2ecf829be756bd85a703378fa8 (patch)
tree5f1e895df39cb1438436cf5893918146f2bd649f /bin/rm/rm.c
parent9ccc4fa11b9cb72eb8ee05bdfa59dcc0411a82cb (diff)
downloadFreeBSD-src-b6f24c61ed1ddb2ecf829be756bd85a703378fa8.zip
FreeBSD-src-b6f24c61ed1ddb2ecf829be756bd85a703378fa8.tar.gz
Find out how flame-proof my underwear really is.
Diffstat (limited to 'bin/rm/rm.c')
-rw-r--r--bin/rm/rm.c23
1 files changed, 23 insertions, 0 deletions
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)
OpenPOWER on IntegriCloud