summaryrefslogtreecommitdiff
path: root/usr.bin/modstat
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/modstat
parentf1530fb5e1f6818aafdfeef038b0b7a755aa35e0 (diff)
make these use setres[ug]id for simple privilege dropping;
ok deraadt@ millert@ moritz@
Diffstat (limited to 'usr.bin/modstat')
-rw-r--r--usr.bin/modstat/modstat.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/modstat/modstat.c b/usr.bin/modstat/modstat.c
index d3934849f28..1eb46177998 100644
--- a/usr.bin/modstat/modstat.c
+++ b/usr.bin/modstat/modstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: modstat.c,v 1.21 2003/06/10 22:20:48 deraadt Exp $ */
+/* $OpenBSD: modstat.c,v 1.22 2005/07/04 01:54:10 djm Exp $ */
/*
* Copyright (c) 1993 Terrence R. Lambert.
@@ -114,6 +114,7 @@ main(int argc, char *argv[])
char *modname = NULL;
char *endptr;
int devfd;
+ gid_t gid;
while ((c = getopt(argc, argv, "i:n:")) != -1) {
switch (c) {
@@ -143,8 +144,9 @@ main(int argc, char *argv[])
if ((devfd = open(_PATH_LKM, O_RDONLY)) == -1)
err(2, "%s", _PATH_LKM);
- setegid(getgid());
- setgid(getgid());
+ gid = getgid();
+ if (setresgid(gid, gid, gid) == -1)
+ err(1, "setresgid");
printf("Type Id Off %-*s Size %-*s Rev Module Name\n",
POINTERSIZE, "Loadaddr", POINTERSIZE, "Info");