X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Firc-mode.c;h=45defeb2b833f4933c24277b6fad077064b37536;hb=6fdd3479f126a866c022c39dcd424d6042de6875;hp=cd470863aa2edea492a9e818cce5103c1d50af72;hpb=f76e0a1db689dadfe32f211002248d03416b3982;p=ngircd-alex.git diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c index cd470863..45defeb2 100644 --- a/src/ngircd/irc-mode.c +++ b/src/ngircd/irc-mode.c @@ -22,27 +22,30 @@ #include "defines.h" #include "conn.h" -#include "client.h" #include "channel.h" #include "irc-write.h" #include "lists.h" #include "log.h" #include "parse.h" #include "messages.h" -#include "resolve.h" #include "conf.h" #include "exp.h" #include "irc-mode.h" -static bool Client_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )); -static bool Channel_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )); +static bool Client_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, + CLIENT *Target )); +static bool Channel_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, + CHANNEL *Channel )); -static bool Add_Ban_Invite PARAMS((int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Pattern)); -static bool Del_Ban_Invite PARAMS((int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Pattern)); +static bool Add_Ban_Invite PARAMS((int what, CLIENT *Prefix, CLIENT *Client, + CHANNEL *Channel, const char *Pattern)); +static bool Del_Ban_Invite PARAMS((int what, CLIENT *Prefix, CLIENT *Client, + CHANNEL *Channel, const char *Pattern)); -static bool Send_ListChange PARAMS(( char *Mode, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Mask )); +static bool Send_ListChange PARAMS((const char *Mode, CLIENT *Prefix, + CLIENT *Client, CHANNEL *Channel, const char *Mask)); GLOBAL bool @@ -294,7 +297,8 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel) { 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; @@ -311,14 +315,13 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel) /* 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; @@ -326,6 +329,10 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel) use_servermode = true; /* Change Origin to Server */ } } + + if (!onchannel && !modeok) + return IRC_WriteStrClient(Origin, ERR_NOTONCHANNEL_MSG, + Client_ID(Origin), Channel_Name(Channel)); } mode_arg = 1; @@ -758,7 +765,8 @@ Del_Ban_Invite(int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const static bool -Send_ListChange( char *Mode, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Mask ) +Send_ListChange(const char *Mode, CLIENT *Prefix, CLIENT *Client, + CHANNEL *Channel, const char *Mask) { bool ok;