X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fm_kick.c;h=c789e372acc6349cb2992e6dbedcd25dc1893478;hb=refs%2Fheads%2Fupstream;hp=f5a488a933d770e9333a27be74cec793b7547dcc;hpb=7ea8cb4b365a53becdd7b7fd2b2a8923ed6164b9;p=ircu2.10.12-pk.git diff --git a/ircd/m_kick.c b/ircd/m_kick.c index f5a488a..c789e37 100644 --- a/ircd/m_kick.c +++ b/ircd/m_kick.c @@ -79,26 +79,22 @@ * note: it is guaranteed that parv[0]..parv[parc-1] are all * non-NULL pointers. */ -#if 0 -/* - * No need to include handlers.h here the signatures must match - * and we don't need to force a rebuild of all the handlers everytime - * we add a new one to the list. --Bleep - */ -#include "handlers.h" -#endif /* 0 */ +#include "config.h" + #include "channel.h" #include "client.h" #include "hash.h" #include "ircd.h" +#include "ircd_log.h" #include "ircd_reply.h" #include "ircd_string.h" #include "msg.h" #include "numeric.h" #include "numnicks.h" #include "send.h" +#include "ircd_features.h" -#include +/* #include -- Now using assert in ircd_log.h */ /* * m_kick - generic message handler @@ -113,9 +109,10 @@ int m_kick(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) struct Client *who; struct Channel *chptr; struct Membership *member = 0; + struct Membership* member2; char *name, *comment; - sptr->flags &= ~FLAGS_TS8; + ClrFlag(sptr, FLAG_TS8); if (parc < 3 || *parv[1] == '\0') return need_more_params(sptr, "KICK"); @@ -126,7 +123,8 @@ int m_kick(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) if (!(chptr = get_channel(sptr, name, CGT_NO_CREATE))) return send_reply(sptr, ERR_NOSUCHCHANNEL, name); - if (!is_chan_op(sptr, chptr) || IsModelessChannel(name)) + if (!(member2 = find_member_link(chptr, sptr)) || IsZombie(member2) + || !IsChanOp(member2)) return send_reply(sptr, ERR_CHANOPRIVSNEEDED, name); if (!(who = find_chasing(sptr, parv[2], 0))) @@ -134,17 +132,25 @@ int m_kick(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) /* Don't allow the channel service to be kicked */ if (IsChannelService(who)) - return send_reply(sptr, ERR_ISCHANSERVICE, who->name, chptr->chname); + return send_reply(sptr, ERR_ISCHANSERVICE, cli_name(who), chptr->chname); -#ifdef NO_OPER_DEOP_LCHAN /* Prevent kicking opers from local channels -DM- */ - if (IsOperOnLocalChannel(who, chptr->chname)) - return send_reply(sptr, ERR_ISOPERLCHAN, who->name, chptr->chname); -#endif + if (IsLocalChannel(chptr->chname) && HasPriv(who, PRIV_DEOP_LCHAN)) + return send_reply(sptr, ERR_ISOPERLCHAN, cli_name(who), chptr->chname); /* check if kicked user is actually on the channel */ if (!(member = find_member_link(chptr, who)) || IsZombie(member)) - return send_reply(sptr, ERR_USERNOTINCHANNEL, who->name, chptr->chname); + return send_reply(sptr, ERR_USERNOTINCHANNEL, cli_name(who), chptr->chname); + + /* Don't allow to kick member with a higher op-level, + * or members with the same op-level unless both are MAXOPLEVEL. + */ + if (OpLevel(member) < OpLevel(member2) + || (OpLevel(member) == OpLevel(member2) + && OpLevel(member) < MAXOPLEVEL)) + return send_reply(sptr, ERR_NOTLOWEROPLEVEL, cli_name(who), chptr->chname, + OpLevel(member2), OpLevel(member), "kick", + OpLevel(member) == OpLevel(member2) ? "the same" : "a higher"); /* We rely on ircd_snprintf to truncate the comment */ comment = EmptyString(parv[parc - 1]) ? parv[0] : parv[parc - 1]; @@ -153,8 +159,17 @@ int m_kick(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) sendcmdto_serv_butone(sptr, CMD_KICK, cptr, "%H %C :%s", chptr, who, comment); - sendcmdto_channel_butserv(sptr, CMD_KICK, chptr, "%H %C :%s", chptr, who, - comment); + if (IsDelayedJoin(member)) { + /* If it's a delayed join, only send the KICK to the person doing + * the kicking and the victim */ + if (MyUser(who)) + sendcmdto_one(sptr, CMD_KICK, who, "%H %C :%s", chptr, who, comment); + sendcmdto_one(who, CMD_JOIN, sptr, "%H", chptr); + sendcmdto_one(sptr, CMD_KICK, sptr, "%H %C :%s", chptr, who, comment); + CheckDelayedJoins(chptr); + } else + sendcmdto_channel_butserv_butone(sptr, CMD_KICK, chptr, NULL, 0, "%H %C :%s", chptr, who, + comment); make_zombie(member, who, cptr, sptr, chptr); @@ -176,7 +191,7 @@ int ms_kick(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) struct Membership *member = 0, *sptr_link = 0; char *name, *comment; - sptr->flags &= ~FLAGS_TS8; + ClrFlag(sptr, FLAG_TS8); if (parc < 3 || *parv[1] == '\0') return need_more_params(sptr, "KICK"); @@ -191,11 +206,27 @@ int ms_kick(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) return 0; /* We go ahead and pass on the KICK for users not on the channel */ - if (!(member = find_member_link(chptr, who)) || IsZombie(member)) + member = find_member_link(chptr, who); + if (member && IsZombie(member)) + { + /* We might get a KICK from a zombie's own server because the user + * net-rode during a burst (which always generates a KICK) *and* + * was kicked via another server. In that case, we must remove + * the user from the channel. + */ + if (sptr == cli_user(who)->server) + { + remove_user_from_channel(who, chptr); + } + /* Otherwise, we treat zombies like they are not channel members. */ member = 0; + } /* Send HACK notice, but not for servers in BURST */ - if (IsServer(sptr) && !IsBurstOrBurstAck(sptr)) + /* 2002-10-17: Don't send HACK if the users local server is kicking them */ + if (IsServer(sptr) && + !IsBurstOrBurstAck(sptr) && + sptr!=cli_user(who)->server) sendto_opmask_butone(0, SNO_HACK4, "HACK: %C KICK %H %C %s", sptr, chptr, who, comment); @@ -203,7 +234,7 @@ int ms_kick(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) * here), if kicker is not on channel, or if kicker is not a channel * operator, bounce the kick */ - if (!IsServer(sptr) && member && who->from != cptr && + if (!IsServer(sptr) && member && cli_from(who) != cptr && (!(sptr_link = find_member_link(chptr, sptr)) || !IsChanOp(sptr_link))) { sendto_opmask_butone(0, SNO_HACK2, "HACK: %C KICK %H %C %s", sptr, chptr, who, comment); @@ -220,9 +251,9 @@ int ms_kick(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) MODEBUF_DEST_BOUNCE)); /* And bounce the MODE */ if (IsChanOp(member)) - modebuf_mode_client(&mbuf, MODE_DEL | MODE_CHANOP, who); + modebuf_mode_client(&mbuf, MODE_DEL | MODE_CHANOP, who, OpLevel(member)); if (HasVoice(member)) - modebuf_mode_client(&mbuf, MODE_DEL | MODE_VOICE, who); + modebuf_mode_client(&mbuf, MODE_DEL | MODE_VOICE, who, MAXOPLEVEL + 1); modebuf_flush(&mbuf); } @@ -232,8 +263,15 @@ int ms_kick(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) comment); if (member) { /* and tell the channel about it */ - sendcmdto_channel_butserv(sptr, CMD_KICK, chptr, "%H %C :%s", chptr, who, - comment); + if (IsDelayedJoin(member)) { + if (MyUser(who)) + sendcmdto_one(IsServer(sptr) ? &his : sptr, CMD_KICK, + who, "%H %C :%s", chptr, who, comment); + } else { + sendcmdto_channel_butserv_butone(IsServer(sptr) ? &his : sptr, CMD_KICK, + chptr, NULL, 0, "%H %C :%s", chptr, who, + comment); + } make_zombie(member, who, cptr, sptr, chptr); }