Wanted to make simple `makeself` analog......
____________
#!/bin/sh -e
set -e
trap 'echo "${0##*/}: Unexpected abort, exiting..."' 0
umask 377
F="./bina$$"
{ dd bs=65536 0<&8 1>"$F" 8<&- 2>&-
exec 8<&-
chmod u+x "$F"
echo 1>&2 "Running binary \`$F'...
"
(exec "$F")
trap "{
echo '
Exit status: '$?
test $? -eq 2 && \
echo '(Possibly kernel and fallback \`/bin/sh\` couldn'\''t execute this file,
because it is a broken binary or unspecified/unsupported script.
File not removed.)
' # disabled for show || rm -f "$F"
} 1>&2" 0
exit 0
} 8<<""
======================
If works with payload like:
_________________
#!/usr/bin/printf $$Running from file: %s\n
not used and ran
=================
[EMAIL PROTECTED]:/tmp$ sh bixelf
Running binary `./bina13936'...
$$Running from file: ./bina13936
Exit status: 0
[EMAIL PROTECTED]:/tmp$
=================
It fails with binaries due to NUL (and maybe something more) removal.
== Another issues ==
Looking at parser, this piece of code:
#
TRACE(("Here document %d\n", n->type));
if (! noexpand(wordtext) || (i = strlen(wordtext)) == 0 || i > EOFMARKLEN)
synerror("Illegal eof marker for << redirection");
#
[0] google.com/search?q=here-document+opengroup+2004
In [0] it's stated, that delimiter isn't evaluated (expanded), only
quoiting must be checked. That if() seems to be completely bogus.
* strlen() == 0 isn't triggered -- empty delimiter is handled by syntax;
* check for max line isn't needed, i think;
* noexpand() checks for special symbols, while [0] says, that `word'
must be used as is (with escaping/quotes removed).
pdksh seems to do so, i.e $WHATEVER can be used and it is not expanded.
Bash doesn't care also, but i don't know if it expands that.
pdksh doesn't like no delimiter in the end of file with, thus no
expansion is obvious (but such behavior is bad, i.e. no possibility to
leave whatever stuff until the EOF):
#
[EMAIL PROTECTED]:/tmp$ pdksh bixelf
bixelf[27]: here document `$NULL' unclosed
bixelf: Unexpected abort, exiting...
[EMAIL PROTECTED]:/tmp$
[EMAIL PROTECTED]:/tmp$ bash bixelf
Running binary `./bina26446'...
$$Running from file: /tmp/bina26446
Exit status: 0
[EMAIL PROTECTED]:/tmp$ sh bixelf
bixelf: 23: Syntax error: Illegal eof marker for << redirection
bixelf: Unexpected abort, exiting...
[EMAIL PROTECTED]:/tmp$
#
== * ==
Placing binary stuff safely with optimized reading/writing by big
blocks without parsing, if delimiter is "", are things, that i'd like
to propose and possibly fix/implement soon.
--
-o--=O`C
#oo'L O
<___=E M
-
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html