]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
A problem with missing get_hw_addr function when --enable-use-sockets
authorShawn Routhier <sar@isc.org>
Fri, 8 Jun 2012 23:28:11 +0000 (23:28 +0000)
committerShawn Routhier <sar@isc.org>
Fri, 8 Jun 2012 23:28:11 +0000 (23:28 +0000)
was used is now solved on GNU/Linux, BSD and GNU/Hurd systems. Note
that use-sockets feature was not tested on those systems. Client and
server code no longer use MAX_PATH constant that is not defined on
GNU/Hurd systems. [ISC-Bugs 25979]

RELNOTES
client/dhclient.c
common/bpf.c
common/lpf.c
includes/osdep.h
server/dhcpd.c

index 061a000fc21a0a1544358e18270416368216a782..3b25d6a900d6072f1f2447bd247cff5601c27319 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -52,6 +52,12 @@ work on other platforms. Please report any problems and suggested fixes to
   matching billing class tried before failing to provide a billing.
   [ISC-Bugs #21759]
 
+- A problem with missing get_hw_addr function when --enable-use-sockets
+  was used is now solved on GNU/Linux, BSD and GNU/Hurd systems. Note
+  that use-sockets feature was not tested on those systems. Client and
+  server code no longer use MAX_PATH constant that is not defined on
+  GNU/Hurd systems. [ISC-Bugs 25979]
+
                        Changes since 4.2.4
 
 - Correct code to calculate timing values in client to compare
index f38a155db79a2c2d39da9a851842516f5b73233d..fa8a3130ce59793f434958607298f8497964e24e 100644 (file)
@@ -374,21 +374,17 @@ main(int argc, char **argv) {
         * to be reopened after chdir() has been called
         */
        if (path_dhclient_db[0] != '/') {
-               char *path = dmalloc(PATH_MAX, MDL);
-               if (path == NULL)
-                       log_fatal("No memory for filename\n");
-               path_dhclient_db = realpath(path_dhclient_db, path);
+               const char *old_path = path_dhclient_db;
+               path_dhclient_db = realpath(path_dhclient_db, NULL);
                if (path_dhclient_db == NULL)
-                       log_fatal("%s: %s", path, strerror(errno));
+                       log_fatal("Failed to get realpath for %s: %s", old_path, strerror(errno));
        }
 
        if (path_dhclient_script[0] != '/') {
-               char *path = dmalloc(PATH_MAX, MDL);
-               if (path == NULL)
-                       log_fatal("No memory for filename\n");
-               path_dhclient_script = realpath(path_dhclient_script, path);
+               const char *old_path = path_dhclient_script;
+               path_dhclient_script = realpath(path_dhclient_script, NULL);
                if (path_dhclient_script == NULL)
-                       log_fatal("%s: %s", path, strerror(errno));
+                       log_fatal("Failed to get realpath for %s: %s", old_path, strerror(errno));
        }
 
        /*
index b0ef6579726559e0a8fbe095e430a0f604bf0638..39c5abfd8ce229a3d942d4cc339310ff23cf422f 100644 (file)
@@ -3,7 +3,8 @@
    BPF socket interface code, originally contributed by Archie Cobbs. */
 
 /*
- * Copyright (c) 2004,2007,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009,2012 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1996-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -43,7 +44,6 @@
 #  include <sys/ioctl.h>
 #  include <sys/uio.h>
 #  include <net/bpf.h>
-#  include <net/if_types.h>
 #  if defined (NEED_OSF_PFILT_HACKS)
 #   include <net/pfilt.h>
 #  endif
@@ -55,7 +55,8 @@
 #include "includes/netinet/if_ether.h"
 #endif
 
-#ifdef USE_BPF_RECEIVE
+#if defined(USE_BPF_SEND) || defined(USE_BPF_RECEIVE) || defined(USE_BPF_HWADDR)
+#include <net/if_types.h>
 #include <ifaddrs.h>
 #endif
 
@@ -550,7 +551,9 @@ void maybe_setup_fallback ()
                interface_dereference (&fbi, MDL);
        }
 }
+#endif
 
+#if defined(USE_BPF_RECEIVE) || defined(USE_BPF_HWADDR)
 void
 get_hw_addr(const char *name, struct hardware *hw) {
        struct ifaddrs *ifa;
index 16eecc95800280584cad0b0cf0df3b793f82586f..0f0ebe4c4f7bf4ba9715d9313b0ac5450975db1d 100644 (file)
@@ -28,7 +28,6 @@
 
 #include "dhcpd.h"
 #if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE)
-#include <sys/ioctl.h>
 #include <sys/uio.h>
 #include <errno.h>
 
 #include "includes/netinet/ip.h"
 #include "includes/netinet/udp.h"
 #include "includes/netinet/if_ether.h"
+#endif
+
+#if defined (USE_LPF_RECEIVE) || defined (USE_LPF_HWADDR)
+#include <sys/ioctl.h>
 #include <net/if.h>
+#endif
 
+#if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE)
 /* Reinitializes the specified interface after an address change.   This
    is not required for packet-filter APIs. */
 
@@ -417,7 +422,9 @@ void maybe_setup_fallback ()
                interface_dereference (&fbi, MDL);
        }
 }
+#endif
 
+#if defined (USE_LPF_RECEIVE) || defined (USE_LPF_HWADDR)
 void
 get_hw_addr(const char *name, struct hardware *hw) {
        int sock;
index a8d8bb787840195da940cb0fdb5c6e496c4f567a..792dc90d54c381c3710cca8dbe6949d5e7b3c899 100644 (file)
 #  define USE_SOCKET_RECEIVE
 #  if defined(HAVE_DLPI)
 #    define USE_DLPI_HWADDR
+#  elif defined(HAVE_LPF)
+#    define USE_LPF_HWADDR
+#  elif defined(HAVE_BPF)
+#    define USE_BPF_HWADDR
 #  endif
 #endif
 
index 3239459f8fafc7f0c0c53f2d94aa2fb1b182a50b..dd48e46a1202b35020330c6760b2f659dcd18552 100644 (file)
@@ -464,12 +464,11 @@ main(int argc, char **argv) {
          * to be reopened after chdir() has been called
          */
         if (path_dhcpd_db[0] != '/') {
-                char *path = dmalloc(PATH_MAX, MDL);
-                if (path == NULL)
-                        log_fatal("No memory for filename\n");
-                path_dhcpd_db = realpath(path_dhcpd_db,  path);
+               const char *path = path_dhcpd_db;
+                path_dhcpd_db = realpath(path_dhcpd_db, NULL);
                 if (path_dhcpd_db == NULL)
-                        log_fatal("%s: %s", path, strerror(errno));
+                        log_fatal("Failed to get realpath for %s: %s", path, 
+                                   strerror(errno));
         }
 
        if (!quiet) {