summaryrefslogtreecommitdiff
path: root/usr.bin/w/w.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-30 09:11:28 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-30 09:11:28 +0000
commit41981d661c44b639e39a98633f4f3a73850dc48e (patch)
tree53347e2ee6881422eb0c41d5faefc0b6783161a0 /usr.bin/w/w.c
parent28ef74179be25b670085ca4bcdb42ecf5f2a5e4c (diff)
revoke privs before opening kvm if user has specified mem/kernel paths
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 1eee27dde0b..f7deb59f1f7 100644
--- a/usr.bin/w/w.c
+++ b/usr.bin/w/w.c
@@ -166,6 +166,13 @@ main(argc, argv)
argc -= optind;
argv += optind;
+ /*
+ * 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);