]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add ifdef around code
authorAlan T. DeKok <aland@freeradius.org>
Mon, 30 Nov 2020 14:10:30 +0000 (09:10 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 30 Nov 2020 14:10:30 +0000 (09:10 -0500)
src/lib/util/socket.c

index d6f1efc3934d35418392a037afa87669ee3598bf..d4dd34f698c5a75f978260d39ec1b7284f3ea5df 100644 (file)
@@ -898,8 +898,17 @@ int fr_socket_bind(int sockfd, fr_ipaddr_t const *src_ipaddr, uint16_t *src_port
                        /*
                         *      The internet hints that CAP_NET_RAW
                         *      is required to use SO_BINDTODEVICE.
+                        *
+                        *      This function also sets fr_strerror()
+                        *      on failure, which will be seen if the
+                        *      bind fails.  If the bind succeeds,
+                        *      then we don't really care that the
+                        *      capability change has failed.  We must
+                        *      already have that capability.
                         */
-                       (void)fr_cap_enable(CAP_NET_RAW, CAP_EFFECTIVE);        /* Sets error on failure, which will be seen if the bind fails */
+#ifdef HAVE_CAPABILITY_H
+                       (void)fr_cap_enable(CAP_NET_RAW, CAP_EFFECTIVE);
+#endif
                        ret = setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, interface, strlen(interface));
                        if (ret < 0) {
                                fr_strerror_printf_push("Bind failed on interface %s: %s",