Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 May 2020 01:35:44 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r361148 - head/usr.sbin/certctl
Message-ID:  <202005180135.04I1ZiBn071950@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202005180135.04I1ZiBn071950>