new error message (if you can't rm 'cause you're not owner)
authorBill Joy <root@ucbvax.Berkeley.EDU>
Fri, 12 Feb 1982 04:26:57 +0000 (20:26 -0800)
committerBill Joy <root@ucbvax.Berkeley.EDU>
Fri, 12 Feb 1982 04:26:57 +0000 (20:26 -0800)
SCCS-vsn: bin/rm/rm.c 4.4

usr/src/bin/rm/rm.c

index 0920b90..575deca 100644 (file)
@@ -1,5 +1,6 @@
-static char *sccsid = "@(#)rm.c        4.3 (Berkeley) %G%";
+static char *sccsid = "@(#)rm.c        4.4 (Berkeley) %G%";
 int    errcode;
 int    errcode;
+short  uid, euid;
 
 #include <stdio.h>
 #include <sys/types.h>
 
 #include <stdio.h>
 #include <sys/types.h>
@@ -19,6 +20,8 @@ char *argv[];
                fflg++;
        iflg = 0;
        rflg = 0;
                fflg++;
        iflg = 0;
        rflg = 0;
+       uid = getuid();
+       euid = geteuid();
        while(argc>1 && argv[1][0]=='-') {
                arg = *++argv;
                argc--;
        while(argc>1 && argv[1][0]=='-') {
                arg = *++argv;
                argc--;
@@ -109,9 +112,15 @@ char arg[];
        }
        else if(!fflg) {
                if (access(arg, 02)<0) {
        }
        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;
                                return;
+                       }
                }
        }
        if(unlink(arg) && (fflg==0 || iflg)) {
                }
        }
        if(unlink(arg) && (fflg==0 || iflg)) {