Allow imagact_binmisc to remap argv if another activator
has already processed the command line, e.g. shell activator remapping
argv to /usr/local/bin/perl
We need recursive protection here. The old "flag" wasn't sufficient. Maybe you need to set the interpreted bit to be a pointer to the base imgact that's being the interpreter and we should test equality not != 0.
These changes compile, but are untested at the moment. This is proof of concept
Change quite a bit around the interpreted bit/flag.
- interpreted now stores the address of the last run imgact run
- interpreted is only set to non-NULL values from inside do_exec()
- interpreted causes the for loop to skip over a previous run's execution
Cleared interpreted when we detect that this is the address of the
current imgact function and continue checking.
As an aside, the current code in the tree defeats all recursive attempts
by using a single hardstop on the interpreted flag. If its set, imgact_shell
and imgact_binmisc abort and do not further adjust argv.
The propsed changes here do *not* defeat complicated recursion, but they do
defeat simple recursion. In order to exploit this version, one would have to
craft a binary/script to recursively execute a binary *then* a script in
succession, and then alternate back to a binary.
e.g. a script is called that invokes imgact_shell, that shell interpreter
is a binary that has a handler set in imgact_binmisc. That handler in
imgact_binmisc is set to the original script. I think this is a recursive
blackhole that I'd like to design around.