From 3106f3b90e37dba8a13f9766447e0affefde13a6 Mon Sep 17 00:00:00 2001 From: psychon Date: Thu, 24 Jul 2008 10:16:52 +0000 Subject: [PATCH] modperl: Fail if modperl.pm can not be loaded git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1147 726aef4b-f618-498e-8847-2d620e286838 --- modules/modperl.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/modules/modperl.cpp b/modules/modperl.cpp index bfdf8b5e..45e0a372 100644 --- a/modules/modperl.cpp +++ b/modules/modperl.cpp @@ -238,23 +238,24 @@ public: m_pPerl = NULL; } - void SetupZNCScript() + bool SetupZNCScript() { CString sModule, sTmp; - if (CZNC::Get().FindModPath("modperl.pm", sModule, sTmp)) - { - CString sBuffer, sScript; - CFile cFile(sModule); - if ((cFile.Exists()) && (cFile.Open(O_RDONLY))) - { - while (cFile.ReadLine(sBuffer)) - sScript += sBuffer; - cFile.Close(); + if (!CZNC::Get().FindModPath("modperl.pm", sModule, sTmp)) + return false; - eval_pv(sScript.c_str(), FALSE); - } - } + CString sBuffer, sScript; + CFile cFile(sModule); + if (!cFile.Exists() || !cFile.Open(O_RDONLY)) + return false; + + while (cFile.ReadLine(sBuffer)) + sScript += sBuffer; + cFile.Close(); + + eval_pv(sScript.c_str(), FALSE); + return true; } virtual EModRet OnConfigLine(const CString& sName, const CString& sValue, CUser* pUser, CChan* pChan) @@ -1016,7 +1017,10 @@ bool CModPerl::OnLoad(const CString & sArgs, CString & sMessage) newXS("ZNC::SetSockValue", XS_ZNC_SetSockValue, "modperl"); // this sets up the eval CB that we call from here on out. this way we can grab the error produced - SetupZNCScript(); + if (!SetupZNCScript()) { + sMessage = "Failed to load modperl.pm"; + return false; + } HV *pZNCSpace = get_hv("ZNC::", TRUE);