diff options
author | pst <pst@FreeBSD.org> | 1996-05-30 02:20:10 +0000 |
---|---|---|
committer | pst <pst@FreeBSD.org> | 1996-05-30 02:20:10 +0000 |
commit | 10d32f7a70eaa6dcc9bd498e4bf78130094d6fdd (patch) | |
tree | 215b821d997715296d28d3fd6abd875bfae577d1 /usr.sbin | |
parent | 20544fa323e08da49e207624c4e1a7626ce6acbc (diff) | |
download | FreeBSD-src-10d32f7a70eaa6dcc9bd498e4bf78130094d6fdd.zip FreeBSD-src-10d32f7a70eaa6dcc9bd498e4bf78130094d6fdd.tar.gz |
Drop privileges if not using standard namelist or kernel file.
Submitted by: smpatel (Sujal Patel)
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/slstat/slstat.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.sbin/slstat/slstat.c b/usr.sbin/slstat/slstat.c index 402c248..eb7d3b7 100644 --- a/usr.sbin/slstat/slstat.c +++ b/usr.sbin/slstat/slstat.c @@ -22,7 +22,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: slstat.c,v 1.3 1994/11/19 13:57:21 jkh Exp $"; +static char rcsid[] = "$Id: slstat.c,v 1.4 1995/05/30 03:52:30 rgrimes Exp $"; #endif #include <stdio.h> @@ -132,6 +132,13 @@ main(argc, argv) kflag++; } } + /* + * Discard setgid privileges if not the running kernel so that bad + * guys can't print interesting stuff from kernel memory. + */ + if (system != NULL || kmemf != NULL) + setgid(getgid()); + kvm_h = kvm_openfiles(system, kmemf, NULL, O_RDONLY, errbuf); if (kvm_h == 0) { (void)fprintf(stderr, |