[Firehol-support] running FireHOL under busybox's ash-shell

Costa Tsaousis costa at tsaousis.gr
Thu Oct 7 22:38:55 BST 2004

Hi Christian,

> It's a pity that ASH doesn't know array variables.

I am not sure that this will be the only difference. I tried in the past
to port FireHOL to ASH myself, and gave up when I realized that ASH lacks

>> Without array variables, FireHOL should be re-written to use file based
>> arrays,
> Hmm, couldn't find more on this. Do you have somthing in mind? Might it
> be possible to construct some file_array() function I could then
> substitute all uses of bash array variables with?

I guess there should be the following functions:

BASH: local -a name=()
ASH : array_create [name]

In ASH, this should (re)create a directory 'arrays/name' in FireHOL's
temporary directory.

BASH: name=(arg1 arg2 arg3...)
ASH : array_init name arg1 arg2 arg3

In ASH, each argument should be placed in a file, with filename its
position (starting from 0).

BASH: name[x]=arg
ASH : array_set name x arg

In ASH, this should write to file 'arrays/name/x' the argument.

BASH: name[x]
ASH : array_get name x

In ASH, this should read the file 'arrays/name/x' and return its contents.

This will be a little bit complicated because FireHOL uses:


The above produce different results in BASH. Assuming that the array has:

# name=("hello" "world and friends")

# /usr/bin/printf "'%s'\n" ${name[@]}

As you see, printf did not inherited the arguments correctly.

# /usr/bin/printf "'%s'\n" "${name[@]}"
'world and friends'

In this case, printf got the information that there are two arguments from
which the second contains many words. This is used by FireHOL extensively
to pass arguments from function to function.

At this point we have a bigger problem: Returning strings from functions.
If this is done like this:

some_function `array_get name @`

it will make the whole thing VERY slow, since ASH will fork itself to
execute the array_get function. Also, array_get will have by itself to
loop and read all the files in directory 'arrays/name/', execute a sed
command to escape the spaces in each file individually, and return the
whole array as a string like this:

some_function hello world\ and\ friends

This way some_function will be able to process the arguments correctly,
but I guess the whole thing will slow down FireHOL significantly.

Of course, as I said before, once this problem is solved, another one
might be found (for example, FireHOL depends on the internal printf of
BASH - it might not be too difficult to overcome it, but it will be a
painful again)...



More information about the Firehol-support mailing list