[PATCH] Compress common substrings in applet names to save space

Tito farmatito at tiscali.it
Thu Apr 21 19:06:39 UTC 2016



On 04/21/2016 06:02 PM, Denys Vlasenko wrote:
> On Wed, Apr 20, 2016 at 5:15 PM, Ron Yorston <rmy at pobox.com> wrote:
>> Denys Vlasenko wrote:
>>> Downside: "busybox BOGUSNAME" has a small chance of actually working
>>> as some applet, if hash(BOGUSNAME) is matching something.
>>
>> Whatever you do, don't run 'busybox rwok -rf /'.
>
> Exactly.
>
> But that in real world usage is not much of a problem.
> Chances of mistakenly typing "busybox rwok -rf /" are about the same
> as chances of mistakenly typing "busybox rm -rf /".

Hi,
you forget Murphy's law....
I still wonder if all this machinery is really needed
just to remove the applets name table which was the
cleanest solution in this case.
It looks to me that we are doing this just because we can and
accept by the way chances of the user mistankenly typing
this or that or small chances of collisions...
Why not use:

handle = dlopen(NULL, RTLD_LAZY);
asprintf(&function_name, "%s_main", argv[0]);
*(void **) (&function_main) = dlsym(handle, function_name);

its as exotic and needs no table at all and has no chances of chances
;-)

> More importantly, people aren't typically type "busybox foo ..." -
> they rely on symlinked names and they just type "foo ...".
> And there is no "rwok" symlink. "rwok -rf /" won't work.
>
> This patch amounts to inventing a poor man's Lempel-Ziv
> for applet names, and the logical step is just to use gzip
> (since we have its decompressor anyway).
>
> There is a case when applet names are not necessary at all.
> They are needed for four users: FEATURE_INSTALLER,
> FEATURE_TAB_COMPLETION + FEATURE_SH_STANDALONE,
> ASH_HELP + FEATURE_SH_STANDALONE,
> and the last one is unconditional:
>
> $ busybox
> BusyBox v1.25.0.git (2016-04-21 15:51:50 CEST) multi-call binary.
> ...
> Currently defined functions:
>      [, [[, acpid, add-shell, addgroup, adduser, adjtimex, ar, arp,
> arping, ash...
>
> Yes. This list also requires applet names[].
>
> If you add an option to make this output disable-able,

How will you than know what applets are compiled in
by trying them one by one?  8-)

> then even gzipped applet names[] can be dropped in some .configs,
> leaving only a name hash table.
>
> Care to cook up such a patch?

Ciao,
Tito


More information about the busybox mailing list