commit:     80b8bc853f44dbd8e4042b4ac3c64a1f5d8f63af
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 27 10:43:41 2019 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Wed Nov 27 16:05:48 2019 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=80b8bc85

initrd.scripts: start_sshd(): Only set gk.prompt.timeout when dropbear was 
actually started

If we failed to start dropbear for some reason, user has no chance to
answer prompt without physical access so setting gk.prompt.timeout
would only cause an unnecessary delay.

Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 defaults/initrd.scripts | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 96ca339..dd5be3b 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -2250,12 +2250,6 @@ start_sshd() {
                return
        fi
 
-       if [ "${GK_PROMPT_TIMEOUT}" = '0' ]
-       then
-               warn_msg "Changing gk.prompt.timeout=0 to 30 to allow remote 
user to answer prompts ..."
-               GK_PROMPT_TIMEOUT=30
-       fi
-
        if [ ! -x "/usr/sbin/dropbear" ]
        then
                bad_msg "/usr/sbin/dropbear not found! Was initramfs built 
without --ssh parameter?"
@@ -2275,6 +2269,14 @@ start_sshd() {
 
        good_msg "Starting dropbear sshd ..." ${QUIET}
        run /usr/sbin/dropbear -p ${GK_SSHD_PORT} -R -P "${GK_SSHD_PIDFILE}" 
2>/var/log/dropbear.log
+       if [ $? -eq 0 ]
+       then
+               if [ "${GK_PROMPT_TIMEOUT}" = '0' ]
+               then
+                       warn_msg "Changing gk.prompt.timeout=0 to 30 to allow 
remote user to answer prompts ..."
+                       GK_PROMPT_TIMEOUT=30
+               fi
+       fi
 }
 
 wait_sshd() {

Reply via email to