From e6683d0de46d81fc4492af1766c8ea2631f5bd86 Mon Sep 17 00:00:00 2001 From: Alexey Tourbin Date: Fri, 18 Dec 2009 22:55:46 +0300 Subject: [PATCH] brp-verify_elf, verify-elf: simplify VERIFY_ELF_* parameter passing --- scripts/brp-verify_elf.in | 44 +++++++-------------------------------- scripts/verify-elf.in | 12 +++++------ 2 files changed, 13 insertions(+), 43 deletions(-) diff --git a/scripts/brp-verify_elf.in b/scripts/brp-verify_elf.in index 1939bf4..c012496 100755 --- a/scripts/brp-verify_elf.in +++ b/scripts/brp-verify_elf.in @@ -34,42 +34,25 @@ export VERIFY_ELF_UNRESOLVED=normal for t in `printf %s "$RPM_VERIFY_ELF_METHOD" |tr , ' '`; do case "$t" in no|none|skip) + Info 'ELF verification disabled' exit 0 ;; - arch) - VERIFY_ELF_ARCH=normal - ;; - arch=*) + arch=?*) VERIFY_ELF_ARCH="${t#arch=}" ;; - fhs) - VERIFY_ELF_FHS=normal - ;; - fhs=*) + fhs=?*) VERIFY_ELF_FHS="${t#fhs=}" ;; - rpath) - VERIFY_ELF_RPATH=normal - ;; - rpath=*) + rpath=?*) VERIFY_ELF_RPATH="${t#rpath=}" ;; - stack) - VERIFY_ELF_STACK=normal - ;; - stack=*) + stack=?*) VERIFY_ELF_STACK="${t#stack=}" ;; - textrel) - VERIFY_ELF_TEXTREL=normal - ;; - textrel=*) + textrel=?*) VERIFY_ELF_TEXTREL="${t#textrel=}" ;; - unresolved) - VERIFY_ELF_UNRESOLVED=normal - ;; - unresolved=*) + unresolved=?*) VERIFY_ELF_UNRESOLVED="${t#unresolved=}" ;; normal) @@ -106,19 +89,6 @@ done [ -z "$RPM_TARGET_ARCH" -o -n "${RPM_TARGET_ARCH##arm*}" ] || VERIFY_ELF_STACK=no -[ "$VERIFY_ELF_ARCH" != no ] || VERIFY_ELF_ARCH= -[ -z "$RPM_VERIFY_ELF_ARCH" ] || VERIFY_ELF_ARCH="$RPM_VERIFY_ELF_ARCH" -[ "$VERIFY_ELF_FHS" != no ] || VERIFY_ELF_FHS= -[ -z "$RPM_VERIFY_ELF_FHS" ] || VERIFY_ELF_FHS="$RPM_VERIFY_ELF_FHS" -[ "$VERIFY_ELF_RPATH" != no ] || VERIFY_ELF_RPATH= -[ -z "$RPM_VERIFY_ELF_RPATH" ] || VERIFY_ELF_RPATH="$RPM_VERIFY_ELF_RPATH" -[ "$VERIFY_ELF_STACK" != no ] || VERIFY_ELF_STACK= -[ -z "$RPM_VERIFY_ELF_STACK" ] || VERIFY_ELF_STACK="$RPM_VERIFY_ELF_STACK" -[ "$VERIFY_ELF_TEXTREL" != no ] || VERIFY_ELF_TEXTREL= -[ -z "$RPM_VERIFY_ELF_TEXTREL" ] || VERIFY_ELF_TEXTREL="$RPM_VERIFY_ELF_TEXTREL" -[ "$VERIFY_ELF_UNRESOLVED" != no ] || VERIFY_ELF_UNRESOLVED= -[ -z "$RPM_VERIFY_ELF_UNRESOLVED" ] || VERIFY_ELF_UNRESOLVED="$RPM_VERIFY_ELF_UNRESOLVED" - : ${RPM_VERIFY_ELF_TOPDIR:=} : ${RPM_VERIFY_ELF_SKIPLIST:=} [ -d "$RPM_BUILD_ROOT$RPM_VERIFY_ELF_TOPDIR" ] || exit 0 diff --git a/scripts/verify-elf.in b/scripts/verify-elf.in index 61ee355..620b544 100755 --- a/scripts/verify-elf.in +++ b/scripts/verify-elf.in @@ -57,19 +57,19 @@ VerifyELF() fname="${f#$RPM_BUILD_ROOT}" fname="${fname#.}" - if [ -n "$VERIFY_ELF_ARCH" -a "$RPM_TARGET_ARCH" = noarch ]; then + if [ "${VERIFY_ELF_ARCH:=normal}" != no ] && [ "$RPM_TARGET_ARCH" = noarch ]; then [ "$VERIFY_ELF_ARCH" = relaxed ] && prefix=WARNING || prefix=ERROR [ "$VERIFY_ELF_ARCH" = relaxed ] || rc=1 Info "$prefix: $f: ELF object for \"$RPM_TARGET_ARCH\" architecture" fi - if [ -n "$VERIFY_ELF_FHS" ] && [ -z "${fname##/usr/share/*}" -o -z "${fname##/etc/*}" ]; then + if [ "${VERIFY_ELF_FHS:=normal}" != no ] && [ -z "${fname##/usr/share/*}" -o -z "${fname##/etc/*}" ]; then [ "$VERIFY_ELF_FHS" = relaxed ] && prefix=WARNING || prefix=ERROR [ "$VERIFY_ELF_FHS" = relaxed ] || rc=1 Info "$prefix: $f: ELF object out of allowed directory tree" fi - if [ -n "$VERIFY_ELF_RPATH" ]; then + if [ "${VERIFY_ELF_RPATH:=normal}" != no ]; then rpath="$(printf %s "$objdump_info" |awk '{if ($1=="RPATH") print $2}')" if [ -n "$rpath" ]; then prefix= @@ -106,7 +106,7 @@ VerifyELF() fi fi - if [ -n "$VERIFY_ELF_STACK" ]; then + if [ "${VERIFY_ELF_STACK:=normal}" != no ]; then if [ -z "${t##*ELF* executable*}" -o -z "${t##*ELF* shared object*}" ]; then stack="$(printf %s "$objdump_info" |sed -ne 's/^[[:space:]]*STACK[[:space:]]\+\([^[:space:]]\+\).*/\1/p')" if [ -z "$stack" ]; then @@ -122,7 +122,7 @@ VerifyELF() fi fi - if [ -n "$VERIFY_ELF_TEXTREL" ]; then + if [ "${VERIFY_ELF_TEXTREL:=normal}" != no ]; then textrel="$(printf %s "$objdump_info" |sed -ne 's/^[[:space:]]*TEXTREL[[:space:]]\+\([^[:space:]]\+\).*/\1/p')" if [ -n "$textrel" ]; then [ "$VERIFY_ELF_TEXTREL" = relaxed ] && prefix=WARNING || prefix=ERROR @@ -131,7 +131,7 @@ VerifyELF() fi fi - if [ -n "$VERIFY_ELF_UNRESOLVED" ]; then + if [ "${VERIFY_ELF_UNRESOLVED:=normal}" != no ]; then while [ -z "${t##*ELF* executable*dynamically linked*}" -o -z "${t##*ELF* shared object*}" ]; do rpath="$(printf %s "$objdump_info" |awk '{if ($1=="RPATH") print $2}' |tr -s : ' ' |sed -e "s|\$ORIGIN|${fname%/*}|g")" if [ -n "$rpath" ]; then