Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Wed, 3 Apr 2002 04:29:52 +0000 (04:29 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Wed, 3 Apr 2002 04:29:52 +0000 (04:29 +0000)
Log message:

Kills didn't get sent to remote servers correctly.  They do now.  This
fixes bug 39.

(pull-up from u2_10_11 branch)

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@705 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/ircd_log.h
ircd/ircd_log.c
ircd/m_kill.c

index 995529d59bb28bffc592a9c940ce50a0b08b7abc..284284ef5e050914de71580f62aba99d7ba564f4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2002-04-02  Kevin L Mitchell  <klmitch@mit.edu>
+
+       * ircd/m_kill.c: let ms_kill() and mo_kill() seperate the message
+       from the path before calling do_kill(); add a msg argument to
+       do_kill() and use it in preference to comment; remove all that old
+       code that fiddled with the buf and the comment
+
+       * ircd/ircd_log.c (log_write_kill): add a seperate msg argument
+
+       * include/ircd_log.h: add a seperate msg argument to
+       log_write_kill()
+
        * ircd/ircd.c: display event engine and MAXCONNECTIONS information
  
 2002-04-02  Alex Badea <vampire@p16.pub.ro>
index 871534c839bb1adf4feb36404d5bf139edda1d36..3d1f50f915f5371bc8ed57475445e3ff72390c00 100644 (file)
@@ -63,7 +63,8 @@ extern void log_vwrite(enum LogSys subsys, enum LogLevel severity,
 extern void log_write_kill(const struct Client *victim,
                           const struct Client *killer,
                           const char          *inpath,
-                          const char          *path);
+                          const char          *path,
+                          const char          *msg);
 
 #define LOG_NOSYSLOG   0x01
 #define LOG_NOFILELOG  0x02
index 89ad01fc8934cfc5de28575357f8379d7b7ed11f..bbc3e363640c837883984211bb8e1009fbc7827f 100644 (file)
@@ -438,15 +438,16 @@ log_vwrite(enum LogSys subsys, enum LogLevel severity, unsigned int flags,
 /* log kills for fun and profit */
 void
 log_write_kill(const struct Client *victim, const struct Client *killer,
-              const char *inpath, const char *path)
+              const char *inpath, const char *path, const char *msg)
 {
   if (MyUser(victim))
     log_write(IsServer(killer) ? LS_SERVKILL : LS_OPERKILL, L_TRACE, 0,
-             "A local client %#C KILLED by %#C Path: %s!%s",
-             victim, killer, inpath, path);
+             "A local client %#C KILLED by %#C Path: %s!%s %s",
+             victim, killer, inpath, path, msg);
   else
     log_write(IsServer(killer) ? LS_SERVKILL : LS_OPERKILL, L_TRACE, 0,
-             "KILL from %C For %C Path: %s!%s", killer, victim, inpath, path);
+             "KILL from %C For %C Path: %s!%s %s", killer, victim, inpath,
+             path, msg);
 }
 
 /* return a struct LogFile for a specific filename--reference counted */
index c32c6ef138da1c4a91535c987ebf142cf2c70ab2..1a47c9bff00e5744dea157390da94619f4044bf4 100644 (file)
  *
  */
 static int do_kill(struct Client* cptr, struct Client* sptr,
-                  struct Client* victim, char* inpath, char* path)
+                  struct Client* victim, char* inpath, char* path, char *msg)
 {
-  char*        comment;
-  char         buf[BUFSIZE];
-
   assert(0 != cptr);
   assert(0 != sptr);
   assert(IsUser(victim));
 
-  /* If we got this from a *local* oper, then path only contains the
-   * kill comment. Remote oper or server kills will at least have
-   * some kind of path preceding it.    -GW
-   */
-  if (IsServer(cptr)) 
-  {
-     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;
-
   /*
    * Notify all *local* opers about the KILL (this includes the one
    * originating the kill, if from this server--the special numeric
@@ -144,10 +119,10 @@ static int do_kill(struct Client* cptr, struct Client* sptr,
    *       have changed the target because of the nickname change.
    */
   sendto_opmask_butone(0, IsServer(sptr) ? SNO_SERVKILL : SNO_OPERKILL,
-                       "Received KILL message for %s. From %s Path: %s!%s",
+                       "Received KILL message for %s. From %s Path: %s!%s %s",
                        get_client_name(victim, SHOW_IP), cli_name(sptr),
-                       inpath, comment);
-  log_write_kill(victim, sptr, inpath, path);
+                       inpath, path, msg);
+  log_write_kill(victim, sptr, inpath, path, msg);
 
   /*
    * And pass on the message to other servers. Note, that if KILL
@@ -156,8 +131,8 @@ 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
@@ -175,19 +150,18 @@ 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);
+  if (MyConnect(victim))
+    sendcmdto_one(&me, CMD_KILL, victim, "%C :%s %s", victim,
+                  HEAD_IN_SAND_SERVERNAME, msg);
+  return exit_client_msg(cptr, victim, &me, "Killed (%s %s)",
+                        HEAD_IN_SAND_SERVERNAME, msg);
 #else
-  return exit_client_msg(cptr, victim, sptr, "Killed (%s)", comment);
+  if (MyConnect(victim))
+    sendcmdto_one(sptr, CMD_KILL, victim, "%C :%s %s", victim,
+                  cli_name(sptr), msg);
+  return exit_client_msg(cptr, victim, sptr, "Killed (%s %s)", cli_name(sptr),
+                        msg);
 #endif
 }
 
@@ -204,6 +178,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);
@@ -220,6 +195,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 "
@@ -247,7 +227,7 @@ 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, cli_name(cptr), path);
+  return do_kill(cptr, sptr, victim, cli_name(cptr), path, msg);
 }
 
 /*
@@ -264,7 +244,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);
@@ -278,10 +258,7 @@ 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))) {
     /*
@@ -313,5 +290,6 @@ int mo_kill(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
                  sptr, cli_name(victim));
     return 0;
   }
-  return do_kill(cptr, sptr, victim, cli_user(sptr)->host, path);
+  return do_kill(cptr, sptr, victim, cli_user(sptr)->host, cli_name(sptr),
+                msg);
 }