Changeset View
Changeset View
Standalone View
Standalone View
sbin/ping6/ping6.c
Show First 20 Lines • Show All 655 Lines • ▼ Show 20 Lines | #endif | ||||
if ((ssend = socket(res->ai_family, res->ai_socktype, | if ((ssend = socket(res->ai_family, res->ai_socktype, | ||||
res->ai_protocol)) < 0) | res->ai_protocol)) < 0) | ||||
err(1, "socket ssend"); | err(1, "socket ssend"); | ||||
if ((srecv = socket(res->ai_family, res->ai_socktype, | if ((srecv = socket(res->ai_family, res->ai_socktype, | ||||
res->ai_protocol)) < 0) | res->ai_protocol)) < 0) | ||||
err(1, "socket srecv"); | err(1, "socket srecv"); | ||||
freeaddrinfo(res); | 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. */ | /* set the source address if specified. */ | ||||
if ((options & F_SRCADDR) != 0) { | if ((options & F_SRCADDR) != 0) { | ||||
/* properly fill sin6_scope_id */ | /* properly fill sin6_scope_id */ | ||||
if (IN6_IS_ADDR_LINKLOCAL(&src.sin6_addr) && ( | if (IN6_IS_ADDR_LINKLOCAL(&src.sin6_addr) && ( | ||||
IN6_IS_ADDR_LINKLOCAL(&dst.sin6_addr) || | IN6_IS_ADDR_LINKLOCAL(&dst.sin6_addr) || | ||||
IN6_IS_ADDR_MC_LINKLOCAL(&dst.sin6_addr) || | IN6_IS_ADDR_MC_LINKLOCAL(&dst.sin6_addr) || | ||||
IN6_IS_ADDR_MC_NODELOCAL(&dst.sin6_addr))) { | IN6_IS_ADDR_MC_NODELOCAL(&dst.sin6_addr))) { | ||||
if (src.sin6_scope_id == 0) | if (src.sin6_scope_id == 0) | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | if (setsockopt(srecv, IPPROTO_IPV6, IPV6_DSTOPTS, &opton, | ||||
err(1, "setsockopt(IPV6_DSTOPTS)"); | err(1, "setsockopt(IPV6_DSTOPTS)"); | ||||
#endif | #endif | ||||
#ifdef IPV6_RECVRTHDRDSTOPTS | #ifdef IPV6_RECVRTHDRDSTOPTS | ||||
if (setsockopt(srecv, IPPROTO_IPV6, IPV6_RECVRTHDRDSTOPTS, &opton, | if (setsockopt(srecv, IPPROTO_IPV6, IPV6_RECVRTHDRDSTOPTS, &opton, | ||||
sizeof(opton))) | sizeof(opton))) | ||||
err(1, "setsockopt(IPV6_RECVRTHDRDSTOPTS)"); | err(1, "setsockopt(IPV6_RECVRTHDRDSTOPTS)"); | ||||
#endif | #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)) | if ((options & F_FLOOD) && (options & F_INTERVAL)) | ||||
errx(1, "-f and -i incompatible options"); | errx(1, "-f and -i incompatible options"); | ||||
if ((options & F_NOUSERDATA) == 0) { | if ((options & F_NOUSERDATA) == 0) { | ||||
if (datalen >= sizeof(struct tv32)) { | if (datalen >= sizeof(struct tv32)) { | ||||
/* we can time transfer */ | /* we can time transfer */ | ||||
timing = 1; | timing = 1; | ||||
▲ Show 20 Lines • Show All 2,123 Lines • Show Last 20 Lines |