non-busybox dhcp clients (was: PATCH: ifupdown.c, udhcpc, and standalone shell)

Denis Vlasenko vda.linux at googlemail.com
Tue Oct 3 12:44:06 PDT 2006


On Tuesday 03 October 2006 20:43, Eric Spakman wrote:
> Hi Gabriel,
> 
> That would make me and the LEAF project very happy ;-)

But the patch is _technically incorrect_, that's the point.

> > +#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
....
> > +#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("pump -i %iface% [[-h %hostname%]] [[-l %leasehours%]]",
> > +			ifd, exec);

What if I have pump in /usr/local/bin? It will not work.

I _hate_ systems with scripts riddled with "/usr/bin/something" instead
of just "something". $PATH is there for a reason, guys.

If you want to make calls to non-installed software to fail silently,
maybe do this?

type pump >/dev/null 2>&1  &&  pump ....

(type is a shell builtin which says whether blah will be executed or not...
dunno whether it is bashism or what...)

bash-3.00# type firefox && echo "OK"
firefox is /usr/bin/firefox
OK
bash-3.00# type bogon && echo "OK"
bash: type: bogon: not found
bash-3.00# type /etc/passwd && echo "OK"
bash: type: /etc/passwd: not found
bash-3.00# type type && echo "OK"
type is a shell builtin
OK


--
vda


More information about the busybox mailing list