From 617e732f663da27e5f3294b2e700648f76bdc191 Mon Sep 17 00:00:00 2001 From: psychon Date: Tue, 1 Apr 2008 08:57:21 +0000 Subject: [PATCH] Only allow admins to load the shell module The exception to this is if ZNC is compiled with -DMOD_SHELL_ALLOW_EVERYONE x-x wanted this. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1007 726aef4b-f618-498e-8847-2d620e286838 --- modules/shell.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/shell.cpp b/modules/shell.cpp index 155a5cd9..ab4c3b8f 100644 --- a/modules/shell.cpp +++ b/modules/shell.cpp @@ -43,6 +43,18 @@ public: } } + virtual bool OnLoad(const CString& sArgs, CString& sMessage) + { +#ifndef MOD_SHELL_ALLOW_EVERYONE + if (!m_pUser->IsAdmin()) { + sMessage = "You must be admin to use the shell module"; + return false; + } +#endif + + return true; + } + virtual void OnModCommand(const CString& sCommand) { if ((strcasecmp(sCommand.c_str(), "cd") == 0) || (strncasecmp(sCommand.c_str(), "cd ", 3) == 0)) { CString sPath = CUtils::ChangeDir(m_sPath, ((sCommand.length() == 2) ? CString(CZNC::Get().GetHomePath()) : CString(sCommand.substr(3))), CZNC::Get().GetHomePath());