diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-02-09 23:46:24 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-02-09 23:46:24 +0000 |
commit | e90099569f910f7c19040166d79bd022811740de (patch) | |
tree | fbc06595f04a91672c3b8f6e020ebc1e4d066a45 | |
parent | 7b514d5e4bdf73e58ba9deb3823f78ca6f2575c0 (diff) |
If the kmem options are in use, drop the gid earlier.
ok djm
-rw-r--r-- | usr.bin/tcpbench/tcpbench.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/usr.bin/tcpbench/tcpbench.c b/usr.bin/tcpbench/tcpbench.c index a9e83873ed9..6bd2027296e 100644 --- a/usr.bin/tcpbench/tcpbench.c +++ b/usr.bin/tcpbench/tcpbench.c @@ -1114,6 +1114,17 @@ main(int argc, char **argv) (UDP_MODE && (ptb->kvars || nconn != 1))) usage(); + if (ptb->kvars) { + if ((ptb->kvmh = kvm_openfiles(NULL, NULL, NULL, + O_RDONLY, kerr)) == NULL) + errx(1, "kvm_open: %s", kerr); + drop_gid(); + if (kvm_nlist(ptb->kvmh, nl) < 0 || nl[0].n_type == 0) + errx(1, "kvm: no namelist"); + ptb->ktcbtab = nl[0].n_value; + } else + drop_gid(); + if (!ptb->sflag) host = argv[0]; /* @@ -1157,16 +1168,6 @@ main(int argc, char **argv) else errx(1, "getaddrinfo: %s", gai_strerror(herr)); } - if (ptb->kvars) { - if ((ptb->kvmh = kvm_openfiles(NULL, NULL, NULL, - O_RDONLY, kerr)) == NULL) - errx(1, "kvm_open: %s", kerr); - drop_gid(); - if (kvm_nlist(ptb->kvmh, nl) < 0 || nl[0].n_type == 0) - errx(1, "kvm: no namelist"); - ptb->ktcbtab = nl[0].n_value; - } else - drop_gid(); if (getrlimit(RLIMIT_NOFILE, &rl) == -1) err(1, "getrlimit"); |