Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Aug 2019 14:20:26 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r351216 - head/sbin/ping6
Message-ID:  <201908191420.x7JEKQWH060830@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Mon Aug 19 14:20:26 2019
New Revision: 351216
URL: https://svnweb.freebsd.org/changeset/base/351216

Log:
  ping6: revert r350857
  
  Some socket options require root privileges to set.  The old code did indeed
  drop privileges at the earliest opportunity.
  
  Submitted by:	Ján Sučan <sucanjan@gmail.com>
  MFC after:	Never
  Sponsored by:	Google, Inc. (Google Summer of Code 2019)
  Differential Revision:	https://reviews.freebsd.org/D21319

Modified:
  head/sbin/ping6/ping6.c

Modified: head/sbin/ping6/ping6.c
==============================================================================
--- head/sbin/ping6/ping6.c	Mon Aug 19 14:11:54 2019	(r351215)
+++ head/sbin/ping6/ping6.c	Mon Aug 19 14:20:26 2019	(r351216)
@@ -663,12 +663,6 @@ main(int argc, char *argv[])
 		err(1, "socket srecv");
 	freeaddrinfo(res);
 
-	/* revoke root privilege */
-	if (seteuid(getuid()) != 0)
-		err(1, "seteuid() failed");
-	if (setuid(getuid()) != 0)
-		err(1, "setuid() failed");
-
 	/* set the source address if specified. */
 	if ((options & F_SRCADDR) != 0) {
 		/* properly fill sin6_scope_id */
@@ -738,6 +732,12 @@ main(int argc, char *argv[])
 			err(1, "setsockopt(IPV6_RECVRTHDRDSTOPTS)");
 #endif
 	}
+
+	/* revoke root privilege */
+	if (seteuid(getuid()) != 0)
+		err(1, "seteuid() failed");
+	if (setuid(getuid()) != 0)
+		err(1, "setuid() failed");
 
 	if ((options & F_FLOOD) && (options & F_INTERVAL))
 		errx(1, "-f and -i incompatible options");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201908191420.x7JEKQWH060830>