}
TAILQ_INIT(ifs);
-#if defined(PRIVSEP) && defined(HAVE_CAPSICUM)
+#ifdef PRIVSEP_GETIFADDRS
if (ctx->options & DHCPCD_PRIVSEP) {
if (ps_root_getifaddrs(ctx, ifaddrs) == -1) {
logerr("ps_root_getifaddrs");
return psr_ctx.psr_error.psr_result;
}
-#ifdef HAVE_CAPSICUM
+#ifdef PRIVSEP_GETIFADDRS
static void
ps_root_mreaderrorcb(void *arg)
{
}
#endif
-#ifdef HAVE_CAPSICUM
+#ifdef PRIVSEP_GETIFADDRS
#define IFA_NADDRS 3
static ssize_t
ps_root_dogetifaddrs(void **rdata, size_t *rlen)
}
break;
#endif
-#ifdef HAVE_CAPSICUM
+#ifdef PRIVSEP_GETIFADDRS
case PS_GETIFADDRS:
err = ps_root_dogetifaddrs(&rdata, &rlen);
free_rdata = true;
return ps_root_readerror(ctx, time, sizeof(*time));
}
-#ifdef HAVE_CAPSICUM
+#ifdef PRIVSEP_GETIFADDRS
int
ps_root_getifaddrs(struct dhcpcd_ctx *ctx, struct ifaddrs **ifahead)
{
bp = buf;
*ifahead = (struct ifaddrs *)(void *)bp;
- for (ifa = *ifahead; len != 0; ifa = ifa->ifa_next) {
+ for (ifa = *ifahead; ifa != NULL; ifa = ifa->ifa_next) {
if (len < ALIGN(sizeof(*ifa)) +
ALIGN(IFNAMSIZ) + ALIGN(sizeof(salen) * IFA_NADDRS))
goto err;
COPYOUTSA(ifa->ifa_addr);
COPYOUTSA(ifa->ifa_netmask);
COPYOUTSA(ifa->ifa_broadaddr);
- ifa->ifa_next = (struct ifaddrs *)(void *)bp;
+ if (len != 0)
+ ifa->ifa_next = (struct ifaddrs *)(void *)bp;
+ else
+ ifa->ifa_next = NULL;
}
- ifa->ifa_next = NULL;
return 0;
err:
#include "if.h"
+#if defined(PRIVSEP) && (defined(HAVE_CAPSICUM) || defined(__linux__))
+#define PRIVSEP_GETIFADDRS
+#endif
+
pid_t ps_root_start(struct dhcpcd_ctx *ctx);
int ps_root_stop(struct dhcpcd_ctx *ctx);
const void *, size_t);
ssize_t ps_root_script(struct dhcpcd_ctx *, const void *, size_t);
int ps_root_getauthrdm(struct dhcpcd_ctx *, uint64_t *);
+#ifdef PRIVSEP_GETIFADDRS
int ps_root_getifaddrs(struct dhcpcd_ctx *, struct ifaddrs **);
+#endif
ssize_t ps_root_os(struct ps_msghdr *, struct msghdr *, void **, size_t *);
#if defined(BSD) || defined(__sun)
ps_dropprivs(struct dhcpcd_ctx *ctx)
{
struct passwd *pw = ctx->ps_user;
-#if !defined(HAVE_PLEDGE) && !defined(__linux__)
+#if !defined(HAVE_PLEDGE)
struct rlimit rzero = { .rlim_cur = 0, .rlim_max = 0 };
#endif
return -1;
}
-#if defined(HAVE_PLEDGE) || defined(__linux__)
+#if defined(HAVE_PLEDGE)
/* None of these resource limits work with pledge. */
#else
+#ifndef __linux__ /* breaks ppoll */
/* Prohibit new files, sockets, etc */
if (setrlimit(RLIMIT_NOFILE, &rzero) == -1) {
logerr("setrlimit RLIMIT_NOFILE");
return -1;
}
+#endif
-#ifndef HAVE_CAPSICUM /* Seems to break our IPC. */
+#ifndef HAVE_CAPSICUM /* breaks sending over our IPC */
/* Prohibit large files */
if (setrlimit(RLIMIT_FSIZE, &rzero) == -1) {
logerr("setrlimit RLIMIT_FSIZE");