PATCH: ifupdown.c, udhcpc, and standalone shell
Gabriel L. Somlo
somlo at cmu.edu
Mon Sep 25 20:26:11 UTC 2006
I'm using busybox 1.2.1, with CONFIG_FEATURE_SH_STANDALONE_SHELL
turned on so the shell will execute any applets without needing
symlinks.
However, when configuring an interface in /etc/network/interfaces
with dhcp, ifupdown explicitly checks for '/sbin/udhcpc', and if it
can't find it (or any other dhcp client) prints a rather misleading
error message:
'ifup: Don't seem to have all the variables for eth0/inet.'
The attached patch removes the check for '/sbin/udhcpc', and simply
attempts to execute it as a last-resort option. If any other of the
candidate dhcp clients is present, it is used instead. If not, and
udhcpc isn't built into busybox, we get a more useful error message
stating that the shell couldn't find udhcpc.
Please apply, or let me know if I should file this via the bugtracker
instead.
Thanks much,
Gabriel
-------------- next part --------------
diff -NarU5 busybox-1.2.1.orig/networking/ifupdown.c busybox-1.2.1/networking/ifupdown.c
--- busybox-1.2.1.orig/networking/ifupdown.c 2006-06-30 18:42:02.000000000 -0400
+++ busybox-1.2.1/networking/ifupdown.c 2006-09-25 15:10:46.000000000 -0400
@@ -464,39 +464,39 @@
return(0);
}
static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
{
- if (execable("/sbin/udhcpc")) {
- return( execute("udhcpc -n -p /var/run/udhcpc.%iface%.pid -i "
- "%iface% [[-H %hostname%]] [[-c %clientid%]]", ifd, exec));
- } else if (execable("/sbin/pump")) {
+ if (execable("/sbin/pump")) {
return( execute("pump -i %iface% [[-h %hostname%]] [[-l %leasehours%]]", ifd, exec));
} else if (execable("/sbin/dhclient")) {
return( execute("dhclient -pf /var/run/dhclient.%iface%.pid %iface%", ifd, exec));
} else if (execable("/sbin/dhcpcd")) {
return( execute("dhcpcd [[-h %hostname%]] [[-i %vendor%]] [[-I %clientid%]] "
"[[-l %leasetime%]] %iface%", ifd, exec));
+ } else { /* fall back to built-in udhcpc */
+ return( execute("udhcpc -n -p /var/run/udhcpc.%iface%.pid -i "
+ "%iface% [[-H %hostname%]] [[-c %clientid%]]", ifd, exec));
}
return(0);
}
static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
{
int result = 0;
- if (execable("/sbin/udhcpc")) {
- /* SIGUSR2 forces udhcpc to release the current lease and go inactive,
- * and SIGTERM causes udhcpc to exit. Signals are queued and processed
- * sequentially so we don't need to sleep */
- result = execute("kill -USR2 `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
- result += execute("kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
- } else if (execable("/sbin/pump")) {
+ if (execable("/sbin/pump")) {
result = execute("pump -i %iface% -k", ifd, exec);
} else if (execable("/sbin/dhclient")) {
result = execute("kill -9 `cat /var/run/dhclient.%iface%.pid` 2>/dev/null", ifd, exec);
} else if (execable("/sbin/dhcpcd")) {
result = execute("dhcpcd -k %iface%", ifd, exec);
+ } else { /* fall back to built-in udhcpc */
+ /* SIGUSR2 forces udhcpc to release the current lease and go inactive,
+ * and SIGTERM causes udhcpc to exit. Signals are queued and processed
+ * sequentially so we don't need to sleep */
+ result = execute("kill -USR2 `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
+ result += execute("kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
}
return (result || static_down(ifd, exec));
}
static int bootp_up(struct interface_defn_t *ifd, execfn *exec)
More information about the busybox
mailing list