diff options
author | peter <peter@FreeBSD.org> | 1999-11-17 15:28:45 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1999-11-17 15:28:45 +0000 |
commit | 6bdffedcb9b1df9502bdd21183f9a73368bbc372 (patch) | |
tree | bc86a7a2d7e79b3c54f762de225e07063f09d78f /usr.bin/w/w.c | |
parent | f6968a45e699c9984182f62f527d954e31bae663 (diff) | |
download | FreeBSD-src-6bdffedcb9b1df9502bdd21183f9a73368bbc372.zip FreeBSD-src-6bdffedcb9b1df9502bdd21183f9a73368bbc372.tar.gz |
Use the same technique as ps(1) to avoid the need for setgid. (ie: use
/dev/null as the default kernel and /dev/mem filenames, but still allow
the usual overrides)
Diffstat (limited to 'usr.bin/w/w.c')
-rw-r--r-- | usr.bin/w/w.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index 6441ee8..d91aa8c 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -134,7 +134,7 @@ main(argc, argv) struct stat *stp; FILE *ut; u_long l; - int ch, i, nentries, nusers, wcmd, longidle; + int ch, i, nentries, nusers, wcmd, longidle, dropgid; char *memf, *nlistf, *p, *x; char buf[MAXHOSTNAMELEN], errbuf[256]; @@ -149,7 +149,8 @@ main(argc, argv) p = "dhiflM:N:nsuw"; } - memf = nlistf = NULL; + dropgid = 0; + memf = nlistf = _PATH_DEVNULL; while ((ch = getopt(argc, argv, p)) != -1) switch (ch) { case 'd': @@ -164,9 +165,11 @@ main(argc, argv) case 'M': header = 0; memf = optarg; + dropgid = 1; break; case 'N': nlistf = optarg; + dropgid = 1; break; case 'n': nflag = 1; @@ -190,7 +193,7 @@ main(argc, argv) * 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) + if (dropgid) setgid(getgid()); if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf)) == NULL) |