From 57ddf56ae31367153d5e39cc851c01e206ba2bcd Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Tue, 22 Aug 2017 10:01:08 +0200 Subject: [PATCH 192/325] sys/geom/eli: Ignore the passphrase set in the loader if it doesn't contain a single character Obtained from: ElectroBSD --- sys/geom/eli/g_eli.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index 8411063478e2..d5a5d59570bd 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -104,9 +104,24 @@ fetch_loader_passphrase(void * dummy) KASSERT(dynamic_kenv, ("need dynamic kenv")); if ((env_passphrase = kern_getenv("kern.geom.eli.passphrase")) != NULL) { - /* Extract passphrase from the environment. */ - strlcpy(cached_passphrase, env_passphrase, - sizeof(cached_passphrase)); + if (env_passphrase[0] != '\0') { + /* Extract passphrase from the environment. */ + strlcpy(cached_passphrase, env_passphrase, + sizeof(cached_passphrase)); + G_ELI_DEBUG(0, "Using cached passphrase!"); + } else { + /* + * Passphrase is set in the environment but empty. + * This can happen if the user actually uses an empty + * passphrase (unlikely) and if the user pressed return + * to skip the passphrase prompt in the loader. + * + * In the second case we do not want to delay the boot + * by iterating over the empty and bogus passphrase and + * ask for another passphrase right away. + */ + G_ELI_DEBUG(0, "Ignoring cached passphrase as it seems to be empty!"); + } freeenv(env_passphrase); /* Wipe the passphrase from the environment. */ -- 2.32.0