[go: nahoru, domu]

Skip to content

Commit

Permalink
installscript: Workaround awk sandboxing
Browse files Browse the repository at this point in the history
Prevents errors such as:
  awk: run time error: 'system' function not allowed in sandbox mode
by manually finding the source location and including the file
at the correct location.
  • Loading branch information
drinkcat committed Nov 14, 2017
1 parent 11e084d commit 20fe6fd
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions installer/functions
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ installscript() {
# This should never happen.
error 1 "Unable to find common functions file."
fi
awk '/^\. .*\/installer\/functions/ {
system("'"awk 'ok; !ok && /^###/ {ok=1}' '$thisfile'"'");
next
}
1' "$src" | sed -e "${3:-;}" > "$dst"
{
# Find the line sourcing the functions file
line=$(grep -n '^\. .*/installer/functions' "$src" | cut -d : -f 1)
if [ -n "$line" ]; then
head -n $((line - 1)) "$src"
awk 'ok; !ok && /^###/ {ok=1}' "$thisfile"
tail -n +$((line + 1)) "$src"
else
cat "$src"
fi
} | sed -e "${3:-;}" > "$dst"
}

### Everything after this line will be statically inserted into scripts.
Expand Down

0 comments on commit 20fe6fd

Please sign in to comment.