added basic ssl support to ircu
[ircu2.10.12-pk.git] / ircd / m_kick.c
index 5af0a4d3d85246c6ff61d6ec81fd48d9a0be53b4..c789e372acc6349cb2992e6dbedcd25dc1893478 100644 (file)
@@ -142,8 +142,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))
+  /* 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");
@@ -160,6 +164,7 @@ int m_kick(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
      * 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
@@ -201,14 +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 */
   /* 2002-10-17: Don't send HACK if the users local server is kicking them */
   if (IsServer(sptr) &&
       !IsBurstOrBurstAck(sptr) &&
-      sptr!=cli_from(who))
+      sptr!=cli_user(who)->server)
     sendto_opmask_butone(0, SNO_HACK4, "HACK: %C KICK %H %C %s", sptr, chptr,
                         who, comment);
 
@@ -233,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);
     }
@@ -245,9 +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_butone(IsServer(sptr) ? &me : sptr, CMD_KICK,
-                                      chptr, NULL, 0, "%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);
     }