1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-10 07:04:03 +00:00
freebsd-ports/sysutils/fuser/files/patch-fuser.c
Stanislav Sedov c3c507c2cf - Fix build on HEAD.
- Do not allow the user to send signals to arbitrary processes if
  setuid binary is used.

PR:		ports/141852
Submitted by:	Denis Barov <dindin@dindin.ru>
Security:	http://www.freebsd.org/ports/portaudit/4d6076fe-ee7a-11de-9cd0-001a926c7637.html
2009-12-21 21:49:39 +00:00

36 lines
884 B
C

--- fuser.c.orig 2006-03-14 14:07:08.000000000 +0300
+++ fuser.c 2009-12-21 22:51:33.000000000 +0300
@@ -608,6 +608,7 @@
char *ep;
char *kernimg = NULL; /* We are using curr. sys by default */
char *mcore = NULL;
+ int retvalue = 0;
while ((ch = getopt(argc, argv, "C:K:cfkms:u")) != -1)
switch(ch) {
@@ -696,8 +697,13 @@
if (ufl != 0) {
print_file_info(pinfo->pid, \
pinfo->uid, ufl);
- if ((flags & KFLAG) != 0)
- (void)kill(pinfo->pid, sig);
+ if ((flags & KFLAG) != 0) {
+ if (geteuid() == getuid() || pinfo->uid == getuid()) {
+ (void)kill(pinfo->pid, sig);
+ } else {
+ retvalue = 1;
+ }
+ }
}
}
(void)fprintf(stderr, "\n");
@@ -707,7 +713,7 @@
SLIST_FREE(&prclist, next, pinfo_free);
(void)kvm_close(kd);
- return 0;
+ return retvalue;
}