diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2005-05-03 03:41:12 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2005-05-03 03:41:12 +0000 |
commit | 5c95f5e2f59798905d4a5b67439d42ae084252e1 (patch) | |
tree | 25eaa465c5ea04d1c9908ea6d801304b16d2d948 /usr.sbin/trpt | |
parent | 9160bd40bfe1cf2a8155e00c62a9eeed136cfd91 (diff) |
setresgid; ok deraadt@
Diffstat (limited to 'usr.sbin/trpt')
-rw-r--r-- | usr.sbin/trpt/trpt.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.sbin/trpt/trpt.c b/usr.sbin/trpt/trpt.c index ba04d962fcf..b68a3e07045 100644 --- a/usr.sbin/trpt/trpt.c +++ b/usr.sbin/trpt/trpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trpt.c,v 1.20 2004/09/24 15:02:43 markus Exp $ */ +/* $OpenBSD: trpt.c,v 1.21 2005/05/03 03:41:11 djm Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -146,6 +146,7 @@ main(int argc, char *argv[]) char *system = NULL, *core = NULL, *cp, errbuf[_POSIX2_LINE_MAX]; int ch, i, jflag = 0, npcbs = 0; unsigned long l; + gid_t gid; while ((ch = getopt(argc, argv, "afjM:N:p:st")) != -1) { switch (ch) { @@ -197,17 +198,18 @@ main(int argc, char *argv[]) * Discard setgid privileged if not the running kernel so that bad * guys can't print interesting stuff from kernel memory. */ - if (core != NULL || system != NULL) { - setegid(getgid()); - setgid(getgid()); - } + gid = getgid(); + if (core != NULL || system != NULL) + if (setresgid(gid, gid, gid) == -1) + err(1, "setresgid"); kd = kvm_openfiles(system, core, NULL, O_RDONLY, errbuf); if (kd == NULL) errx(1, "can't open kmem: %s", errbuf); - setegid(getgid()); - setgid(getgid()); + if (core == NULL && system == NULL) + if (setresgid(gid, gid, gid) == -1) + err(1, "setresgid"); if (kvm_nlist(kd, nl)) errx(2, "%s: no namelist", system ? system : _PATH_UNIX); |