Author: kevans
Date: Mon May 18 01:35:44 2020
New Revision: 361148
URL: https://svnweb.freebsd.org/changeset/base/361148

Log:
  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

Modified:
  head/usr.sbin/certctl/certctl.sh

Modified: head/usr.sbin/certctl/certctl.sh
==============================================================================
--- head/usr.sbin/certctl/certctl.sh    Mon May 18 00:32:42 2020        
(r361147)
+++ head/usr.sbin/certctl/certctl.sh    Mon May 18 01:35:44 2020        
(r361148)
@@ -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
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to