mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] dropbear: rc-once: Fix error handling
@ 2021-12-09 10:51 Alexander Dahl
  2021-12-10 13:07 ` [ptxdist] [APPLIED] " Michael Olbrich
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Dahl @ 2021-12-09 10:51 UTC (permalink / raw)
  To: ptxdist; +Cc: Alexander Dahl

The return of gen_keys() never threw an error, so last block was useless
so far. Script worked because gen_key() exited instead of returning.
Messages are done like in the openssh rc-once script now.

Fixes: cf0424f8ba23 ("dropbear: Refactor rc-once and init to use KEYTYPES")
Signed-off-by: Alexander Dahl <ada@thorsis.com>
---
 projectroot/etc/rc.once.d/dropbear | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/projectroot/etc/rc.once.d/dropbear b/projectroot/etc/rc.once.d/dropbear
index 8a0440624..a8725616a 100644
--- a/projectroot/etc/rc.once.d/dropbear
+++ b/projectroot/etc/rc.once.d/dropbear
@@ -13,15 +13,9 @@ gen_key() {
 
 	rm -f $key_file > /dev/null 2>&1
 
-	echo -n "generating $key_type key..."
-	dropbearkey -t $key_type -f $key_file > /dev/null 2>&1
-
-	if [ "$?" = "0" ]; then
-		echo "done"
-	else
-		echo "failed"
-		exit 1
-	fi
+	echo "Create $key_type key; this may take some time ..."
+	dropbearkey -t $key_type -f $key_file > /dev/null 2>&1 || return
+	echo "Created $key_type key."
 }
 
 gen_keys() {
@@ -29,10 +23,10 @@ gen_keys() {
 	do
 		case "$keytype" in
 			rsa)
-				gen_key rsa "$DROPBEAR_RSAKEY"
+				gen_key rsa "$DROPBEAR_RSAKEY" || return
 				;;
 			ecdsa)
-				gen_key ecdsa "$DROPBEAR_ECDSAKEY"
+				gen_key ecdsa "$DROPBEAR_ECDSAKEY" || return
 				;;
 			*)
 				echo "Key type '$keytype' not supported"

base-commit: 70205d7cc77ff2bd36860291bf767f91bb4bc989
-- 
2.20.1


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ptxdist] [APPLIED] dropbear: rc-once: Fix error handling
  2021-12-09 10:51 [ptxdist] [PATCH] dropbear: rc-once: Fix error handling Alexander Dahl
@ 2021-12-10 13:07 ` Michael Olbrich
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Olbrich @ 2021-12-10 13:07 UTC (permalink / raw)
  To: ptxdist; +Cc: Alexander Dahl

Thanks, applied as a467e398aeed82d2a96e5e72a86aa9ac09f3e261.

Michael

[sent from post-receive hook]

On Fri, 10 Dec 2021 14:07:24 +0100, Alexander Dahl <ada@thorsis.com> wrote:
> The return of gen_keys() never threw an error, so last block was useless
> so far. Script worked because gen_key() exited instead of returning.
> Messages are done like in the openssh rc-once script now.
> 
> Fixes: cf0424f8ba23 ("dropbear: Refactor rc-once and init to use KEYTYPES")
> Signed-off-by: Alexander Dahl <ada@thorsis.com>
> Message-Id: <20211209105127.120588-1-ada@thorsis.com>
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> 
> diff --git a/projectroot/etc/rc.once.d/dropbear b/projectroot/etc/rc.once.d/dropbear
> index 8a04406242e4..a8725616a7f2 100644
> --- a/projectroot/etc/rc.once.d/dropbear
> +++ b/projectroot/etc/rc.once.d/dropbear
> @@ -13,15 +13,9 @@ gen_key() {
>  
>  	rm -f $key_file > /dev/null 2>&1
>  
> -	echo -n "generating $key_type key..."
> -	dropbearkey -t $key_type -f $key_file > /dev/null 2>&1
> -
> -	if [ "$?" = "0" ]; then
> -		echo "done"
> -	else
> -		echo "failed"
> -		exit 1
> -	fi
> +	echo "Create $key_type key; this may take some time ..."
> +	dropbearkey -t $key_type -f $key_file > /dev/null 2>&1 || return
> +	echo "Created $key_type key."
>  }
>  
>  gen_keys() {
> @@ -29,10 +23,10 @@ gen_keys() {
>  	do
>  		case "$keytype" in
>  			rsa)
> -				gen_key rsa "$DROPBEAR_RSAKEY"
> +				gen_key rsa "$DROPBEAR_RSAKEY" || return
>  				;;
>  			ecdsa)
> -				gen_key ecdsa "$DROPBEAR_ECDSAKEY"
> +				gen_key ecdsa "$DROPBEAR_ECDSAKEY" || return
>  				;;
>  			*)
>  				echo "Key type '$keytype' not supported"

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-10 13:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09 10:51 [ptxdist] [PATCH] dropbear: rc-once: Fix error handling Alexander Dahl
2021-12-10 13:07 ` [ptxdist] [APPLIED] " Michael Olbrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox