Patch dhcpd 3.0.X to ignore the uid sent by the client via the

client-uid off

option. This helps if you want dual boot windows/linux clients to acquire the
same IP. It also fixes the problem of DDNS updates failing since windows
clients don't release their DHCP lease properly upon shutdown.

diff -Naur -u bla/dhcp3-3.0.1/includes/dhcpd.h dhcp3-3.0.1/includes/dhcpd.h
--- bla/dhcp3-3.0.1/includes/dhcpd.h	2004-06-10 19:59:29.000000000 +0200
+++ dhcp3-3.0.1/includes/dhcpd.h	2005-05-17 13:02:20.000000000 +0200
@@ -412,6 +412,7 @@
 #define SV_UPDATE_STATIC_LEASES		43
 #define SV_LOG_FACILITY			44 #define SV_DO_FORWARD_UPDATES		45
 #define SV_PING_TIMEOUT         46
+#define SV_CLIENT_UID			47
 
 #if !defined (DEFAULT_PING_TIMEOUT)
 # define DEFAULT_PING_TIMEOUT 1
diff -Naur -u bla/dhcp3-3.0.1/includes/dhctoken.h dhcp3-3.0.1/includes/dhctoken.h
--- bla/dhcp3-3.0.1/includes/dhctoken.h	2004-06-10 19:59:30.000000000 +0200
+++ dhcp3-3.0.1/includes/dhctoken.h	2005-05-17 13:05:40.000000000 +0200
@@ -307,7 +307,8 @@
 	REMOVE = 611,
 	REFRESH = 612,
 	DOMAIN_NAME = 613,
-	DO_FORWARD_UPDATE = 614
+	DO_FORWARD_UPDATE = 614,
+	CLIENT_UID = 615,
 };
 
 #define is_identifier(x)	((x) >= FIRST_TOKEN &&	\
diff -Naur -u bla/dhcp3-3.0.1/server/confpars.c dhcp3-3.0.1/server/confpars.c
--- bla/dhcp3-3.0.1/server/confpars.c	2004-06-10 19:59:51.000000000 +0200
+++ dhcp3-3.0.1/server/confpars.c	2005-05-17 13:01:10.000000000 +0200
@@ -3288,6 +3288,12 @@
 				       MDL);
 		break;
 
+	      case CLIENT_UID:
+		status = option_cache (oc, (struct data_string *)0, data,
+				       &server_options [SV_CLIENT_UID],
+				       MDL);
+		break;
+
 	      default:
 		parse_warn (cfile, "expecting allow/deny key");
 		skip_to_semi (cfile);
diff -Naur -u bla/dhcp3-3.0.1/server/stables.c dhcp3-3.0.1/server/stables.c
--- bla/dhcp3-3.0.1/server/stables.c	2004-06-10 19:59:58.000000000 +0200
+++ dhcp3-3.0.1/server/stables.c	2005-05-17 12:56:25.000000000 +0200
@@ -483,7 +483,7 @@
 	{ "log-facility", "Nsyslog-facilities.",	&server_universe, 44 },
 	{ "do-forward-updates", "f",			&server_universe, 45 },
 	{ "ping-timeout", "T",				&server_universe, 46 },
-	{ "unknown-47", "X",				&server_universe, 47 },
+	{ "client-uid", "f",				&server_universe, 47 },
 	{ "unknown-48", "X",				&server_universe, 48 },
 	{ "unknown-49", "X",				&server_universe, 49 },
 	{ "unknown-50", "X",				&server_universe, 50 },
diff -Naur -u bla/dhcp3-3.0.1/includes/dhcpd.h dhcp3-3.0.1/includes/dhcpd.h
--- bla/dhcp3-3.0.1/includes/dhcpd.h	2004-06-10 19:59:29.000000000 +0200
+++ dhcp3-3.0.1/includes/dhcpd.h	2005-05-17 13:59:39.000000000 +0200
@@ -1119,6 +1119,7 @@
 extern TIME cur_time;
 
 int ddns_update_style;
+extern int client_uid;
 
 extern const char *path_dhcpd_conf;
 extern const char *path_dhcpd_db;
