From 7a985ac077d35adde6c244a4fcae8f45f81e11e5 Mon Sep 17 00:00:00 2001 From: psychon Date: Fri, 20 Feb 2009 19:15:31 +0000 Subject: [PATCH] Don't ever ask for a password via stdin in away and savebuff git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1388 726aef4b-f618-498e-8847-2d620e286838 --- modules/away.cpp | 22 +++++++--------------- modules/savebuff.cpp | 30 +++++++++++------------------- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/modules/away.cpp b/modules/away.cpp index df824c35..313df00d 100644 --- a/modules/away.cpp +++ b/modules/away.cpp @@ -62,28 +62,20 @@ public: if (!sMyArgs.empty()) { m_sPassword = CBlowfish::MD5(sMyArgs); - } - - return true; - } - - virtual bool OnBoot() - { - if (m_sPassword.empty()) - { - CString sTmp = CUtils::GetPass("Enter Encryption Key for away.so: "); - - if (!sTmp.empty()) - m_sPassword = CBlowfish::MD5(sTmp); + } else { + sMessage = "This module needs as an argument a keyphrase used for encryption"; + return false; } if (!BootStrap()) { + sMessage = "Failed to decrypt your saved messages - " + "Did you give the right encryption key as an argument to this module?"; m_bBootError = true; - return(false); + return false; } - return(true); + return true; } virtual void OnIRCConnected() diff --git a/modules/savebuff.cpp b/modules/savebuff.cpp index 21b4cc1b..ab16c980 100644 --- a/modules/savebuff.cpp +++ b/modules/savebuff.cpp @@ -58,26 +58,16 @@ public: virtual bool OnLoad(const CString& sArgs, CString& sMessage) { - if (!sArgs.empty()) - { - m_sPassword = CBlowfish::MD5(sArgs); - return(OnBoot()); - } - - return true; - } - - virtual bool OnBoot() - { - if (m_sPassword.empty()) - { - CString sTmp = CUtils::GetPass("Enter Encryption Key for " + GetModName() + ".so"); - - if (!sTmp.empty()) - m_sPassword = CBlowfish::MD5(sTmp); - } - const vector& vChans = m_pUser->GetChans(); + + if (sArgs.empty()) + { + sMessage = "This module needs as an argument a keyphrase used for encryption"; + return false; + } + + m_sPassword = CBlowfish::MD5(sArgs); + for (u_int a = 0; a < vChans.size(); a++) { if (!vChans[a]->KeepBuffer()) @@ -85,6 +75,8 @@ public: if (!BootStrap(vChans[a])) { + sMessage = "Failed to decrypt your saved messages - " + "Did you give the right encryption key as an argument to this module?"; m_bBootError = true; return(false); }