summaryrefslogtreecommitdiffstats
path: root/usr.bin/w/w.c
diff options
context:
space:
mode:
authorpst <pst@FreeBSD.org>1996-05-30 02:20:10 +0000
committerpst <pst@FreeBSD.org>1996-05-30 02:20:10 +0000
commit10d32f7a70eaa6dcc9bd498e4bf78130094d6fdd (patch)
tree215b821d997715296d28d3fd6abd875bfae577d1 /usr.bin/w/w.c
parent20544fa323e08da49e207624c4e1a7626ce6acbc (diff)
downloadFreeBSD-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.bin/w/w.c')
-rw-r--r--usr.bin/w/w.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c
index b75f7f4..924ba11 100644
--- a/usr.bin/w/w.c
+++ b/usr.bin/w/w.c
@@ -179,6 +179,13 @@ main(argc, argv)
_res.retrans = 2; /* resolver timeout to 2 seconds per try */
_res.retry = 1; /* only try once.. */
+ /*
+ * Discard setgid privileges if not the running kernel so that bad
+ * guys can't print interesting stuff from kernel memory.
+ */
+ if (nlistf != NULL || memf != NULL)
+ setgid(getgid());
+
if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf)) == NULL)
errx(1, "%s", errbuf);
OpenPOWER on IntegriCloud