BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0005864 [BusyBox] New Features minor always 10-30-08 06:24 11-04-08 04:33
Reporter Eero Tamminen View Status public  
Assigned To BusyBox
Priority normal Resolution open  
Status assigned   Product Version 1.10.x
Summary 0005864: Disabling features not disabling corresponding command line options & Busybox not erroring on unknown options
Description Busybox has two related issues:

1. Although Busybox features are configured out, it doesn't disable the corresponding command line options, it just silently ignores them

2. Busybox doesn't give any errors on unknown options (in "ps" case, it ignores all options)

This means that when e.g. building software using BB, Busybox can just silently corrupt the generated data; when installing software, installation scripts that given Busybox configuration breaks, don't fail as they should etc.
Additional Information I'm the person whose issue was forwarded here from bugs.maemo.org as bug 5764, but as I couldn't comment on that one, I needed to create an new (better formulated) one.

---------- comments from bug 5764 -----------

>> Then I started to look into Busybox 1.10 sources. In our version
>> CONFIG_FEATURE_SORT_BIG isn't currently enabled. *Keys and -k work
>> only if it's enabled*.
>
> D'oh. You disabled the feature and then complain that it doesn't work.

I didn't. The person(s) configuring Busybox for a given disto or device, are different from person(s) using it and may not even related e.g. by being employed by the same company. This is the case in Debian, Maemo etc.

There are persons configuring Busybox for their own use such as the Busybox maintainers, but is this even majority of all Busybox users?


>>This is the most annoying thing in Busybox. If you configure out features,
>>it doesn't disable the corresponding command line options,
>>it just silently ignores them (in "ps" case, it ignores all options).
>
> The opposite behavior would just annoy different group of people, which
> prefers utilities to ignore some switches instead of bombing out.

Best would of course be if this behavior would be configurable[1], but at least BB should (be able to) warn about requested options being not implemented.

[1] There could be BB config options like UNIMPLEMENTED_OPTION_WARNINGS & FATAL_OPTION_WARNINGS. I would assume thing like this to be useful also for Busybox test-suite.


>> This means that when e.g. building software using BB, Busybox can just
>> silently corrupt the generated data
>
> D'oh again. If you plan to build software on the machine you install
> busybox on, you'd better enable most of the options, since you want maximum
> compatibility. Disabling options implies that you know that in this
> particular installation it's ok.

Building a bit more demanding things (like base Debian distribution) with Busybox doesn't work very well even with all options enabled. With the warnings many of the issues could be found much faster.
Attached Files  debian-mappings.txt [^] (7,855 bytes) 11-03-08 09:21
 option-configs.txt [^] (1,438 bytes) 11-03-08 09:24
 option-warn.diff [^] (3,752 bytes) 11-04-08 04:28

- Relationships

- Notes
(0014704)
vda
10-30-08 16:51

I don't know what to do with this report.

There are more than 200 applets now, should I go and check all applets and all options and whether they are accepted but ignored, or implemented not exactly compatibly? How many days (years?) would that take?
 
(0014764)
Eero Tamminen
10-31-08 03:25

> I don't know what to do with this report.
>
> There are more than 200 applets now, should I go and check all applets and
> all options and whether they are accepted but ignored, or implemented not
> exactly compatibly? How many days (years?) would that take?

First step would be adding the "missing option" warning and fatal config option support for Busbox getopt() style functions. This should fix half the issue and be pretty easy to do (default switch case with ifdeffed printf() & exit(-1)?).

IMHO the warning could be enabled by default as anybody building Busybox himself can easily switch it off. The message could be: "WARNING: option '%s' isn't implemented or enabled in Busybox."


I guess second step would be updating the instructions about the applet development to state that if config option removes handling of options, it should also change the getopt arguments appropriately.


Third step would be fixing the applets. A quick grep for "option", "argument" and " -[a-z]" of the Busybox v1.10 config options reveals some busybox config settings that modify what options are parsed, the list of them is attached. This tool probably would need an update too:
          Busybox chat require no options. To make it not fail when used
          in place of original chat (which has a bunch of options) turn
          this on.

First just the applets which are commonly used from scripts (e.g. in Debian packages) could be fixed. From the attached list those would be:
echo, head, tail, find, grep, pidof, ps, tar, xargs.

Rest could be fixed when noticed later on and have separate bugs. Does this sound reasonable?
 
(0014774)
vda
10-31-08 17:15

> adding the "missing option" warning and fatal config option support for Busbox getopt() style functions. This should fix half the issue and be pretty easy to do (default switch case with ifdeffed printf() & exit(-1)?).

Can you demonstrate this in a patch form?
 
(0014964)
Eero Tamminen
11-03-08 06:51

> Can you demonstrate this in a patch form?

I took a look at the BB sources and this seems a bit more complicated to do than my naive proposal. Some of the applets and even Busybox getopt32() call the C-library getopt() (which I had initially thought to be BB implementation) which cannot be modified although BB getop32() could.