diff -Naur -u bla/dhcp3-3.0.1/server/ddns.c dhcp3-3.0.1/server/ddns.c
--- bla/dhcp3-3.0.1/server/ddns.c	2004-06-17 22:54:40.000000000 +0200
+++ dhcp3-3.0.1/server/ddns.c	2005-05-17 13:59:39.000000000 +0200
@@ -519,7 +519,7 @@
 	 */
 	if (server_updates_a) {
 		memset (&ddns_dhcid, 0, sizeof ddns_dhcid);
-		if (lease -> uid && lease -> uid_len)
+		if ( client_uid && lease -> uid && lease -> uid_len)
 			result = get_dhcid (&ddns_dhcid,
 					    DHO_DHCP_CLIENT_IDENTIFIER,
 					    lease -> uid, lease -> uid_len);
diff -Naur -u bla/dhcp3-3.0.1/server/dhcpd.c dhcp3-3.0.1/server/dhcpd.c
--- bla/dhcp3-3.0.1/server/dhcpd.c	2004-07-10 02:11:18.000000000 +0200
+++ dhcp3-3.0.1/server/dhcpd.c	2005-05-17 13:57:37.000000000 +0200
@@ -145,6 +145,7 @@
 }";
 
 int ddns_update_style;
+int client_uid;
 #endif /* NSUPDATE */
 
 const char *path_dhcpd_conf = _PATH_DHCPD_CONF;
@@ -614,7 +615,7 @@
 	char *s;
 	isc_result_t result;
 	struct parse *parse;
-	int tmp;
+	int tmp, ignorep;
 
 	/* Now try to get the lease file name. */
 	option_state_allocate (&options, MDL);
@@ -809,6 +809,22 @@
 		}
 	}
 
+#if defined (NSUPDATE)
+	/* Should we use the client uid for ddns updates? */
+	oc = lookup_option (&server_universe, options,
+			    SV_CLIENT_UID);
+	if (oc) {
+	    client_uid = evaluate_boolean_option_cache(&ignorep,
+		                                       (struct packet *)0,
+				   	               (struct lease *)0, 
+						       (struct client_state *)0,
+				                       options, (struct option_state *)0,
+				                       &global_scope, oc, MDL);
+	} else {
+	     client_uid = 1;
+	}
+	log_info ("%s client-uid for ddns updates\n", client_uid ? "Using" : "Ignoring");
+#endif
 	/* Don't need the options anymore. */
 	option_state_dereference (&options, MDL);

--- dhcp3-3.0.1/server/dhcp.c.agx	2005-08-08 14:43:31.000000000 +0200
+++ dhcp3-3.0.1/server/dhcp.c	2005-08-08 19:22:03.000000000 +0200
@@ -697,7 +697,7 @@
 	oc = lookup_option (&dhcp_universe, packet -> options,
 			    DHO_DHCP_CLIENT_IDENTIFIER);
 	memset (&data, 0, sizeof data);
-	if (oc &&
+	if (oc && client_uid &&
 	    evaluate_option_cache (&data, packet, (struct lease *)0,
 				   (struct client_state *)0,
 				   packet -> options, (struct option_state *)0,
@@ -1731,7 +1731,7 @@
 		   can be used. */
 		oc = lookup_option (&dhcp_universe, packet -> options,
 				    DHO_DHCP_CLIENT_IDENTIFIER);
-		if (oc &&
+		if (oc && client_uid &&
 		    evaluate_option_cache (&d1, packet, lease,
 					   (struct client_state *)0,
 					   packet -> options, state -> options,
@@ -2089,7 +2089,7 @@
 	/* Record the uid, if given... */
 	oc = lookup_option (&dhcp_universe, packet -> options,
 			    DHO_DHCP_CLIENT_IDENTIFIER);
-	if (oc &&
+	if (oc && client_uid &&
 	    evaluate_option_cache (&d1, packet, lease,
 				   (struct client_state *)0,
 				   packet -> options, state -> options,
@@ -2943,7 +2943,7 @@
 	oc = lookup_option (&dhcp_universe, packet -> options,
 			    DHO_DHCP_CLIENT_IDENTIFIER);
 	memset (&client_identifier, 0, sizeof client_identifier);
-	if (oc &&
+	if (oc && client_uid &&
 	    evaluate_option_cache (&client_identifier,
 				   packet, (struct lease *)0,
 				   (struct client_state *)0,
