int on = 1;
#endif
+#ifdef PRIVSEP
+ if (ctx->options & DHCPCD_PRIVSEPROOT) {
+ ctx->link_fd = -1;
+ goto setup_priv;
+ }
+#endif
+
/* Open the link socket first so it gets pid() for the socket.
* Then open our persistent route socket so we get a unique
* pid that doesn't clash with a process id for after we fork. */
logerr("%s: NETLINK_BROADCAST_ERROR", __func__);
#endif
+#ifdef PRIVSEP
+setup_priv:
+#endif
if ((priv = calloc(1, sizeof(*priv))) == NULL)
return -1;
switch(protocol) {
case NETLINK_GENERIC:
- s = priv->netlink_fd;
+ s = priv->generic_fd;
break;
case NETLINK_ROUTE:
s = priv->route_fd;
}
if (sendmsg(s, msg, 0) == -1)
- return =-1;
+ return -1;
return if_getnetlink(NULL, &riov, s, 0, NULL, NULL);
}
if (if_opensockets(ctx) == -1)
logerr("%s: if_opensockets", __func__);
- else {
#ifdef BSD
+ else {
/* We only want to write to this socket, so set
* a small as possible buffer size. */
socklen_t smallbuf = 1;
if (setsockopt(ctx->link_fd, SOL_SOCKET, SO_RCVBUF,
&smallbuf, (socklen_t)sizeof(smallbuf)) == -1)
logerr("%s: setsockopt(SO_RCVBUF)", __func__);
-#endif
-#ifdef __linux__
- /* See if_opensockets_os as to why we close link_fd
- * rather than not open it. */
- close(ctx->link_fd);
- ctx->link_fd = -1;
-#endif
}
+#endif
/* Open network sockets for sending.
* This is a small bit wasteful for non sandboxed OS's
(DHCPCD_MANAGER | DHCPCD_DEV))
dev_start(ctx, ps_root_handleinterface);
#endif
+
return 0;
}