Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 205286 - sys-apps/busybox: udhcpc applet not compatible with gentoo rc scripts
Summary: sys-apps/busybox: udhcpc applet not compatible with gentoo rc scripts
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal with 4 votes (vote)
Assignee: OpenRC Team
URL:
Whiteboard: openrc:oldnet:dhcp
Keywords:
Depends on:
Blocks: 295613
  Show dependency tree
 
Reported: 2008-01-11 10:30 UTC by Matthijs Kooijman
Modified: 2011-04-26 20:33 UTC (History)
14 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch against 1.7.4 (busybox-1.7.4-udhcpc-env.patch,3.76 KB, patch)
2008-01-11 10:32 UTC, Matthijs Kooijman
Details | Diff
busybox dhcp module, put into /lib/rcscripts/net (busybox.sh,3.99 KB, text/plain)
2009-01-05 12:05 UTC, jackieku
Details
busybox's udhcpc hook script, put into /lib/rcscripts/sh (udhcpc.sh,2.37 KB, text/plain)
2009-01-05 12:07 UTC, jackieku
Details
/lib/rc/net/busybox.sh for baselayout-2 (busybox.sh,2.73 KB, text/plain)
2009-01-05 17:16 UTC, jackieku
Details
busybox's udhcpc hook script (default.script,2.47 KB, text/plain)
2011-04-17 09:26 UTC, jackieku
Details
/lib/rc/net/busybox.sh for baselayout-2 (busybox.sh,2.60 KB, text/plain)
2011-04-17 09:30 UTC, jackieku
Details
udhcpc.sh (udhcpc.sh,2.57 KB, text/plain)
2011-04-21 23:36 UTC, William Hubbs
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthijs Kooijman 2008-01-11 10:30:46 UTC
The gentoo RC scripts (/lib/rcscripts/net/udhcpc.sh in baselayout-1 and /lib/rc/net/udhcpc.sh in baselayout-2) call udhcpc using the --env option. Busybox' udhcpc does not support this option. Currently, busybox cannot be used as a dhcp client on a Gentoo system. The attached patch adds the --env option and makes busybox work as a udhcpc replacement.

The udhcp ebuild has the same patch, in fact, the attached patch is fully based on  /usr/portage/net-misc/udhcp/files/udhcp-0.9.9_pre20041216-env.patch. The only changes are to account for busybox' different getopt and memory implementations.

I understand that this patch for the udhcpc ebuild will stay in portage because it was not accepted upstream. I expect the same will go for this patch, so I'm filing this report here instead of upstream.
Comment 1 Matthijs Kooijman 2008-01-11 10:32:22 UTC
Created attachment 140670 [details, diff]
Patch against 1.7.4

Patch was tested with 1.7.4. Also applies and compiles with 1.8.2, running was not tested.
Comment 2 solar (RETIRED) gentoo-dev 2008-01-13 19:46:05 UTC
Please send this patch upstream. Should make it a configurable option also.
Comment 3 Matthijs Kooijman 2008-01-13 20:19:21 UTC
I explicitely reported this bug here and not upstream. I found the original reference, which was from [1]

        # Setup options for the udhcpc script
        # This requires a specfic Gentoo patch to udhcp which will not
        # be accepted upstream.

Also, seeing that the equivalent patch to udhcpc (which essentially has the same codebase as busybox, and AFAIK the same maintainers) is also in Portage as a patch instead of upstream since april 2006, I think the place for this patch is in Gentoo.

However, since I can't seem to find any reference on busybox' and udhcp's bugtrackers, I'll see what upstream thinks of this patch.
[1]: http://archive.netbsd.se/?ml=gentoo-embedded&a=2007-10&m=5404844
Comment 4 Ed Wildgoose 2008-02-14 18:59:04 UTC
I second the addition of this patch.  It's already considered acceptable for udhcpc so it should pass the smell test to do the same patch for busybox

If upstream ever accept the patch already offered then great - in the meantime though lets not have half just half the ebuilds patched.

