summaryrefslogtreecommitdiff
path: root/usr.bin/systat
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2005-07-04 01:54:12 +0000
committerDamien Miller <djm@cvs.openbsd.org>2005-07-04 01:54:12 +0000
commit111f17112e935f1768e0da7a24ee15f428f61872 (patch)
treeb1f09cb1f6a1931201c21470d665ce24d382e1b5 /usr.bin/systat
parentf1530fb5e1f6818aafdfeef038b0b7a755aa35e0 (diff)
make these use setres[ug]id for simple privilege dropping;
ok deraadt@ millert@ moritz@
Diffstat (limited to 'usr.bin/systat')
-rw-r--r--usr.bin/systat/main.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/systat/main.c b/usr.bin/systat/main.c
index 78e5acf5ee2..f74c6647eb6 100644
--- a/usr.bin/systat/main.c
+++ b/usr.bin/systat/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.30 2004/04/26 19:22:30 itojun Exp $ */
+/* $OpenBSD: main.c,v 1.31 2005/07/04 01:54:10 djm Exp $ */
/* $NetBSD: main.c,v 1.8 1996/05/10 23:16:36 thorpej Exp $ */
/*-
@@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: main.c,v 1.30 2004/04/26 19:22:30 itojun Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.31 2005/07/04 01:54:10 djm Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -87,6 +87,7 @@ main(int argc, char *argv[])
{
int ch;
char errbuf[_POSIX2_LINE_MAX];
+ gid_t gid;
kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
if (kd == NULL) {
@@ -94,8 +95,9 @@ main(int argc, char *argv[])
exit(1);
}
- setegid(getgid());
- setgid(getgid());
+ gid = getgid();
+ if (setresgid(gid, gid, gid) == -1)
+ err(1, "setresgid");
while ((ch = getopt(argc, argv, "nw:")) != -1)
switch (ch) {