Simplify ping sandbox.
We don't need to check if casper is present, this is done in the library itself. Reviewed by: emaste, cem, ed Differential Revision: https://reviews.freebsd.org/D8754
This commit is contained in:
parent
9aba65fa24
commit
0b9d37d25f
@ -76,10 +76,8 @@ __FBSDID("$FreeBSD$");
|
||||
#include <netinet/ip_var.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#ifdef WITH_CASPER
|
||||
#include <libcasper.h>
|
||||
#include <casper/cap_dns.h>
|
||||
#endif
|
||||
|
||||
#ifdef IPSEC
|
||||
#include <netipsec/ipsec.h>
|
||||
@ -204,15 +202,11 @@ static double tsumsq = 0.0; /* sum of all times squared, for std. dev. */
|
||||
static volatile sig_atomic_t finish_up;
|
||||
static volatile sig_atomic_t siginfo_p;
|
||||
|
||||
#ifdef WITH_CASPER
|
||||
static cap_channel_t *capdns;
|
||||
#endif
|
||||
|
||||
static void fill(char *, char *);
|
||||
static u_short in_cksum(u_short *, int);
|
||||
#ifdef WITH_CASPER
|
||||
static cap_channel_t *capdns_setup(void);
|
||||
#endif
|
||||
static void check_status(void);
|
||||
static void finish(void) __dead2;
|
||||
static void pinger(void);
|
||||
@ -563,21 +557,17 @@ main(int argc, char *const *argv)
|
||||
if (options & F_PINGFILLED) {
|
||||
fill((char *)datap, payload);
|
||||
}
|
||||
#ifdef WITH_CASPER
|
||||
capdns = capdns_setup();
|
||||
#endif
|
||||
if (source) {
|
||||
bzero((char *)&sock_in, sizeof(sock_in));
|
||||
sock_in.sin_family = AF_INET;
|
||||
if (inet_aton(source, &sock_in.sin_addr) != 0) {
|
||||
shostname = source;
|
||||
} else {
|
||||
#ifdef WITH_CASPER
|
||||
if (capdns != NULL)
|
||||
hp = cap_gethostbyname2(capdns, source,
|
||||
AF_INET);
|
||||
else
|
||||
#endif
|
||||
hp = gethostbyname2(source, AF_INET);
|
||||
if (!hp)
|
||||
errx(EX_NOHOST, "cannot resolve %s: %s",
|
||||
@ -606,11 +596,9 @@ main(int argc, char *const *argv)
|
||||
if (inet_aton(target, &to->sin_addr) != 0) {
|
||||
hostname = target;
|
||||
} else {
|
||||
#ifdef WITH_CASPER
|
||||
if (capdns != NULL)
|
||||
hp = cap_gethostbyname2(capdns, target, AF_INET);
|
||||
else
|
||||
#endif
|
||||
hp = gethostbyname2(target, AF_INET);
|
||||
if (!hp)
|
||||
errx(EX_NOHOST, "cannot resolve %s: %s",
|
||||
@ -624,7 +612,6 @@ main(int argc, char *const *argv)
|
||||
hostname = hnamebuf;
|
||||
}
|
||||
|
||||
#ifdef WITH_CASPER
|
||||
/* From now on we will use only reverse DNS lookups. */
|
||||
if (capdns != NULL) {
|
||||
const char *types[1];
|
||||
@ -633,7 +620,6 @@ main(int argc, char *const *argv)
|
||||
if (cap_dns_type_limit(capdns, types, 1) < 0)
|
||||
err(1, "unable to limit access to system.dns service");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (connect(ssend, (struct sockaddr *)&whereto, sizeof(whereto)) != 0)
|
||||
err(1, "connect");
|
||||
@ -722,10 +708,8 @@ main(int argc, char *const *argv)
|
||||
|
||||
if (options & F_NUMERIC)
|
||||
cansandbox = true;
|
||||
#ifdef WITH_CASPER
|
||||
else if (capdns != NULL)
|
||||
cansandbox = true;
|
||||
#endif
|
||||
else
|
||||
cansandbox = false;
|
||||
|
||||
@ -1707,11 +1691,9 @@ pr_addr(struct in_addr ina)
|
||||
if (options & F_NUMERIC)
|
||||
return inet_ntoa(ina);
|
||||
|
||||
#ifdef WITH_CASPER
|
||||
if (capdns != NULL)
|
||||
hp = cap_gethostbyaddr(capdns, (char *)&ina, 4, AF_INET);
|
||||
else
|
||||
#endif
|
||||
hp = gethostbyaddr((char *)&ina, 4, AF_INET);
|
||||
|
||||
if (hp == NULL)
|
||||
@ -1791,7 +1773,6 @@ fill(char *bp, char *patp)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_CASPER
|
||||
static cap_channel_t *
|
||||
capdns_setup(void)
|
||||
{
|
||||
@ -1817,7 +1798,6 @@ capdns_setup(void)
|
||||
|
||||
return (capdnsloc);
|
||||
}
|
||||
#endif /* WITH_CASPER */
|
||||
|
||||
#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
|
||||
#define SECOPT " [-P policy]"
|
||||
|
Loading…
x
Reference in New Issue
Block a user