14757b351SPierre Pronchery#!/bin/sh 24757b351SPierre Pronchery 34757b351SPierre Pronchery# To test this OpenSSL version's applications against another version's 44757b351SPierre Pronchery# shared libraries, simply set 54757b351SPierre Pronchery# 64757b351SPierre Pronchery# OPENSSL_REGRESSION=/path/to/other/OpenSSL/build/tree 74757b351SPierre Proncheryif [ -n "$OPENSSL_REGRESSION" ]; then 84757b351SPierre Pronchery shlibwrap="$OPENSSL_REGRESSION/util/shlib_wrap.sh" 94757b351SPierre Pronchery if [ -x "$shlibwrap" ]; then 104757b351SPierre Pronchery # We clear OPENSSL_REGRESSION to avoid a loop, should the shlib_wrap.sh 114757b351SPierre Pronchery # we exec also support that mechanism... 124757b351SPierre Pronchery OPENSSL_REGRESSION= exec "$shlibwrap" "$@" 134757b351SPierre Pronchery else 144757b351SPierre Pronchery if [ -f "$shlibwrap" ]; then 154757b351SPierre Pronchery echo "Not permitted to run $shlibwrap" >&2 164757b351SPierre Pronchery else 174757b351SPierre Pronchery echo "No $shlibwrap, perhaps OPENSSL_REGRESSION isn't properly set?" >&2 184757b351SPierre Pronchery fi 194757b351SPierre Pronchery exit 1 204757b351SPierre Pronchery fi 214757b351SPierre Proncheryfi 224757b351SPierre Pronchery 234757b351SPierre Pronchery[ $# -ne 0 ] || set -x # debug mode without arguments:-) 244757b351SPierre Pronchery 254757b351SPierre ProncheryTHERE="`echo $0 | sed -e 's|[^/]*$||' 2>/dev/null`.." 264757b351SPierre Pronchery[ -d "${THERE}" ] || exec "$@" # should never happen... 274757b351SPierre Pronchery 28*267f8c1fSEnji CooperLIBCRYPTOSO="${THERE}/libcrypto.so.3" 29*267f8c1fSEnji CooperLIBSSLSO="${THERE}/libssl.so.3" 304757b351SPierre Pronchery 314757b351SPierre ProncherySYSNAME=`(uname -s) 2>/dev/null`; 324757b351SPierre Proncherycase "$SYSNAME" in 334757b351SPierre ProncherySunOS|IRIX*) 344757b351SPierre Pronchery # SunOS and IRIX run-time linkers evaluate alternative 354757b351SPierre Pronchery # variables depending on target ABI... 364757b351SPierre Pronchery rld_var=LD_LIBRARY_PATH 374757b351SPierre Pronchery case "`(/usr/bin/file "$LIBCRYPTOSO") 2>/dev/null`" in 384757b351SPierre Pronchery *ELF\ 64*SPARC*|*ELF\ 64*AMD64*) 394757b351SPierre Pronchery [ -n "$LD_LIBRARY_PATH_64" ] && rld_var=LD_LIBRARY_PATH_64 404757b351SPierre Pronchery LD_PRELOAD_64="$LIBCRYPTOSO $LIBSSLSO"; export LD_PRELOAD_64 414757b351SPierre Pronchery preload_var=LD_PRELOAD_64 424757b351SPierre Pronchery ;; 434757b351SPierre Pronchery *ELF\ 32*SPARC*|*ELF\ 32*80386*) 444757b351SPierre Pronchery # We only need to change LD_PRELOAD_32 and LD_LIBRARY_PATH_32 454757b351SPierre Pronchery # on a multi-arch system. Otherwise, trust the fallbacks. 464757b351SPierre Pronchery if [ -f /lib/64/ld.so.1 ]; then 474757b351SPierre Pronchery [ -n "$LD_LIBRARY_PATH_32" ] && rld_var=LD_LIBRARY_PATH_32 484757b351SPierre Pronchery LD_PRELOAD_32="$LIBCRYPTOSO $LIBSSLSO"; export LD_PRELOAD_32 494757b351SPierre Pronchery preload_var=LD_PRELOAD_32 504757b351SPierre Pronchery fi 514757b351SPierre Pronchery ;; 524757b351SPierre Pronchery # Why are newly built .so's preloaded anyway? Because run-time 534757b351SPierre Pronchery # .so lookup path embedded into application takes precedence 544757b351SPierre Pronchery # over LD_LIBRARY_PATH and as result application ends up linking 554757b351SPierre Pronchery # to previously installed .so's. On IRIX instead of preloading 564757b351SPierre Pronchery # newly built .so's we trick run-time linker to fail to find 574757b351SPierre Pronchery # the installed .so by setting _RLD_ROOT variable. 584757b351SPierre Pronchery *ELF\ 32*MIPS*) 594757b351SPierre Pronchery #_RLD_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLD_LIST 604757b351SPierre Pronchery _RLD_ROOT=/no/such/dir; export _RLD_ROOT 614757b351SPierre Pronchery eval $rld_var=\"/usr/lib'${'$rld_var':+:$'$rld_var'}'\" 624757b351SPierre Pronchery preload_var=_RLD_LIST 634757b351SPierre Pronchery ;; 644757b351SPierre Pronchery *ELF\ N32*MIPS*) 654757b351SPierre Pronchery [ -n "$LD_LIBRARYN32_PATH" ] && rld_var=LD_LIBRARYN32_PATH 664757b351SPierre Pronchery #_RLDN32_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLDN32_LIST 674757b351SPierre Pronchery _RLDN32_ROOT=/no/such/dir; export _RLDN32_ROOT 684757b351SPierre Pronchery eval $rld_var=\"/usr/lib32'${'$rld_var':+:$'$rld_var'}'\" 694757b351SPierre Pronchery preload_var=_RLDN32_LIST 704757b351SPierre Pronchery ;; 714757b351SPierre Pronchery *ELF\ 64*MIPS*) 724757b351SPierre Pronchery [ -n "$LD_LIBRARY64_PATH" ] && rld_var=LD_LIBRARY64_PATH 734757b351SPierre Pronchery #_RLD64_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLD64_LIST 744757b351SPierre Pronchery _RLD64_ROOT=/no/such/dir; export _RLD64_ROOT 754757b351SPierre Pronchery eval $rld_var=\"/usr/lib64'${'$rld_var':+:$'$rld_var'}'\" 764757b351SPierre Pronchery preload_var=_RLD64_LIST 774757b351SPierre Pronchery ;; 784757b351SPierre Pronchery esac 794757b351SPierre Pronchery eval $rld_var=\"${THERE}'${'$rld_var':+:$'$rld_var'}'\"; export $rld_var 804757b351SPierre Pronchery unset rld_var 814757b351SPierre Pronchery ;; 824757b351SPierre ProncheryNONSTOP_KERNEL) 834757b351SPierre Pronchery # HPE NonStop has a proprietary mechanism for specifying 844757b351SPierre Pronchery # the location of DLLs. It does not use PATH or variables 854757b351SPierre Pronchery # commonly used on other platforms. The platform has a limited 864757b351SPierre Pronchery # environment space keeping extraneous variables to a minimum 874757b351SPierre Pronchery # is recommended. 884757b351SPierre Pronchery _RLD_LIB_PATH="${THERE}:$LD_LIBRARY_PATH" 894757b351SPierre Pronchery export _RLD_LIB_PATH 904757b351SPierre Pronchery ;; 914757b351SPierre Pronchery*) LD_LIBRARY_PATH="${THERE}:$LD_LIBRARY_PATH" # Linux, ELF HP-UX 924757b351SPierre Pronchery DYLD_LIBRARY_PATH="${THERE}:$DYLD_LIBRARY_PATH" # MacOS X 934757b351SPierre Pronchery SHLIB_PATH="${THERE}:$SHLIB_PATH" # legacy HP-UX 944757b351SPierre Pronchery LIBPATH="${THERE}:$LIBPATH" # AIX, OS/2 954757b351SPierre Pronchery export LD_LIBRARY_PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH 964757b351SPierre Pronchery # Even though $PATH is adjusted [for Windows sake], it doesn't 974757b351SPierre Pronchery # necessarily does the trick. Trouble is that with introduction 984757b351SPierre Pronchery # of SafeDllSearchMode in XP/2003 it's more appropriate to copy 994757b351SPierre Pronchery # .DLLs in vicinity of executable, which is done elsewhere... 1004757b351SPierre Pronchery if [ "$OSTYPE" != msdosdjgpp ]; then 1014757b351SPierre Pronchery PATH="${THERE}:$PATH"; export PATH 1024757b351SPierre Pronchery fi 1034757b351SPierre Pronchery ;; 1044757b351SPierre Proncheryesac 1054757b351SPierre Pronchery 1064757b351SPierre Pronchery 1074757b351SPierre Pronchery 1084757b351SPierre Proncherycmd="$1"; [ -x "$cmd" ] || cmd="$cmd${EXE_EXT}" 1094757b351SPierre Proncheryshift 1104757b351SPierre Proncheryif [ $# -eq 0 ]; then 1114757b351SPierre Pronchery exec "$cmd" # old sh, such as Tru64 4.x, fails to expand empty "$@" 1124757b351SPierre Proncheryelse 1134757b351SPierre Pronchery exec "$cmd" "$@" 1144757b351SPierre Proncheryfi 115