From b92f71e94bd0c8b74e191dac72f69e20fd6edcc4 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 12 Jan 2013 20:55:55 +0100 Subject: [PATCH] dropbear: Make sure the dropbear key is generated on first boot The previous patch made sure a truncated key would be re-generated but it broke the case that there is no key at all. This code is handling both cases now. Use quotes as code outside this method is using them too. Use the -a and not the && operator to work with the busybox version of [ and ]. --- recipes-fixes/dropbear/files/init | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes-fixes/dropbear/files/init b/recipes-fixes/dropbear/files/init index 8b99ecb..c1747e7 100644 --- a/recipes-fixes/dropbear/files/init +++ b/recipes-fixes/dropbear/files/init @@ -58,13 +58,13 @@ gen_keys() { for t in $DROPBEAR_KEYTYPES; do case $t in rsa) - if [ ! -s $DROPBEAR_RSAKEY ]; then + if [ -f "$DROPBEAR_RSAKEY" -a ! -s "$DROPBEAR_RSAKEY" ]; then rm $DROPBEAR_RSAKEY fi test -f $DROPBEAR_RSAKEY || dropbearkey -t rsa -f $DROPBEAR_RSAKEY ;; dsa) - if [ ! -s $DROPBEAR_DSSKEY ]; then + if [ -f "$DROPBEAR_DSSKEY" -a ! -s "$DROPBEAR_DSSKEY" ]; then rm $DROPBEAR_DSSKEY fi test -f $DROPBEAR_DSSKEY || dropbearkey -t dss -f $DROPBEAR_DSSKEY