So... Even the support for warnings needs some changes to applets too. In the libc getopt case it should be simple:
----------
  If getopt() does not recognize an option character, it prints an error
  message to stderr, stores the character in optopt, and returns ’?’.
  The calling program may prevent the error message by setting opterr to 0.
----------
I.e. code using getopt() should zero opterr only when the new options warnings feature is disabled and with warn=fatal feature, they should check for the '?' getopt() return value.

I'm not sure what should be done with BB getopt32() to have this, but maybe you have some idea?


As to giving different options strings depending on what features are selected, I noticed this in BB getopt32() comments:
--------
        If one of the given options is found, a flag value is added to
        the return value (an unsigned long).

        The flag value is determined by the position of the char in
        applet_opts string.
--------

I.e. if applets give different argument strings to getopt32() depending on selected features like I proposed, either the defines need to change, or the additional ones need to be last ones. I think it's easier just to add some extra code for checking the flags getopt32() returns and what getopt() returns.

The warn/fatal code could in a separate libb function, it needs to take only the option name as argument.
 
(0014974)
dvv
11-03-08 08:34

I almost went crazy while trying to make BB sendmail "compatible". Its flavors managed to use for options almost entire alphabet :) Fantastic "declared" flexibility and ... a couple of really useful options. Why should we follow that way? A swiss-army-knife doesn't mean to be used as drop-in replacement for a steam hammer...

Let us clarify whether we _must_ achieve in applets all the functionality of their big brothers. Or should we _just accept_ all options the latter accept? Or should we keep options people _really_ need? (I recall a thread Walter was starting on the set of options applets should accept...) The resolution should then unconditionally be applied to all applets. FEATURE_DESKTOP leaves too much degrees of freedom for developers...

I think the set of options should not be an #ifdef forest. If we choose to mimic big brothers, _all_ options should be declared as contiguous string. A special char *opt_unsupported should be introduced which would enlist options we don't provide handlers for. That way consistency of option char to option mask value mapping would be kept.

Regards,
--
Vladimir
 
(0014984)
Eero Tamminen
11-03-08 09:17

> Let us clarify whether we _must_ achieve in applets all the functionality of their big brothers. Or should we _just accept_ all options the latter accept? Or should we keep options people _really_ need?

Because Busybox has such a large number of tools, even just checking for option
compatibility would be a huge job. I've done some work in trying to map Busybox utilities to what Debian has and in which package (using the file search at packages.debian.org), attached is the current list.

The answer to your particular problem should be clear though.

If Busybox tool uses different options or their semantics are different than for a similarly named already existing tool[1], Busybox should really use a different (symlink) name for the tool. For example by adding a common prefix to it like "bb-".

If the tool name is same, then the supported options should be some subset of the all options, and having the same semantics.

[1] For example:
pscan: Busybox version scans ports, Debian C-source
ftpput: Busybox version has regular FTP, Debian camera additions


However, that's separate issue. The problem this bug is about is that Busybox doesn't even tell whether it recognized the option letter. And if it recognized, whether it had an actual implementation for it.
 
(0015024)
vda
11-03-08 14:09

> Because Busybox has such a large number of tools, even just checking for option
compatibility would be a huge job.

Huge job -> bad idea. Let's do something of a small, manageable step. Apparently you had a problem with one specific applet, with a few specific options being silently ignored.

Can you produce a patch which fixes this problem _for this applet only_? If the solution will look good, it can be extended to other applets, piecemeal.
 
(0015054)
Eero Tamminen
11-04-08 04:33

> Can you produce a patch which fixes this problem _for this applet only_? If the solution will look good, it can be extended to other applets, piecemeal.

Attached patch for sort. getopt32() needs similar stuff also, but I'll leave that to somebody else as it's more complicated.
 

- Issue History
Date Modified Username Field Change
10-30-08 06:24 Eero Tamminen New Issue
10-30-08 06:24 Eero Tamminen Status new => assigned
10-30-08 06:24 Eero Tamminen Assigned To  => BusyBox
10-30-08 16:51 vda Note Added: 0014704
10-31-08 03:25 Eero Tamminen Note Added: 0014764
10-31-08 17:15 vda Note Added: 0014774
11-03-08 06:51 Eero Tamminen Note Added: 0014964
11-03-08 08:34 dvv Note Added: 0014974
11-03-08 09:17 Eero Tamminen Note Added: 0014984
11-03-08 09:21 Eero Tamminen File Added: debian-mappings.txt
11-03-08 09:24 Eero Tamminen File Added: option-configs.txt
11-03-08 14:09 vda Note Added: 0015024
11-04-08 04:28 Eero Tamminen File Added: option-warn.diff
11-04-08 04:33 Eero Tamminen Note Added: 0015054


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker