summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-09 13:41:29 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-09 13:41:29 +0000
commit6dfc98470938a932ddee0100f515658dffe94438 (patch)
treef496107a29fe8f32778f30e00eff0401937836b9
parent0b5f8887db6916c367975146e12e157b4b1ceae3 (diff)
Stripcolor not finished yet.
Add security check into censor and botmode (om you will need this in cloaking) which prevents non-opers from changing other users modes git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4213 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/m_botmode.cpp4
-rw-r--r--src/modules/m_censor.cpp4
-rw-r--r--src/modules/m_stripcolor.cpp65
3 files changed, 73 insertions, 0 deletions
diff --git a/src/modules/m_botmode.cpp b/src/modules/m_botmode.cpp
index f56db1e8b..57ab1e91c 100644
--- a/src/modules/m_botmode.cpp
+++ b/src/modules/m_botmode.cpp
@@ -32,6 +32,10 @@ class BotMode : public ModeHandler
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
+ /* Only opers can change other users modes */
+ if ((source != dest) && (!*source->oper))
+ return MODEACTION_DENY;
+
if (adding)
{
if (!dest->IsModeSet('B'))
diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp
index d1e864419..69db8bbe6 100644
--- a/src/modules/m_censor.cpp
+++ b/src/modules/m_censor.cpp
@@ -43,6 +43,10 @@ class CensorUser : public ModeHandler
ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
+ /* Only opers can change other users modes */
+ if ((source != dest) && (!*source->oper))
+ return MODEACTION_DENY;
+
if (adding)
{
if (!dest->IsModeSet('G'))
diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp
index 1b8f8c72d..485f05c14 100644
--- a/src/modules/m_stripcolor.cpp
+++ b/src/modules/m_stripcolor.cpp
@@ -25,6 +25,71 @@ using namespace std;
/* $ModDesc: Provides channel +S mode (strip ansi colour) */
+class ChannelStripColor : public ModeHandler
+{
+ public:
+ StripColor() : ModeHandler('S', 0, 0, false, MODETYPE_CHANNEL, false) { }
+
+ ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
+ {
+ /* Only opers can change other users modes */
+ if ((source != dest) && (!*source->oper))
+ return MODEACTION_DENY;
+
+ if (adding)
+ {
+ if (!channel->IsModeSet('S'))
+ {
+ channel->SetMode('S',true);
+ return MODEACTION_ALLOW;
+ }
+ }
+ else
+ {
+ if (channel->IsModeSet('S'))
+ {
+ channel->SetMode('S',false);
+ return MODEACTION_ALLOW;
+ }
+ }
+
+ return MODEACTION_DENY;
+ }
+};
+
+class UserStripColor : public ModeHandler
+{
+ public:
+ StripColor() : ModeHandler('S', 0, 0, false, MODETYPE_USER, false) { }
+
+ ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
+ {
+ /* Only opers can change other users modes */
+ if ((source != dest) && (!*source->oper))
+ return MODEACTION_DENY;
+
+ if (adding)
+ {
+ if (!dest->IsModeSet('S'))
+ {
+ dest->SetMode('S',true);
+ return MODEACTION_ALLOW;
+ }
+ }
+ else
+ {
+ if (dest->IsModeSet('S'))
+ {
+ dest->SetMode('S',false);
+ return MODEACTION_ALLOW;
+ }
+ }
+
+ return MODEACTION_DENY;
+ }
+};
+
+
class ModuleStripColor : public Module
{
Server *Srv;