projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
new error message (if you can't rm 'cause you're not owner)
[unix-history]
/
usr
/
src
/
bin
/
rm
/
rm.c
diff --git
a/usr/src/bin/rm/rm.c
b/usr/src/bin/rm/rm.c
index
0920b90
..
575deca
100644
(file)
--- 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;
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)) {