[BusyBox] udhp/dhcpd.c (lost/rejected) patch

Doug Kehn rdkehn at yahoo.com
Tue Dec 14 16:03:41 UTC 2004


--- Paul Fox wrote:

> typo alert:
> 
>  > +
>  > +	static const struct option arg_options[] = {
>  > +		{"forground", no_argument, 0, 'f'},
>                   ^^^^^^^^^
> 

Need more coffee!!  Thanks Paul.  Corrected patch
below...

--- busybox/networking/udhcp/dhcpd.c.orig	2004-11-28
20:55:24.000000000 -0500
+++ busybox/networking/udhcp/dhcpd.c	2004-12-14
07:58:13.000000000 -0500
@@ -35,6 +35,7 @@
 #include <sys/ioctl.h>
 #include <time.h>
 #include <sys/time.h>
+#include <getopt.h>
 
 #include "dhcpd.h"
 #include "arpping.h"
@@ -74,6 +75,32 @@
 	unsigned long num_ips;
 
 	uint32_t static_lease_ip;
+	int daemonize = 1;
+
+	static const struct option arg_options[] = {
+		{"foreground", no_argument, 0, 'f'},
+		{0, 0, 0, 0}
+	};
+
+	/* get options */
+	while (1) {
+		int option_index = 0;
+		int c = getopt_long(argc, argv, "f", arg_options,
&option_index);
+		if (c == -1) {
+			argv += optind - 1;
+			argc -= optind - 1;
+			break;
+		}
+
+		switch (c) {
+		case 'f':
+			daemonize = 0;
+			break;
+		default:
+			LOG(LOG_ERR, "unsupported option: %c", c);
+			break;
+		}
+	}
 
 	memset(&server_config, 0, sizeof(struct
server_config_t));
 	read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]);
@@ -104,7 +131,8 @@
 		return 1;
 
 #ifndef UDHCP_DEBUG
-	background(server_config.pidfile); /* hold lock
during fork. */
+	if (daemonize)
+		background(server_config.pidfile); /* hold lock
during fork. */
 #endif
 
 	/* Setup the signal pipe */


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail



More information about the busybox mailing list