From 2c24f714b6627fd38e97f296eb37d2ae5443c9b8 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Tue, 9 Jun 2015 09:26:57 +0200
Subject: kike: fix INVITE
Didn't allow ban circumvention.
---
kike.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/kike.c b/kike.c
index d5136d7..45dd02b 100644
--- a/kike.c
+++ b/kike.c
@@ -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
--
cgit v1.2.3-70-g09d2