From: Bill Joy Date: Fri, 12 Feb 1982 04:26:57 +0000 (-0800) Subject: new error message (if you can't rm 'cause you're not owner) X-Git-Tag: BSD-4_1c_2-Snapshot-Development~4217 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/563bb12231365d717432f347419519754c76e528?ds=inline new error message (if you can't rm 'cause you're not owner) SCCS-vsn: bin/rm/rm.c 4.4 --- diff --git a/usr/src/bin/rm/rm.c b/usr/src/bin/rm/rm.c index 0920b90541..575deca25f 100644 --- a/usr/src/bin/rm/rm.c +++ b/usr/src/bin/rm/rm.c @@ -1,5 +1,6 @@ -static char *sccsid = "@(#)rm.c 4.3 (Berkeley) %G%"; +static char *sccsid = "@(#)rm.c 4.4 (Berkeley) %G%"; int errcode; +short uid, euid; #include #include @@ -19,6 +20,8 @@ char *argv[]; fflg++; iflg = 0; rflg = 0; + uid = getuid(); + euid = geteuid(); while(argc>1 && argv[1][0]=='-') { arg = *++argv; argc--; @@ -109,9 +112,15 @@ char arg[]; } else if(!fflg) { if (access(arg, 02)<0) { - printf("rm: override protection %o for %s? ", buf.st_mode&0777, arg); - if(!yes()) + if (uid == buf.st_uid || euid == buf.st_uid) { + printf("rm: override protection %o for %s? ", + buf.st_mode&0777, arg); + if(!yes()) + return; + } else { + printf("rm: %s: not owner.\n", arg); return; + } } } if(unlink(arg) && (fflg==0 || iflg)) {