certctl: don't fall over flat with relative DESTDIR

Up until now, all of our DESTDIR use has been with absolute paths. It turned
out that the cd in/out dance we do here breaks us down later on, as the
relative path no longer resolves.

Convert EXTENSIONS to an ERE that we'll use to grep ls -1 of the dir we're
inspecting, rather than cd'ing into it and globbing it up.

MFC after:	3 days
This commit is contained in:
Kyle Evans 2020-05-18 01:35:44 +00:00
parent 3d7650f04c
commit 09841aabfa
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=361148

View File

@ -34,7 +34,7 @@
: ${BLACKLISTPATH:=${DESTDIR}/usr/share/certs/blacklisted:${DESTDIR}/usr/local/etc/ssl/blacklisted}
: ${CERTDESTDIR:=${DESTDIR}/etc/ssl/certs}
: ${BLACKLISTDESTDIR:=${DESTDIR}/etc/ssl/blacklisted}
: ${EXTENSIONS:="*.pem *.crt *.cer *.crl *.0"}
: ${FILEPAT:="\.pem$|\.crt$|\.cer$|\.crl$|\.0$"}
: ${VERBOSE:=0}
############################################################ GLOBALS
@ -104,13 +104,11 @@ do_scan()
for CPATH in "$@"; do
[ -d "$CPATH" ] || continue
echo "Scanning $CPATH for certificates..."
cd "$CPATH"
for CFILE in $EXTENSIONS; do
[ -e "$CFILE" ] || continue
for CFILE in $(ls -1 "${CPATH}" | grep -Ee "${FILEPAT}"); do
[ -e "$CPATH/$CFILE" ] || continue
[ $VERBOSE -gt 0 ] && echo "Reading $CFILE"
"$CFUNC" "$CPATH/$CFILE"
done
cd -
done
}