From 5cca791420a94d44fa3bfc9129dfea22ec5eb83f Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Tue, 22 Aug 2017 10:01:08 +0200 Subject: [PATCH 176/310] 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 529e0f006224..1da042018145 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -112,9 +112,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.37.1