Package: dhcp3-client
Version: 3.0.1-1
Severity: wishlist
Tags: patch

This is a patch to allow dhclient3 to eXit gracefully without releasing
its current lease and still run the dhclient-script with reason=STOP.

The main reason for this patch is #246621 and its sibling #196865.

Regards
 /Jocke

-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.10-1-k7
Locale: LANG=en_US.ISO-8859-15, LC_CTYPE=en_US.ISO-8859-15 (charmap=ISO-8859-15)

Versions of packages dhcp3-client depends on:
ii  debconf                     1.4.30.11    Debian configuration management sy
ii  debianutils                 2.8.4        Miscellaneous utilities specific t
ii  dhcp3-common                3.0.1-1      Common files used by all the dhcp3
ii  libc6                       2.3.2.ds1-20 GNU C Library: Shared libraries an
--- dhclient.c.orig	2005-02-13 02:18:27.000000000 +0100
+++ dhclient.c	2005-02-13 02:10:51.000000000 +0100
@@ -78,6 +78,7 @@
 static void usage PROTO ((void));
 
 void do_release(struct client_state *);
+void state_stop (void *);
 
 int main (argc, argv, envp)
 	int argc;
@@ -91,6 +92,7 @@
 	char *server = (char *)0;
 	char *relay = (char *)0;
 	isc_result_t status;
+        int exit_mode = 0;
 	int release_mode = 0;
 	omapi_object_t *listener;
 	isc_result_t result;
@@ -141,6 +143,10 @@
 		if (!strcmp (argv [i], "-r")) {
 			release_mode = 1;
 			no_daemon = 1;
+                } else if (!strcmp (argv [i], "-x")) { /* eXit, no release */
+                        release_mode = 0;
+                        no_daemon = 0;
+                        exit_mode = 1;
 		} else if (!strcmp (argv [i], "-p")) {
 			if (++i == argc)
 				usage ();
@@ -241,7 +247,7 @@
 	}
 
 	/* first kill of any currently running client */
-	if (release_mode) {
+	if (release_mode || exit_mode) {
 		FILE *pidfd;
 		pid_t oldpid;
 		long temp;
@@ -365,7 +371,7 @@
 			log_info ("No broadcast interfaces found - exiting.");
 			exit (0);
 		}
-	} else if (!release_mode) {
+	} else if (!release_mode && !exit_mode) {
 		/* Call the script with the list of interfaces. */
 		for (ip = interfaces; ip; ip = ip -> next) {
 			/* If interfaces were specified, don't configure
@@ -411,7 +417,9 @@
 	for (ip = interfaces; ip; ip = ip -> next) {
 		ip -> flags |= INTERFACE_RUNNING;
 		for (client = ip -> client; client; client = client -> next) {
-			if (release_mode)
+                        if (exit_mode)
+                                state_stop (client);
+                        else if (release_mode)
 				do_release (client);
 			else {
 				client -> state = S_INIT;
@@ -423,7 +431,7 @@
 		}
 	}
 
-	if (release_mode)
+	if (release_mode || exit_mode)
 		return 0;
 
 	/* Start up a listener for the object management API protocol. */

Reply via email to