Author: beware
[ircu2.10.12-pk.git] / ircd / m_kick.c
index 86e7af844898cca6e156a30a54a438bff2affd3d..97b59e4d1b18f77d76555d5164b454175dbc28db 100644 (file)
  */
 #include "config.h"
 
-#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 "channel.h"
 #include "client.h"
 #include "hash.h"
@@ -99,6 +91,7 @@
 #include "numeric.h"
 #include "numnicks.h"
 #include "send.h"
+#include "ircd_features.h"
 
 #include <assert.h>
 
@@ -115,9 +108,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;
 
-  cli_flags(sptr) &= ~FLAGS_TS8;
+  ClrFlag(sptr, FLAG_TS8);
 
   if (parc < 3 || *parv[1] == '\0')
     return need_more_params(sptr, "KICK");
@@ -128,7 +122,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)))
@@ -146,6 +141,12 @@ int m_kick(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
   if (!(member = find_member_link(chptr, who)) || IsZombie(member))
     return send_reply(sptr, ERR_USERNOTINCHANNEL, cli_name(who), chptr->chname);
 
+  /* Don't allow to kick member with a higher or equal op-level */
+  if ((OpLevel(member) <= OpLevel(member2)) && feature_bool(FEAT_OPLEVELS))
+    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,7 +154,7 @@ 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,
+  sendcmdto_channel_butserv_butone(sptr, CMD_KICK, chptr, NULL, "%H %C :%s", chptr, who,
                            comment);
 
   make_zombie(member, who, cptr, sptr, chptr);
@@ -176,7 +177,7 @@ int ms_kick(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
   struct Membership *member = 0, *sptr_link = 0;
   char *name, *comment;
 
-  cli_flags(sptr) &= ~FLAGS_TS8;
+  ClrFlag(sptr, FLAG_TS8);
 
   if (parc < 3 || *parv[1] == '\0')
     return need_more_params(sptr, "KICK");
@@ -195,7 +196,10 @@ int ms_kick(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     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_from(who))
     sendto_opmask_butone(0, SNO_HACK4, "HACK: %C KICK %H %C %s", sptr, chptr,
                         who, comment);
 
@@ -232,8 +236,9 @@ 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);
+      sendcmdto_channel_butserv_butone(IsServer(sptr) ? &me : sptr, CMD_KICK,
+                                      chptr, NULL, "%H %C :%s", chptr, who,
+                                      comment);
 
       make_zombie(member, who, cptr, sptr, chptr);
     }