From: Shawn Routhier Date: Fri, 8 Jun 2012 23:28:11 +0000 (+0000) Subject: A problem with missing get_hw_addr function when --enable-use-sockets X-Git-Tag: v4_3_0a1~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32e651c41804c06f764fd53540384f1e4fcd7309;p=thirdparty%2Fdhcp.git 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] --- diff --git a/RELNOTES b/RELNOTES index 061a000fc..3b25d6a90 100644 --- 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 diff --git a/client/dhclient.c b/client/dhclient.c index f38a155db..fa8a3130c 100644 --- a/client/dhclient.c +++ b/client/dhclient.c @@ -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)); } /* diff --git a/common/bpf.c b/common/bpf.c index b0ef65797..39c5abfd8 100644 --- a/common/bpf.c +++ b/common/bpf.c @@ -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 # include # include -# include # if defined (NEED_OSF_PFILT_HACKS) # include # 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 #include #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; diff --git a/common/lpf.c b/common/lpf.c index 16eecc958..0f0ebe4c4 100644 --- a/common/lpf.c +++ b/common/lpf.c @@ -28,7 +28,6 @@ #include "dhcpd.h" #if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE) -#include #include #include @@ -40,8 +39,14 @@ #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 #include +#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; diff --git a/includes/osdep.h b/includes/osdep.h index a8d8bb787..792dc90d5 100644 --- a/includes/osdep.h +++ b/includes/osdep.h @@ -108,6 +108,10 @@ # 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 diff --git a/server/dhcpd.c b/server/dhcpd.c index 3239459f8..dd48e46a1 100644 --- a/server/dhcpd.c +++ b/server/dhcpd.c @@ -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) {