non-busybox dhcp clients (was: PATCH: ifupdown.c, udhcpc, and standalone shell)
Denis Vlasenko
vda.linux at googlemail.com
Wed Oct 11 22:16:43 UTC 2006
On Tuesday 10 October 2006 17:52, Gabriel L. Somlo wrote:
> Denis,
>
> I just realized that my 'execable' patch was done before the migration
> to kbuild, so here it goes again.
>
> First three diffs add execable to libbb (execable.c, libbb.h, and
> libbb/Kbuild)
+ char *path = xstrdup(getenv("PATH"));
What if getenv returns NULL?
+ char *p, *n, *r, *ret = NULL;
+
+ p = path;
+ while (p) {
+ n = strchr(p, ':');
+ if (n)
+ *n++ = '\0';
+ if (*p != '\0') { /* handle PATH=":foo::bar:" situation */
+ r = concat_path_file(p, filename);
+ if (execable_file(r)) {
+ ret = r;
+ break;
+ }
+ free(r);
+ }
+ p = n;
+ }
+ if (path)
+ free(path);
path is always !NULL.
+ return ret;
>
> Next diff modifies ifupdown.c to use udhcpc if built-in or find an
> external client by searching the $PATH using execable.
+ bb_error_msg("No dhcp clients found.");
bb_error_msg("no dhcp clients found") because it really prints:
<applet>: no dhcp clients found
> Last diff is against debianutils/which.c and makes it much simpler and
> more readable by calling execable to find things in $PATH.
+ if ((p = find_execable(*argv)))
Obfuscated C contest again.
> Please apply.
Applied. Please test svn version.
--
vda
More information about the busybox
mailing list