Revert to dhcp-3.1.0
This commit is contained in:
parent
6a2e4a260b
commit
203b45caac
14
dhcp-3.0.5-fast-timeout.patch
Normal file
14
dhcp-3.0.5-fast-timeout.patch
Normal file
@ -0,0 +1,14 @@
|
||||
--- dhcp-3.0.5/client/dhclient.c.fast 2007-03-30 16:22:54.000000000 -0400
|
||||
+++ dhcp-3.0.5/client/dhclient.c 2007-03-30 16:26:11.000000000 -0400
|
||||
@@ -766,10 +766,7 @@
|
||||
do_release (client);
|
||||
else {
|
||||
client -> state = S_INIT;
|
||||
- /* Set up a timeout to start the initialization
|
||||
- process. */
|
||||
- add_timeout (cur_time + random () % 5,
|
||||
- state_reboot, client, 0, 0);
|
||||
+ add_timeout (cur_time, state_reboot, client, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
17
dhcp-3.0.5-inherit-leases.patch
Normal file
17
dhcp-3.0.5-inherit-leases.patch
Normal file
@ -0,0 +1,17 @@
|
||||
--- dhcp-3.0.5/client/dhclient.c.inherit 2007-03-30 16:06:30.000000000 -0400
|
||||
+++ dhcp-3.0.5/client/dhclient.c 2007-03-30 16:09:06.000000000 -0400
|
||||
@@ -720,6 +720,14 @@
|
||||
continue;
|
||||
script_init (ip -> client,
|
||||
"PREINIT", (struct string_list *)0);
|
||||
+ /* Has an active lease */
|
||||
+ if (ip->client->active &&
|
||||
+ !ip->client->active->is_bootp &&
|
||||
+ ip->client->active->expiry > cur_time &&
|
||||
+ ip->primary_address.s_addr != 0 &&
|
||||
+ ip->client->active->address.len == 4 &&
|
||||
+ memcmp(ip->client->active->address.iabuf, &ip->primary_address, 4) == 0)
|
||||
+ client_envadd(ip->client, "", "keep_old_ip", "%s", "yes");
|
||||
if (ip -> client -> alias)
|
||||
script_write_params (ip -> client, "alias_",
|
||||
ip -> client -> alias);
|
73
dhcp-3.0.5-prototypes.patch
Normal file
73
dhcp-3.0.5-prototypes.patch
Normal file
@ -0,0 +1,73 @@
|
||||
--- dhcp-3.0.5/dst/dst_api.c.prototypes 2007-04-01 16:29:10.000000000 -0400
|
||||
+++ dhcp-3.0.5/dst/dst_api.c 2007-04-01 16:29:10.000000000 -0400
|
||||
@@ -58,6 +58,10 @@
|
||||
|
||||
#include "dst_internal.h"
|
||||
|
||||
+/* prototypes */
|
||||
+extern int b64_pton(char const *src, u_char *target, size_t targsize);
|
||||
+extern int b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize);
|
||||
+
|
||||
/* static variables */
|
||||
static int done_init = 0;
|
||||
dst_func *dst_t_func[DST_MAX_ALGS];
|
||||
--- dhcp-3.0.5/dst/dst_support.c.prototypes 2001-02-22 02:22:08.000000000 -0500
|
||||
+++ dhcp-3.0.5/dst/dst_support.c 2007-04-01 16:29:10.000000000 -0400
|
||||
@@ -32,6 +32,10 @@
|
||||
|
||||
#include "dst_internal.h"
|
||||
|
||||
+/* prototypes */
|
||||
+extern int b64_pton(char const *src, u_char *target, size_t targsize);
|
||||
+extern int b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize);
|
||||
+
|
||||
/*
|
||||
* dst_s_conv_bignum_u8_to_b64
|
||||
* This function converts binary data stored as a u_char[] to a
|
||||
--- dhcp-3.0.5/includes/minires/minires.h.prototypes 2004-06-10 13:59:37.000000000 -0400
|
||||
+++ dhcp-3.0.5/includes/minires/minires.h 2007-04-01 16:29:10.000000000 -0400
|
||||
@@ -65,7 +65,6 @@
|
||||
#define res_protocolname MRres_protocolname
|
||||
#define res_servicename MRres_servicename
|
||||
#define ns_datetosecs MRns_datetosecs
|
||||
-#define b64_pton MRb64_pton
|
||||
#define res_ninit minires_ninit
|
||||
#define res_randomid MRres_randomid
|
||||
#define res_findzonecut MRres_findzonecut
|
||||
--- dhcp-3.0.5/minires/res_mkupdate.c.prototypes 2007-04-01 16:29:10.000000000 -0400
|
||||
+++ dhcp-3.0.5/minires/res_mkupdate.c 2007-04-01 16:30:12.000000000 -0400
|
||||
@@ -49,6 +49,10 @@
|
||||
#include "minires/minires.h"
|
||||
#include "arpa/nameser.h"
|
||||
|
||||
+/* prototypes */
|
||||
+extern int b64_pton(char const *src, u_char *target, size_t targsize);
|
||||
+int dn_comp(const char *src, u_char *dst, unsigned dstsiz, u_char **dnptrs, u_char **lastdnptr);
|
||||
+
|
||||
/* Options. Leave them on. */
|
||||
#define DEBUG
|
||||
#define MAXPORT 1024
|
||||
--- dhcp-3.0.5/minires/res_comp.c.prototypes 2004-06-10 13:59:42.000000000 -0400
|
||||
+++ dhcp-3.0.5/minires/res_comp.c 2007-04-01 16:31:02.000000000 -0400
|
||||
@@ -91,6 +91,11 @@
|
||||
#include "minires/minires.h"
|
||||
#include "arpa/nameser.h"
|
||||
|
||||
+/* prototypes */
|
||||
+int ns_name_uncompress(const u_char *msg, const u_char *eom, const u_char *src, char *dst, size_t dstsiz);
|
||||
+int ns_name_compress(const char *src, u_char *dst, size_t dstsiz, const u_char **dnptrs, const u_char **lastdnptr);
|
||||
+int ns_name_skip(const u_char **ptrptr, const u_char *eom);
|
||||
+
|
||||
/*
|
||||
* Expand compressed domain name 'comp_dn' to full domain name.
|
||||
* 'msg' is a pointer to the begining of the message,
|
||||
--- dhcp-3.0.5/minires/res_init.c.prototypes 2004-06-10 13:59:43.000000000 -0400
|
||||
+++ dhcp-3.0.5/minires/res_init.c 2007-04-01 16:31:38.000000000 -0400
|
||||
@@ -102,6 +102,7 @@
|
||||
#define DEBUG
|
||||
|
||||
static void res_setoptions (res_state, const char *, const char *);
|
||||
+u_int res_randomid(void);
|
||||
|
||||
#ifdef RESOLVSORT
|
||||
static const char sort_mask[] = "/&";
|
84
dhcp-3.0.5-release-by-ifup.patch
Normal file
84
dhcp-3.0.5-release-by-ifup.patch
Normal file
@ -0,0 +1,84 @@
|
||||
--- dhcp-3.0.5/client/dhclient.c.release 2007-03-30 15:30:14.000000000 -0400
|
||||
+++ dhcp-3.0.5/client/dhclient.c 2007-03-30 15:29:58.000000000 -0400
|
||||
@@ -366,9 +366,81 @@
|
||||
}
|
||||
}
|
||||
fclose(pidfd);
|
||||
+ } else {
|
||||
+ /* handle release for interfaces requested with Red Hat
|
||||
+ * /sbin/ifup - pidfile will be /var/run/dhclient-$interface.pid
|
||||
+ */
|
||||
+
|
||||
+ if ((path_dhclient_pid == NULL) || (*path_dhclient_pid == '\0'))
|
||||
+ path_dhclient_pid = "/var/run/dhclient.pid";
|
||||
+
|
||||
+ char *new_path_dhclient_pid;
|
||||
+ struct interface_info *ip;
|
||||
+ int pdp_len = strlen(path_dhclient_pid), pfx, dpfx;
|
||||
+
|
||||
+ /* find append point: beginning of any trailing '.pid'
|
||||
+ * or '-$IF.pid' */
|
||||
+ for (pfx=pdp_len; (pfx >= 0) && (path_dhclient_pid[pfx] != '.') && (path_dhclient_pid[pfx] != '/'); pfx--);
|
||||
+ if (pfx == -1)
|
||||
+ pfx = pdp_len;
|
||||
+
|
||||
+ if (path_dhclient_pid[pfx] == '/')
|
||||
+ pfx += 1;
|
||||
+
|
||||
+ for (dpfx=pfx; (dpfx >= 0) && (path_dhclient_pid[dpfx] != '-') && (path_dhclient_pid[dpfx] != '/'); dpfx--);
|
||||
+ if ((dpfx > -1) && (path_dhclient_pid[dpfx] != '/'))
|
||||
+ pfx = dpfx;
|
||||
+
|
||||
+ for (ip = interfaces; ip; ip = ip->next) {
|
||||
+ if (interfaces_requested && (ip->flags & (INTERFACE_REQUESTED)) && (ip->name != NULL)) {
|
||||
+ int n_len = strlen(ip->name);
|
||||
+
|
||||
+ new_path_dhclient_pid = (char*) malloc(pfx + n_len + 6);
|
||||
+ strncpy(new_path_dhclient_pid, path_dhclient_pid, pfx);
|
||||
+ sprintf(new_path_dhclient_pid + pfx, "-%s.pid", ip->name);
|
||||
+
|
||||
+ if ((pidfd = fopen(new_path_dhclient_pid, "r")) != NULL) {
|
||||
+ e = fscanf(pidfd, "%ld\n", &temp);
|
||||
+ oldpid = (pid_t)temp;
|
||||
+
|
||||
+ if (e != 0 && e != EOF) {
|
||||
+ if (oldpid) {
|
||||
+ if (kill(oldpid, SIGTERM) == 0)
|
||||
+ unlink(path_dhclient_pid);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ fclose(pidfd);
|
||||
+ }
|
||||
+
|
||||
+ free(new_path_dhclient_pid);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ FILE *pidfp = NULL;
|
||||
+ long temp = 0;
|
||||
+ pid_t dhcpid = 0;
|
||||
+ int dhc_running = 0;
|
||||
+ char procfn[256] = "";
|
||||
+
|
||||
+ if ((pidfp = fopen(path_dhclient_pid, "r")) != NULL) {
|
||||
+ if ((fscanf(pidfp, "%ld", &temp)==1) && ((dhcpid=(pid_t)temp) > 0)) {
|
||||
+ snprintf(procfn,256,"/proc/%u",dhcpid);
|
||||
+ dhc_running = (access(procfn, F_OK) == 0);
|
||||
+ }
|
||||
+
|
||||
+ fclose(pidfp);
|
||||
+ }
|
||||
+
|
||||
+ if (dhc_running) {
|
||||
+ log_fatal("dhclient(%u) is already running - exiting. ", dhcpid);
|
||||
+ return(1);
|
||||
}
|
||||
}
|
||||
|
||||
+ write_client_pid_file();
|
||||
+
|
||||
if (!quiet) {
|
||||
log_info ("%s %s", message, DHCP_VERSION);
|
||||
log_info (copyright);
|
11
dhcp-3.0.5-selinux.patch
Normal file
11
dhcp-3.0.5-selinux.patch
Normal file
@ -0,0 +1,11 @@
|
||||
--- dhcp-3.0.5/client/dhclient.c.selinux 2007-03-30 16:11:54.000000000 -0400
|
||||
+++ dhcp-3.0.5/client/dhclient.c 2007-03-30 16:12:27.000000000 -0400
|
||||
@@ -3009,6 +3009,8 @@
|
||||
wstatus = 0;
|
||||
}
|
||||
} else {
|
||||
+ if (leaseFile)
|
||||
+ fclose(leaseFile);
|
||||
execve (scriptName, argv, envp);
|
||||
log_error ("execve (%s, ...): %m", scriptName);
|
||||
exit (0);
|
97
dhcp-3.0.5-unicast-bootp.patch
Normal file
97
dhcp-3.0.5-unicast-bootp.patch
Normal file
@ -0,0 +1,97 @@
|
||||
--- dhcp-3.0.5/server/bootp.c.unicast 2005-05-18 15:54:17.000000000 -0400
|
||||
+++ dhcp-3.0.5/server/bootp.c 2007-03-30 16:16:00.000000000 -0400
|
||||
@@ -62,6 +62,7 @@
|
||||
char msgbuf [1024];
|
||||
int ignorep;
|
||||
int peer_has_leases = 0;
|
||||
+ int norelay = 0;
|
||||
|
||||
if (packet -> raw -> op != BOOTREQUEST)
|
||||
return;
|
||||
@@ -77,7 +78,7 @@
|
||||
? inet_ntoa (packet -> raw -> giaddr)
|
||||
: packet -> interface -> name);
|
||||
|
||||
- if (!locate_network (packet)) {
|
||||
+ if ((norelay = locate_network (packet)) == 0) {
|
||||
log_info ("%s: network unknown", msgbuf);
|
||||
return;
|
||||
}
|
||||
@@ -357,6 +358,13 @@
|
||||
from, &to, &hto);
|
||||
goto out;
|
||||
}
|
||||
+ } else if (norelay == 2) {
|
||||
+ to.sin_addr = raw.ciaddr;
|
||||
+ to.sin_port = remote_port;
|
||||
+ if (fallback_interface) {
|
||||
+ result = send_packet (fallback_interface, (struct packet *)0, &raw, outgoing.packet_length, from, &to, &hto);
|
||||
+ goto out;
|
||||
+ }
|
||||
|
||||
/* If it comes from a client that already knows its address
|
||||
and is not requesting a broadcast response, and we can
|
||||
--- dhcp-3.0.5/server/dhcp.c.unicast 2007-03-30 16:13:36.000000000 -0400
|
||||
+++ dhcp-3.0.5/server/dhcp.c 2007-03-30 16:19:35.000000000 -0400
|
||||
@@ -3817,6 +3817,7 @@
|
||||
struct data_string data;
|
||||
struct subnet *subnet = (struct subnet *)0;
|
||||
struct option_cache *oc;
|
||||
+ int norelay = 0;
|
||||
|
||||
/* See if there's a subnet selection option. */
|
||||
oc = lookup_option (&dhcp_universe, packet -> options,
|
||||
@@ -3826,12 +3827,24 @@
|
||||
from the interface, if there is one. If not, fail. */
|
||||
if (!oc && !packet -> raw -> giaddr.s_addr) {
|
||||
if (packet -> interface -> shared_network) {
|
||||
- shared_network_reference
|
||||
- (&packet -> shared_network,
|
||||
- packet -> interface -> shared_network, MDL);
|
||||
- return 1;
|
||||
+ struct in_addr any_addr;
|
||||
+ any_addr.s_addr = INADDR_ANY;
|
||||
+
|
||||
+ if (!packet -> packet_type && memcmp(&packet -> raw -> ciaddr, &any_addr, 4)) {
|
||||
+ struct iaddr cip;
|
||||
+ memcpy(cip.iabuf, &packet -> raw -> ciaddr, 4);
|
||||
+ cip.len = 4;
|
||||
+ if (!find_grouped_subnet(&subnet, packet->interface->shared_network, cip, MDL))
|
||||
+ norelay = 2;
|
||||
+ }
|
||||
+
|
||||
+ if (!norelay) {
|
||||
+ shared_network_reference(&packet -> shared_network, packet -> interface -> shared_network, MDL);
|
||||
+ return 1;
|
||||
+ }
|
||||
+ } else {
|
||||
+ return 0;
|
||||
}
|
||||
- return 0;
|
||||
}
|
||||
|
||||
/* If there's an SSO, and it's valid, use it to figure out the
|
||||
@@ -3853,7 +3866,10 @@
|
||||
data_string_forget (&data, MDL);
|
||||
} else {
|
||||
ia.len = 4;
|
||||
- memcpy (ia.iabuf, &packet -> raw -> giaddr, 4);
|
||||
+ if (norelay)
|
||||
+ memcpy (ia.iabuf, &packet->raw->ciaddr, 4);
|
||||
+ else
|
||||
+ memcpy (ia.iabuf, &packet->raw->giaddr, 4);
|
||||
}
|
||||
|
||||
/* If we know the subnet on which the IP address lives, use it. */
|
||||
@@ -3861,7 +3877,10 @@
|
||||
shared_network_reference (&packet -> shared_network,
|
||||
subnet -> shared_network, MDL);
|
||||
subnet_dereference (&subnet, MDL);
|
||||
- return 1;
|
||||
+ if (norelay)
|
||||
+ return norelay;
|
||||
+ else
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
/* Otherwise, fail. */
|
13
dhcp-3.0.6-ignore-hyphen-x.patch
Normal file
13
dhcp-3.0.6-ignore-hyphen-x.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff -up dhcp-3.0.6/client/dhclient.c.enoi dhcp-3.0.6/client/dhclient.c
|
||||
--- dhcp-3.0.6/client/dhclient.c.enoi 2007-08-15 16:14:32.000000000 -0400
|
||||
+++ dhcp-3.0.6/client/dhclient.c 2007-08-15 16:17:17.000000000 -0400
|
||||
@@ -259,6 +259,9 @@ int main (argc, argv, envp)
|
||||
} else if (!strcmp (argv [i], "--version")) {
|
||||
log_info ("isc-dhclient-%s", DHCP_VERSION);
|
||||
exit (0);
|
||||
+ } else if (!strcmp (argv [i], "-x")) {
|
||||
+ /* ignored for compatibility */
|
||||
+ continue;
|
||||
} else if (!strcmp (argv [i], "-I")) {
|
||||
if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||||
usage ();
|
37
dhcp-3.0.6-memory.patch
Normal file
37
dhcp-3.0.6-memory.patch
Normal file
@ -0,0 +1,37 @@
|
||||
diff -up dhcp-3.0.6/minires/ns_name.c.memory dhcp-3.0.6/minires/ns_name.c
|
||||
--- dhcp-3.0.6/minires/ns_name.c.memory 2004-06-10 13:59:40.000000000 -0400
|
||||
+++ dhcp-3.0.6/minires/ns_name.c 2007-07-10 11:43:29.000000000 -0400
|
||||
@@ -71,6 +71,11 @@ ns_name_ntop(const u_char *src, char *ds
|
||||
dn = dst;
|
||||
eom = dst + dstsiz;
|
||||
|
||||
+ if (dn >= eom) {
|
||||
+ errno = EMSGSIZE;
|
||||
+ return (-1);
|
||||
+ }
|
||||
+
|
||||
while ((n = *cp++) != 0) {
|
||||
if ((n & NS_CMPRSFLGS) != 0) {
|
||||
/* Some kind of compression pointer. */
|
||||
diff -up dhcp-3.0.6/common/packet.c.memory dhcp-3.0.6/common/packet.c
|
||||
--- dhcp-3.0.6/common/packet.c.memory 2007-05-01 16:42:55.000000000 -0400
|
||||
+++ dhcp-3.0.6/common/packet.c 2007-07-10 11:43:29.000000000 -0400
|
||||
@@ -140,6 +140,7 @@ void assemble_udp_ip_header (interface,
|
||||
struct ip ip;
|
||||
struct udphdr udp;
|
||||
|
||||
+ memset( &ip, '\0', sizeof ip);
|
||||
/* Fill out the IP header */
|
||||
IP_V_SET (&ip, 4);
|
||||
IP_HL_SET (&ip, 20);
|
||||
diff -up dhcp-3.0.6/common/lpf.c.memory dhcp-3.0.6/common/lpf.c
|
||||
--- dhcp-3.0.6/common/lpf.c.memory 2007-07-10 11:43:29.000000000 -0400
|
||||
+++ dhcp-3.0.6/common/lpf.c 2007-07-10 11:43:29.000000000 -0400
|
||||
@@ -246,6 +246,7 @@ static void lpf_tr_filter_setup (info)
|
||||
struct interface_info *info;
|
||||
{
|
||||
struct sock_fprog p;
|
||||
+ memset(&p,'\0', sizeof(struct sock_fprog));
|
||||
|
||||
/* Set up the bpf filter program structure. This is defined in
|
||||
bpf.c */
|
82
dhcp-3.1.0-dhclient-anycast.patch
Normal file
82
dhcp-3.1.0-dhclient-anycast.patch
Normal file
@ -0,0 +1,82 @@
|
||||
diff -up dhcp-3.1.0/common/lpf.c.anycast dhcp-3.1.0/common/lpf.c
|
||||
--- dhcp-3.1.0/common/lpf.c.anycast 2007-10-22 16:16:48.000000000 -0400
|
||||
+++ dhcp-3.1.0/common/lpf.c 2007-10-22 16:19:01.000000000 -0400
|
||||
@@ -334,6 +334,9 @@ ssize_t send_packet (interface, packet,
|
||||
return send_fallback (interface, packet, raw,
|
||||
len, from, to, hto);
|
||||
|
||||
+ if (hto == NULL && interface->anycast_mac_addr.hlen)
|
||||
+ hto = &interface->anycast_mac_addr;
|
||||
+
|
||||
/* Assemble the headers... */
|
||||
assemble_hw_header (interface, (unsigned char *)hh, &hbufp, hto);
|
||||
fudge = hbufp % 4; /* IP header must be word-aligned. */
|
||||
diff -up dhcp-3.1.0/common/conflex.c.anycast dhcp-3.1.0/common/conflex.c
|
||||
--- dhcp-3.1.0/common/conflex.c.anycast 2007-10-22 16:16:47.000000000 -0400
|
||||
+++ dhcp-3.1.0/common/conflex.c 2007-10-22 16:18:52.000000000 -0400
|
||||
@@ -549,6 +549,8 @@ static enum dhcp_token intern (atom, dfv
|
||||
}
|
||||
if (!strcasecmp (atom + 1, "nd"))
|
||||
return AND;
|
||||
+ if (!strcasecmp (atom + 1, "nycast-mac"))
|
||||
+ return ANYCAST_MAC;
|
||||
if (!strcasecmp (atom + 1, "ppend"))
|
||||
return APPEND;
|
||||
if (!strcasecmp (atom + 1, "llow"))
|
||||
diff -up dhcp-3.1.0/includes/site.h.anycast dhcp-3.1.0/includes/site.h
|
||||
--- dhcp-3.1.0/includes/site.h.anycast 2007-10-22 16:16:47.000000000 -0400
|
||||
+++ dhcp-3.1.0/includes/site.h 2007-10-22 16:19:43.000000000 -0400
|
||||
@@ -184,6 +184,8 @@
|
||||
|
||||
#define TRACING
|
||||
|
||||
+#define USE_LPF
|
||||
+
|
||||
/* Define this if you want to read your config from LDAP. Read README.ldap
|
||||
about how to set this up */
|
||||
|
||||
diff -up dhcp-3.1.0/includes/dhcpd.h.anycast dhcp-3.1.0/includes/dhcpd.h
|
||||
--- dhcp-3.1.0/includes/dhcpd.h.anycast 2007-10-22 16:16:48.000000000 -0400
|
||||
+++ dhcp-3.1.0/includes/dhcpd.h 2007-10-22 16:19:17.000000000 -0400
|
||||
@@ -990,6 +990,7 @@ struct interface_info {
|
||||
int dlpi_sap_length;
|
||||
struct hardware dlpi_broadcast_addr;
|
||||
# endif /* DLPI_SEND || DLPI_RECEIVE */
|
||||
+ struct hardware anycast_mac_addr;
|
||||
};
|
||||
|
||||
struct hardware_link {
|
||||
diff -up dhcp-3.1.0/includes/dhctoken.h.anycast dhcp-3.1.0/includes/dhctoken.h
|
||||
--- dhcp-3.1.0/includes/dhctoken.h.anycast 2007-10-22 16:16:48.000000000 -0400
|
||||
+++ dhcp-3.1.0/includes/dhctoken.h 2007-10-22 16:20:33.000000000 -0400
|
||||
@@ -326,7 +326,8 @@ enum dhcp_token {
|
||||
DOMAIN_LIST = 630,
|
||||
LEASEQUERY = 631,
|
||||
EXECUTE = 632,
|
||||
- BOOTP_BROADCAST_ALWAYS = 633
|
||||
+ BOOTP_BROADCAST_ALWAYS = 633,
|
||||
+ ANYCAST_MAC = 634
|
||||
};
|
||||
|
||||
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
|
||||
diff -up dhcp-3.1.0/client/clparse.c.anycast dhcp-3.1.0/client/clparse.c
|
||||
--- dhcp-3.1.0/client/clparse.c.anycast 2007-10-22 16:16:48.000000000 -0400
|
||||
+++ dhcp-3.1.0/client/clparse.c 2007-10-22 16:18:40.000000000 -0400
|
||||
@@ -407,6 +407,17 @@ void parse_client_statement (cfile, ip,
|
||||
}
|
||||
return;
|
||||
|
||||
+ case ANYCAST_MAC:
|
||||
+ token = next_token (&val, (unsigned *)0, cfile);
|
||||
+ if (ip) {
|
||||
+ parse_hardware_param (cfile, &ip -> anycast_mac_addr);
|
||||
+ } else {
|
||||
+ parse_warn (cfile, "anycast mac address parameter %s",
|
||||
+ "not allowed here.");
|
||||
+ skip_to_semi (cfile);
|
||||
+ }
|
||||
+ return;
|
||||
+
|
||||
case REQUEST:
|
||||
token = next_token (&val, (unsigned *)0, cfile);
|
||||
if (config -> requested_options == default_requested_options)
|
39
dhcp-3.1.0-dhclient-usage.patch
Normal file
39
dhcp-3.1.0-dhclient-usage.patch
Normal file
@ -0,0 +1,39 @@
|
||||
diff -up dhcp-3.1.0/client/dhclient.c.usage dhcp-3.1.0/client/dhclient.c
|
||||
--- dhcp-3.1.0/client/dhclient.c.usage 2007-10-22 15:52:06.000000000 -0400
|
||||
+++ dhcp-3.1.0/client/dhclient.c 2007-10-22 15:54:21.000000000 -0400
|
||||
@@ -818,16 +818,25 @@ int main (argc, argv, envp)
|
||||
|
||||
static void usage ()
|
||||
{
|
||||
- log_info ("%s %s", message, DHCP_VERSION);
|
||||
- log_info (copyright);
|
||||
- log_info (arr);
|
||||
- log_info (url);
|
||||
-
|
||||
- log_error ("Usage: dhclient [-1dqrx] [-nw] [-p <port>] %s",
|
||||
- "[-s server]");
|
||||
- log_error (" [-cf config-file] [-lf lease-file]%s",
|
||||
- "[-pf pid-file] [-e VAR=val]");
|
||||
- log_fatal (" [-sf script-file] [interface]");
|
||||
+ printf ("%s %s\n", message, DHCP_VERSION);
|
||||
+ printf (copyright);
|
||||
+ printf ("\n");
|
||||
+ printf (arr);
|
||||
+ printf ("\n");
|
||||
+ printf (url);
|
||||
+ printf ("\n");
|
||||
+
|
||||
+ printf ("Usage: dhclient [-1dqr] [-nw] [-p <port>] %s",
|
||||
+ "[-s server]");
|
||||
+ printf (" [-cf config-file] [-lf lease-file]%s",
|
||||
+ "[-pf pid-file] [-e VAR=val]");
|
||||
+ printf (" [ -I <dhcp-client-identifier> ] [-B]\n");
|
||||
+ printf (" [ -H <host-name> | -F <fqdn.fqdn> ] [ -T <timeout> ]\n");
|
||||
+ printf (" [ -V <vendor-class-identifier> ]\n");
|
||||
+ printf (" [ -R <request option list> ]\n");
|
||||
+ printf (" [-sf script-file] [interface]\n");
|
||||
+
|
||||
+ exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
isc_result_t find_class (struct class **c,
|
2724
dhcp-3.1.0-ldap-configuration.patch
Normal file
2724
dhcp-3.1.0-ldap-configuration.patch
Normal file
File diff suppressed because it is too large
Load Diff
402
dhcp-3.1.0-options.patch
Normal file
402
dhcp-3.1.0-options.patch
Normal file
@ -0,0 +1,402 @@
|
||||
diff -up dhcp-3.1.0/common/conflex.c.options dhcp-3.1.0/common/conflex.c
|
||||
--- dhcp-3.1.0/common/conflex.c.options 2007-10-22 15:46:24.000000000 -0400
|
||||
+++ dhcp-3.1.0/common/conflex.c 2007-10-22 15:48:07.000000000 -0400
|
||||
@@ -599,6 +599,8 @@ static enum dhcp_token intern (atom, dfv
|
||||
return BALANCE;
|
||||
if (!strcasecmp (atom + 1, "ound"))
|
||||
return BOUND;
|
||||
+ if (!strcasecmp (atom + 1, "ootp-broadcast-always"))
|
||||
+ return BOOTP_BROADCAST_ALWAYS;
|
||||
break;
|
||||
case 'c':
|
||||
if (!strcasecmp (atom + 1, "ase"))
|
||||
diff -up dhcp-3.1.0/includes/dhcpd.h.options dhcp-3.1.0/includes/dhcpd.h
|
||||
--- dhcp-3.1.0/includes/dhcpd.h.options 2007-10-22 15:46:24.000000000 -0400
|
||||
+++ dhcp-3.1.0/includes/dhcpd.h 2007-10-22 15:48:21.000000000 -0400
|
||||
@@ -912,6 +912,9 @@ struct client_config {
|
||||
int do_forward_update; /* If nonzero, and if we have the
|
||||
information we need, update the
|
||||
A record for the address we get. */
|
||||
+
|
||||
+ int bootp_broadcast_always; /* If nonzero, always set the BOOTP_BROADCAST
|
||||
+ flag in requests */
|
||||
};
|
||||
|
||||
/* Per-interface state used in the dhcp client... */
|
||||
diff -up dhcp-3.1.0/includes/dhctoken.h.options dhcp-3.1.0/includes/dhctoken.h
|
||||
--- dhcp-3.1.0/includes/dhctoken.h.options 2006-07-31 18:19:51.000000000 -0400
|
||||
+++ dhcp-3.1.0/includes/dhctoken.h 2007-10-22 15:49:24.000000000 -0400
|
||||
@@ -325,7 +325,8 @@ enum dhcp_token {
|
||||
MIN_BALANCE = 629,
|
||||
DOMAIN_LIST = 630,
|
||||
LEASEQUERY = 631,
|
||||
- EXECUTE = 632
|
||||
+ EXECUTE = 632,
|
||||
+ BOOTP_BROADCAST_ALWAYS = 633
|
||||
};
|
||||
|
||||
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
|
||||
diff -up dhcp-3.1.0/client/dhclient.c.options dhcp-3.1.0/client/dhclient.c
|
||||
--- dhcp-3.1.0/client/dhclient.c.options 2007-05-22 16:37:04.000000000 -0400
|
||||
+++ dhcp-3.1.0/client/dhclient.c 2007-10-22 15:47:51.000000000 -0400
|
||||
@@ -38,6 +38,12 @@ static char ocopyright[] =
|
||||
#include "dhcpd.h"
|
||||
#include "version.h"
|
||||
|
||||
+/*
|
||||
+ * Defined in stdio.h when _GNU_SOURCE is set, but we don't want to define
|
||||
+ * that when building ISC code.
|
||||
+ */
|
||||
+extern int asprintf(char **strp, const char *fmt, ...);
|
||||
+
|
||||
TIME default_lease_time = 43200; /* 12 hours... */
|
||||
TIME max_lease_time = 86400; /* 24 hours... */
|
||||
|
||||
@@ -74,6 +80,9 @@ int client_env_count=0;
|
||||
int onetry=0;
|
||||
int quiet=0;
|
||||
int nowait=0;
|
||||
+int bootp_broadcast_always = 0;
|
||||
+
|
||||
+extern u_int32_t default_requested_options[];
|
||||
|
||||
static void usage PROTO ((void));
|
||||
|
||||
@@ -101,6 +110,15 @@ int main (argc, argv, envp)
|
||||
int no_dhclient_pid = 0;
|
||||
int no_dhclient_script = 0;
|
||||
char *s;
|
||||
+ char *dhcp_client_identifier_arg = NULL;
|
||||
+ char *dhcp_host_name_arg = NULL;
|
||||
+ char *dhcp_fqdn_arg = NULL;
|
||||
+ char *dhcp_vendor_class_identifier_arg = NULL;
|
||||
+ char *dhclient_request_options = NULL;
|
||||
+
|
||||
+ int timeout_arg = 0;
|
||||
+ char *arg_conf = NULL;
|
||||
+ int arg_conf_len = 0;
|
||||
|
||||
/* Make sure that file descriptors 0 (stdin), 1, (stdout), and
|
||||
2 (stderr) are open. To do this, we assume that when we
|
||||
@@ -211,6 +229,88 @@ int main (argc, argv, envp)
|
||||
} else if (!strcmp (argv [i], "--version")) {
|
||||
log_info ("isc-dhclient-%s", DHCP_VERSION);
|
||||
exit (0);
|
||||
+ } else if (!strcmp (argv [i], "-I")) {
|
||||
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||||
+ usage ();
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
+
|
||||
+ if (strlen(argv[i]) >= DHCP_OPTION_LEN) {
|
||||
+ log_error("-I option dhcp-client-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ dhcp_client_identifier_arg = argv[i];
|
||||
+ } else if (!strcmp (argv [i], "-B")) {
|
||||
+ bootp_broadcast_always = 1;
|
||||
+ } else if (!strcmp (argv [i], "-H")) {
|
||||
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||||
+ usage ();
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
+
|
||||
+ if (strlen(argv[i]) >= DHCP_OPTION_LEN) {
|
||||
+ log_error("-H option host-name string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ if (dhcp_host_name_arg != NULL) {
|
||||
+ log_error("The -H <host-name> and -F <fqdn> arguments are mutually exclusive");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ dhcp_host_name_arg = argv[i];
|
||||
+ } else if (!strcmp (argv [i], "-F")) {
|
||||
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||||
+ usage ();
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
+
|
||||
+ if (strlen(argv[i]) >= DHCP_OPTION_LEN) {
|
||||
+ log_error("-F option fqdn.fqdn string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ if (dhcp_fqdn_arg != NULL) {
|
||||
+ log_error("Only one -F <fqdn> argument can be specified");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ if (dhcp_host_name_arg != NULL) {
|
||||
+ log_error("The -F <fqdn> and -H <host-name> arguments are mutually exclusive");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ dhcp_fqdn_arg = argv[i];
|
||||
+ } else if (!strcmp (argv [i], "-T")) {
|
||||
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||||
+ usage ();
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
+
|
||||
+ if ((timeout_arg = atoi(argv[i])) <= 0) {
|
||||
+ log_error("-T timeout option must be > 0 - bad value: %s",argv[i]);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ } else if (!strcmp (argv [i], "-V")) {
|
||||
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||||
+ usage ();
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
+
|
||||
+ if (strlen(argv[i]) >= DHCP_OPTION_LEN) {
|
||||
+ log_error("-V option vendor-class-identifier string \"%s\" is too long - maximum length is: %d", argv[i], DHCP_OPTION_LEN-1);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
+ dhcp_vendor_class_identifier_arg = argv[i];
|
||||
+ } else if (!strcmp (argv [i], "-R")) {
|
||||
+ if ((++i == argc) || (argv[i] == NULL) || (*(argv[i])=='\0')) {
|
||||
+ usage ();
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
+
|
||||
+ dhclient_request_options=argv[i];
|
||||
} else if (argv [i][0] == '-') {
|
||||
usage ();
|
||||
} else {
|
||||
@@ -347,6 +447,167 @@ int main (argc, argv, envp)
|
||||
/* Parse the dhclient.conf file. */
|
||||
read_client_conf ();
|
||||
|
||||
+ /* Parse any extra command line configuration arguments: */
|
||||
+ if ((dhcp_client_identifier_arg != NULL) && (*dhcp_client_identifier_arg != '\0')) {
|
||||
+ arg_conf_len = asprintf(&arg_conf, "send dhcp-client-identifier \"%s\";", dhcp_client_identifier_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to send -I option dhcp-client-identifier");
|
||||
+ }
|
||||
+
|
||||
+ if ((dhcp_host_name_arg != NULL) && (*dhcp_host_name_arg != '\0')) {
|
||||
+ if (arg_conf == 0) {
|
||||
+ arg_conf_len = asprintf(&arg_conf, "send host-name \"%s\";", dhcp_host_name_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to send -H option host-name");
|
||||
+ } else {
|
||||
+ char *last_arg_conf = arg_conf;
|
||||
+ arg_conf = NULL;
|
||||
+ arg_conf_len = asprintf( &arg_conf, "%s\nsend host-name \"%s\";", last_arg_conf, dhcp_host_name_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to send -H option host-name");
|
||||
+
|
||||
+ free(last_arg_conf);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if ((dhcp_fqdn_arg != NULL) && (*dhcp_fqdn_arg != '\0')) {
|
||||
+ if (arg_conf == 0) {
|
||||
+ arg_conf_len = asprintf(&arg_conf, "send fqdn.fqdn \"%s\";", dhcp_fqdn_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to send -F option fqdn.fqdn");
|
||||
+ } else {
|
||||
+ char *last_arg_conf = arg_conf;
|
||||
+ arg_conf = NULL;
|
||||
+ arg_conf_len = asprintf( &arg_conf, "%s\nsend fqdn.fqdn \"%s\";", last_arg_conf, dhcp_fqdn_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to send -F option fqdn.fqdn");
|
||||
+
|
||||
+ free(last_arg_conf);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (timeout_arg) {
|
||||
+ if (arg_conf == 0) {
|
||||
+ arg_conf_len = asprintf(&arg_conf, "timeout %d;", timeout_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to process -T timeout argument");
|
||||
+ } else {
|
||||
+ char *last_arg_conf = arg_conf;
|
||||
+ arg_conf = NULL;
|
||||
+ arg_conf_len = asprintf( &arg_conf, "%s\ntimeout %d;", last_arg_conf, timeout_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len == 0))
|
||||
+ log_fatal("Unable to process -T timeout argument");
|
||||
+
|
||||
+ free(last_arg_conf);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if ((dhcp_vendor_class_identifier_arg != NULL) && (*dhcp_vendor_class_identifier_arg != '\0')) {
|
||||
+ if (arg_conf == 0) {
|
||||
+ arg_conf_len = asprintf(&arg_conf, "send vendor-class-identifier \"%s\";", dhcp_vendor_class_identifier_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to send -V option vendor-class-identifier");
|
||||
+ } else {
|
||||
+ char *last_arg_conf = arg_conf;
|
||||
+ arg_conf = NULL;
|
||||
+ arg_conf_len = asprintf(&arg_conf, "%s\nsend vendor-class-identifier \"%s\";", last_arg_conf, dhcp_vendor_class_identifier_arg);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to send -V option vendor-class-identifier");
|
||||
+
|
||||
+ free(last_arg_conf);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (dhclient_request_options != NULL) {
|
||||
+ if (arg_conf == 0) {
|
||||
+ arg_conf_len = asprintf(&arg_conf, "request %s;", dhclient_request_options);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to parse -R <request options list> argument");
|
||||
+ } else {
|
||||
+ char *last_arg_conf = arg_conf;
|
||||
+ arg_conf = NULL;
|
||||
+ arg_conf_len = asprintf(&arg_conf, "%s\nrequest %s;", last_arg_conf, dhclient_request_options);
|
||||
+
|
||||
+ if ((arg_conf == 0) || (arg_conf_len <= 0))
|
||||
+ log_fatal("Unable to parse -R <request options list> argument");
|
||||
+
|
||||
+ free(last_arg_conf);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (arg_conf) {
|
||||
+ if (arg_conf_len == 0)
|
||||
+ if ((arg_conf_len = strlen(arg_conf)) == 0)
|
||||
+ /* huh ? cannot happen ! */
|
||||
+ log_fatal("Unable to process -I/-H/-F/-T/-V/-R configuration arguments");
|
||||
+
|
||||
+ /* parse the extra dhclient.conf configuration arguments
|
||||
+ * into top level config: */
|
||||
+ struct parse *cfile = (struct parse *)0;
|
||||
+ const char *val = NULL;
|
||||
+ int token;
|
||||
+
|
||||
+ status = new_parse (&cfile, -1, arg_conf, arg_conf_len, "extra dhclient -I/-H/-F/-T/-V/-R configuration arguments", 0);
|
||||
+
|
||||
+ if ((status != ISC_R_SUCCESS) || (cfile -> warnings_occurred))
|
||||
+ log_fatal("Cannot parse -I/-H/-F/-T/-V/-R configuration arguments !");
|
||||
+ /* more detailed parse failures will be logged */
|
||||
+
|
||||
+ do {
|
||||
+ token = peek_token (&val, (unsigned *)0, cfile);
|
||||
+ if (token == END_OF_FILE)
|
||||
+ break;
|
||||
+
|
||||
+ parse_client_statement (cfile, (struct interface_info *)0, &top_level_config);
|
||||
+ } while (1);
|
||||
+
|
||||
+ if (cfile -> warnings_occurred)
|
||||
+ log_fatal ("Cannot parse -I/-H/-F/-T/-V/-R configuration arguments !");
|
||||
+ end_parse (&cfile);
|
||||
+
|
||||
+ if (timeout_arg) {
|
||||
+ /* we just set the toplevel timeout, but per-client
|
||||
+ * timeouts may still be at defaults. Also, it makes no
|
||||
+ * sense having the reboot_timeout or backoff_cutoff
|
||||
+ * greater than the timeout:
|
||||
+ */
|
||||
+ if ((top_level_config.backoff_cutoff == 15) && (top_level_config.backoff_cutoff > (timeout_arg / 2)))
|
||||
+ top_level_config.backoff_cutoff = (((unsigned long)(timeout_arg / 2)) == 0) ? timeout_arg : (unsigned long)(timeout_arg / 2);
|
||||
+
|
||||
+ for (ip = interfaces; ip; ip = ip -> next) {
|
||||
+ if (ip->client->config->timeout == 60)
|
||||
+ ip->client->config->timeout = timeout_arg;
|
||||
+
|
||||
+ if ((ip->client->config->reboot_timeout == 10) && (ip->client->config->reboot_timeout > ip->client->config->timeout))
|
||||
+ ip->client->config->reboot_timeout = ip->client->config->timeout;
|
||||
+
|
||||
+ if ((ip->client->config->backoff_cutoff == 15) && (ip->client->config->backoff_cutoff > top_level_config.backoff_cutoff))
|
||||
+ ip->client->config->backoff_cutoff = top_level_config.backoff_cutoff;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if ((dhclient_request_options != 0) && (top_level_config.requested_options != default_requested_options)) {
|
||||
+ for (ip = interfaces; ip; ip = ip -> next) {
|
||||
+ if (ip->client->config->requested_options == default_requested_options)
|
||||
+ ip->client->config->requested_options = top_level_config.requested_options;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ free(arg_conf);
|
||||
+ arg_conf = NULL;
|
||||
+ arg_conf_len = 0;
|
||||
+ }
|
||||
+
|
||||
/* Parse the lease database. */
|
||||
read_client_leases ();
|
||||
|
||||
@@ -1978,7 +2239,8 @@ void make_discover (client, lease)
|
||||
client -> packet.xid = random ();
|
||||
client -> packet.secs = 0; /* filled in by send_discover. */
|
||||
|
||||
- if (can_receive_unicast_unconfigured (client -> interface))
|
||||
+ if ((!(bootp_broadcast_always || client->config->bootp_broadcast_always))
|
||||
+ && can_receive_unicast_unconfigured(client->interface))
|
||||
client -> packet.flags = 0;
|
||||
else
|
||||
client -> packet.flags = htons (BOOTP_BROADCAST);
|
||||
@@ -2065,7 +2327,9 @@ void make_request (client, lease)
|
||||
} else {
|
||||
memset (&client -> packet.ciaddr, 0,
|
||||
sizeof client -> packet.ciaddr);
|
||||
- if (can_receive_unicast_unconfigured (client -> interface))
|
||||
+ if ((!(bootp_broadcast_always ||
|
||||
+ client ->config->bootp_broadcast_always)) &&
|
||||
+ can_receive_unicast_unconfigured (client -> interface))
|
||||
client -> packet.flags = 0;
|
||||
else
|
||||
client -> packet.flags = htons (BOOTP_BROADCAST);
|
||||
@@ -2125,7 +2389,8 @@ void make_decline (client, lease)
|
||||
client -> packet.hops = 0;
|
||||
client -> packet.xid = client -> xid;
|
||||
client -> packet.secs = 0; /* Filled in by send_request. */
|
||||
- if (can_receive_unicast_unconfigured (client -> interface))
|
||||
+ if ((!(bootp_broadcast_always || client->config-> bootp_broadcast_always))
|
||||
+ && can_receive_unicast_unconfigured (client->interface))
|
||||
client -> packet.flags = 0;
|
||||
else
|
||||
client -> packet.flags = htons (BOOTP_BROADCAST);
|
||||
diff -up dhcp-3.1.0/client/clparse.c.options dhcp-3.1.0/client/clparse.c
|
||||
--- dhcp-3.1.0/client/clparse.c.options 2007-02-14 17:41:22.000000000 -0500
|
||||
+++ dhcp-3.1.0/client/clparse.c 2007-10-22 15:47:12.000000000 -0400
|
||||
@@ -84,6 +84,7 @@ isc_result_t read_client_conf ()
|
||||
top_level_config.requested_options = default_requested_options;
|
||||
top_level_config.omapi_port = -1;
|
||||
top_level_config.do_forward_update = 1;
|
||||
+ top_level_config.bootp_broadcast_always = 0;
|
||||
|
||||
group_allocate (&top_level_config.on_receipt, MDL);
|
||||
if (!top_level_config.on_receipt)
|
||||
@@ -230,7 +231,8 @@ void read_client_leases ()
|
||||
interface-declaration |
|
||||
LEASE client-lease-statement |
|
||||
ALIAS client-lease-statement |
|
||||
- KEY key-definition */
|
||||
+ KEY key-definition |
|
||||
+ BOOTP_BROADCAST_ALWAYS */
|
||||
|
||||
void parse_client_statement (cfile, ip, config)
|
||||
struct parse *cfile;
|
||||
@@ -554,6 +556,12 @@ void parse_client_statement (cfile, ip,
|
||||
parse_reject_statement (cfile, config);
|
||||
return;
|
||||
|
||||
+ case BOOTP_BROADCAST_ALWAYS:
|
||||
+ token = next_token(&val, (unsigned*)0, cfile);
|
||||
+ config -> bootp_broadcast_always = 1;
|
||||
+ parse_semi (cfile);
|
||||
+ return;
|
||||
+
|
||||
default:
|
||||
lose = 0;
|
||||
stmt = (struct executable_statement *)0;
|
2631
dhcp-3.1.0-warnings.patch
Normal file
2631
dhcp-3.1.0-warnings.patch
Normal file
File diff suppressed because it is too large
Load Diff
243
dhcp-3.1.0-xen-checksum.patch
Normal file
243
dhcp-3.1.0-xen-checksum.patch
Normal file
@ -0,0 +1,243 @@
|
||||
diff -up dhcp-3.1.0/common/nit.c.xen dhcp-3.1.0/common/nit.c
|
||||
--- dhcp-3.1.0/common/nit.c.xen 2007-05-23 19:30:32.000000000 -0400
|
||||
+++ dhcp-3.1.0/common/nit.c 2007-10-22 16:12:27.000000000 -0400
|
||||
@@ -371,7 +371,7 @@ ssize_t receive_packet (interface, buf,
|
||||
|
||||
/* Decode the IP and UDP headers... */
|
||||
offset = decode_udp_ip_header (interface, ibuf, bufix,
|
||||
- from, length, &paylen);
|
||||
+ from, length, &paylen, 0);
|
||||
|
||||
/* If the IP or UDP checksum was bad, skip the packet... */
|
||||
if (offset < 0)
|
||||
diff -up dhcp-3.1.0/common/dlpi.c.xen dhcp-3.1.0/common/dlpi.c
|
||||
--- dhcp-3.1.0/common/dlpi.c.xen 2007-05-23 19:30:32.000000000 -0400
|
||||
+++ dhcp-3.1.0/common/dlpi.c 2007-10-22 16:12:11.000000000 -0400
|
||||
@@ -680,7 +680,7 @@ ssize_t receive_packet (interface, buf,
|
||||
length -= offset;
|
||||
#endif
|
||||
offset = decode_udp_ip_header (interface, dbuf, bufix,
|
||||
- from, length, &paylen);
|
||||
+ from, length, &paylen, 0);
|
||||
|
||||
/* If the IP or UDP checksum was bad, skip the packet... */
|
||||
if (offset < 0) {
|
||||
diff -up dhcp-3.1.0/common/upf.c.xen dhcp-3.1.0/common/upf.c
|
||||
--- dhcp-3.1.0/common/upf.c.xen 2007-05-23 19:30:32.000000000 -0400
|
||||
+++ dhcp-3.1.0/common/upf.c 2007-10-22 16:12:52.000000000 -0400
|
||||
@@ -322,7 +322,7 @@ ssize_t receive_packet (interface, buf,
|
||||
|
||||
/* Decode the IP and UDP headers... */
|
||||
offset = decode_udp_ip_header (interface, ibuf, bufix,
|
||||
- from, length, &paylen);
|
||||
+ from, length, &paylen, 0);
|
||||
|
||||
/* If the IP or UDP checksum was bad, skip the packet... */
|
||||
if (offset < 0)
|
||||
diff -up dhcp-3.1.0/common/lpf.c.xen dhcp-3.1.0/common/lpf.c
|
||||
--- dhcp-3.1.0/common/lpf.c.xen 2007-10-22 16:11:12.000000000 -0400
|
||||
+++ dhcp-3.1.0/common/lpf.c 2007-10-22 16:15:24.000000000 -0400
|
||||
@@ -34,16 +34,31 @@ static char copyright[] =
|
||||
#include "dhcpd.h"
|
||||
#if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE)
|
||||
#include <sys/ioctl.h>
|
||||
+#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <asm/types.h>
|
||||
#include <linux/filter.h>
|
||||
#include <linux/if_ether.h>
|
||||
+#include <linux/if_packet.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include "includes/netinet/ip.h"
|
||||
#include "includes/netinet/udp.h"
|
||||
#include "includes/netinet/if_ether.h"
|
||||
|
||||
+#ifndef PACKET_AUXDATA
|
||||
+#define PACKET_AUXDATA 8
|
||||
+
|
||||
+struct tpacket_auxdata
|
||||
+{
|
||||
+ __u32 tp_status;
|
||||
+ __u32 tp_len;
|
||||
+ __u32 tp_snaplen;
|
||||
+ __u16 tp_mac;
|
||||
+ __u16 tp_net;
|
||||
+};
|
||||
+#endif
|
||||
+
|
||||
/* Reinitializes the specified interface after an address change. This
|
||||
is not required for packet-filter APIs. */
|
||||
|
||||
@@ -71,10 +86,14 @@ int if_register_lpf (info)
|
||||
int sock;
|
||||
char filename[50];
|
||||
int b;
|
||||
- struct sockaddr sa;
|
||||
+ union {
|
||||
+ struct sockaddr_ll ll;
|
||||
+ struct sockaddr common;
|
||||
+ } sa;
|
||||
+ struct ifreq ifr;
|
||||
|
||||
/* Make an LPF socket. */
|
||||
- if ((sock = socket(PF_PACKET, SOCK_PACKET,
|
||||
+ if ((sock = socket(PF_PACKET, SOCK_RAW,
|
||||
htons((short)ETH_P_ALL))) < 0) {
|
||||
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
|
||||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
|
||||
@@ -89,11 +108,16 @@ int if_register_lpf (info)
|
||||
log_fatal ("Open a socket for LPF: %m");
|
||||
}
|
||||
|
||||
+ memset (&ifr, 0, sizeof ifr);
|
||||
+ strncpy (ifr.ifr_name, (const char *)info -> ifp, sizeof ifr.ifr_name);
|
||||
+ if (ioctl (sock, SIOCGIFINDEX, &ifr))
|
||||
+ log_fatal ("Failed to get interface index: %m");
|
||||
+
|
||||
/* Bind to the interface name */
|
||||
memset (&sa, 0, sizeof sa);
|
||||
- sa.sa_family = AF_PACKET;
|
||||
- strncpy (sa.sa_data, (const char *)info -> ifp, sizeof sa.sa_data);
|
||||
- if (bind (sock, &sa, sizeof sa)) {
|
||||
+ sa.ll.sll_family = AF_PACKET;
|
||||
+ sa.ll.sll_ifindex = ifr.ifr_ifindex;
|
||||
+ if (bind (sock, &sa.common, sizeof sa)) {
|
||||
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
|
||||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
|
||||
errno == EAFNOSUPPORT || errno == EINVAL) {
|
||||
@@ -173,9 +197,18 @@ static void lpf_gen_filter_setup (struct
|
||||
void if_register_receive (info)
|
||||
struct interface_info *info;
|
||||
{
|
||||
+ int val;
|
||||
+
|
||||
/* Open a LPF device and hang it on this interface... */
|
||||
info -> rfdesc = if_register_lpf (info);
|
||||
|
||||
+ val = 1;
|
||||
+ if (setsockopt (info -> rfdesc, SOL_PACKET, PACKET_AUXDATA, &val,
|
||||
+ sizeof val) < 0) {
|
||||
+ if (errno != ENOPROTOOPT)
|
||||
+ log_fatal ("Failed to set auxiliary packet data: %m");
|
||||
+ }
|
||||
+
|
||||
#if defined (HAVE_TR_SUPPORT)
|
||||
if (info -> hw_address.hbuf [0] == HTYPE_IEEE802)
|
||||
lpf_tr_filter_setup (info);
|
||||
@@ -294,7 +327,6 @@ ssize_t send_packet (interface, packet,
|
||||
double hh [16];
|
||||
double ih [1536 / sizeof (double)];
|
||||
unsigned char *buf = (unsigned char *)ih;
|
||||
- struct sockaddr sa;
|
||||
int result;
|
||||
int fudge;
|
||||
|
||||
@@ -312,15 +344,7 @@ ssize_t send_packet (interface, packet,
|
||||
(unsigned char *)raw, len);
|
||||
memcpy (buf + ibufp, raw, len);
|
||||
|
||||
- /* For some reason, SOCK_PACKET sockets can't be connected,
|
||||
- so we have to do a sentdo every time. */
|
||||
- memset (&sa, 0, sizeof sa);
|
||||
- sa.sa_family = AF_PACKET;
|
||||
- strncpy (sa.sa_data,
|
||||
- (const char *)interface -> ifp, sizeof sa.sa_data);
|
||||
-
|
||||
- result = sendto (interface -> wfdesc,
|
||||
- buf + fudge, ibufp + len - fudge, 0, &sa, sizeof sa);
|
||||
+ result = write (interface -> wfdesc, buf + fudge, ibufp + len - fudge);
|
||||
if (result < 0)
|
||||
log_error ("send_packet: %m");
|
||||
return result;
|
||||
@@ -338,14 +362,35 @@ ssize_t receive_packet (interface, buf,
|
||||
int nread;
|
||||
int length = 0;
|
||||
int offset = 0;
|
||||
+ int nocsum = 0;
|
||||
unsigned char ibuf [1536];
|
||||
unsigned bufix = 0;
|
||||
unsigned paylen;
|
||||
+ unsigned char cmsgbuf[CMSG_LEN(sizeof(struct tpacket_auxdata))];
|
||||
+ struct iovec iov = {
|
||||
+ .iov_base = ibuf,
|
||||
+ .iov_len = sizeof ibuf,
|
||||
+ };
|
||||
+ struct msghdr msg = {
|
||||
+ .msg_iov = &iov,
|
||||
+ .msg_iovlen = 1,
|
||||
+ .msg_control = cmsgbuf,
|
||||
+ .msg_controllen = sizeof(cmsgbuf),
|
||||
+ };
|
||||
+ struct cmsghdr *cmsg;
|
||||
|
||||
- length = read (interface -> rfdesc, ibuf, sizeof ibuf);
|
||||
+ length = recvmsg (interface -> rfdesc, &msg, 0);
|
||||
if (length <= 0)
|
||||
return length;
|
||||
|
||||
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
|
||||
+ if (cmsg->cmsg_level == SOL_PACKET &&
|
||||
+ cmsg->cmsg_type == PACKET_AUXDATA) {
|
||||
+ struct tpacket_auxdata *aux = (void *)CMSG_DATA(cmsg);
|
||||
+ nocsum = aux->tp_status & TP_STATUS_CSUMNOTREADY;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
bufix = 0;
|
||||
/* Decode the physical header... */
|
||||
offset = decode_hw_header (interface, ibuf, bufix, hfrom);
|
||||
@@ -362,7 +407,7 @@ ssize_t receive_packet (interface, buf,
|
||||
|
||||
/* Decode the IP and UDP headers... */
|
||||
offset = decode_udp_ip_header (interface, ibuf, bufix, from,
|
||||
- (unsigned)length, &paylen);
|
||||
+ (unsigned)length, &paylen, nocsum);
|
||||
|
||||
/* If the IP or UDP checksum was bad, skip the packet... */
|
||||
if (offset < 0)
|
||||
diff -up dhcp-3.1.0/common/bpf.c.xen dhcp-3.1.0/common/bpf.c
|
||||
--- dhcp-3.1.0/common/bpf.c.xen 2007-05-23 19:30:32.000000000 -0400
|
||||
+++ dhcp-3.1.0/common/bpf.c 2007-10-22 16:13:14.000000000 -0400
|
||||
@@ -478,7 +478,7 @@ ssize_t receive_packet (interface, buf,
|
||||
offset = decode_udp_ip_header (interface,
|
||||
interface -> rbuf,
|
||||
interface -> rbuf_offset,
|
||||
- from, hdr.bh_caplen, &paylen);
|
||||
+ from, hdr.bh_caplen, &paylen, 0);
|
||||
|
||||
/* If the IP or UDP checksum was bad, skip the packet... */
|
||||
if (offset < 0) {
|
||||
diff -up dhcp-3.1.0/common/packet.c.xen dhcp-3.1.0/common/packet.c
|
||||
--- dhcp-3.1.0/common/packet.c.xen 2007-10-22 16:11:12.000000000 -0400
|
||||
+++ dhcp-3.1.0/common/packet.c 2007-10-22 16:12:41.000000000 -0400
|
||||
@@ -215,7 +215,7 @@ ssize_t
|
||||
decode_udp_ip_header(struct interface_info *interface,
|
||||
unsigned char *buf, unsigned bufix,
|
||||
struct sockaddr_in *from, unsigned buflen,
|
||||
- unsigned *rbuflen)
|
||||
+ unsigned *rbuflen, int nocsum)
|
||||
{
|
||||
unsigned char *data;
|
||||
struct ip ip;
|
||||
@@ -326,7 +326,7 @@ decode_udp_ip_header(struct interface_in
|
||||
8, IPPROTO_UDP + ulen))));
|
||||
|
||||
udp_packets_seen++;
|
||||
- if (usum && usum != sum) {
|
||||
+ if (!nocsum && usum && usum != sum) {
|
||||
udp_packets_bad_checksum++;
|
||||
if (udp_packets_seen > 4 &&
|
||||
(udp_packets_seen / udp_packets_bad_checksum) < 2) {
|
||||
diff -up dhcp-3.1.0/includes/dhcpd.h.xen dhcp-3.1.0/includes/dhcpd.h
|
||||
--- dhcp-3.1.0/includes/dhcpd.h.xen 2007-10-22 16:11:12.000000000 -0400
|
||||
+++ dhcp-3.1.0/includes/dhcpd.h 2007-10-22 16:13:01.000000000 -0400
|
||||
@@ -2140,7 +2140,7 @@ ssize_t decode_hw_header PROTO ((struct
|
||||
unsigned, struct hardware *));
|
||||
ssize_t decode_udp_ip_header PROTO ((struct interface_info *, unsigned char *,
|
||||
unsigned, struct sockaddr_in *,
|
||||
- unsigned, unsigned *));
|
||||
+ unsigned, unsigned *, int));
|
||||
|
||||
/* ethernet.c */
|
||||
void assemble_ethernet_header PROTO ((struct interface_info *, unsigned char *,
|
760
dhcpd-conf-to-ldap
Executable file
760
dhcpd-conf-to-ldap
Executable file
@ -0,0 +1,760 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# Brian Masney <masneyb@ntelos.net>
|
||||
# To use this script, set your base DN below. Then run
|
||||
# ./dhcpd-conf-to-ldap.pl < /path-to-dhcpd-conf/dhcpd.conf > output-file
|
||||
# The output of this script will generate entries in LDIF format. You can use
|
||||
# the slapadd command to add these entries into your LDAP server. You will
|
||||
# definately want to double check that your LDAP entries are correct before
|
||||
# you load them into LDAP.
|
||||
|
||||
# This script does not do much error checking. Make sure before you run this
|
||||
# that the DHCP server doesn't give any errors about your config file
|
||||
|
||||
# FailOver notes:
|
||||
# Failover is disabled by default, since it may need manually intervention.
|
||||
# You can try the '--use=failover' option to see what happens :-)
|
||||
#
|
||||
# If enabled, the failover pool references will be written to LDIF output.
|
||||
# The failover configs itself will be added to the dhcpServer statements
|
||||
# and not to the dhcpService object (since this script uses only one and
|
||||
# it may be usefull to have multiple service containers in failover mode).
|
||||
# Further, this script does not check if primary or secondary makes sense,
|
||||
# it simply converts what it gets...
|
||||
|
||||
use Net::Domain qw(hostname hostfqdn hostdomain);
|
||||
use Getopt::Long;
|
||||
|
||||
my $domain = hostdomain(); # your.domain
|
||||
my $basedn = "dc=".$domain;
|
||||
$basedn =~ s/\./,dc=/g; # dc=your,dc=domain
|
||||
my $server = hostname(); # hostname (nodename)
|
||||
my $dhcpcn = 'DHCP Config'; # CN of DHCP config tree
|
||||
my $dhcpdn = "cn=$dhcpcn, $basedn"; # DHCP config tree DN
|
||||
my $second = ''; # secondary server DN / hostname
|
||||
my $i_conf = ''; # dhcp.conf file to read or stdin
|
||||
my $o_ldif = ''; # output ldif file name or stdout
|
||||
my @use = (); # extended flags (failover)
|
||||
|
||||
sub usage($;$)
|
||||
{
|
||||
my $rc = shift;
|
||||
my $err= shift;
|
||||
|
||||
print STDERR "Error: $err\n\n" if(defined $err);
|
||||
print STDERR <<__EOF_USAGE__;
|
||||
usage:
|
||||
$0 [options] < dhcpd.conf > dhcpd.ldif
|
||||
|
||||
options:
|
||||
|
||||
--basedn "dc=your,dc=domain" ("$basedn")
|
||||
|
||||
--dhcpdn "dhcp config DN" ("$dhcpdn")
|
||||
|
||||
--server "dhcp server name" ("$server")
|
||||
|
||||
--second "secondary server or DN" ("$second")
|
||||
|
||||
--conf "/path/to/dhcpd.conf" (default is stdin)
|
||||
--ldif "/path/to/output.ldif" (default is stdout)
|
||||
|
||||
--use "extended features" (see source comments)
|
||||
__EOF_USAGE__
|
||||
exit($rc);
|
||||
}
|
||||
|
||||
|
||||
sub next_token
|
||||
{
|
||||
local ($lowercase) = @_;
|
||||
local ($token, $newline);
|
||||
|
||||
do
|
||||
{
|
||||
if (!defined ($line) || length ($line) == 0)
|
||||
{
|
||||
$line = <>;
|
||||
return undef if !defined ($line);
|
||||
chop $line;
|
||||
$line_number++;
|
||||
$token_number = 0;
|
||||
}
|
||||
|
||||
$line =~ s/#.*//;
|
||||
$line =~ s/^\s+//;
|
||||
$line =~ s/\s+$//;
|
||||
}
|
||||
while (length ($line) == 0);
|
||||
|
||||
if (($token, $newline) = $line =~ /^(.*?)\s+(.*)/)
|
||||
{
|
||||
if ($token =~ /^"/) {
|
||||
#handle quoted token
|
||||
if ($token !~ /"\s*$/)
|
||||
{
|
||||
($tok, $newline) = $newline =~ /([^"]+")(.*)/;
|
||||
$token .= " $tok";
|
||||
}
|
||||
}
|
||||
$line = $newline;
|
||||
}
|
||||
else
|
||||
{
|
||||
$token = $line;
|
||||
$line = '';
|
||||
}
|
||||
$token_number++;
|
||||
|
||||
$token =~ y/[A-Z]/[a-z]/ if $lowercase;
|
||||
|
||||
return ($token);
|
||||
}
|
||||
|
||||
|
||||
sub remaining_line
|
||||
{
|
||||
local ($block) = shift || 0;
|
||||
local ($tmp, $str);
|
||||
|
||||
$str = "";
|
||||
while (defined($tmp = next_token (0)))
|
||||
{
|
||||
$str .= ' ' if !($str eq "");
|
||||
$str .= $tmp;
|
||||
last if $tmp =~ /;\s*$/;
|
||||
last if($block and $tmp =~ /\s*[}{]\s*$/);
|
||||
}
|
||||
|
||||
$str =~ s/;$//;
|
||||
return ($str);
|
||||
}
|
||||
|
||||
|
||||
sub
|
||||
add_dn_to_stack
|
||||
{
|
||||
local ($dn) = @_;
|
||||
|
||||
$current_dn = "$dn, $current_dn";
|
||||
}
|
||||
|
||||
|
||||
sub
|
||||
remove_dn_from_stack
|
||||
{
|
||||
$current_dn =~ s/^.*?,\s*//;
|
||||
}
|
||||
|
||||
|
||||
sub
|
||||
parse_error
|
||||
{
|
||||
print "Parse error on line number $line_number at token number $token_number\n";
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
sub
|
||||
print_entry
|
||||
{
|
||||
return if (scalar keys %curentry == 0);
|
||||
|
||||
if (!defined ($curentry{'type'}))
|
||||
{
|
||||
$hostdn = "cn=$server, $basedn";
|
||||
print "dn: $hostdn\n";
|
||||
print "cn: $server\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpServer\n";
|
||||
print "dhcpServiceDN: $current_dn\n";
|
||||
if(grep(/FaIlOvEr/i, @use))
|
||||
{
|
||||
foreach my $fo_peer (keys %failover)
|
||||
{
|
||||
next if(scalar(@{$failover{$fo_peer}}) <= 1);
|
||||
print "dhcpStatements: failover peer $fo_peer { ",
|
||||
join('; ', @{$failover{$fo_peer}}), "; }\n";
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: $dhcpcn\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpService\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
print "dhcpPrimaryDN: $hostdn\n";
|
||||
if(grep(/FaIlOvEr/i, @use) and ($second ne ''))
|
||||
{
|
||||
print "dhcpSecondaryDN: $second\n";
|
||||
}
|
||||
}
|
||||
elsif ($curentry{'type'} eq 'subnet')
|
||||
{
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: " . $curentry{'ip'} . "\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpSubnet\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
|
||||
print "dhcpNetMask: " . $curentry{'netmask'} . "\n";
|
||||
if (defined ($curentry{'ranges'}))
|
||||
{
|
||||
foreach $statement (@{$curentry{'ranges'}})
|
||||
{
|
||||
print "dhcpRange: $statement\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif ($curentry{'type'} eq 'shared-network')
|
||||
{
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: " . $curentry{'descr'} . "\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpSharedNetwork\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
}
|
||||
elsif ($curentry{'type'} eq 'group')
|
||||
{
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: group", $curentry{'idx'}, "\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpGroup\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
}
|
||||
elsif ($curentry{'type'} eq 'host')
|
||||
{
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: " . $curentry{'host'} . "\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpHost\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
|
||||
if (defined ($curentry{'hwaddress'}))
|
||||
{
|
||||
$curentry{'hwaddress'} =~ y/[A-Z]/[a-z]/;
|
||||
print "dhcpHWAddress: " . $curentry{'hwaddress'} . "\n";
|
||||
}
|
||||
}
|
||||
elsif ($curentry{'type'} eq 'pool')
|
||||
{
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: pool", $curentry{'idx'}, "\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpPool\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
|
||||
if (defined ($curentry{'ranges'}))
|
||||
{
|
||||
foreach $statement (@{$curentry{'ranges'}})
|
||||
{
|
||||
print "dhcpRange: $statement\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif ($curentry{'type'} eq 'class')
|
||||
{
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: " . $curentry{'class'} . "\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpClass\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
}
|
||||
elsif ($curentry{'type'} eq 'subclass')
|
||||
{
|
||||
print "dn: $current_dn\n";
|
||||
print "cn: " . $curentry{'subclass'} . "\n";
|
||||
print "objectClass: top\n";
|
||||
print "objectClass: dhcpSubClass\n";
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
print "objectClass: dhcpOptions\n";
|
||||
}
|
||||
print "dhcpClassData: " . $curentry{'class'} . "\n";
|
||||
}
|
||||
|
||||
if (defined ($curentry{'statements'}))
|
||||
{
|
||||
foreach $statement (@{$curentry{'statements'}})
|
||||
{
|
||||
print "dhcpStatements: $statement\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (defined ($curentry{'options'}))
|
||||
{
|
||||
foreach $statement (@{$curentry{'options'}})
|
||||
{
|
||||
print "dhcpOption: $statement\n";
|
||||
}
|
||||
}
|
||||
|
||||
print "\n";
|
||||
undef (%curentry);
|
||||
}
|
||||
|
||||
|
||||
sub parse_netmask
|
||||
{
|
||||
local ($netmask) = @_;
|
||||
local ($i);
|
||||
|
||||
if ((($a, $b, $c, $d) = $netmask =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) != 4)
|
||||
{
|
||||
parse_error ();
|
||||
}
|
||||
|
||||
$num = (($a & 0xff) << 24) |
|
||||
(($b & 0xff) << 16) |
|
||||
(($c & 0xff) << 8) |
|
||||
($d & 0xff);
|
||||
|
||||
for ($i=1; $i<=32 && $num & (1 << (32 - $i)); $i++)
|
||||
{
|
||||
}
|
||||
$i--;
|
||||
|
||||
return ($i);
|
||||
}
|
||||
|
||||
|
||||
sub parse_subnet
|
||||
{
|
||||
local ($ip, $tmp, $netmask);
|
||||
|
||||
print_entry () if %curentry;
|
||||
|
||||
$ip = next_token (0);
|
||||
parse_error () if !defined ($ip);
|
||||
|
||||
$tmp = next_token (1);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq 'netmask');
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
$netmask = parse_netmask ($tmp);
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq '{');
|
||||
|
||||
add_dn_to_stack ("cn=$ip");
|
||||
$curentry{'type'} = 'subnet';
|
||||
$curentry{'ip'} = $ip;
|
||||
$curentry{'netmask'} = $netmask;
|
||||
$cursubnet = $ip;
|
||||
$curcounter{$ip} = { pool => 0, group => 0 };
|
||||
}
|
||||
|
||||
|
||||
sub parse_shared_network
|
||||
{
|
||||
local ($descr, $tmp);
|
||||
|
||||
print_entry () if %curentry;
|
||||
|
||||
$descr = next_token (0);
|
||||
parse_error () if !defined ($descr);
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq '{');
|
||||
|
||||
add_dn_to_stack ("cn=$descr");
|
||||
$curentry{'type'} = 'shared-network';
|
||||
$curentry{'descr'} = $descr;
|
||||
}
|
||||
|
||||
|
||||
sub parse_host
|
||||
{
|
||||
local ($descr, $tmp);
|
||||
|
||||
print_entry () if %curentry;
|
||||
|
||||
$host = next_token (0);
|
||||
parse_error () if !defined ($host);
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq '{');
|
||||
|
||||
add_dn_to_stack ("cn=$host");
|
||||
$curentry{'type'} = 'host';
|
||||
$curentry{'host'} = $host;
|
||||
}
|
||||
|
||||
|
||||
sub parse_group
|
||||
{
|
||||
local ($descr, $tmp);
|
||||
|
||||
print_entry () if %curentry;
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq '{');
|
||||
|
||||
my $idx;
|
||||
if(exists($curcounter{$cursubnet})) {
|
||||
$idx = ++$curcounter{$cursubnet}->{'group'};
|
||||
} else {
|
||||
$idx = ++$curcounter{''}->{'group'};
|
||||
}
|
||||
|
||||
add_dn_to_stack ("cn=group".$idx);
|
||||
$curentry{'type'} = 'group';
|
||||
$curentry{'idx'} = $idx;
|
||||
}
|
||||
|
||||
|
||||
sub parse_pool
|
||||
{
|
||||
local ($descr, $tmp);
|
||||
|
||||
print_entry () if %curentry;
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq '{');
|
||||
|
||||
my $idx;
|
||||
if(exists($curcounter{$cursubnet})) {
|
||||
$idx = ++$curcounter{$cursubnet}->{'pool'};
|
||||
} else {
|
||||
$idx = ++$curcounter{''}->{'pool'};
|
||||
}
|
||||
|
||||
add_dn_to_stack ("cn=pool".$idx);
|
||||
$curentry{'type'} = 'pool';
|
||||
$curentry{'idx'} = $idx;
|
||||
}
|
||||
|
||||
|
||||
sub parse_class
|
||||
{
|
||||
local ($descr, $tmp);
|
||||
|
||||
print_entry () if %curentry;
|
||||
|
||||
$class = next_token (0);
|
||||
parse_error () if !defined ($class);
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq '{');
|
||||
|
||||
$class =~ s/\"//g;
|
||||
add_dn_to_stack ("cn=$class");
|
||||
$curentry{'type'} = 'class';
|
||||
$curentry{'class'} = $class;
|
||||
}
|
||||
|
||||
|
||||
sub parse_subclass
|
||||
{
|
||||
local ($descr, $tmp);
|
||||
|
||||
print_entry () if %curentry;
|
||||
|
||||
$class = next_token (0);
|
||||
parse_error () if !defined ($class);
|
||||
|
||||
$subclass = next_token (0);
|
||||
parse_error () if !defined ($subclass);
|
||||
|
||||
$tmp = next_token (0);
|
||||
parse_error () if !defined ($tmp);
|
||||
parse_error () if !($tmp eq '{');
|
||||
|
||||
add_dn_to_stack ("cn=$subclass");
|
||||
$curentry{'type'} = 'subclass';
|
||||
$curentry{'class'} = $class;
|
||||
$curentry{'subclass'} = $subclass;
|
||||
}
|
||||
|
||||
|
||||
sub parse_hwaddress
|
||||
{
|
||||
local ($type, $hw, $tmp);
|
||||
|
||||
$type = next_token (1);
|
||||
parse_error () if !defined ($type);
|
||||
|
||||
$hw = next_token (1);
|
||||
parse_error () if !defined ($hw);
|
||||
$hw =~ s/;$//;
|
||||
|
||||
$curentry{'hwaddress'} = "$type $hw";
|
||||
}
|
||||
|
||||
|
||||
sub parse_range
|
||||
{
|
||||
local ($tmp, $str);
|
||||
|
||||
$str = remaining_line ();
|
||||
|
||||
if (!($str eq ''))
|
||||
{
|
||||
$str =~ s/;$//;
|
||||
push (@{$curentry{'ranges'}}, $str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub parse_statement
|
||||
{
|
||||
local ($token) = shift;
|
||||
local ($str);
|
||||
|
||||
if ($token eq 'option')
|
||||
{
|
||||
$str = remaining_line ();
|
||||
push (@{$curentry{'options'}}, $str);
|
||||
}
|
||||
elsif($token eq 'failover')
|
||||
{
|
||||
$str = remaining_line (1); # take care on block
|
||||
if($str =~ /[{]/)
|
||||
{
|
||||
my ($peername, @statements);
|
||||
|
||||
parse_error() if($str !~ /^\s*peer\s+(.+?)\s+[{]\s*$/);
|
||||
parse_error() if(($peername = $1) !~ /^\"?[^\"]+\"?$/);
|
||||
|
||||
#
|
||||
# failover config block found:
|
||||
# e.g. 'failover peer "some-name" {'
|
||||
#
|
||||
if(not grep(/FaIlOvEr/i, @use))
|
||||
{
|
||||
print STDERR "Warning: Failover config 'peer $peername' found!\n";
|
||||
print STDERR " Skipping it, since failover disabled!\n";
|
||||
print STDERR " You may try out --use=failover option.\n";
|
||||
}
|
||||
|
||||
until($str =~ /[}]/ or $str eq "")
|
||||
{
|
||||
$str = remaining_line (1);
|
||||
# collect all statements, except ending '}'
|
||||
push(@statements, $str) if($str !~ /[}]/);
|
||||
}
|
||||
$failover{$peername} = [@statements];
|
||||
}
|
||||
else
|
||||
{
|
||||
#
|
||||
# pool reference to failover config is fine
|
||||
# e.g. 'failover peer "some-name";'
|
||||
#
|
||||
if(not grep(/FaIlOvEr/i, @use))
|
||||
{
|
||||
print STDERR "Warning: Failover reference '$str' found!\n";
|
||||
print STDERR " Skipping it, since failover disabled!\n";
|
||||
print STDERR " You may try out --use=failover option.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
push (@{$curentry{'statements'}}, $token. " " . $str);
|
||||
}
|
||||
}
|
||||
}
|
||||
elsif($token eq 'zone')
|
||||
{
|
||||
$str = $token;
|
||||
while($str !~ /}$/) {
|
||||
$str .= ' ' . next_token (0);
|
||||
}
|
||||
push (@{$curentry{'statements'}}, $str);
|
||||
}
|
||||
elsif($token =~ /^(authoritative)[;]*$/)
|
||||
{
|
||||
push (@{$curentry{'statements'}}, $1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$str = $token . " " . remaining_line ();
|
||||
push (@{$curentry{'statements'}}, $str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my $ok = GetOptions(
|
||||
'basedn=s' => \$basedn,
|
||||
'dhcpdn=s' => \$dhcpdn,
|
||||
'server=s' => \$server,
|
||||
'second=s' => \$second,
|
||||
'conf=s' => \$i_conf,
|
||||
'ldif=s' => \$o_ldif,
|
||||
'use=s' => \@use,
|
||||
'h|help|usage' => sub { usage(0); },
|
||||
);
|
||||
|
||||
unless($server =~ /^\w+/)
|
||||
{
|
||||
usage(1, "invalid server name '$server'");
|
||||
}
|
||||
unless($basedn =~ /^\w+=[^,]+/)
|
||||
{
|
||||
usage(1, "invalid base dn '$basedn'");
|
||||
}
|
||||
|
||||
if($dhcpdn =~ /^cn=([^,]+)/i)
|
||||
{
|
||||
$dhcpcn = "$1";
|
||||
}
|
||||
$second = '' if not defined $second;
|
||||
unless($second eq '' or $second =~ /^cn=[^,]+\s*,\s*\w+=[^,]+/i)
|
||||
{
|
||||
if($second =~ /^cn=[^,]+$/i)
|
||||
{
|
||||
# relative DN 'cn=name'
|
||||
$second = "$second, $basedn";
|
||||
}
|
||||
elsif($second =~ /^\w+/)
|
||||
{
|
||||
# assume hostname only
|
||||
$second = "cn=$second, $basedn";
|
||||
}
|
||||
else
|
||||
{
|
||||
usage(1, "invalid secondary '$second'")
|
||||
}
|
||||
}
|
||||
|
||||
usage(1) unless($ok);
|
||||
|
||||
if($i_conf ne "" and -f $i_conf)
|
||||
{
|
||||
if(not open(STDIN, '<', $i_conf))
|
||||
{
|
||||
print STDERR "Error: can't open conf file '$i_conf': $!\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if($o_ldif ne "")
|
||||
{
|
||||
if(-e $o_ldif)
|
||||
{
|
||||
print STDERR "Error: output ldif name '$o_ldif' already exists!\n";
|
||||
exit(1);
|
||||
}
|
||||
if(not open(STDOUT, '>', $o_ldif))
|
||||
{
|
||||
print STDERR "Error: can't open ldif file '$o_ldif': $!\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print STDERR "Creating LDAP Configuration with the following options:\n";
|
||||
print STDERR "\tBase DN: $basedn\n";
|
||||
print STDERR "\tDHCP DN: $dhcpdn\n";
|
||||
print STDERR "\tServer DN: cn=$server, $basedn\n";
|
||||
print STDERR "\tSecondary DN: $second\n"
|
||||
if(grep(/FaIlOvEr/i, @use) and $second ne '');
|
||||
print STDERR "\n";
|
||||
|
||||
my $token;
|
||||
my $token_number = 0;
|
||||
my $line_number = 0;
|
||||
my %curentry;
|
||||
my $cursubnet = '';
|
||||
my %curcounter = ( '' => { pool => 0, group => 0 } );
|
||||
|
||||
$current_dn = "$dhcpdn";
|
||||
$curentry{'descr'} = $dhcpcn;
|
||||
$line = '';
|
||||
%failover = ();
|
||||
|
||||
while (($token = next_token (1)))
|
||||
{
|
||||
if ($token eq '}')
|
||||
{
|
||||
print_entry () if %curentry;
|
||||
if($current_dn =~ /.+?,\s*${dhcpdn}$/) {
|
||||
# don't go below dhcpdn ...
|
||||
remove_dn_from_stack ();
|
||||
}
|
||||
}
|
||||
elsif ($token eq 'subnet')
|
||||
{
|
||||
parse_subnet ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'shared-network')
|
||||
{
|
||||
parse_shared_network ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'class')
|
||||
{
|
||||
parse_class ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'subclass')
|
||||
{
|
||||
parse_subclass ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'pool')
|
||||
{
|
||||
parse_pool ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'group')
|
||||
{
|
||||
parse_group ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'host')
|
||||
{
|
||||
parse_host ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'hardware')
|
||||
{
|
||||
parse_hwaddress ();
|
||||
next;
|
||||
}
|
||||
elsif ($token eq 'range')
|
||||
{
|
||||
parse_range ();
|
||||
next;
|
||||
}
|
||||
else
|
||||
{
|
||||
parse_statement ($token);
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
close(STDIN) if($i_conf);
|
||||
close(STDOUT) if($o_ldif);
|
||||
|
||||
print STDERR "Done.\n";
|
||||
|
4
dhcpd.conf
Normal file
4
dhcpd.conf
Normal file
@ -0,0 +1,4 @@
|
||||
#
|
||||
# DHCP Server Configuration file.
|
||||
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
|
||||
#
|
Loading…
Reference in New Issue
Block a user