treewide: Use (( "${NIX_DEBUG:-0}" >= 1) ))
consistently
This commit is contained in:
parent
bc0aec5d97
commit
127a5f3357
@ -16,14 +16,14 @@ do
|
|||||||
hardeningDisableMap[$flag]=1
|
hardeningDisableMap[$flag]=1
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -n "${NIX_DEBUG:-}" ]]; then
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then
|
||||||
printf 'HARDENING: disabled flags:' >&2
|
printf 'HARDENING: disabled flags:' >&2
|
||||||
(( "${#hardeningDisableMap[@]}" )) && printf ' %q' "${!hardeningDisableMap[@]}" >&2
|
(( "${#hardeningDisableMap[@]}" )) && printf ' %q' "${!hardeningDisableMap[@]}" >&2
|
||||||
echo >&2
|
echo >&2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${hardeningDisableMap[all]:-}" ]]; then
|
if [[ -z "${hardeningDisableMap[all]:-}" ]]; then
|
||||||
if [[ -n "${NIX_DEBUG:-}" ]]; then
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then
|
||||||
echo 'HARDENING: Is active (not completely disabled with "all" flag)' >&2;
|
echo 'HARDENING: Is active (not completely disabled with "all" flag)' >&2;
|
||||||
fi
|
fi
|
||||||
for flag in "${hardeningFlags[@]}"
|
for flag in "${hardeningFlags[@]}"
|
||||||
@ -31,40 +31,40 @@ if [[ -z "${hardeningDisableMap[all]:-}" ]]; then
|
|||||||
if [[ -z "${hardeningDisableMap[$flag]:-}" ]]; then
|
if [[ -z "${hardeningDisableMap[$flag]:-}" ]]; then
|
||||||
case $flag in
|
case $flag in
|
||||||
fortify)
|
fortify)
|
||||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling fortify >&2; fi
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling fortify >&2; fi
|
||||||
hardeningCFlags+=('-O2' '-D_FORTIFY_SOURCE=2')
|
hardeningCFlags+=('-O2' '-D_FORTIFY_SOURCE=2')
|
||||||
;;
|
;;
|
||||||
stackprotector)
|
stackprotector)
|
||||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling stackprotector >&2; fi
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling stackprotector >&2; fi
|
||||||
hardeningCFlags+=('-fstack-protector-strong' '--param' 'ssp-buffer-size=4')
|
hardeningCFlags+=('-fstack-protector-strong' '--param' 'ssp-buffer-size=4')
|
||||||
;;
|
;;
|
||||||
pie)
|
pie)
|
||||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling CFlags -fPIE >&2; fi
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling CFlags -fPIE >&2; fi
|
||||||
hardeningCFlags+=('-fPIE')
|
hardeningCFlags+=('-fPIE')
|
||||||
if [[ ! ("$*" =~ " -shared " || "$*" =~ " -static ") ]]; then
|
if [[ ! ("$*" =~ " -shared " || "$*" =~ " -static ") ]]; then
|
||||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling LDFlags -pie >&2; fi
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling LDFlags -pie >&2; fi
|
||||||
hardeningCFlags+=('-pie')
|
hardeningCFlags+=('-pie')
|
||||||
hardeningLDFlags+=('-pie')
|
hardeningLDFlags+=('-pie')
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
pic)
|
pic)
|
||||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling pic >&2; fi
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling pic >&2; fi
|
||||||
hardeningCFlags+=('-fPIC')
|
hardeningCFlags+=('-fPIC')
|
||||||
;;
|
;;
|
||||||
strictoverflow)
|
strictoverflow)
|
||||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling strictoverflow >&2; fi
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling strictoverflow >&2; fi
|
||||||
hardeningCFlags+=('-fno-strict-overflow')
|
hardeningCFlags+=('-fno-strict-overflow')
|
||||||
;;
|
;;
|
||||||
format)
|
format)
|
||||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling format >&2; fi
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling format >&2; fi
|
||||||
hardeningCFlags+=('-Wformat' '-Wformat-security' '-Werror=format-security')
|
hardeningCFlags+=('-Wformat' '-Wformat-security' '-Werror=format-security')
|
||||||
;;
|
;;
|
||||||
relro)
|
relro)
|
||||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling relro >&2; fi
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling relro >&2; fi
|
||||||
hardeningLDFlags+=('-z' 'relro')
|
hardeningLDFlags+=('-z' 'relro')
|
||||||
;;
|
;;
|
||||||
bindnow)
|
bindnow)
|
||||||
if [[ -n "${NIX_DEBUG:-}" ]]; then echo HARDENING: enabling bindnow >&2; fi
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling bindnow >&2; fi
|
||||||
hardeningLDFlags+=('-z' 'now')
|
hardeningLDFlags+=('-z' 'now')
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -161,7 +161,7 @@ if [ "$*" = -v ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Optionally print debug info.
|
# Optionally print debug info.
|
||||||
if [ -n "${NIX_DEBUG:-}" ]; then
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then
|
||||||
# Old bash workaround, see ld-wrapper for explanation.
|
# Old bash workaround, see ld-wrapper for explanation.
|
||||||
echo "extra flags before to @prog@:" >&2
|
echo "extra flags before to @prog@:" >&2
|
||||||
printf " %q\n" ${extraBefore+"${extraBefore[@]}"} >&2
|
printf " %q\n" ${extraBefore+"${extraBefore[@]}"} >&2
|
||||||
|
@ -109,7 +109,7 @@ fi
|
|||||||
#fi
|
#fi
|
||||||
|
|
||||||
# Optionally print debug info.
|
# Optionally print debug info.
|
||||||
if [ -n "${NIX_DEBUG:-}" ]; then
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then
|
||||||
echo "extra flags before to @prog@:" >&2
|
echo "extra flags before to @prog@:" >&2
|
||||||
printf " %q\n" "${extraBefore[@]}" >&2
|
printf " %q\n" "${extraBefore[@]}" >&2
|
||||||
echo "original flags to @prog@:" >&2
|
echo "original flags to @prog@:" >&2
|
||||||
|
@ -24,7 +24,7 @@ extraBefore=()
|
|||||||
#export NIX_@infixSalt@_LDFLAGS_SET=1
|
#export NIX_@infixSalt@_LDFLAGS_SET=1
|
||||||
|
|
||||||
# Optionally print debug info.
|
# Optionally print debug info.
|
||||||
if [ -n "${NIX_DEBUG:-}" ]; then
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then
|
||||||
echo "extra flags before to @prog@:" >&2
|
echo "extra flags before to @prog@:" >&2
|
||||||
printf " %q\n" "${extraBefore[@]}" >&2
|
printf " %q\n" "${extraBefore[@]}" >&2
|
||||||
echo "original flags to @prog@:" >&2
|
echo "original flags to @prog@:" >&2
|
||||||
|
@ -156,7 +156,7 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
# Optionally print debug info.
|
# Optionally print debug info.
|
||||||
if [ -n "${NIX_DEBUG:-}" ]; then
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then
|
||||||
# Old bash workaround, see above.
|
# Old bash workaround, see above.
|
||||||
echo "extra flags before to @prog@:" >&2
|
echo "extra flags before to @prog@:" >&2
|
||||||
printf " %q\n" ${extraBefore+"${extraBefore[@]}"} >&2
|
printf " %q\n" ${extraBefore+"${extraBefore[@]}"} >&2
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
skip () {
|
skip () {
|
||||||
if [ -n "${NIX_DEBUG:-}" ]; then
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then
|
||||||
echo "skipping impure path $1" >&2
|
echo "skipping impure path $1" >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ for i in $initialPath; do
|
|||||||
addToSearchPath PATH "$i/bin"
|
addToSearchPath PATH "$i/bin"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "${NIX_DEBUG:-}" = 1 ]; then
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then
|
||||||
echo "initial path: $PATH"
|
echo "initial path: $PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -429,7 +429,7 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
PATH="${_PATH-}${_PATH:+${PATH:+:}}$PATH"
|
PATH="${_PATH-}${_PATH:+${PATH:+:}}$PATH"
|
||||||
if [ "${NIX_DEBUG:-}" = 1 ]; then
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then
|
||||||
echo "final path: $PATH"
|
echo "final path: $PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -539,7 +539,7 @@ substituteAll() {
|
|||||||
local -a args=()
|
local -a args=()
|
||||||
|
|
||||||
for varName in $(awk 'BEGIN { for (v in ENVIRON) if (v ~ /^[a-z][a-zA-Z0-9_]*$/) print v }'); do
|
for varName in $(awk 'BEGIN { for (v in ENVIRON) if (v ~ /^[a-z][a-zA-Z0-9_]*$/) print v }'); do
|
||||||
if [ "${NIX_DEBUG:-}" = "1" ]; then
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then
|
||||||
printf "@%s@ -> %q\n" "${varName}" "${!varName}"
|
printf "@%s@ -> %q\n" "${varName}" "${!varName}"
|
||||||
fi
|
fi
|
||||||
args+=("--subst-var" "$varName")
|
args+=("--subst-var" "$varName")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user