From 7ced47e9b37382e2d40bd11f163bc2519f66fe96 Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 14 Sep 2015 18:09:39 -0700 Subject: [PATCH] bots: don't allow setting umode +o on InspIRCd users (forbidden and causes desync) --- classes.py | 3 +++ plugins/bots.py | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/classes.py b/classes.py index e156370..6cf9630 100644 --- a/classes.py +++ b/classes.py @@ -399,6 +399,9 @@ class Protocol(): # Whether the IRCd allows forcing user mode changes on other servers' clients. self.allow_forceset_usermodes = False + # Ditto, but for setting user mode +o. InspIRCd forbids this as an example. + self.allow_forceoper = False + class FakeProto(Protocol): """Dummy protocol module for testing purposes.""" def handle_events(self, data): diff --git a/plugins/bots.py b/plugins/bots.py index 8c454f2..c3d0f5a 100644 --- a/plugins/bots.py +++ b/plugins/bots.py @@ -146,17 +146,21 @@ def mode(irc, source, args): irc.msg(source, 'Error: Not enough arguments. Needs 3: source nick, target, modes to set.') return target = utils.nickToUid(irc, target) or target + extclient = target in irc.users and not utils.isInternalClient(irc, target) + parsedmodes = utils.parseModes(irc, target, modes) if not (target in irc.users or target in irc.channels): irc.msg(source, "Error: Invalid channel or nick %r." % target) return - elif target in irc.users and not utils.isInternalClient(irc, target) and \ - not irc.proto.allow_forceset_usermodes: + elif not parsedmodes: + irc.msg(source, "Error: No valid modes were given.") + return + elif extclient and not irc.proto.allow_forceset_usermodes: irc.msg(source, "Error: this IRCd does not allow forcing user mode " "changes on other servers' users!") return - parsedmodes = utils.parseModes(irc, target, modes) - if not parsedmodes: - irc.msg(source, "Error: No valid modes were given.") + elif extclient and ("+o", None) in parsedmodes and not irc.proto.allow_forceoper: + irc.msg(source, "Error: this IRCd does not allow forcing an oper up " + "for other servers' users!") return if utils.isInternalServer(irc, modesource): # Setting modes from a server.