diff options
Diffstat (limited to 'usr.bin/w')
-rw-r--r-- | usr.bin/w/w.c | 7 |
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); |