commit acb66d64637d33661ff4345e9bb37444109e9d11 from: Florian Westphal via: Alexander Barton date: Sun Jul 25 14:18:25 2010 UTC Allow IRC operators to use MODE command on any channel (closes: #100) This allows IRC operators to change channel modes of ANY channel, even without joining these channels first. commit - 63a304755acc107287ac6fd86d6aca6f7b6e004b commit + acb66d64637d33661ff4345e9bb37444109e9d11 blob - 80a6003fc576ec6ceac1beb2eb1fe69dfc961cc8 blob + 86a509da52e91bd1f5730b46739d885a3cfe072e --- src/ngircd/irc-mode.c +++ src/ngircd/irc-mode.c @@ -297,7 +297,8 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Ori { char the_modes[COMMAND_LEN], the_args[COMMAND_LEN], x[2], argadd[CLIENT_PASS_LEN], *mode_ptr; - bool connected, set, modeok = true, skiponce, use_servermode = false, retval; + bool connected, set, skiponce, retval, onchannel; + bool modeok = true, use_servermode = false; int mode_arg, arg_arg; CLIENT *client; long l; @@ -314,14 +315,13 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Ori /* Is the user allowed to change modes? */ if (Client_Type(Client) == CLIENT_USER) { /* Is the originating user on that channel? */ - if (!Channel_IsMemberOf(Channel, Origin)) - return IRC_WriteStrClient(Origin, ERR_NOTONCHANNEL_MSG, - Client_ID(Origin), Channel_Name(Channel)); + onchannel = Channel_IsMemberOf(Channel, Origin); modeok = false; /* channel operator? */ - if (strchr(Channel_UserModes(Channel, Origin), 'o')) + if (onchannel && + strchr(Channel_UserModes(Channel, Origin), 'o')) { modeok = true; - else if (Conf_OperCanMode) { + } else if (Conf_OperCanMode) { /* IRC-Operators can use MODE as well */ if (Client_OperByMe(Origin)) { modeok = true; @@ -329,6 +329,10 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Ori use_servermode = true; /* Change Origin to Server */ } } + + if (!onchannel && !use_servermode) + return IRC_WriteStrClient(Origin, ERR_NOTONCHANNEL_MSG, + Client_ID(Origin), Channel_Name(Channel)); } mode_arg = 1;