From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 09 Jul 2021 15:36:11 +0200 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1m1qfr-0007pJ-AW for lore@lore.pengutronix.de; Fri, 09 Jul 2021 15:36:11 +0200 Received: from localhost ([127.0.0.1] helo=metis.ext.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1m1qfq-0002E8-UW; Fri, 09 Jul 2021 15:36:10 +0200 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1qfg-0002DZ-Qa; Fri, 09 Jul 2021 15:36:00 +0200 Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1m1qfg-0003zu-AW; Fri, 09 Jul 2021 15:36:00 +0200 Received: from mol by dude03.red.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1m1qfg-001eHs-9m; Fri, 09 Jul 2021 15:36:00 +0200 Date: Fri, 9 Jul 2021 15:36:00 +0200 From: Michael Olbrich To: Roland Hieber Message-ID: <20210709133600.GB375046@pengutronix.de> Mail-Followup-To: Roland Hieber , ptxdist@pengutronix.de, Marc Kleine-Budde References: <20210708203941.30212-1-rhi@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210708203941.30212-1-rhi@pengutronix.de> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [ptxdist] [PATCH v3 1/5] ptxd_lib_code_signing: cs_get_ca(): improve error handling X-BeenThere: ptxdist@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Cc: Marc Kleine-Budde , ptxdist@pengutronix.de Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "ptxdist" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ptxdist-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false On Thu, Jul 08, 2021 at 10:39:37PM +0200, Roland Hieber wrote: > From: Marc Kleine-Budde > > This patch changes cs_get_ca() to only output the CA if it actually > exists, or print an error and return 1 instead. This makes it possible > to use make's $(if $(filter-out, ERROR_CA_NOT_YET_SET, ...)) > conditional. > > Co-authored-by: Roland Hieber > Signed-off-by: Marc Kleine-Budde > Signed-off-by: Roland Hieber > --- > PATCH v3: > - correctly check for existence of ${keydir} instead of ${ca} (feedback > from Michael Olbrich) > - drop controversial re-indentation patches 6/7 and 7/7 from the series > > PATCH v2 (rhi): https://lore.ptxdist.org/ptxdist/20210627231121.28313-1-rhi@pengutronix.de > - reorder from PATCH 3/n to PATCH 1/n > - echo "ERROR_CA_NOT_YET_SET" in case of error (feedback from Michael > Olbrich) and also return 1 > > PATCH v1 (mkl): https://lore.ptxdist.org/ptxdist/20210412161900.2376802-3-mkl@pengutronix.de > --- > scripts/lib/ptxd_lib_code_signing.sh | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/scripts/lib/ptxd_lib_code_signing.sh b/scripts/lib/ptxd_lib_code_signing.sh > index 3e1654bb36e4..199f679ef828 100644 > --- a/scripts/lib/ptxd_lib_code_signing.sh > +++ b/scripts/lib/ptxd_lib_code_signing.sh > @@ -243,7 +243,13 @@ cs_get_ca() { > local role="${1}" > cs_init_variables > > - echo "${keydir}/${role}/ca.pem" > + local ca="${keydir}/${role}/ca.pem" > + > + if [ ! -d "${keydir}" ]; then > + echo "ERROR_CA_NOT_YET_SET" > + return 1 > + fi So this is not what we want here. Sorry, I didn't notice this in the last version. The idea is this: If the keydir does not exist, then cs_get_ca)() was evaluated too early. So the check above should be added as it is here. What's now missing is what Marc originally intended and was part of the first version of the patch: If the keydir exists but no CA, then there will never be a CA and we want to match that. So this should be there as well: if [ -e "${ca}" ]; then echo "${ca}" fi instead of this: > + echo "${ca}" Now we can do $(if $(shell cs_get_ca ...), ...) to do something only if the CA exists. Marc, that was the use-case, right? Michael > } > export -f cs_get_ca > > -- > 2.30.2 > > > _______________________________________________ > ptxdist mailing list > ptxdist@pengutronix.de > To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ ptxdist mailing list ptxdist@pengutronix.de To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de