From: Alexander Dahl <ada@thorsis.com>
To: ptxdist@pengutronix.de
Cc: Alexander Dahl <ada@thorsis.com>
Subject: [ptxdist] [PATCH] dropbear: rc-once: Fix error handling
Date: Thu, 9 Dec 2021 11:51:27 +0100 [thread overview]
Message-ID: <20211209105127.120588-1-ada@thorsis.com> (raw)
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
next reply other threads:[~2021-12-09 10:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-09 10:51 Alexander Dahl [this message]
2021-12-10 13:07 ` [ptxdist] [APPLIED] " Michael Olbrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211209105127.120588-1-ada@thorsis.com \
--to=ada@thorsis.com \
--cc=ptxdist@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox