]> WPIA git - nre.git/commitdiff
Allow finding libfaketime in multiple locations
authorLucas Werkmeister <mail@lucaswerkmeister.de>
Fri, 22 Apr 2016 16:00:55 +0000 (18:00 +0200)
committerLucas Werkmeister <mail@lucaswerkmeister.de>
Fri, 22 Apr 2016 16:00:55 +0000 (18:00 +0200)
The install location of libfaketime varies across distributions.

commonFunctions.bash
generateCRLs
generateInfra

index 0d8b897869686aabec612d2ece4a93e5f114120e..36ffa19fad613285b80585cc1a3f0f39fe278020 100644 (file)
@@ -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
+}
+
index be4cf83499fb2d944e783dc0c4e0d17deea9eeec..e31bb54e8ac3d311cd7facbf530bd21f8eb910e1 100755 (executable)
@@ -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
 }
 
index 4bee84ad8d776ece281734769c6663475b597236..819635fd15a0a26fa1acac3c50f10bfb38a190f2 100755 (executable)
@@ -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"
     
 }