[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    ifupdown / udhcpc: override UDHCPC_CMD_OPTIONS, -n/-b mutually exclusive
From:       Michael Rendell <michael () mytelescope ! com>
Date:       2013-04-15 13:36:17
Message-ID: 20130415111817.4c04fa6d () sea ! tw ! teletrek ! com
[Download RAW message or body]

Hello,

  Had a need to remove the default "-n" flag that is passed to udhcpc
by ifup.  The patch below changes networking/udhcp/dhcpc.c to make
the -n and -b command line options mutually exclusive (two ways of
doing this, one via opt_complementary another by clearing OPT_n when
backgrounding).  The patch also changes networking/ifupdown.c to add
an optional udhcpc_def_opts interface parameter that can override the
compiled in default (UDHCPC_CMD_OPTIONS).

Best wishes,
Michael

--- busybox-1.19.4/networking/udhcp/dhcpc.c.Orig	2013-04-10 11:53:36.302705348 -0230
+++ busybox-1.19.4/networking/udhcp/dhcpc.c	2013-04-10 12:35:44.230219373 -0230
@@ -1082,8 +1082,8 @@
 	str_V = "udhcp "BB_VER;
 
 	/* Parse command line */
-	/* O,x: list; -T,-t,-A take numeric param */
-	opt_complementary = "O::x::T+:t+:A+"
+	/* O,x: list; -T,-t,-A take numeric param, only one of -n,-b */
+	opt_complementary = "O::x::T+:t+:A+:n-b:b-n"
 #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1
 		":vv"
 #endif
@@ -1283,7 +1283,7 @@
 					bb_info_msg("No lease, forking to background");
 					client_background();
 					/* do not background again! */
-					opt = ((opt & ~OPT_b) | OPT_f);
+					opt = ((opt & ~OPT_b & ~OPT_n) | OPT_f);
 				} else
 #endif
 				if (opt & OPT_n) { /* abort if no lease */
--- busybox-1.19.4/networking/ifupdown.c.Orig	2012-02-04 16:04:24.000000000 -0330
+++ busybox-1.19.4/networking/ifupdown.c	2013-04-10 14:29:47.896458346 -0230
@@ -188,6 +188,10 @@
 			return ifd->option[i].value;
 		}
 	}
+	/* Provide a default value for this. */
+	if (strncmpz(id, "udhcpc_def_opts", idlen) == 0) {
+		return UDHCPC_CMD_OPTIONS;
+	}
 	return NULL;
 }
 
@@ -534,7 +538,7 @@
 		"pump -i %iface% -k",
 	},
 	{ "udhcpc",
-		"udhcpc " UDHCPC_CMD_OPTIONS " -p /var/run/udhcpc.%iface%.pid -i %iface%[[ -H \
%hostname%]][[ -c %client%]]" +		"udhcpc %udhcpc_def_opts% -p \
/var/run/udhcpc.%iface%.pid -i %iface%[[ -H %hostname%]][[ -c %client%]]"  "[[ -s \
%script%]][[ %udhcpc_opts%]]",  "kill `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null",
 	},
@@ -573,7 +577,7 @@
 	if (!execute("ifconfig %iface%[[ hw %hwaddress%]] up", ifd, exec))
 		return 0;
 #  endif
-	return execute("udhcpc " UDHCPC_CMD_OPTIONS " -p /var/run/udhcpc.%iface%.pid "
+	return execute("udhcpc %udhcpc_def_opts% -p /var/run/udhcpc.%iface%.pid "
 			"-i %iface%[[ -H %hostname%]][[ -c %client%]][[ -s %script%]][[ %udhcpc_opts%]]",
 			ifd, exec);
 }

[end]

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic