Changeset View
Changeset View
Standalone View
Standalone View
sbin/ping/ping.c
Context not available. | |||||
#include <netinet/ip_icmp.h> | #include <netinet/ip_icmp.h> | ||||
#include <netinet/ip_var.h> | #include <netinet/ip_var.h> | ||||
#include <arpa/inet.h> | #include <arpa/inet.h> | ||||
#ifdef HAVE_LIBCAPSICUM | |||||
#include <libcapsicum.h> | #ifdef HAVE_LIBCASPER | ||||
#include <libcapsicum_dns.h> | #include <libcasper.h> | ||||
#include <libcapsicum_service.h> | #include <casper/cap_dns.h> | ||||
#endif | #endif | ||||
#ifdef IPSEC | #ifdef IPSEC | ||||
Context not available. | |||||
static volatile sig_atomic_t finish_up; | static volatile sig_atomic_t finish_up; | ||||
static volatile sig_atomic_t siginfo_p; | static volatile sig_atomic_t siginfo_p; | ||||
#ifdef HAVE_LIBCAPSICUM | #ifdef HAVE_LIBCASPER | ||||
static cap_channel_t *capdns; | static cap_channel_t *capdns; | ||||
#endif | #endif | ||||
static void fill(char *, char *); | static void fill(char *, char *); | ||||
static u_short in_cksum(u_short *, int); | static u_short in_cksum(u_short *, int); | ||||
#ifdef HAVE_LIBCAPSICUM | #ifdef HAVE_LIBCASPER | ||||
static cap_channel_t *capdns_setup(void); | static cap_channel_t *capdns_setup(void); | ||||
#endif | #endif | ||||
static void check_status(void); | static void check_status(void); | ||||
Context not available. | |||||
if (options & F_PINGFILLED) { | if (options & F_PINGFILLED) { | ||||
fill((char *)datap, payload); | fill((char *)datap, payload); | ||||
} | } | ||||
#ifdef HAVE_LIBCAPSICUM | #ifdef HAVE_LIBCASPER | ||||
capdns = capdns_setup(); | capdns = capdns_setup(); | ||||
#endif | #endif | ||||
if (source) { | if (source) { | ||||
Context not available. | |||||
if (inet_aton(source, &sock_in.sin_addr) != 0) { | if (inet_aton(source, &sock_in.sin_addr) != 0) { | ||||
shostname = source; | shostname = source; | ||||
} else { | } else { | ||||
#ifdef HAVE_LIBCAPSICUM | #ifdef HAVE_LIBCASPER | ||||
if (capdns != NULL) | if (capdns != NULL) | ||||
hp = cap_gethostbyname2(capdns, source, | hp = cap_gethostbyname2(capdns, source, | ||||
AF_INET); | AF_INET); | ||||
Context not available. | |||||
if (inet_aton(target, &to->sin_addr) != 0) { | if (inet_aton(target, &to->sin_addr) != 0) { | ||||
hostname = target; | hostname = target; | ||||
} else { | } else { | ||||
#ifdef HAVE_LIBCAPSICUM | #ifdef HAVE_LIBCASPER | ||||
if (capdns != NULL) | if (capdns != NULL) | ||||
hp = cap_gethostbyname2(capdns, target, AF_INET); | hp = cap_gethostbyname2(capdns, target, AF_INET); | ||||
else | else | ||||
Context not available. | |||||
hostname = hnamebuf; | hostname = hnamebuf; | ||||
} | } | ||||
#ifdef HAVE_LIBCAPSICUM | #ifdef HAVE_LIBCASPER | ||||
/* From now on we will use only reverse DNS lookups. */ | /* From now on we will use only reverse DNS lookups. */ | ||||
if (capdns != NULL) { | if (capdns != NULL) { | ||||
const char *types[1]; | const char *types[1]; | ||||
Context not available. | |||||
if (options & F_NUMERIC) | if (options & F_NUMERIC) | ||||
cansandbox = true; | cansandbox = true; | ||||
#ifdef HAVE_LIBCAPSICUM | #ifdef HAVE_LIBCASPER | ||||
else if (capdns != NULL) | else if (capdns != NULL) | ||||
cansandbox = true; | cansandbox = true; | ||||
#endif | #endif | ||||
Context not available. | |||||
if (options & F_NUMERIC) | if (options & F_NUMERIC) | ||||
return inet_ntoa(ina); | return inet_ntoa(ina); | ||||
#ifdef HAVE_LIBCAPSICUM | #ifdef HAVE_LIBCASPER | ||||
if (capdns != NULL) | if (capdns != NULL) | ||||
hp = cap_gethostbyaddr(capdns, (char *)&ina, 4, AF_INET); | hp = cap_gethostbyaddr(capdns, (char *)&ina, 4, AF_INET); | ||||
else | else | ||||
Context not available. | |||||
} | } | ||||
} | } | ||||
#ifdef HAVE_LIBCAPSICUM | #ifdef HAVE_LIBCASPER | ||||
static cap_channel_t * | static cap_channel_t * | ||||
capdns_setup(void) | capdns_setup(void) | ||||
{ | { | ||||
Context not available. | |||||
int families[1]; | int families[1]; | ||||
capcas = cap_init(); | capcas = cap_init(); | ||||
if (capcas == NULL) { | if (capcas == NULL) | ||||
warn("unable to contact casperd"); | err(1, "unable to create casper process"); | ||||
return (NULL); | |||||
} | |||||
capdnsloc = cap_service_open(capcas, "system.dns"); | capdnsloc = cap_service_open(capcas, "system.dns"); | ||||
/* Casper capability no longer needed. */ | /* Casper capability no longer needed. */ | ||||
cap_close(capcas); | cap_close(capcas); | ||||
Context not available. | |||||
return (capdnsloc); | return (capdnsloc); | ||||
} | } | ||||
#endif /* HAVE_LIBCAPSICUM */ | #endif /* HAVE_LIBCASPER */ | ||||
#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC) | #if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC) | ||||
#define SECOPT " [-P policy]" | #define SECOPT " [-P policy]" | ||||
Context not available. |