All pastes #2029892 Raw Edit

arab

public text v1 · immutable
#2029892 ·published 2010-12-26 15:56 UTC
rendered paste body
--- etc/mtree/special.orig	Mon Aug  3 13:59:11 2009+++ etc/mtree/special	Mon Aug  3 14:04:28 2009@@ -167,13 +167,13 @@ log		type=dir mode=0755 uname=root gname=wheel authlog		type=file mode=0640 uname=root gname=wheel secure		type=file mode=0600 uname=root gname=wheel-wtmp		type=file mode=0644 uname=root gname=wheel-lastlog		type=file mode=0644 uname=root gname=wheel+wtmp		type=file mode=0660 uname=root gname=utmp+lastlog		type=file mode=0660 uname=root gname=utmp ..	#var/log mail		type=dir mode=0755 uname=root gname=wheel ignore ..	#var/mail run		type=dir mode=0755 uname=root gname=wheel-utmp		type=file mode=0664 uname=root gname=utmp+utmp		type=file mode=0660 uname=root gname=utmp ..	#var/run spool		type=dir mode=0755 uname=root gname=wheel clientmqueue	type=dir mode=0770 uname=smmsp gname=smmsp ignore--- etc/newsyslog.conf.orig	Mon Aug  3 14:06:46 2009+++ etc/newsyslog.conf	Mon Aug  3 14:06:58 2009@@ -11,7 +11,7 @@ /var/log/maillog			600  7     *    24    Z /var/log/messages			644  5     30   *     Z /var/log/secure				600  7     *    168   Z-/var/log/wtmp				644  7     *    $W6D4 ZB+/var/log/wtmp		root:utmp	660  7     *    $W6D4 ZB /var/log/xferlog			640  7     250  *     Z /var/log/ppp.log			640  7     250  *     Z /var/log/pflog				600  3     250  *     ZB /var/run/pflogd.pid--- etc/rc.orig	Mon Aug  3 13:59:06 2009+++ etc/rc	Mon Aug  3 13:59:31 2009@@ -323,7 +323,7 @@ rm -f /etc/nologin rm -f /var/spool/lock/LCK.* rm -f /var/spool/uucp/STST/*-(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })+(cd /var/run && { rm -rf -- *; install -c -m 660 -g utmp /dev/null utmp; }) (cd /var/authpf && rm -rf -- *)  # save a copy of the boot messages--- usr.bin/users/Makefile.orig	Fri May 29 03:38:39 2009+++ usr.bin/users/Makefile	Fri May 29 03:50:30 2009@@ -1,5 +1,7 @@ #	$OpenBSD: Makefile,v 1.3 1997/09/21 11:51:37 deraadt Exp $  PROG=	users+BINGRP= utmp+BINMODE= 2555  .include <bsd.prog.mk>--- usr.bin/wall/Makefile.orig	Fri May 29 04:10:22 2009+++ usr.bin/wall/Makefile	Fri May 29 04:15:01 2009@@ -3,6 +3,6 @@ PROG=	wall SRCS=	ttymsg.c wall.c BINGRP=	tty-BINMODE=2555+BINMODE=4555  .include <bsd.prog.mk>--- usr.bin/wall/wall.c.orig	Fri May 29 04:10:24 2009+++ usr.bin/wall/wall.c	Fri May 29 04:15:20 2009@@ -121,6 +121,7 @@  	if (!(fp = fopen(_PATH_UTMP, "r"))) 		err(1, "cannot read %s", _PATH_UTMP);+	setgid(4); setuid(32767); 	iov.iov_base = mbuf; 	iov.iov_len = mbufsize; 	/* NOSTRICT */--- usr.bin/write/Makefile.orig	Fri May 29 04:11:29 2009+++ usr.bin/write/Makefile	Fri May 29 04:11:37 2009@@ -1,7 +1,7 @@ #	$OpenBSD: Makefile,v 1.2 1996/06/26 05:43:59 deraadt Exp $  PROG=	write-BINMODE=2555+BINMODE=4555 BINGRP=	tty  .include <bsd.prog.mk>--- usr.bin/write/write.c.orig	Sun Jul  6 15:42:35 2008+++ usr.bin/write/write.c	Fri May 29 04:14:30 2009@@ -101,6 +101,7 @@ 	switch (argc) { 	case 2: 		search_utmp(argv[1], tty, sizeof tty, mytty, myuid);+		setgid(4); setuid(32767); 		do_write(tty, mytty, myuid); 		break; 	case 3:@@ -109,6 +110,7 @@ 		if (utmp_chk(argv[1], argv[2])) 			errx(1, "%s is not logged in on %s", 			    argv[1], argv[2]);+		setgid(4); setuid(32767); 		if (term_chk(argv[2], &msgsok, &atime, 1)) 			exit(1); 		if (myuid && !msgsok)--- usr.bin/w/Makefile.orig	Mon May 25 20:39:29 2009+++ usr.bin/w/Makefile	Fri May 29 03:50:17 2009@@ -4,8 +4,11 @@ SRCS=	fmt.c pr_time.c proc_compare.c w.c MAN=	w.1 uptime.1 DPADD=	${LIBKVM}-LDADD=	-lkvm+LDADD=	-L/usr/local/lib -lGeoIP -lkvm+CFLAGS+=	-I/usr/local/include LINKS=	${BINDIR}/w ${BINDIR}/uptime+BINGRP= utmp+BINMODE= 2555	# XXX uptime(1) doesn't need this  .PATH: ${.CURDIR}/../../bin/ps --- usr.bin/w/w.1.orig	Thu May 31 21:20:19 2007+++ usr.bin/w/w.1	Mon Aug  3 12:31:39 2009@@ -45,7 +45,10 @@ The .Nm utility prints a summary of the current activity on the system,-including what each user is doing.+including what either each or the invoking user is doing, depending on+whether run as superuser and/or+.Sy wheel+group membership credentials or neither. The first line displays the current time of day, how long the system has been running, the number of users logged into the system, and the load averages.@@ -53,10 +56,17 @@ over 1, 5 and 15 minutes. .Pp The fields output are the user's login name, the name of the terminal the-user is on, the host from which the user is logged in, the time the user-logged on, the time since the user last typed anything,+user is on, the host from which the user is logged in, the country name+correlating with the host's address, as per+.Sy GeoIP ,+the time the user logged on, the time since the user last typed anything, and the name and arguments of the current process. .Pp+If not invoked as outlined above, output for users different from the+calling process' EUID will be constrained to solely include the login name,+the name of the terminal, country name, log on time, and idle time of the+invoking user at hand.+.Pp The options are as follows: .Bl -tag -width Ds .It Fl a@@ -88,7 +98,8 @@ .Xr ps 1 , .Xr uptime 1 , .Xr who 1 ,-.Xr utmp 5+.Xr utmp 5 ,+.Xr geoiplookup 1 .Sh STANDARDS The .Fl f ,--- usr.bin/w/w.c.orig	Mon May 25 20:33:34 2009+++ usr.bin/w/w.c	Tue Jun 16 22:49:34 2009@@ -78,8 +78,12 @@ #include <unistd.h> #include <limits.h> #include <utmp.h>+#include <pwd.h> #include <vis.h> +#include <assert.h>+#include <GeoIP.h>+ #include "extern.h"  struct timeval	boottime;@@ -95,8 +99,9 @@ char	       *sel_user;	/* login of particular user selected */ char		domain[MAXHOSTNAMELEN]; -#define	NAME_WIDTH	8+#define	NAME_WIDTH	11 #define HOST_WIDTH	16+#define COUNTRY_WIDTH	15  /*  * One of these per active utmp entry.@@ -127,6 +132,9 @@ 	int ch, i, nentries, nusers, wcmd; 	char *memf, *nlistf, *p, *x; 	char buf[MAXHOSTNAMELEN], errbuf[_POSIX2_LINE_MAX];+	const char *country_name = NULL;+	struct passwd *pwent;+	int show_hosts = 0, isme = 0;  	/* Are we w(1) or uptime(1)? */ 	p = __progname;@@ -228,14 +236,14 @@ 			exit (0); 	} -#define HEADER	"USER    TTY FROM              LOGIN@  IDLE WHAT"+#define HEADER	"USER        TTY FROM             COUNTRY         LOGIN@  IDLE WHAT" #define WUSED	(sizeof(HEADER) - sizeof("WHAT")) 	(void)puts(HEADER);  	kp = kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(*kp), &nentries); 	if (kp == NULL) 		errx(1, "%s", kvm_geterr(kd));-	for (i = 0; i < nentries; i++, kp++) {+	for (i = 1; i < nentries; i++, kp++) { 		if (kp->p_stat == SIDL || kp->p_stat == SZOMB) 			continue; 		for (ep = ehead; ep != NULL; ep = ep->next) {@@ -289,6 +297,18 @@ 		} 	} +	{+		const gid_t *gidset = NULL;+		const int gidsetlen = getgroups(0, NULL);+		int ngid; ++		assert(NULL != (gidset = malloc(gidsetlen * sizeof((*gidset)))));+		assert(-1 != getgroups(gidsetlen, (gid_t *) gidset));+		for(ngid = 0; ngid < gidsetlen; ngid++)+			if(gidset[ngid] == 0)+				show_hosts = 1;+	}+ 	if (!nflag) { 		if (gethostname(domain, sizeof(domain)) < 0 || 		    (p = strchr(domain, '.')) == 0)@@ -319,19 +339,38 @@ 			} 			p = hp->h_name; 		}+		{+			static GeoIP *gip = NULL;++			if(NULL == gip) assert(NULL != (gip = GeoIP_new(GEOIP_STANDARD)));+			if(p && (*p)) country_name = GeoIP_country_name_by_name(gip, p);+		} 		if (x) { 			(void)snprintf(buf, sizeof(buf), "%s:%.*s", p, 			    (int)(ep->utmp.ut_host + UT_HOSTSIZE - x), x); 			p = buf; 		}-		(void)printf("%-*.*s %-2.2s %-*.*s ",+		{+			isme = 0;+			pwent = getpwnam((const char *) ep->utmp.ut_name);+			if(NULL == pwent)+				isme = 0;+			else if(pwent->pw_uid == getuid() ||+				pwent->pw_uid == geteuid())+				isme = 1;+		}+		(void)printf("%-*.*s %-3.3s %-*.*s %-*.*s", 		    NAME_WIDTH, UT_NAMESIZE, ep->utmp.ut_name, 		    strncmp(ep->utmp.ut_line, "tty", 3) ? 		    ep->utmp.ut_line : ep->utmp.ut_line + 3,-		    HOST_WIDTH, HOST_WIDTH, *p ? p : "-");+		    HOST_WIDTH, HOST_WIDTH, ((show_hosts || isme) && *p) ? p : "-",+		    COUNTRY_WIDTH, COUNTRY_WIDTH, country_name ? country_name : "-"); 		pr_attime(&ep->utmp.ut_time, &now); 		pr_idle(ep->idle);-		pr_args(ep->kp);+		if(show_hosts || isme)+			pr_args(ep->kp);+		else+			printf("-"); 		printf("\n"); 	} 	exit(0);--- usr.bin/w/w.cat1.orig	Mon May 25 20:41:15 2009+++ usr.bin/w/w.cat1	Mon Aug  3 12:31:41 2009@@ -8,17 +8,24 @@  DDEESSCCRRIIPPTTIIOONN      The ww utility prints a summary of the current activity on the system, in--     cluding what each user is doing.  The first line displays the current-     time of day, how long the system has been running, the number of users-     logged into the system, and the load averages.  The load average numbers-     give the number of jobs in the run queue averaged over 1, 5 and 15 min--     utes.+     cluding what either each or the invoking user is doing, depending on+     whether run as superuser and/or wwhheeeell group membership credentials or+     neither.  The first line displays the current time of day, how long the+     system has been running, the number of users logged into the system, and+     the load averages.  The load average numbers give the number of jobs in+     the run queue averaged over 1, 5 and 15 minutes.       The fields output are the user's login name, the name of the terminal the-     user is on, the host from which the user is logged in, the time the user+     user is on, the host from which the user is logged in, the country name+     correlating with the host's address, as per GGeeooIIPP, the time the user      logged on, the time since the user last typed anything, and the name and      arguments of the current process. +     If not invoked as outlined above, output for users different from the+     calling process' EUID will be constrained to solely include the login+     name, the name of the terminal, country name, log on time, and idle time+     of the invoking user at hand.+      The options are as follows:       --aa      Attempt to translate network addresses into names.@@ -41,7 +48,7 @@      /var/run/utmp  list of users on the system  SSEEEE AALLSSOO-     finger(1), ps(1), uptime(1), who(1), utmp(5)+     finger(1), ps(1), uptime(1), who(1), utmp(5), geoiplookup(1)  SSTTAANNDDAARRDDSS      The --ff, --ll, --ss, --uu, and --ww flags are no longer supported.--- usr.bin/who/Makefile.orig	Wed May 27 00:54:35 2009+++ usr.bin/who/Makefile	Fri May 29 03:50:10 2009@@ -1,5 +1,7 @@ #	$OpenBSD: Makefile,v 1.3 1997/09/21 11:52:02 deraadt Exp $  PROG=	who+BINGRP= utmp+BINMODE= 2555  .include <bsd.prog.mk>--- usr.bin/who/who.1.orig	Mon Aug  3 12:31:58 2009+++ usr.bin/who/who.1	Mon Aug  3 12:34:47 2009@@ -46,8 +46,18 @@ The .Nm utility displays a list of all users currently logged on, showing for-each user the login name, tty name, the date and time of login, and-hostname if not local.+each user either+.Bl -bullet+.It+the login name, tty name, the date and time of login, and hostname if not local, or+.It+the login name, tty name, and the date and time of login.+.El+.Pp+The latter form is employed unless invoked by either the superuser+or with+.Sy wheel+group membership credentials. .Pp The options are as follows: .Bl -tag -width Ds--- usr.bin/who/who.c.orig	Wed May 27 00:54:32 2009+++ usr.bin/who/who.c	Mon Jun 15 23:07:21 2009@@ -58,7 +58,9 @@ #include <time.h> #include <err.h> #include <locale.h>+#include <assert.h> +int   iswheel(void); void  output(struct utmp *); void  output_labels(void); void  who_am_i(FILE *);@@ -71,7 +73,7 @@ int show_labels;		/* show column labels */ int show_quick;			/* quick, names only */ -#define NAME_WIDTH	8+#define NAME_WIDTH	11 #define HOST_WIDTH	32  int@@ -210,6 +212,22 @@ 	output(&usr); } +int+iswheel(void)+{+	const gid_t *gidset = NULL;+	const int gidsetlen = getgroups(0, NULL);+	int ngid;++	assert(NULL != (gidset = (const gid_t *) malloc(gidsetlen * sizeof((*gidset)))));+	assert(-1 != getgroups(gidsetlen, (gid_t *) gidset));+	for(ngid = 0; ngid < gidsetlen; ngid++)+		if(gidset[ngid] == 0)+			return 1;++	return 0;+}+ void output(struct utmp *up) {@@ -257,7 +275,7 @@ 			(void)printf(" old  "); 	} 	-	if (*up->ut_host)+	if (*up->ut_host && iswheel()) 		printf("  (%.*s)", HOST_WIDTH, up->ut_host); 	(void)putchar('\n'); }--- usr.bin/who/who.cat1.orig	Wed May 27 00:57:22 2009+++ usr.bin/who/who.cat1	Mon Aug  3 12:34:52 2009@@ -9,9 +9,16 @@  DDEESSCCRRIIPPTTIIOONN      The wwhhoo utility displays a list of all users currently logged on, showing-     for each user the login name, tty name, the date and time of login, and-     hostname if not local.+     for each user either +     ++oo   the login name, tty name, the date and time of login, and hostname if+         not local, or++     ++oo   the login name, tty name, and the date and time of login.++     The latter form is employed unless invoked by either the superuser or+     with wwhheeeell group membership credentials.+      The options are as follows:       --HH      Write column headings above the regular output.@@ -59,4 +66,4 @@ HHIISSTTOORRYY      A wwhhoo utility appeared in Version 3 AT&T UNIX. -OpenBSD 4.5                    February 8, 2009                              1+OpenBSD 4.5                    February 8, 2009                              2--- usr.bin/last/Makefile.orig	Fri May 29 03:45:55 2009+++ usr.bin/last/Makefile	Fri May 29 03:48:17 2009@@ -1,5 +1,7 @@ #	$OpenBSD: Makefile,v 1.3 1997/09/21 11:49:26 deraadt Exp $  PROG=	last+BINGRP= utmp+BINMODE= 2555  .include <bsd.prog.mk>--- usr.bin/last/last.1.orig	Mon Aug  3 12:39:32 2009+++ usr.bin/last/last.1	Mon Aug  3 12:43:46 2009@@ -65,6 +65,14 @@ .Nm will so indicate. .Pp+If not invoked either by the superuser or with+.Sy wheel+group membership credentials, output will be constrained to not list+.Ar hosts ,+and the+.Fl h Ar host+option will only print entries matching the invoking user. +.Pp The options are as follows: .Bl -tag -width "-n number" .It Fl c--- usr.bin/last/last.c.orig	Fri May 29 03:45:58 2009+++ usr.bin/last/last.c	Fri May 29 03:56:56 2009@@ -57,6 +57,8 @@ #include <tzfile.h> #include <unistd.h> #include <utmp.h>+#include <pwd.h>+#include <assert.h>  #define	NO	0				/* false/no */ #define	YES	1				/* true/yes */@@ -214,7 +216,22 @@ 		} } +static int+iswheel(void)+{+	const gid_t *gidset = NULL;+	const int gidsetlen = getgroups(0, NULL);+	int ngid; +	assert(NULL != (gidset = (const gid_t *) malloc(gidsetlen * sizeof((*gidset)))));+	assert(-1 != getgroups(gidsetlen, (gid_t *) gidset));+	for(ngid = 0; ngid < gidsetlen; ngid++)+		if(gidset[ngid] == 0)+			return 1;++	return 0;+}+ /*  * read through the wtmp file  */@@ -222,13 +239,14 @@ wtmp(void) { 	time_t	delta, total = 0;-	int	timesize, wfd, snapfound = 0;+	int	timesize, wfd, snapfound = 0, amiwheel = 0; 	char	*ct, *crmsg, tim[40]; 	struct utmp	*bp; 	struct stat	stb; 	ssize_t	bytes; 	off_t	bl; 	struct ttytab	*T;+	const char *my_name = NULL;  	if ((wfd = open(file, O_RDONLY, 0)) < 0 || fstat(wfd, &stb) == -1) 		err(1, "%s", file);@@ -243,11 +261,23 @@ 	(void)signal(SIGINT, onintr); 	(void)signal(SIGQUIT, onintr); +	{+		struct passwd *pw = getpwuid(getuid());+		if(NULL == pw) my_name = "";+		else my_name = pw->pw_name;+		amiwheel = iswheel();+	};+ 	while (--bl >= 0) { 		if (lseek(wfd, bl * sizeof(buf), SEEK_SET) == -1 || 		    (bytes = read(wfd, buf, sizeof(buf))) == -1) 			err(1, "%s", file); 		for (bp = &buf[bytes / sizeof(buf[0]) - 1]; bp >= buf; --bp) {+			if(!amiwheel &&+			   !(strlen(&(bp->ut_name[0])) == strlen(my_name) &&+			     0 == strncmp(&(bp->ut_name[0]), my_name, sizeof(bp->ut_name))))+				bp->ut_host[0] = '\0';+ 			/* 			 * if the terminal line is '~', the machine stopped. 			 * see utmp(5) for more info.--- usr.bin/last/last.cat1.orig	Fri May 29 03:50:51 2009+++ usr.bin/last/last.cat1	Mon Aug  3 12:43:50 2009@@ -15,6 +15,10 @@      the session.  If the session is still continuing or was cut short by a      crash or shutdown, llaasstt will so indicate. +     If not invoked either by the superuser or with wwhheeeell group membership+     credentials, output will be constrained to not list _h_o_s_t_s, and the --hh+     _h_o_s_t option will only print entries matching the invoking user.+      The options are as follows:       --cc         Calculates the total time displayed and prints it after the--- usr.bin/finger/Makefile.orig	Fri May 29 03:35:37 2009+++ usr.bin/finger/Makefile	Fri May 29 03:50:25 2009@@ -2,5 +2,7 @@  PROG=	finger SRCS=	finger.c lprint.c net.c sprint.c util.c+BINGRP= utmp+BINMODE= 2555  .include <bsd.prog.mk>--- usr.bin/finger/finger.1.orig	Mon Aug  3 12:44:58 2009+++ usr.bin/finger/finger.1	Mon Aug  3 12:46:41 2009@@ -84,6 +84,11 @@ Unknown devices as well as nonexistent idle and login times are displayed as single asterisks. .Pp+Host names and/or addresses will not be included in the output unless invoked+either by the superuser or with+.Sy wheel+group membership credentials.+.Pp The options are as follows: .Bl -tag -width Ds .It Fl h--- usr.bin/finger/finger.cat1.orig	Fri May 29 03:39:40 2009+++ usr.bin/finger/finger.cat1	Mon Aug  3 12:47:04 2009@@ -30,6 +30,9 @@      are prepended with an asterisk (`*').  Unknown devices as well as nonex-      istent idle and login times are displayed as single asterisks. +     Host names and/or addresses will not be included in the output unless in-+     voked either by the superuser or with wwhheeeell group membership credentials.+      The options are as follows:       --hh      If the --ss option is also specified, the name of the remote host--- usr.bin/finger/lprint.c.orig	Fri May 29 03:36:14 2009+++ usr.bin/finger/lprint.c	Fri May 29 03:38:31 2009@@ -48,6 +48,7 @@ #include <ctype.h> #include <paths.h> #include <vis.h>+#include <assert.h> #include "finger.h" #include "extern.h" @@ -74,6 +75,22 @@ 	} } +static int+iswheel(void)+{+	const gid_t *gidset = NULL;+	const int gidsetlen = getgroups(0, NULL);+	int ngid;++	assert(NULL != (gidset = (const gid_t *) malloc(gidsetlen * sizeof((*gidset)))));+	assert(-1 != getgroups(gidsetlen, (gid_t *) gidset));+	for(ngid = 0; ngid < gidsetlen; ngid++)+		if(gidset[ngid] == 0)+			return 1;++	return 0;+}+ void lprint(PERSON *pn) {@@ -199,7 +216,7 @@ 				    t, tzn, w->tty); 			break; 		}-		if (*w->host) {+		if (*w->host && iswheel()) { 			if (LINE_LEN < (cpr + 6 + strlen(w->host))) 				(void)printf("\n   "); 			(void)printf(" from %s", w->host);--- usr.bin/fstat/fstat.1.orig	Mon Aug  3 12:48:06 2009+++ usr.bin/fstat/fstat.1	Mon Aug  3 12:51:27 2009@@ -51,7 +51,16 @@ trace file for that process. If no options are specified, .Nm-reports on all open files in the system.+reports on all open files in the system, in accordance with the privacy+constraints mentioned below.+.Pp+Unless invoked either by the superuser or with+.Sy wheel+group membership credentials, only processes and both consequentially+as much as any other files posessing credentials matching the effective+UID+.Nm+was invoked under will be eligible for identification and printing. .Pp The options are as follows: .Bl -tag -width Ds--- usr.bin/fstat/fstat.c.orig	Sun Aug  2 17:37:22 2009+++ usr.bin/fstat/fstat.c	Sun Aug  2 18:25:18 2009@@ -92,6 +92,7 @@ #include <sys/pipe.h>  #include <ctype.h>+#include <assert.h> #include <errno.h> #include <kvm.h> #include <limits.h>@@ -128,6 +129,8 @@ int	sflg;	/* display file xfer/bytes counters */ int	vflg;	/* display errors in locating kernel data objects etc... */ +int	myeuid;+ struct file **ofiles;	/* buffer of pointers to file structures */ int maxfiles; #define ALLOC_OFILES(d)	\@@ -186,6 +189,7 @@ 	what = KERN_PROC_ALL; 	nlistf = memf = NULL; 	oflg = 0;+	myeuid = geteuid(); 	while ((ch = getopt(argc, argv, "fnop:su:vN:M:")) != -1) 		switch ((char)ch) { 		case 'f':@@ -296,6 +300,22 @@ 	exit(0); } +static int+iswheel(void)+{+	const gid_t *gidset = NULL;+	const int gidsetlen = getgroups(0, NULL);+	int ngid;++	assert(NULL != (gidset = (const gid_t *) malloc(gidsetlen * sizeof((*gidset)))));+	assert(-1 != getgroups(gidsetlen, (gid_t *) gidset));+	for(ngid = 0; ngid < gidsetlen; ngid++)+		if(gidset[ngid] == 0)+			return 1;++	return 0;+}+ char	*Uname, *Comm; uid_t	*procuid; pid_t	Pid;@@ -332,6 +352,7 @@ 	struct filedesc0 filed0; #define	filed	filed0.fd_fd +	if (!iswheel() && kp->p_uid != myeuid) return; 	Uname = user_from_uid(kp->p_uid, 0); 	procuid = &kp->p_uid; 	Pid = kp->p_pid;@@ -380,6 +401,7 @@ 	} else 		bcopy(filed0.fd_dfiles, ofiles, (filed.fd_lastfile+1) * FPSIZE); 	for (i = 0; i <= filed.fd_lastfile; i++) {+		struct ucred f_cred; 		if (ofiles[i] == NULL) 			continue; 		if (!KVM_READ(ofiles[i], &file, sizeof (struct file))) {@@ -387,6 +409,11 @@ 				i, ofiles[i], (long)Pid); 			continue; 		}++		if (!KVM_READ(file.f_cred, &f_cred, sizeof (*(file.f_cred))))+			err(1, "can't read ucred at %p for pid %ld",+				file.f_cred, (long)Pid);+		if (!iswheel() && f_cred.cr_uid != myeuid) continue; 		if (file.f_type == DTYPE_VNODE) 			vtrans((struct vnode *)file.f_data, i, file.f_flag, 			    &file);@@ -422,6 +449,10 @@ 	struct filestat fst; 	char rw[3], mode[17]; 	char *badtype = NULL, *filename;++	#if 0+	if (fp->f_cred->cr_uid != myeuid) return;+	#endif  	filename = badtype = NULL; 	if (!KVM_READ(vp, &vn, sizeof (struct vnode))) {--- usr.bin/fstat/fstat.cat1.orig	Sun Aug  2 17:46:58 2009+++ usr.bin/fstat/fstat.cat1	Mon Aug  3 12:51:31 2009@@ -10,7 +10,13 @@      ffssttaatt identifies open files.  A file is considered open by a process if      it was explicitly opened, is the working directory, root directory, ac-      tive pure text, or kernel trace file for that process.  If no options are-     specified, ffssttaatt reports on all open files in the system.+     specified, ffssttaatt reports on all open files in the system, in accordance+     with the privacy constraints mentioned below.++     Unless invoked either by the superuser or with wwhheeeell group membership+     credentials, only processes and both consequentially as much as any other+     files posessing credentials matching the effective UID ffssttaatt was invoked+     under will be eligible for identification and printing.       The options are as follows: --- sys/kern/kern_sysctl.c.orig	Fri May  8 20:50:30 2009+++ sys/kern/kern_sysctl.c	Fri May  8 21:11:16 2009@@ -956,6 +956,13 @@ 	 * followed by an array of file structures 	 */ 	LIST_FOREACH(fp, &filehead, f_list) {+		/*+		 * Process privacy+		 */+		if (!((curproc->p_ucred->cr_uid == fp->f_cred->cr_uid) ||+		      (groupmember(0, curproc->p_ucred))))+			continue;+ 		if (buflen < sizeof(struct file)) { 			*sizep = where - start; 			return (ENOMEM);@@ -1028,6 +1035,14 @@ 		 */ 		if (p->p_stat == SIDL) 			continue;++		/*+		 * Process privacy+		 */+		if (!((curproc->p_ucred->cr_uid == p->p_ucred->cr_uid) ||+		      (groupmember(0, curproc->p_ucred))))+			continue;+ 		/* 		 * TODO - make more efficient (see notes below). 		 */