From owner-svn-src-all@freebsd.org Wed Dec 19 17:48:39 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EF372133E118; Wed, 19 Dec 2018 17:48:38 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9558D8B976; Wed, 19 Dec 2018 17:48:38 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 63FD01945B; Wed, 19 Dec 2018 17:48:38 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wBJHmcab089172; Wed, 19 Dec 2018 17:48:38 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wBJHmclf089171; Wed, 19 Dec 2018 17:48:38 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201812191748.wBJHmclf089171@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 19 Dec 2018 17:48:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r342222 - stable/12/sbin/ping X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sbin/ping X-SVN-Commit-Revision: 342222 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 9558D8B976 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.92 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.93)[-0.925,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.998,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Dec 2018 17:48:39 -0000 Author: markj Date: Wed Dec 19 17:48:37 2018 New Revision: 342222 URL: https://svnweb.freebsd.org/changeset/base/342222 Log: Revert r342219. It depends on a Capsicum helper not present in stable/12. Modified: stable/12/sbin/ping/ping.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/ping/ping.c ============================================================================== --- stable/12/sbin/ping/ping.c Wed Dec 19 17:45:16 2018 (r342221) +++ stable/12/sbin/ping/ping.c Wed Dec 19 17:48:37 2018 (r342222) @@ -85,7 +85,6 @@ __FBSDID("$FreeBSD$"); #include #endif /*IPSEC*/ -#include #include #include #include @@ -259,6 +258,7 @@ main(int argc, char *const *argv) policy_in = policy_out = NULL; #endif cap_rights_t rights; + bool cansandbox; /* * Do the stuff that we need root priv's for *first*, and @@ -709,20 +709,27 @@ main(int argc, char *const *argv) ip->ip_dst = to->sin_addr; } + if (options & F_NUMERIC) + cansandbox = true; + else if (capdns != NULL) + cansandbox = CASPER_SUPPORT; + else + cansandbox = false; + /* * Here we enter capability mode. Further down access to global * namespaces (e.g filesystem) is restricted (see capsicum(4)). * We must connect(2) our socket before this point. */ - caph_cache_catpages(); - if (caph_enter_casper() < 0) + if (cansandbox && cap_enter() < 0 && errno != ENOSYS) err(1, "cap_enter"); cap_rights_init(&rights, CAP_RECV, CAP_EVENT, CAP_SETSOCKOPT); - if (caph_rights_limit(srecv, &rights) < 0) + if (cap_rights_limit(srecv, &rights) < 0 && errno != ENOSYS) err(1, "cap_rights_limit srecv"); + cap_rights_init(&rights, CAP_SEND, CAP_SETSOCKOPT); - if (caph_rights_limit(ssend, &rights) < 0) + if (cap_rights_limit(ssend, &rights) < 0 && errno != ENOSYS) err(1, "cap_rights_limit ssend"); /* record route option */ @@ -807,14 +814,14 @@ main(int argc, char *const *argv) sizeof(hold)); /* CAP_SETSOCKOPT removed */ cap_rights_init(&rights, CAP_RECV, CAP_EVENT); - if (caph_rights_limit(srecv, &rights) < 0) + if (cap_rights_limit(srecv, &rights) < 0 && errno != ENOSYS) err(1, "cap_rights_limit srecv setsockopt"); if (uid == 0) (void)setsockopt(ssend, SOL_SOCKET, SO_SNDBUF, (char *)&hold, sizeof(hold)); /* CAP_SETSOCKOPT removed */ cap_rights_init(&rights, CAP_SEND); - if (caph_rights_limit(ssend, &rights) < 0) + if (cap_rights_limit(ssend, &rights) < 0 && errno != ENOSYS) err(1, "cap_rights_limit ssend setsockopt"); if (to->sin_family == AF_INET) {