summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2021-01-28 13:17:57 +0000
committerRoy Marples <roy@marples.name>2021-01-28 13:17:57 +0000
commit55c9cda13bd94fac444a42c449f22f3d8c42ae27 (patch)
tree414e88229d7627d22ce4544fa77bbdd776622ddf
parentb62b3780ac9ee1f87e11ee4fb8735b167eb5d846 (diff)
downloaddhcpcd-55c9cda13bd94fac444a42c449f22f3d8c42ae27.tar.xz
privsep: Restore the poll maxfd + 1 for state engine
It wasn't fixed, it was using kqueue so avoided!
-rw-r--r--src/eloop.c2
-rw-r--r--src/privsep.c5
2 files changed, 5 insertions, 2 deletions
diff --git a/src/eloop.c b/src/eloop.c
index 6b01bdd8..031d7507 100644
--- a/src/eloop.c
+++ b/src/eloop.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <stdio.h>
+
#if (defined(__unix__) || defined(unix)) && !defined(USG)
#include <sys/param.h>
#endif
diff --git a/src/privsep.c b/src/privsep.c
index fb77bd27..60ef649a 100644
--- a/src/privsep.c
+++ b/src/privsep.c
@@ -137,7 +137,8 @@ ps_dropprivs(struct dhcpcd_ctx *ctx)
if (ctx->ps_control_pid != getpid()) {
/* Prohibit new files, sockets, etc */
-#if defined(__linux__) || defined(__sun) || defined(__OpenBSD__)
+#if (defined(__linux__) || defined(__sun) || defined(__OpenBSD__)) && \
+ !defined(HAVE_KQUEUE)
/*
* If poll(2) is called with nfds > RLIMIT_NOFILE
* then it returns EINVAL.
@@ -148,6 +149,8 @@ ps_dropprivs(struct dhcpcd_ctx *ctx)
*/
unsigned long maxfd;
maxfd = (unsigned long)eloop_event_count(ctx->eloop);
+ if (IN_PRIVSEP_SE(ctx))
+ maxfd++; /* why? */
struct rlimit rmaxfd = {
.rlim_cur = maxfd,