From 5d9dc0e74d03f018aee28bbc7b3f0f7d07c3b176 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 27 Aug 2025 15:33:26 +0100 Subject: [PATCH] Put decrypt in a try/catch Signed-off-by: snipe --- app/Console/Commands/LdapTroubleshooter.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/LdapTroubleshooter.php b/app/Console/Commands/LdapTroubleshooter.php index f9b9f4bb0d..8c45bcf6c6 100644 --- a/app/Console/Commands/LdapTroubleshooter.php +++ b/app/Console/Commands/LdapTroubleshooter.php @@ -161,7 +161,15 @@ class LdapTroubleshooter extends Command $output[] = "-x"; $output[] = "-b ".escapeshellarg($settings->ldap_basedn); $output[] = "-D ".escapeshellarg($settings->ldap_uname); - $output[] = "-w ".escapeshellarg(Crypt::Decrypt($settings->ldap_pword)); + + try { + $w = Crypt::Decrypt($settings->ldap_pword); + } catch (\Exception $e) { + $this->warn("Could not decrypt password. This usually means an LDAP password was not set or the APP_KEY was changed since the LDAP pasword was last saved. Aborting."); + exit(0); + } + + $output[] = "-w ". escapeshellarg($w); $output[] = escapeshellarg(parenthesized_filter($settings->ldap_filter)); if($settings->ldap_tls) { $this->line("# adding STARTTLS option");