From 15a2e696752bba33decf70e4ac7eed5e36d8d93e Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 22 Apr 2016 18:00:55 +0200 Subject: [PATCH] Allow finding libfaketime in multiple locations The install location of libfaketime varies across distributions. --- commonFunctions.bash | 11 +++++++++++ generateCRLs | 2 +- generateInfra | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/commonFunctions.bash b/commonFunctions.bash index 0d8b897..36ffa19 100644 --- a/commonFunctions.bash +++ b/commonFunctions.bash @@ -39,3 +39,14 @@ caSign(){ # csr,ca,config,start,end echo "Signed" } +findLibfaketime() { + for candidate in /usr/lib/faketime/libfaketime.so.1 /usr/lib/*/faketime/libfaketime.so.1; do + if [[ -f "$candidate" ]]; then + printf '%s\n' "$candidate" + return + fi + done + printf >&2 'error: no libfaketime found\n' + exit 1 # unfortunately, this will only exit the $() subshell +} + diff --git a/generateCRLs b/generateCRLs index be4cf83..e31bb54 100755 --- a/generateCRLs +++ b/generateCRLs @@ -13,7 +13,7 @@ generateCRL() { # name, year, month echo CRL $1 $2-$3 BASE="$PWD" pushd $1.ca > /dev/null - TZ=UTC LD_PRELOAD=`ls /usr/lib/*/faketime/libfaketime.so.1` FAKETIME="${year}-${month}-01 00:00:00" openssl ca -gencrl -config "$BASE/../selfsign.config" -keyfile key.key -cert key.crt -crldays 35 -out $2_$3.crl + TZ=UTC LD_PRELOAD="$(findLibfaketime)" FAKETIME="${year}-${month}-01 00:00:00" openssl ca -gencrl -config "$BASE/../selfsign.config" -keyfile key.key -cert key.crt -crldays 35 -out $2_$3.crl popd > /dev/null } diff --git a/generateInfra b/generateInfra index 4bee84a..819635f 100755 --- a/generateInfra +++ b/generateInfra @@ -49,7 +49,7 @@ genserver(){ #key, subject, config openssl req -new -key $1.key -out $1.csr -subj "$2" caSign $1 $year/ca/env_${year}_1 "$3" "${year}${points[1]}" "$((${year} + 2))${points[1]}" - TZ=UTC LD_PRELOAD=`ls /usr/lib/*/faketime/libfaketime.so.1` FAKETIME="${year}-01-01 00:00:00" openssl pkcs12 -inkey $1.key -in $1.crt -CAfile env.chain.crt -chain -name $1 -export -passout pass:changeit -out $1.pkcs12 -name "$4" + TZ=UTC LD_PRELOAD="$(findLibfaketime)" FAKETIME="${year}-01-01 00:00:00" openssl pkcs12 -inkey $1.key -in $1.crt -CAfile env.chain.crt -chain -name $1 -export -passout pass:changeit -out $1.pkcs12 -name "$4" } -- 2.39.2