Page MenuHomeFreeBSD

D18514.diff
No OneTemporary

D18514.diff

Index: head/sbin/ping/ping.c
===================================================================
--- head/sbin/ping/ping.c
+++ head/sbin/ping/ping.c
@@ -85,6 +85,7 @@
#include <netipsec/ipsec.h>
#endif /*IPSEC*/
+#include <capsicum_helpers.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
@@ -258,7 +259,6 @@
policy_in = policy_out = NULL;
#endif
cap_rights_t rights;
- bool cansandbox;
/*
* Do the stuff that we need root priv's for *first*, and
@@ -702,27 +702,20 @@
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.
*/
- if (cansandbox && cap_enter() < 0 && errno != ENOSYS)
+ caph_cache_catpages();
+ if (caph_enter() < 0)
err(1, "cap_enter");
cap_rights_init(&rights, CAP_RECV, CAP_EVENT, CAP_SETSOCKOPT);
- if (cap_rights_limit(srecv, &rights) < 0 && errno != ENOSYS)
+ if (caph_rights_limit(srecv, &rights) < 0)
err(1, "cap_rights_limit srecv");
-
cap_rights_init(&rights, CAP_SEND, CAP_SETSOCKOPT);
- if (cap_rights_limit(ssend, &rights) < 0 && errno != ENOSYS)
+ if (caph_rights_limit(ssend, &rights) < 0)
err(1, "cap_rights_limit ssend");
/* record route option */
@@ -807,14 +800,14 @@
sizeof(hold));
/* CAP_SETSOCKOPT removed */
cap_rights_init(&rights, CAP_RECV, CAP_EVENT);
- if (cap_rights_limit(srecv, &rights) < 0 && errno != ENOSYS)
+ if (caph_rights_limit(srecv, &rights) < 0)
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 (cap_rights_limit(ssend, &rights) < 0 && errno != ENOSYS)
+ if (caph_rights_limit(ssend, &rights) < 0)
err(1, "cap_rights_limit ssend setsockopt");
if (to->sin_family == AF_INET) {

File Metadata

Mime Type
text/plain
Expires
Mon, Sep 14, 8:30 AM (15 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38897230
Default Alt Text
D18514.diff (2 KB)

Event Timeline