Bug 13096

Summary: Patch to make busybox build on Hurd
Product: Busybox Reporter: Michael Schierl <schierlm>
Component: OtherAssignee: unassigned
Status: VERIFIED FIXED    
Severity: minor CC: busybox-cvs
Priority: P5    
Version: 1.32.x   
Target Milestone: ---   
Hardware: All   
OS: Other   
Host: Target:
Build:
Attachments: Busybox patch
IP_PKTINFO patch

Description Michael Schierl 2020-07-18 21:26:13 UTC
Created attachment 8541 [details]
Busybox patch

For my Hurd rescue system, I decided to include busybox as it has many useful tools.

However, I ran into 4 small issues while compiling my desired collection of applets (other applets do not compile at all as they use Linux specific APIs, but that is fine as I can always exclude them from my busybox build).


PATH_MAX is undefined, which is used on the host to compute applet tables.
Work around it by simply defining it to 1024 if undefined.

LOGIN_NAME_MAX is undefined, which is used in die_if_bad_username.c. Conditionally exclude this check if undefined.

mailutils.c includes prctl.h, although only two applets (sendmail and popmaildir) need it.

RLIMIT_NICE is undefined on Hurd, which is used in shell_common.c. Note that I took the liberty to reorder the limits list so that LIMIT_F_IDX can always stay at 2.

Patch is attached, and also available from <https://github.com/schierlm/HurdRescue/blob/master/busybox-1.32.0-fixes.patch>. Config is available from <https://github.com/schierlm/HurdRescue/blob/master/busybox-1.32.0-.config>.
Comment 1 Denys Vlasenko 2020-12-17 12:19:04 UTC
(In reply to Michael Schierl from comment #0)
> RLIMIT_NICE is undefined on Hurd, which is used in shell_common.c. Note that I took the liberty to reorder the limits list so that LIMIT_F_IDX can always stay at 2.

This changes the order of "ulimit -a", which was matching bash.

I applied most of your fixes. Please try current git.
Comment 2 Michael Schierl 2020-12-17 14:55:26 UTC
Created attachment 8711 [details]
IP_PKTINFO patch
Comment 3 Michael Schierl 2020-12-17 14:56:02 UTC
As of commit cd48f0, compared to 1.32.0:

1) I needed to disable CONFIG_MAKEMIME and CONFIG_REFORMIME due to the not applied hunk to mailutils/mail.c, but I can live with that.

2) I also needed to disable CONFIG_FEATURE_DD_IBS_OBS as it depends on O_DIRECT, and I can also live with that

3) I can confirm that the limits work well and the order matches the order printed by bash (bash also prints -b and -p which are missing from busybox, but I can live wit that as well)

4) The biggest obstacle for me is that I also had to disable CONFIG_TRACEROUTE and CONFIG_TRACEROUTE6 which depend on IP_PKTINFO (even if that option is, if I can see correctly, only needed if CONFIG_FEATURE_TRACEROUTE_VERBOSE is active). I could live with a non-verbose traceroute, but having no traceroute at all is disappointing.

This can be worked around by disabling the corresponding setsockopts call if CONFIG_FEATURE_TRACEROUTE_VERBOSE is unset. Patch is attached.


The rest builds and (from a quick smoke test) works fine.
Comment 4 Denys Vlasenko 2020-12-17 16:52:40 UTC
(In reply to Michael Schierl from comment #3)
> I can confirm that the limits work well and the order matches the order printed by bash (bash also prints -b and -p which are missing from busybox, but I can live wit that as well)

My bash has no "ulimit -b". What is that?

> This can be worked around by disabling the corresponding setsockopts call if CONFIG_FEATURE_TRACEROUTE_VERBOSE is unset. Patch is attached.

Actually... we can disable much more for !VERBOSE case.
Comment 5 Michael Schierl 2020-12-17 19:09:51 UTC
I can confirm that it builds and runs fine as of commit ff4ca1.

-b is "socket buffer size" (RLIMIT_SBSIZE).

On Linux, my bash (binary) does not have it either. But it is in the source code: 

https://git.savannah.gnu.org/cgit/bash.git/tree/builtins/ulimit.def#n243

And you can see it live in action on Hurd, FreeBSD and maybe more OSes.