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.bin/w/w.c | |
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.bin/w/w.c')
-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); |