Oops -- wrong patch
Gabriel L. Somlo
somlo at cmu.edu
Tue Oct 3 18:09:43 UTC 2006
This is the right patch -- sorry.
Thanks,
Gabriel
On Tue, Oct 03, 2006 at 02:04:43PM -0400, Gabriel L. Somlo wrote:
> So, I've included a patch against svn 16294 which causes ifupdown to
> do just that. I don't mind it, it would make Eric happy :) so unless
> you object to #ifdef's or, more importantly, the return of hardcoded
> paths, please apply it...
diff -NarU5 busybox-svn-16294.orig/networking/ifupdown.c busybox-svn-16294/networking/ifupdown.c
--- busybox-svn-16294.orig/networking/ifupdown.c 2006-10-03 13:01:04.000000000 -0400
+++ busybox-svn-16294/networking/ifupdown.c 2006-10-03 13:42:30.000000000 -0400
@@ -448,47 +448,66 @@
result += execute("ifconfig %iface% down", ifd, exec);
#endif
return ((result == 2) ? 2 : 0);
}
+#ifndef CONFIG_APP_UDHCPC
+/* only needed for hardcoded dhcp client checks if udhcpc not built in */
+static int execable(char *program)
+{
+ struct stat buf;
+ if (stat(program, &buf) == 0 &&
+ S_ISREG(buf.st_mode) && (S_IXUSR & buf.st_mode)) return 1;
+ return 0;
+}
+#endif
+
static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
{
- if (execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid -i %iface% "
- "[[-H %hostname%]] [[-c %clientid%]] [[-s %script%]]", ifd, exec))
- return 1;
-
- /* 2006-09-30: The following are deprecated, and should eventually be
- * removed. For non-busybox (i.e., other than udhcpc) clients, use
- * 'iface foo inet manual' in /etc/network/interfaces, and supply
- * start/stop commands explicitly via up/down. */
-
- if (execute("pump -i %iface% [[-h %hostname%]] [[-l %leasehours%]]",
- ifd, exec)) return 1;
- if (execute("dhclient -pf /var/run/dhclient.%iface%.pid %iface%",
- ifd, exec)) return 1;
- if (execute("dhcpcd [[-h %hostname%]] [[-i %vendor%]] [[-I %clientid%]] "
- "[[-l %leasetime%]] %iface%", ifd, exec)) return 1;
-
+#ifdef CONFIG_APP_UDHCPC
+ return execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid "
+ "-i %iface% [[-H %hostname%]] [[-c %clientid%]] [[-s %script%]]",
+ ifd, exec);
+#else
+ if (execable("/sbin/udhcpc"))
+ return execute("/sbin/udhcpc -R -n -p /var/run/udhcpc.%iface%.pid "
+ "-i %iface% [[-H %hostname%]] [[-c %clientid%]] [[-s %script%]]",
+ ifd, exec);
+ if (execable("/sbin/pump"))
+ return execute("/sbin/pump -i %iface% [[-h %hostname%]] [[-l %leasehours%]]",
+ ifd, exec);
+ if (execable("/sbin/dhclient"))
+ return execute("/sbin/dhclient -pf /var/run/dhclient.%iface%.pid %iface%",
+ ifd, exec);
+ if (execable("/sbin/dhcpcd"))
+ return execute("/sbin/dhcpcd [[-h %hostname%]] [[-i %vendor%]] "
+ "[[-I %clientid%]] [[-l %leasetime%]] %iface%",
+ ifd, exec);
+ bb_error_msg("No dhcp clients found.");
return 0;
+#endif
}
static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
{
- if (execute("kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null",
- ifd, exec)) return 1;
-
- /* 2006-09-30: The following are deprecated, and should eventually be
- * removed. For non-busybox (i.e., other than udhcpc) clients, use
- * 'iface foo inet manual' in /etc/network/interfaces, and supply
- * start/stop commands explicitly via up/down. */
-
- if (execute("pump -i %iface% -k", ifd, exec)) return 1;
- if (execute("kill -9 `cat /var/run/dhclient.%iface%.pid` 2>/dev/null",
- ifd, exec)) return 1;
- if (execute("dhcpcd -k %iface%", ifd, exec)) return 1;
-
+#ifdef CONFIG_APP_UDHCPC
+ return execute("kill -TERM "
+ "`cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
+#else
+ if (execable("/sbin/udhcpc"))
+ return execute("kill -TERM "
+ "`cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
+ if (execable("/sbin/pump"))
+ return execute("/sbin/pump -i %iface% -k", ifd, exec);
+ if (execable("/sbin/dhclient"))
+ return execute("kill -9 "
+ "`cat /var/run/dhclient.%iface%.pid` 2>/dev/null", ifd, exec);
+ if (execable("/sbin/dhcpcd"))
+ return execute("/sbin/dhcpcd -k %iface%", ifd, exec);
+ bb_error_msg("No dhcp clients found. Using static interface shutdown.");
return static_down(ifd, exec);
+#endif
}
static int manual_up_down(struct interface_defn_t *ifd, execfn *exec)
{
return 1;
More information about the busybox
mailing list