ping6: Revoke root privilege earlier
It can be done just after the sockets have been created. Submitted by: Ján Sučan <sucanjan@gmail.com> MFC after: 2 weeks Sponsored by: Google, inc. (Google Summer of Code 2019) Differential Revision: https://reviews.freebsd.org/D21213
This commit is contained in:
parent
51f61fc0c7
commit
0ef7ac044a
@ -659,6 +659,12 @@ 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 */
|
||||
@ -729,12 +735,6 @@ main(int argc, char *argv[])
|
||||
#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");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user