Basically if it's patched in one then I can't see any reason not to patch it for both ebuilds?
Comment 5 Nikos Chantziaras 2008-12-24 22:20:49 UTC
(In reply to comment #0)
> The gentoo RC scripts (/lib/rcscripts/net/udhcpc.sh in baselayout-1 and
> /lib/rc/net/udhcpc.sh in baselayout-2) call udhcpc using the --env option.

Shouldn't those RC scripts be patched not to use this option?  I imagine that's harder, but seems the correct way to do it. :P
Comment 6 Matthijs Kooijman 2008-12-25 11:11:05 UTC
It's been a while since I looked at this code, so I can't really recall why the --env option is needed at all.

I would agree that not using this option would be favorable (that would also allow the --env patch to be removed from the udhcp ebuild). However, I'm afraid that there is no other elegant way to solve whatever --env is trying to solve with existing udhcpc options. On the other hand, it's also not unlikely that this was just the first working solution and initially the --env patch was expected to be accepted upstream as well.

I can look into this a bit closer, but that won't be anytime soon. Also, I'm really not familiar with Gentoo, so fiddling around with internals like baselayout might not work out so great for me :-)
Comment 7 James Le Cuirot gentoo-dev 2009-01-01 12:33:22 UTC
This has become more important now because the standalone udhcp package has been masked.
Comment 8 the_mgt 2009-01-04 14:13:01 UTC
(In reply to comment #2)
> Please send this patch upstream. Should make it a configurable option also.
> 
- net-misc/udhcp-0.9.9_pre20041216-r4 (masked by: package.mask)
/usr/portage/profiles/package.mask:
# Diego Pettenò <flameeyes@gentoo.org> (23 Dec 2008)
# Mask these for removal, busybox provides those already, and are
# unmaintained. As requested by solar.

Why do you request masking and removal of this package while you know that busybox is NOT compatible to the stand alone udhcp ebuild?!

The Gentoo installation manual explicitly listed udhcp as an alternative for smaller systems and I did choose it therefor on purpose. Now I tried to just unmerge udhcp, since the message sounded as if busybox will just do the job "out of the box", but it doesn't.
Would you please stop marking packages for removal and commiting changes to portage BEFORE a proper solution is around?! Thanks...
Comment 9 James Le Cuirot gentoo-dev 2009-01-04 14:24:35 UTC
It's also worth noting that the udhcp package provides a DHCP server, which busybox doesn't. I'm using dnsmasq for a server instead so I'm not too bothered but some people may want this server.
Comment 10 jackieku 2009-01-05 02:57:34 UTC
Current udhcpc in busybox has some new options (-O|--request-option), maybe it can be used to replace --env. At least it can be configured not to request DNS, NTP, routers from server. However, /lib/rcscripts/net/udhcpc.sh also use --env to set to interface metric. I think patches for busybox is not strictly required since the udhcpc hook script can read configurations from /etc/conf.d/net. In other words, read the extra configurations in /lib/rcscript/sh/udhcpc.sh instead of /lib/rcscript/bin/udhcpc.sh.

BTW, /lib/rcscript/sh/udhcpc.sh is a part of net-misc/udhcp, which is masked for removal. But busybox isn't shipped with it..., as busybox is a member of "system" set. Shouldn't it be the default dhcp client for baselayout?
Comment 11 jackieku 2009-01-05 12:05:38 UTC
Created attachment 177461 [details]
busybox dhcp module, put into /lib/rcscripts/net
Comment 12 jackieku 2009-01-05 12:07:25 UTC
Created attachment 177462 [details]
busybox's udhcpc hook script, put into /lib/rcscripts/sh
Comment 13 jackieku 2009-01-05 12:14:56 UTC
(In reply to comment #9)
> It's also worth noting that the udhcp package provides a DHCP server, which
> busybox doesn't. I'm using dnsmasq for a server instead so I'm not too bothered
> but some people may want this server.
busybox has the server, but the official portage tree disables it by default.

I add two attachments, it works with current busybox without patches. This stuff is likely existed before, since there are some codes remains in current baselayout. Even it created temporary files, but I think it not so bad.

to test this stuff
add something like this in /etc/conf.d/net

modules=( "busybox" )
config_eth0=( "dhcp" )
busybox_eth0="..." # extra options passed to busybox udhcpc
Comment 14 the_mgt 2009-01-05 12:51:34 UTC
> to test this stuff
> add something like this in /etc/conf.d/net
> 
> modules=( "busybox" )
> config_eth0=( "dhcp" )
> busybox_eth0="..." # extra options passed to busybox udhcpc

I wanted to test the stuff, unmerged udhcp an used the two files you provided. I put the first two config lines into my net config. I did not get any errors, but I also did not get any IP address, sadly. But thanks for your effort!
Comment 15 jackieku 2009-01-05 13:15:03 UTC
(In reply to comment #14)
> I wanted to test the stuff, unmerged udhcp an used the two files you provided.
> I put the first two config lines into my net config. I did not get any errors,
> but I also did not get any IP address, sadly. But thanks for your effort!

hmm, it's so bad. I tested with baselayout-1.12.11.1 and busybox-1.12.2-r1 without problems. You say you didn't get errors, it's quite strange. May be you could turn on verbose output for /etc/init.d/net.*, it will report what modules is used.
Comment 16 James Le Cuirot gentoo-dev 2009-01-05 14:01:23 UTC
jackieku, you need to redo those for more recent versions. baselayout-2 is very different, primarily because it uses OpenRC. The scripts now go in /lib/rc and bash has been dropped in favour of sh.
Comment 17 jackieku 2009-01-05 14:50:39 UTC
(In reply to comment #16)
> jackieku, you need to redo those for more recent versions. baselayout-2 is very
> different, primarily because it uses OpenRC. The scripts now go in /lib/rc and
> bash has been dropped in favour of sh.
It's sound so bad, I really like bash. :) And I really don't like update to baselayout-2 now until it is stabilized (it seems downgrade back to baselayout-1 needs a lot of works). Anyway, I'll try in a VM, thank for you hints.

PS. Does it mean all script in /etc/init.d can not written in bash? so sad...
Comment 18 James Le Cuirot gentoo-dev 2009-01-05 14:56:33 UTC
It's not as bad as it sounds but I'm not going to get into that debate! I'd be lying if I said I hadn't had a couple of issues with OpenRC but I do like it overall and it's blazingly fast. Not sure about the other init.d scripts but I think that may be the case.
Comment 19 jackieku 2009-01-05 17:16:39 UTC
Created attachment 177485 [details]
/lib/rc/net/busybox.sh for baselayout-2
Comment 20 jackieku 2009-01-05 17:35:57 UTC
I added another attachment for baselayout-2, which uses the same udhcpc.sh file, but it should be placed in /lib/rc/sh instead.

There are some options for passing extra options from /etc/conf.d/net to udhcpc hook script. First, we can create temporary as the attachments. Second, just do "source /etc/conf.d/net" in udhcpc.sh, thank for baselayout-2, it even doesn't need bash. The last option is patching busybox as someone does before, in my opinion, it should be worst choice.

I have no idea about which one should be used, discussion required.
Comment 21 James Le Cuirot gentoo-dev 2009-01-06 11:10:47 UTC
That works for me. Note that you have to make udhcpc.sh executable or it won't work.
Comment 22 the_mgt 2009-01-07 10:53:35 UTC
Ok, shame on me!

I was too utterly stupid to make those shell scripts executable...
After chmodding them it works as intended!

Thanks for the files and the advice!
Comment 23 the_mgt 2010-04-09 09:36:59 UTC
Why isnt this in portage yet? I just installed a new system and omitted any dhcp package because I thought this method would be the default.... But no, it still isn't!

Please include these files in baselayout and make busybox the default fallback dhcp and a lot of people will love you. Thanks

PS: I tried this with baselayout2 and it just works.
Comment 24 solar (RETIRED) gentoo-dev 2010-04-09 15:29:43 UTC
base-system.. Please look over this bug.
Comment 25 Bjoern Ottervik 2010-09-04 20:33:36 UTC
Dear dudes and dudesses. This bug is now quite old and patches have been provided. If I remember correctly, udhcpcd was taken out of the tree with busybox as the suggested replacement. What's up here?

This is a situation where every stage3 ships with a perfectly adequate DHCP client, yet the official docs suggest manually and redundantly installing something as basic, just because already written patches to have it actually work are never commited.
The absurdity of it all struck me recently when carelessly removing networkmanager temporarely left me without a functioning DHCP client. 'Wait,' i thunk, 'what about busybox's?' - and so to this bug. If DHCP can be made to work out of the box without wasting a single byte, why isnt it already?
Comment 26 James Le Cuirot gentoo-dev 2010-09-04 21:20:04 UTC
It would be nice to get this sorted before baselayout-2 is marked stable, which should be happening soon.
Comment 27 the_mgt 2010-09-05 09:04:25 UTC
(In reply to comment #25)
> Dear dudes and dudesses. This bug is now quite old and patches have been
> provided. If I remember correctly, udhcpcd was taken out of the tree with
> busybox as the suggested replacement. What's up here?
> 
> This is a situation where every stage3 ships with a perfectly adequate DHCP
> client, yet the official docs suggest manually and redundantly installing
> something as basic, just because already written patches to have it actually
> work are never commited.
> The absurdity of it all struck me recently when carelessly removing
> networkmanager temporarely left me without a functioning DHCP client. 'Wait,' i
> thunk, 'what about busybox's?' - and so to this bug. If DHCP can be made to
> work out of the box without wasting a single byte, why isnt it already?
> 

Yes, totally agreed. FIVE MONTH AGO, I did not have the patience to write it down in this polite manner anymore. Now, for crying out loud, is it possible that somebody takes some action and just copies the files needed to the appropriate package, PLEASE? This just adds a feature almost everybody wants, it does not add any dangerous behaviour or eats kittens... Those who do not want this can still add a static ip manually, why this procrastination?!

And to the other people on the CC list: maybe it helps if you vote for this bug. Thanks
Comment 28 Bjoern Ottervik 2010-12-26 20:33:43 UTC
This is beyond ridiculous, people... At least give _some_ form of explaination as to what exactly is wrong with the proposed patches, that keeps them from being applied.
Comment 29 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2010-12-26 23:19:11 UTC
solar, Matthijs:
Matthijs said he mailed upstream about it, but the link he provided no longer works. Did upstream reject the busybox patch, and if so, why? Alternatively, did it just get dropped and lost?

Matthijs:
Can you please update your patch for the latest busybox?
Comment 30 Matthijs Kooijman 2010-12-27 15:28:29 UTC
I've never actually mailed upstream about the patch I think. I did ask on IRC, but never got a meaninful reply.

I think the link I gave in my first comment was to this post:
http://www.mail-archive.com/gentoo-embedded@lists.gentoo.org/msg02029.html

Which contains a comment that implies that udhcp's upstream had already rejected the patch.


Anyway, I don't have any Gentoo systems running anymore, so I won't be able to invest more work in this report. If anyone else wants to test and possibly update the patch, or contact upstream (seems busybox and udhcpc have the same upstream developers?), feel free to do so.

Btw, after rereading all the comments in this report it seems jackieku created an alternative solution that doesn't require patching busybox / udhcpc. Perhaps that's a better approach? Seem Comment #10 and comment #20.
Comment 31 the_mgt 2011-01-02 22:40:43 UTC
NO PATCHING NEEDED! 

With jackieku's solution. Just copy the *.sh to the correct places and instant dhcp is avaiable in Gentoo OOB.

As the previous poster wrote (and i omitted in my earlier rantings, sorry for that), it is all done with https://bugs.gentoo.org/show_bug.cgi?id=205286#c10 and https://bugs.gentoo.org/show_bug.cgi?id=205286#c20

To repeat it in other words: All you need to add are two scripts to the system (with different versions of busybox.sh for the different baselayouts!). NO PATCHING, no talk to upstream, no problem. I tested it on 32bit systems with baselayout-1 and -2, also I use it currently on my amd64 system with baselayout-2.

I just stumbled over it again on a VM install of Gentoo...

PS: busybox does not need to be patched in order to get this working, only two simple scripts!
Comment 32 Jérôme Poulin 2011-01-31 01:42:00 UTC
I'd really like to see that, dhcpcd does not handle --request correctly and fails to keep my IP, what I'd need to busybox udhcpc which I failed to have working corretly with Gentoo's networking. Then I searched and found this bug which makes me think it is patched for 2 years but not yet pulled... what a waste...
Comment 33 Adeel 2011-04-13 04:39:17 UTC
nice to know that a fix to a bug that's over 3 and half years old is still not applied as of yet....
Comment 34 Adeel 2011-04-13 16:33:05 UTC
actually, as it turns out, you also need to add the sample.* files from busybox tarball (e.g. busybox-1.18/examples/udhcpc/sample.*) to /lib/rcscripts/sh/ and rename them all to udhcpc.* before this works...otherwise, the address never actually gets bound to the interface
Comment 35 William Hubbs gentoo-dev 2011-04-14 02:36:03 UTC
(In reply to comment #34)
> actually, as it turns out, you also need to add the sample.* files from busybox
> tarball (e.g. busybox-1.18/examples/udhcpc/sample.*) to /lib/rcscripts/sh/ and
> rename them all to udhcpc.* before this works...otherwise, the address never
> actually gets bound to the interface

What about putting them, say, in /usr/share/busybox/udhcpc? I think that is a better location since they are part of the busybox package and not part of openrc.

Can you do that and attach the module with those modifications?
Comment 36 jackieku 2011-04-17 09:26:52 UTC
Created attachment 270243 [details]
busybox's udhcpc hook script

This is the script which actuality configure the network interface, nameservers, and routes, which is called by udhcpc.
The default path of this script is /usr/share/udhcpc/default.script. (see busybox udhcpc --help)
Comment 37 jackieku 2011-04-17 09:30:20 UTC
Created attachment 270247 [details]
/lib/rc/net/busybox.sh for baselayout-2

Do not use /lib/rc/sh.
Comment 38 William Hubbs gentoo-dev 2011-04-21 18:46:08 UTC
I may be able to encorporate the hook script directly into openrc after
all, let me take a look and I'll report back on this bug.
Comment 39 William Hubbs gentoo-dev 2011-04-21 23:36:18 UTC
Created attachment 270817 [details]
udhcpc.sh

I don't think we need a separate module for busybox since udhcpc doesn't
exist now in favor of the busybox applet, so I took your busybox.sh
module and used it as a template to update the udhcpc module.

Also, your hook script will be encorporated into openrc as
${RC_LIBEXECDIR}/rc/udhcpc-hook.sh.

Can you please do the following:

1) remove your busybox.sh module and replace the udhcpc module with this
one.
2) put the hook script in the appropriate location.
3) Test and make sure this setup works.

Also, I would prefer not to use temporary files, so can you please
explain what changes I need to make to the module and the hook script so
that this is not necessary?

Thanks,

William
Comment 40 jackieku 2011-04-22 00:32:53 UTC
(In reply to comment #39)
> Also, I would prefer not to use temporary files, so can you please
> explain what changes I need to make to the module and the hook script so
> that this is not necessary?

As I explained in comment #10, that will require you make the udhcpc hook script can know the magic (PEER_DNR, PEER_NTP, etc) of openrc by itself without the temporary files. Perhaps by parsing the /etc/conf.d/net or some functions provided by openrc that I don't know (I'm not openrc expert).

But I didn't think of there may be a inconsistent issue when I made the comment #10. As the user may modify /etc/conf.d/net after udhcpc start but before the hook script is called, and the hook script will be called by udhcpc multiple times.

Our old way is patching udhcpc, but the patch has been reject by upstream IIRC.
Comment 41 William Hubbs gentoo-dev 2011-04-26 20:33:50 UTC
Commit b712a91 fixes the udhcpc support in openrc to work with busybox
udhcpc. This will be included in openrc-0.8.3.