added basic ssl support to ircu
[ircu2.10.12-pk.git] / ircd / m_kill.c
index 34e1a5ab0eb048b20f399fae37b0e21987862b63..b038bc884d496e770eec2c25badfadc3e967a2ea 100644 (file)
@@ -84,8 +84,8 @@
 #include "client.h"
 #include "hash.h"
 #include "ircd.h"
+#include "ircd_features.h"
 #include "ircd_log.h"
-#include "ircd_policy.h"
 #include "ircd_reply.h"
 #include "ircd_snprintf.h"
 #include "ircd_string.h"
@@ -96,7 +96,7 @@
 #include "send.h"
 #include "whowas.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 #include <string.h>
 
 /*
  *
  */
 static int do_kill(struct Client* cptr, struct Client* sptr,
-                  struct Client* victim, char* path)
+                  struct Client* victim, char* inpath, char* path, char* msg)
 {
-  const char*  inpath;
-  char*        comment;
-  char         buf[BUFSIZE];
-
   assert(0 != cptr);
   assert(0 != sptr);
-  assert(IsUser(victim));
-
-  if (IsServer(sptr)) {
-     if (!(comment = strchr(path, ' ')))
-       comment = "No reason supplied";
-     else
-       comment++; /* Remove first character (space) */
-  }
-  else
-    comment = path;
-
-#ifdef HEAD_IN_SAND_KILLWHO
-  ircd_snprintf(0, buf, sizeof(buf), "%s (%s)", HEAD_IN_SAND_SERVERNAME, comment);
-#else
-  ircd_snprintf(0, buf, sizeof(buf), "%s (%s)", cli_name(sptr),
-                comment);
-#endif
-  comment = buf;
+  assert(!IsServer(victim));
 
   /*
    * Notify all *local* opers about the KILL (this includes the one
@@ -139,13 +118,11 @@ static int do_kill(struct Client* cptr, struct Client* sptr,
    * Note: "victim->name" is used instead of "user" because we may
    *       have changed the target because of the nickname change.
    */
-  inpath = IsServer(sptr) ? cli_name(cptr) : cli_user(sptr)->host;
-
   sendto_opmask_butone(0, IsServer(sptr) ? SNO_SERVKILL : SNO_OPERKILL,
-                       "Received KILL message for %s. From %s Path: %s!%s",
-                       get_client_name(victim, SHOW_IP), cli_name(cptr),
-                       inpath, comment);
-  log_write_kill(victim, sptr, inpath, path);
+                       "Received KILL message for %s from %s Path: %s!%s %s",
+                       get_client_name(victim, SHOW_IP), cli_name(sptr),
+                       inpath, path, msg);
+  log_write_kill(victim, sptr, inpath, path, msg);
 
   /*
    * And pass on the message to other servers. Note, that if KILL
@@ -154,15 +131,15 @@ static int do_kill(struct Client* cptr, struct Client* sptr,
    * Client suicide kills are NOT passed on --SRB
    */
   if (IsServer(cptr) || !MyConnect(victim)) {
-    sendcmdto_serv_butone(sptr, CMD_KILL, cptr, "%C :%s!%s", victim,
-                          inpath, path);
+    sendcmdto_serv_butone(sptr, CMD_KILL, cptr, "%C :%s!%s %s", victim,
+                          inpath, path, msg);
 
     /*
-     * Set FLAGS_KILLED. This prevents exit_one_client from sending
+     * Set FLAG_KILLED. This prevents exit_one_client from sending
      * the unnecessary QUIT for this. (This flag should never be
      * set in any other place)
      */
-    cli_flags(victim) |= FLAGS_KILLED;
+    SetFlag(victim, FLAG_KILLED);
   }
 
   /*
@@ -173,24 +150,19 @@ static int do_kill(struct Client* cptr, struct Client* sptr,
    * In accordance with the new hiding rules, the victim
    * always sees the kill as coming from me.
    */
