mirror of
https://github.com/bol-van/zapret.git
synced 2024-11-26 20:20:53 +03:00
install_bin: glibc execvp calls /bin/sh. use bash if possible
This commit is contained in:
parent
e7a3c8c142
commit
240eaa6425
@ -5,6 +5,11 @@ EXEDIR="$(cd "$EXEDIR"; pwd)"
|
|||||||
BINS=binaries
|
BINS=binaries
|
||||||
BINDIR="$EXEDIR/$BINS"
|
BINDIR="$EXEDIR/$BINS"
|
||||||
|
|
||||||
|
exists()
|
||||||
|
{
|
||||||
|
which "$1" >/dev/null 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
check_dir()
|
check_dir()
|
||||||
{
|
{
|
||||||
local dir="$BINDIR/$1"
|
local dir="$BINDIR/$1"
|
||||||
@ -13,8 +18,15 @@ check_dir()
|
|||||||
if [ -f "$exe" ]; then
|
if [ -f "$exe" ]; then
|
||||||
if [ -x "$exe" ]; then
|
if [ -x "$exe" ]; then
|
||||||
# ash and dash try to execute invalid executables as a script. they interpret binary garbage with possible negative consequences
|
# ash and dash try to execute invalid executables as a script. they interpret binary garbage with possible negative consequences
|
||||||
# find do not use shell exec
|
# bash do not do this
|
||||||
|
if exists bash; then
|
||||||
|
out=$(echo 0.0.0.0 | bash -c "$exe" 2>/dev/null)
|
||||||
|
else
|
||||||
|
# find do not use its own shell exec
|
||||||
|
# it uses execvp(). in musl libc it does not call shell, in glibc it DOES call /bin/sh
|
||||||
|
# that's why prefer bash if present
|
||||||
out=$(echo 0.0.0.0 | find "$dir" -maxdepth 1 -name ip2net -exec {} \; 2>/dev/null)
|
out=$(echo 0.0.0.0 | find "$dir" -maxdepth 1 -name ip2net -exec {} \; 2>/dev/null)
|
||||||
|
fi
|
||||||
[ -n "$out" ]
|
[ -n "$out" ]
|
||||||
else
|
else
|
||||||
echo "$exe is not executable. set proper chmod."
|
echo "$exe is not executable. set proper chmod."
|
||||||
|
Loading…
Reference in New Issue
Block a user