X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_ircv3_ctctags.cpp;h=8dd83bd7f525777cdf0c089ee32c9c33f107584a;hb=e2b0f3dc9ef4d56c71d7abda13e6139ca092e387;hp=16b71e83e1744fa4fdac48b430c6c16e2c1ef913;hpb=4a6fedd9324d87349a806c9c1d0ae6e7d3c1fd38;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_ircv3_ctctags.cpp b/src/modules/m_ircv3_ctctags.cpp index 16b71e83e..8dd83bd7f 100644 --- a/src/modules/m_ircv3_ctctags.cpp +++ b/src/modules/m_ircv3_ctctags.cpp @@ -2,7 +2,7 @@ * InspIRCd -- Internet Relay Chat Daemon * * Copyright (C) 2019 linuxdaemon - * Copyright (C) 2018-2020 Sadie Powell + * Copyright (C) 2018-2021 Sadie Powell * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -109,7 +109,10 @@ class CommandTagMsg : public Command // If the source isn't allowed to mass message users then reject // the attempt to mass-message users. if (!source->HasPrivPermission("users/mass-message")) + { + source->WriteNumeric(ERR_NOPRIVILEGES, "Permission Denied - You do not have the required operator privileges"); return CMD_FAILURE; + } // Extract the server glob match from the target parameter. std::string servername(parameters[0], 1); @@ -231,15 +234,26 @@ class CommandTagMsg : public Command if (parameters[0][0] == '$') return HandleServerTarget(user, parameters); - // If the message begins with a status character then look it up. + // If the message begins with one or more status characters then look them up. const char* target = parameters[0].c_str(); - PrefixMode* pmh = ServerInstance->Modes->FindPrefix(target[0]); - if (pmh) - target++; + PrefixMode* targetpfx = NULL; + for (PrefixMode* pfx; (pfx = ServerInstance->Modes->FindPrefix(target[0])); ++target) + { + // We want the lowest ranked prefix specified. + if (!targetpfx || pfx->GetPrefixRank() < targetpfx->GetPrefixRank()) + targetpfx = pfx; + } + + if (!target[0]) + { + // The target consisted solely of prefix modes. + user->WriteNumeric(ERR_NORECIPIENT, "No recipient given"); + return CMD_FAILURE; + } // The target is a channel name. if (*target == '#') - return HandleChannelTarget(user, parameters, target, pmh); + return HandleChannelTarget(user, parameters, target, targetpfx); // The target is a nickname. return HandleUserTarget(user, parameters); @@ -261,6 +275,7 @@ class C2CTags : public ClientProtocol::MessageTagProvider Cap::Capability& cap; public: + bool allowclientonlytags; C2CTags(Module* Creator, Cap::Capability& Cap) : ClientProtocol::MessageTagProvider(Creator) , cap(Cap) @@ -271,7 +286,7 @@ class C2CTags : public ClientProtocol::MessageTagProvider { // A client-only tag is prefixed with a plus sign (+) and otherwise conforms // to the format specified in IRCv3.2 tags. - if (tagname[0] != '+' || tagname.length() < 2) + if (tagname[0] != '+' || tagname.length() < 2 || !allowclientonlytags) return MOD_RES_PASSTHRU; // If the user is local then we check whether they have the message-tags cap @@ -323,6 +338,17 @@ class ModuleIRCv3CTCTags { } + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE + { + c2ctags.allowclientonlytags = ServerInstance->Config->ConfValue("ctctags")->getBool("allowclientonlytags", true); + } + + void On005Numeric(std::map& tokens) CXX11_OVERRIDE + { + if (!c2ctags.allowclientonlytags) + tokens["CLIENTTAGDENY"] = "*"; + } + ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE { return CopyClientTags(details.tags_in, details.tags_out);