summaryrefslogtreecommitdiffstats
path: root/usr.sbin/traceroute
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2019-03-19 23:27:49 +0000
committertedu <tedu@openbsd.org>2019-03-19 23:27:49 +0000
commitc255d9b662e5f108221bc56547af8f68c9212b7e (patch)
treec6b9c4bf6f7ab77f9d773f54208156e24c8f296f /usr.sbin/traceroute
parentRemove old X proto documentation directories. (diff)
downloadwireguard-openbsd-c255d9b662e5f108221bc56547af8f68c9212b7e.tar.xz
wireguard-openbsd-c255d9b662e5f108221bc56547af8f68c9212b7e.zip
delay dropping privs a bit when root so that setrtable works.
traceroute bits from benno. ok benno claudio
Diffstat (limited to 'usr.sbin/traceroute')
-rw-r--r--usr.sbin/traceroute/traceroute.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c
index 5ebb3df5573..c88ae555434 100644
--- a/usr.sbin/traceroute/traceroute.c
+++ b/usr.sbin/traceroute/traceroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: traceroute.c,v 1.159 2018/11/12 00:26:30 dlg Exp $ */
+/* $OpenBSD: traceroute.c,v 1.160 2019/03/19 23:27:50 tedu Exp $ */
/* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */
/*
@@ -366,9 +366,9 @@ main(int argc, char *argv[])
uid = getuid();
gid = getgid();
}
- if (setgroups(1, &gid) ||
+ if (ouid && (setgroups(1, &gid) ||
setresgid(gid, gid, gid) ||
- setresuid(uid, uid, uid))
+ setresuid(uid, uid, uid)))
err(1, "unable to revoke privs");
if (strcmp("traceroute6", __progname) == 0) {
@@ -559,6 +559,12 @@ main(int argc, char *argv[])
default:
usage(v6flag);
}
+
+ if (ouid == 0 && (setgroups(1, &gid) ||
+ setresgid(gid, gid, gid) ||
+ setresuid(uid, uid, uid)))
+ err(1, "unable to revoke privs");
+
argc -= optind;
argv += optind;