From e2afd9be76c9db64ad2eedf1c456e0b50627a97a Mon Sep 17 00:00:00 2001 From: pk910 Date: Tue, 28 Jun 2011 17:49:03 +0200 Subject: [PATCH] check if the user may join the channel he's getting forwarded by +F --- ircd/m_join.c | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/ircd/m_join.c b/ircd/m_join.c index 0dc5ecf..6a93769 100644 --- a/ircd/m_join.c +++ b/ircd/m_join.c @@ -278,21 +278,41 @@ int m_join(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) char *altchan = chptr->mode.altchan; if (!(chptrb = FindChannel(altchan))) { - if (((altchan[0] == '&') && !feature_bool(FEAT_LOCAL_CHANNELS)) || strlen(altchan) > IRCD_MIN(CHANNELLEN, feature_int(FEAT_CHANNELLEN))) { - //we don't send an error message here - that would be very strange for the user, because they normaly don't know that mode +F is set - } else if ((chptrb = get_channel(sptr, altchan, CGT_CREATE))) { - joinbuf_join(&create, chptrb, CHFL_CHANOP | CHFL_CHANNEL_MANAGER); - do_names(sptr, chptrb, NAMES_ALL|NAMES_EON); - } + if (((altchan[0] == '&') && !feature_bool(FEAT_LOCAL_CHANNELS)) || strlen(altchan) > IRCD_MIN(CHANNELLEN, feature_int(FEAT_CHANNELLEN))) { + //we don't send an error message here - that would be very strange for the user, because they normaly don't know that mode +F is set + } else if ((chptrb = get_channel(sptr, altchan, CGT_CREATE))) { + joinbuf_join(&create, chptrb, CHFL_CHANOP | CHFL_CHANNEL_MANAGER); + do_names(sptr, chptrb, NAMES_ALL|NAMES_EON); + } } else { - joinbuf_join(&join, chptrb, flags); - del_invite(sptr, chptrb); - if (chptrb->topic[0]) { - send_reply(sptr, RPL_TOPIC, chptrb->chname, chptrb->topic); - send_reply(sptr, RPL_TOPICWHOTIME, chptrb->chname, chptrb->topic_nick, chptrb->topic_time); - } - do_names(sptr, chptrb, NAMES_ALL|NAMES_EON); /* send /names list */ - } + //first of all check if we may even join this channel + int err2 = 0; + if (chptrb->users == 0 && !chptrb->mode.apass[0] && !(chptrb->mode.mode & MODE_PERSIST)) { + /* Joining a zombie channel (zannel): give ops and increment TS. */ + flags = CHFL_CHANOP; + chptrb->creationtime++; + } else if (IsInvited(sptr, chptrb)) { + /* Invites and key=OVERRIDE bypass these other checks. */ + } else if (chptrb->mode.mode & MODE_INVITEONLY) + err2 = ERR_INVITEONLYCHAN; + else if (chptrb->mode.limit && (chptrb->users >= chptrb->mode.limit)) + err2 = ERR_CHANNELISFULL; + else if ((chptrb->mode.mode & MODE_REGONLY) && !IsAccount(sptr)) + err2 = ERR_NEEDREGGEDNICK; + else if (find_ban(sptr, chptrb->banlist)) + err2 = ERR_BANNEDFROMCHAN; + else if (*chptrb->mode.key && (!key || strcmp(key, chptrb->mode.key))) + err2 = ERR_BADCHANNELKEY; + if(!err2) { + joinbuf_join(&join, chptrb, flags); + del_invite(sptr, chptrb); + if (chptrb->topic[0]) { + send_reply(sptr, RPL_TOPIC, chptrb->chname, chptrb->topic); + send_reply(sptr, RPL_TOPICWHOTIME, chptrb->chname, chptrb->topic_nick, chptrb->topic_time); + } + do_names(sptr, chptrb, NAMES_ALL|NAMES_EON); /* send /names list */ + } + } } if (err) { -- 2.20.1