kike: fix INVITE

Didn't allow ban circumvention.
This commit is contained in:
Přemysl Eric Janouch 2015-06-09 09:26:57 +02:00
parent 5e26dd726c
commit 2c24f714b6

16
kike.c
View File

@ -2322,14 +2322,10 @@ irc_handle_invite (const struct irc_message *msg, struct client *c)
if (channel_get_user (chan, client))
RETURN_WITH_REPLY (c, IRC_ERR_USERONCHANNEL, target, channel_name);
if ((chan->modes & IRC_CHAN_MODE_INVITE_ONLY))
{
if (!(inviting_user->modes & IRC_CHAN_MODE_OPERATOR))
RETURN_WITH_REPLY (c, IRC_ERR_CHANOPRIVSNEEDED, channel_name);
// Only storing the invite if it makes sense
if ((inviting_user->modes & IRC_CHAN_MODE_OPERATOR))
str_map_set (&client->invites, channel_name, (void *) 1);
}
else if ((chan->modes & IRC_CHAN_MODE_INVITE_ONLY))
RETURN_WITH_REPLY (c, IRC_ERR_CHANOPRIVSNEEDED, channel_name);
}
client_send (client, ":%s!%s@%s INVITE %s %s",
@ -2355,10 +2351,10 @@ irc_try_join (struct client *c, const char *channel_name, const char *key)
else if (channel_get_user (chan, c))
return;
bool invited = str_map_find (&c->invites, channel_name);
bool invited_by_chanop = str_map_find (&c->invites, channel_name);
if ((chan->modes & IRC_CHAN_MODE_INVITE_ONLY)
&& !client_in_mask_list (c, &chan->invite_list)
&& !invited)
&& !invited_by_chanop)
RETURN_WITH_REPLY (c, IRC_ERR_INVITEONLYCHAN, channel_name);
if (chan->key && (!key || strcmp (key, chan->key)))
RETURN_WITH_REPLY (c, IRC_ERR_BADCHANNELKEY, channel_name);
@ -2367,7 +2363,7 @@ irc_try_join (struct client *c, const char *channel_name, const char *key)
RETURN_WITH_REPLY (c, IRC_ERR_CHANNELISFULL, channel_name);
if (client_in_mask_list (c, &chan->ban_list)
&& !client_in_mask_list (c, &chan->exception_list)
&& !invited)
&& !invited_by_chanop)
RETURN_WITH_REPLY (c, IRC_ERR_BANNEDFROMCHAN, channel_name);
// Destroy any invitation as there's no other way to get rid of it