diff options
author | Paul Traina <pst@FreeBSD.org> | 1996-05-30 02:20:10 +0000 |
---|---|---|
committer | Paul Traina <pst@FreeBSD.org> | 1996-05-30 02:20:10 +0000 |
commit | 66e5b18f29ab0ed2884941cbae48dddc64e79836 (patch) | |
tree | 215b821d997715296d28d3fd6abd875bfae577d1 /usr.bin | |
parent | 5110a08c3cd137bf4a08ec0deb7373310116a315 (diff) | |
download | src-66e5b18f29ab0ed2884941cbae48dddc64e79836.tar.gz src-66e5b18f29ab0ed2884941cbae48dddc64e79836.zip |
Drop privileges if not using standard namelist or kernel file.
Submitted by: smpatel (Sujal Patel)
Notes
Notes:
svn path=/head/; revision=15993
Diffstat (limited to 'usr.bin')
-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 b75f7f48de33..924ba11fe253 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); |