From 5c1a77cf66da716e70afa6b7c5f398715016fb88 Mon Sep 17 00:00:00 2001 From: Anders Blomdell Date: Wed, 4 May 2022 14:47:48 +0200 Subject: [PATCH] Get rid of bash arrays, we know that certificate names does not contain whitespace --- easyrsa3/easyrsa | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/easyrsa3/easyrsa b/easyrsa3/easyrsa index b88580d..1647a1c 100755 --- a/easyrsa3/easyrsa +++ b/easyrsa3/easyrsa @@ -2065,23 +2065,24 @@ renewable() { in_dir="$EASYRSA_PKI" if [ $# -eq 0 ] ; then - candidates=( $(ls ${in_dir}/issued/ | sed -e 's|.crt$||p;d' ) ) + candidates=$(find "${in_dir}"/issued/ \ + | sort | sed -e 's|^.*/||;s|.crt$||p;d' ) else - candidates=( $@ ) + candidates=$* fi - matches=() - for candidate in ${candidates[@]} ; do + matches="" + for candidate in $candidates ; do crt_in="$in_dir/issued/$candidate.crt" cert_dates "$crt_in" if [ "$expire_date" -lt "$allow_renew_date" ] ; then - matches+=( $candidate ) + matches="$matches $candidate" fi done - if [ ${#matches[@]} -eq 0 ] ; then + if [ -z "$matches" ] ; then # Nothing to renew exit 1 else - print "${matches[@]}" + print "$matches" fi } # => renewable