cc-wrapper: Fix if syntax

This commit is contained in:
Franz Pletz 2016-03-09 10:08:07 +01:00
parent 9a5b070b45
commit 514a478e61

View File

@ -14,39 +14,39 @@ if [[ ! $hardeningDisable == "all" ]]; then
if [[ ! "${hardeningDisable[@]}" =~ "$flag" ]]; then if [[ ! "${hardeningDisable[@]}" =~ "$flag" ]]; then
case $flag in case $flag in
fortify) fortify)
if [ -n "$NIX_DEBUG" ]; then echo HARDENING: enabling fortify; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling fortify; fi
hardeningCFlags+=('-O2' '-D_FORTIFY_SOURCE=2') hardeningCFlags+=('-O2' '-D_FORTIFY_SOURCE=2')
;; ;;
stackprotector) stackprotector)
if [ -n "$NIX_DEBUG" ]; then echo HARDENING: enabling stackprotector; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling stackprotector; 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; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling CFlags -fPIE; fi
hardeningCFlags+=('-fPIE') hardeningCFlags+=('-fPIE')
if [[ ! ("$*" =~ " -shared " || "$*" =~ " -static ") ]]; then if [[ ! ("$*" =~ " -shared " || "$*" =~ " -static ") ]]; then
if [ -n "$NIX_DEBUG" ]; then echo HARDENING: enabling LDFlags -pie; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling LDFlags -pie; fi
hardeningLDFlags+=('-pie') hardeningLDFlags+=('-pie')
fi fi
;; ;;
pic) pic)
if [ -n "$NIX_DEBUG" ]; then echo HARDENING: enabling pic; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling pic; fi
hardeningCFlags+=('-fPIC') hardeningCFlags+=('-fPIC')
;; ;;
strictoverflow) strictoverflow)
if [ -n "$NIX_DEBUG" ]; then echo HARDENING: enabling strictoverflow; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling strictoverflow; fi
hardeningCFlags+=('-fno-strict-overflow') hardeningCFlags+=('-fno-strict-overflow')
;; ;;
format) format)
if [ -n "$NIX_DEBUG" ]; then echo HARDENING: enabling format; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling format; 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; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling relro; fi
hardeningLDFlags+=('-z relro') hardeningLDFlags+=('-z relro')
;; ;;
bindnow) bindnow)
if [ -n "$NIX_DEBUG" ]; then echo HARDENING: enabling bindnow; fi if [[ -n "$NIX_DEBUG" ]]; then echo HARDENING: enabling bindnow; fi
hardeningLDFlags+=('-z now') hardeningLDFlags+=('-z now')
;; ;;
*) *)