-  if (MyConnect(victim)) {
-#ifdef HEAD_IN_SAND_KILLWHO
-    sendcmdto_one(&me, CMD_KILL, victim, "%C :%s", victim,
-                  comment);
-#else
-    sendcmdto_one(sptr, CMD_KILL, victim, "%C :%s", victim,
-                  comment);
-#endif
-  }
-#ifdef HEAD_IN_SAND_KILLWHO
-  return exit_client_msg(cptr, victim, &me, "Killed (%s)", comment);
-#else
-  return exit_client_msg(cptr, victim, sptr, "Killed (%s)", comment);
-#endif
+  if (MyConnect(victim))
+    sendcmdto_one(feature_bool(FEAT_HIS_KILLWHO) ? &his : sptr, CMD_KILL,
+                 victim, "%C :%s %s", victim, feature_bool(FEAT_HIS_KILLWHO)
+                 ? feature_str(FEAT_HIS_SERVERNAME) : cli_name(sptr), msg);
+  return exit_client_msg(cptr, victim, feature_bool(FEAT_HIS_KILLWHO)
+                        ? &me : sptr, "Killed (%s %s)",
+                        feature_bool(FEAT_HIS_KILLWHO) ?
+                        feature_str(FEAT_HIS_SERVERNAME) : cli_name(sptr),
+                        msg);
 }
 
 /*
- * ms_kill - server message handler template
+ * ms_kill - server message handler
  *
  * NOTE: IsServer(cptr) == true;
  *
@@ -202,6 +174,7 @@ int ms_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
   struct Client* victim;
   char*          path;
+  char*          msg;
 
   assert(0 != cptr);
   assert(0 != sptr);
@@ -218,6 +191,11 @@ int ms_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
   path = parv[parc - 1];        /* Either defined or NULL (parc >= 3) */
 
+  if (!(msg = strchr(path, ' '))) /* Extract out the message */
+    msg = "(No reason supplied)";
+  else
+    *(msg++) = '\0'; /* Remove first character (space) and terminate path */
+
   if (!(victim = findNUser(parv[1]))) {
     if (IsUser(sptr))
       sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :KILL target disconnected "
@@ -245,11 +223,11 @@ int ms_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     sendcmdto_one(&me, CMD_KILL, cptr, "%C :%s (Ghost 5 Numeric Collided)",
                   victim, path);
   }
-  return do_kill(cptr, sptr, victim, path);
+  return do_kill(cptr, sptr, victim, cli_name(cptr), path, msg);
 }
 
 /*
- * mo_kill - oper message handler template
+ * mo_kill - oper message handler
  *
  * NOTE: IsPrivileged(sptr), IsAnOper(sptr) == true
  *       IsServer(cptr), IsServer(sptr) == false
@@ -262,7 +240,7 @@ int mo_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
   struct Client* victim;
   char*          user;
-  char*          path;
+  char           msg[TOPICLEN + 3]; /* (, ), and \0 */
 
   assert(0 != cptr);
   assert(0 != sptr);
@@ -276,14 +254,11 @@ int mo_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     return need_more_params(sptr, "KILL");
 
   user = parv[1];
-  path = parv[parc - 1];
-
-  if (strlen(path) > TOPICLEN)
-    path[TOPICLEN] = '\0';
+  ircd_snprintf(0, msg, sizeof(msg), "(%.*s)", TOPICLEN, parv[parc - 1]);
 
   if (!(victim = FindClient(user))) {
     /*
-     * If the user has recently changed nick, we automaticly
+     * If the user has recently changed nick, we automatically
      * rewrite the KILL for this new nickname--this keeps
      * servers in synch when nick change and kill collide
      */
@@ -307,9 +282,10 @@ int mo_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
 
   if (!MyConnect(victim) && !HasPriv(sptr, PRIV_KILL)) {
-    sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :Nick %s isnt on your server",
+    sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :Nick %s isn't on your server",
                  sptr, cli_name(victim));
     return 0;
   }
-  return do_kill(cptr, sptr, victim, path);
+  return do_kill(cptr, sptr, victim, cli_user(sptr)->host, cli_name(sptr),
+                msg);
 }