summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2012-10-12 23:32:35 +0200
committerattilamolnar <attilamolnar@hush.com>2012-10-28 15:23:38 +0100
commit59cafb70e66c176b837770ae4fd21aa578c80bef (patch)
tree337847642bf48e0aef8af67e7de4e6f493365d2d
parent1357ed09ccdab5c2b19bb108ef3723a1e308e337 (diff)
m_operlog Add tosnomask config option, to log all oper actions to snomask 'r'
If enabled, the commands can be logged to channels with m_chanlog and also other +s +r opers can see them Fixes #325 reported by @SeLEct-
-rw-r--r--docs/conf/modules.conf.example6
-rw-r--r--src/modules/m_operlog.cpp17
2 files changed, 18 insertions, 5 deletions
diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example
index e20769373..de91cf891 100644
--- a/docs/conf/modules.conf.example
+++ b/docs/conf/modules.conf.example
@@ -1225,9 +1225,13 @@
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Oper log module: Logs all oper commands to the ircd log at default
-# loglevel.
+# loglevel, and optionally to the 'r' SNOMASK.
# This module is oper-only.
#<module name="m_operlog.so">
+#
+# If the following option is on then all oper commands will be sent to
+# the snomask 'r'. The default is off.
+#<operlog tosnomask="off">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Oper prefixing module: Gives IRC operators a prefix status character
diff --git a/src/modules/m_operlog.cpp b/src/modules/m_operlog.cpp
index 1913ceeee..17b9887c2 100644
--- a/src/modules/m_operlog.cpp
+++ b/src/modules/m_operlog.cpp
@@ -25,13 +25,15 @@
class ModuleOperLog : public Module
{
- private:
+ bool tosnomask;
public:
ModuleOperLog() {
- Implementation eventlist[] = { I_OnPreCommand, I_On005Numeric };
- ServerInstance->Modules->Attach(eventlist, this, 2);
+ Implementation eventlist[] = { I_OnPreCommand, I_On005Numeric, I_OnRehash };
+ ServerInstance->Modules->Attach(eventlist, this, 3);
+ ServerInstance->SNO->EnableSnomask('r', "OPERLOG");
+ OnRehash(NULL);
}
virtual ~ModuleOperLog()
@@ -43,6 +45,10 @@ class ModuleOperLog : public Module
return Version("A module which logs all oper commands to the ircd log at default loglevel.", VF_VENDOR);
}
+ void OnRehash(User* user)
+ {
+ tosnomask = ServerInstance->Config->ConfValue("operlog")->getBool("tosnomask", false);
+ }
virtual ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, LocalUser *user, bool validated, const std::string &original_line)
{
@@ -58,7 +64,10 @@ class ModuleOperLog : public Module
std::string line;
if (!parameters.empty())
line = irc::stringjoiner(" ", parameters, 0, parameters.size() - 1).GetJoined();
- ServerInstance->Logs->Log("m_operlog",DEFAULT,"OPERLOG: [%s] %s %s", user->GetFullRealHost().c_str(), command.c_str(), line.c_str());
+ std::string msg = "[" + user->GetFullRealHost() + "] " + command + " " + line;
+ ServerInstance->Logs->Log("m_operlog", DEFAULT, "OPERLOG: " + msg);
+ if (tosnomask)
+ ServerInstance->SNO->WriteGlobalSno('r', msg);
}
}