]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
BSD: Fix non INET6 builds
authorJ. Hannken-Illjes <hannken@mailbox.org>
Thu, 27 Apr 2023 11:43:33 +0000 (12:43 +0100)
committerRoy Marples <roy@marples.name>
Thu, 27 Apr 2023 11:43:33 +0000 (12:43 +0100)
src/if-bsd.c

index 8b45d3f8eca9bb32c153276fda55bf06c395950e..bab33c2ca6a9df1db6048fe9faaa49e230d76e8a 100644 (file)
@@ -170,15 +170,13 @@ if_opensockets_os(struct dhcpcd_ctx *ctx)
 
 #ifdef INET6
        priv->pf_inet6_fd = xsocket(PF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0);
-#ifdef PRIVSEP_RIGHTS
-       if (IN_PRIVSEP(ctx))
-               ps_rights_limit_ioctl(priv->pf_inet6_fd);
-#endif
        /* Don't return an error so we at least work on kernels witout INET6
         * even though we expect INET6 support.
         * We will fail noisily elsewhere anyway. */
-#else
-       priv->pf_inet6_fd = -1;
+#ifdef PRIVSEP_RIGHTS
+       if (priv->pf_inet6_fd != -1 && IN_PRIVSEP(ctx))
+               ps_rights_limit_ioctl(priv->pf_inet6_fd);
+#endif
 #endif
 
        ctx->link_fd = xsocket(PF_ROUTE, SOCK_RAW | SOCK_CXNB, AF_UNSPEC);
@@ -237,8 +235,10 @@ if_closesockets_os(struct dhcpcd_ctx *ctx)
        struct priv *priv;
 
        priv = (struct priv *)ctx->priv;
+#ifdef INET6
        if (priv->pf_inet6_fd != -1)
                close(priv->pf_inet6_fd);
+#endif
 #if defined(SIOCALIFADDR) && defined(IFLR_ACTIVE) /*NetBSD */
        if (priv->pf_link_fd != -1)
                close(priv->pf_link_fd);