diff options
author | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2002-06-08 22:57:35 +0000 |
---|---|---|
committer | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2002-06-08 22:57:35 +0000 |
commit | b7c4485ea2d19d61893a97c9ee0692081c06d5e2 (patch) | |
tree | efd7393efab9949567efa45c1a9408d3ec1bac49 /usr.bin/w | |
parent | 584d6525b38474e6be80ccab62474bbea6f34171 (diff) |
No need to be setgid kmem anymore.
Diffstat (limited to 'usr.bin/w')
-rw-r--r-- | usr.bin/w/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/w/w.c | 23 |
2 files changed, 9 insertions, 18 deletions
diff --git a/usr.bin/w/Makefile b/usr.bin/w/Makefile index 718711bb43b..dbf39d4c261 100644 --- a/usr.bin/w/Makefile +++ b/usr.bin/w/Makefile @@ -1,12 +1,10 @@ -# $OpenBSD: Makefile,v 1.5 2001/06/27 06:16:51 art Exp $ +# $OpenBSD: Makefile,v 1.6 2002/06/08 22:57:34 angelos Exp $ PROG= w SRCS= fmt.c pr_time.c proc_compare.c w.c MAN= w.1 uptime.1 DPADD= ${LIBKVM} LDADD= -lkvm -BINGRP= kmem -BINMODE=2555 LINKS= ${BINDIR}/w ${BINDIR}/uptime .PATH: ${.CURDIR}/../../bin/ps diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index f3acb102a78..2a03fbbb55e 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -1,4 +1,4 @@ -/* $OpenBSD: w.c,v 1.36 2002/02/19 18:38:02 mpech Exp $ */ +/* $OpenBSD: w.c,v 1.37 2002/06/08 22:57:34 angelos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -43,7 +43,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)w.c 8.4 (Berkeley) 4/16/94"; #else -static char *rcsid = "$OpenBSD: w.c,v 1.36 2002/02/19 18:38:02 mpech Exp $"; +static char *rcsid = "$OpenBSD: w.c,v 1.37 2002/06/08 22:57:34 angelos Exp $"; #endif #endif /* not lint */ @@ -178,21 +178,14 @@ 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) { - setegid(getgid()); - setgid(getgid()); + if (nlistf == NULL && memf == NULL) { + if ((kd = kvm_openfiles(nlistf, memf, NULL, KVM_NO_FILES, errbuf)) == NULL) + errx(1, "%s", errbuf); + } else { + if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf)) == NULL) + errx(1, "%s", errbuf); } - if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf)) == NULL) - errx(1, "%s", errbuf); - - setegid(getgid()); - setgid(getgid()); - (void)time(&now); if ((ut = fopen(_PATH_UTMP, "r")) == NULL) err(1, "%s", _PATH_UTMP); |