Merge pull request #27215 from obsidiansystems/stdenv-harden

Harden stdenv in two misc ways
This commit is contained in:
John Ericson 2017-07-07 12:48:51 -04:00 committed by GitHub
commit f5364122b5
2 changed files with 10 additions and 5 deletions

View File

@ -1,12 +1,13 @@
--- swift/utils/build-script-impl 2017-01-23 12:47:20.401326309 -0600
+++ swift-pax/utils/build-script-impl 2017-01-23 13:24:10.339366996 -0600
@@ -1823,6 +1823,16 @@ function set_lldb_xcodebuild_options() {
@@ -1823,6 +1823,17 @@ function set_lldb_xcodebuild_options() {
fi
}
+## XXX: Taken from nixpkgs /pkgs/stdenv/generic/setup.sh
+isELF() {
+ local fn="$1"
+ local fd
+ local magic
+ exec {fd}< "$fn"
+ read -n 4 -u $fd magic

View File

@ -17,8 +17,9 @@ runHook() {
shift
local var="$hookName"
if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi
eval "local -a dummy=(\"\${$var[@]}\")"
for hook in "_callImplicitHook 0 $hookName" "${dummy[@]}"; do
local -n var
local hook
for hook in "_callImplicitHook 0 $hookName" "${var[@]}"; do
_eval "$hook" "$@"
done
return 0
@ -32,8 +33,9 @@ runOneHook() {
shift
local var="$hookName"
if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi
eval "local -a dummy=(\"\${$var[@]}\")"
for hook in "_callImplicitHook 1 $hookName" "${dummy[@]}"; do
local -n var
local hook
for hook in "_callImplicitHook 1 $hookName" "${var[@]}"; do
if _eval "$hook" "$@"; then
return 0
fi
@ -192,6 +194,7 @@ _addRpathPrefix() {
# Return success if the specified file is an ELF object.
isELF() {
local fn="$1"
local fd
local magic
exec {fd}< "$fn"
read -n 4 -u $fd magic
@ -203,6 +206,7 @@ isELF() {
# "#!").
isScript() {
local fn="$1"
local fd
local magic
if ! [ -x /bin/sh ]; then return 0; fi
exec {fd}< "$fn"