From ce3cf0da7948e0922eb96c622afc5126326d73d7 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Wed, 3 Apr 2002 04:29:52 +0000 Subject: [PATCH] Author: Kev 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 | 12 +++++++- include/ircd_log.h | 3 +- ircd/ircd_log.c | 9 +++--- ircd/m_kill.c | 76 ++++++++++++++++------------------------------ 4 files changed, 45 insertions(+), 55 deletions(-) diff --git a/ChangeLog b/ChangeLog index 995529d..284284e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2002-04-02 Kevin L Mitchell - + + * 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 diff --git a/include/ircd_log.h b/include/ircd_log.h index 871534c..3d1f50f 100644 --- a/include/ircd_log.h +++ b/include/ircd_log.h @@ -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 diff --git a/ircd/ircd_log.c b/ircd/ircd_log.c index 89ad01f..bbc3e36 100644 --- a/ircd/ircd_log.c +++ b/ircd/ircd_log.c @@ -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 */ diff --git a/ircd/m_kill.c b/ircd/m_kill.c index c32c6ef..1a47c9b 100644 --- a/ircd/m_kill.c +++ b/ircd/m_kill.c @@ -104,37 +104,12 @@ * */ 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); } -- 2.20.1