Hello,

Here is a couple of fixes for GNU/Hurd build of ISC dhcp, for
discussion.

The first part replaces the use of the (optional) PATH_MAX macro with
the use of a GNU extension of realpath(): when its argument is NULL, it
just allocates what is needed.  This is made conditional on GNU/Hurd
(__GNU__ is defined on GNU/Hurd only), so it won't have effect on other
OSes, even GNU/Linux.

The second part adds support for being fine with just using only the
standard BSD socket API (GNU/Hurd has neither linux/filter.h, nor
sys/dlpi.h, nor net/bpf.h, but that's not actually mandatory for basic
dhcp support). Otherwise, undefined references to send_packet etc. would
be emitted. It is enabled automatically when BSD sockets are available.
It does not actually change any code, but simply enables inclusion of
the socket-based get_hw_addr function.

Samuel
#! /bin/sh /usr/share/dpatch/dpatch-run
# fix FTPFS for GNU/Hurd
@DPATCH@
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' 
'--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' 
isc-dhcp-4.1.1-P1~/client/dhclient.c isc-dhcp-4.1.1-P1/client/dhclient.c
--- isc-dhcp-4.1.1-P1~/client/dhclient.c        2011-03-03 01:10:28.000000000 
+0000
+++ isc-dhcp-4.1.1-P1/client/dhclient.c 2011-03-03 01:11:08.000000000 +0000
@@ -342,21 +342,33 @@
         * to be reopened after chdir() has been called
         */
        if (path_dhclient_db[0] != '/') {
-               char *path = dmalloc(PATH_MAX, MDL);
+               char *path;
+#ifdef __GNU__
+               path = realpath(path_dhclient_db, NULL);
+#else
+               path = dmalloc(PATH_MAX, MDL);
                if (path == NULL)
                        log_fatal("No memory for filename\n");
-               path_dhclient_db = realpath(path_dhclient_db, path);
-               if (path_dhclient_db == NULL)
-                       log_fatal("%s: %s", path, strerror(errno));
+               path = realpath(path_dhclient_db, path);
+#endif
+               if (path == NULL)
+                       log_fatal("%s: %s", path_dhclient_db, strerror(errno));
+               path_dhclient_db = path;
        }
 
        if (path_dhclient_script[0] != '/') {
-               char *path = dmalloc(PATH_MAX, MDL);
+               char *path;
+#ifdef __GNU__
+               path = realpath(path_dhclient_script, NULL);
+#else
+               path = dmalloc(PATH_MAX, MDL);
                if (path == NULL)
                        log_fatal("No memory for filename\n");
-               path_dhclient_script = realpath(path_dhclient_script, path);
-               if (path_dhclient_script == NULL)
-                       log_fatal("%s: %s", path, strerror(errno));
+               path = realpath(path_dhclient_script, path);
+#endif
+               if (path == NULL)
+                       log_fatal("%s: %s", path_dhclient_script, 
strerror(errno));
+               path_dhclient_script = path;
        }
 
        /* first kill off any currently running client */
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' 
'--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' 
isc-dhcp-4.1.1-P1~/server/dhcpd.c isc-dhcp-4.1.1-P1/server/dhcpd.c
--- isc-dhcp-4.1.1-P1~/server/dhcpd.c   2011-03-03 01:06:44.000000000 +0000
+++ isc-dhcp-4.1.1-P1/server/dhcpd.c    2011-03-03 01:11:08.000000000 +0000
@@ -449,12 +449,18 @@
          * to be reopened after chdir() has been called
          */
         if (path_dhcpd_db[0] != '/') {
-                char *path = dmalloc(PATH_MAX, MDL);
+                char *path;
+#ifdef __GNU__
+                path = realpath(path_dhcpd_db, NULL);
+#else
+                path = dmalloc(PATH_MAX, MDL);
                 if (path == NULL)
                         log_fatal("No memory for filename\n");
-                path_dhcpd_db = realpath(path_dhcpd_db,  path);
-                if (path_dhcpd_db == NULL)
-                        log_fatal("%s: %s", path, strerror(errno));
+                path = realpath(path_dhcpd_db, path);
+#endif
+                if (path == NULL)
+                        log_fatal("%s: %s", path_dhcpd_db, strerror(errno));
+                path_dhcpd_db = path;
         }
 
        if (!quiet) {
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' 
'--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' 
isc-dhcp-4.1.1-P1~/configure.ac isc-dhcp-4.1.1-P1/configure.ac
--- isc-dhcp-4.1.1-P1~/configure.ac     2011-03-03 01:10:44.000000000 +0000
+++ isc-dhcp-4.1.1-P1/configure.ac      2011-03-03 01:11:36.000000000 +0000
@@ -366,9 +366,17 @@
                AC_CHECK_HEADER(net/bpf.h, DO_BPF=1)
                if test -n "$DO_BPF"
                then
-                       AC_DEFINE([HAVE_BPF], [""],
+                       AC_DEFINE([HAVE_BPF], [1],
                                  [Define to 1 to use the 
                                   Berkeley Packet Filter interface code.])
+               else
+                       AC_CHECK_HEADER(sys/socket.h, DO_SOCKET=1)
+                       if test -n "$DO_SOCKET"
+                       then
+                               AC_DEFINE([USE_SOCKETS], [1],
+                               [Define to 1 to use the
+                                standard BSD socket API.])
+                       fi
                fi
        fi
 fi
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' 
'--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' 
isc-dhcp-4.1.1-P1~/includes/osdep.h isc-dhcp-4.1.1-P1/includes/osdep.h
--- isc-dhcp-4.1.1-P1~/includes/osdep.h 2011-03-03 01:06:44.000000000 +0000
+++ isc-dhcp-4.1.1-P1/includes/osdep.h  2011-03-03 01:13:23.000000000 +0000
@@ -116,6 +116,8 @@
 #  define USE_SOCKET_RECEIVE
 #  if defined(HAVE_DLPI)
 #    define USE_DLPI_HWADDR
+#  else
+#    define USE_LPF_HWADDR
 #  endif
 #endif
 
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' 
'--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' 
isc-dhcp-4.1.1-P1~/common/lpf.c isc-dhcp-4.1.1-P1/common/lpf.c
--- isc-dhcp-4.1.1-P1~/common/lpf.c     2011-03-03 01:06:44.000000000 +0000
+++ isc-dhcp-4.1.1-P1/common/lpf.c      2011-03-03 01:11:08.000000000 +0000
@@ -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>
 
@@ -39,8 +38,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 <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. */
 
@@ -411,7 +416,9 @@
                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;

Reply via email to