]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
privsep: Restore the poll maxfd + 1 for state engine
authorRoy Marples <roy@marples.name>
Thu, 28 Jan 2021 13:17:57 +0000 (13:17 +0000)
committerRoy Marples <roy@marples.name>
Thu, 28 Jan 2021 13:17:57 +0000 (13:17 +0000)
It wasn't fixed, it was using kqueue so avoided!

src/eloop.c
src/privsep.c

index 6b01bdd8f4a7e8e253297be3ba8c19ad636cd319..031d750726dba0507732c9ea34a319a1b52982fc 100644 (file)
@@ -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
index fb77bd27fa884f20b96056484165c38214ca12bf..60ef649acc7abced5651d82b5ff46e515b3a4c88 100644 (file)
@@ -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,