Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Oct 2017 19:39:22 +0000 (UTC)
From:      Mariusz Zaborski <oshogbo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r325064 - head/sbin/ping
Message-ID:  <201710281939.v9SJdMd9026070@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: oshogbo
Date: Sat Oct 28 19:39:22 2017
New Revision: 325064
URL: https://svnweb.freebsd.org/changeset/base/325064

Log:
  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

Modified:
  head/sbin/ping/ping.c

Modified: head/sbin/ping/ping.c
==============================================================================
--- head/sbin/ping/ping.c	Sat Oct 28 19:34:08 2017	(r325063)
+++ head/sbin/ping/ping.c	Sat Oct 28 19:39:22 2017	(r325064)
@@ -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 square
 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]"



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