added basic ssl support to ircu
[ircu2.10.12-pk.git] / ircd / m_trace.c
index e311682a443778f8557571e1c1126603e2aef21d..a0ba9757eef3ef0aa0247edb97bc8664741cfd1b 100644 (file)
@@ -86,6 +86,7 @@
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_features.h"
+#include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "match.h"
 #include "send.h"
 #include "version.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 #include <string.h>
 
 void do_trace(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 {
   int i;
   struct Client *acptr;
+  struct Client *acptr2;
   const struct ConnectionClass* cl;
   char* tname;
   int doall;
@@ -259,14 +261,19 @@ void do_trace(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
          */
 
       case STAT_SERVER:
-        if (cli_serv(acptr)->user)
+        if (cli_serv(acptr)->user) {
+          if (!cli_serv(acptr)->by[0]
+              || !(acptr2 = findNUser(cli_serv(acptr)->by))
+              || (cli_user(acptr2) != cli_serv(acptr)->user))
+            acptr2 = NULL;
          send_reply(sptr, RPL_TRACESERVER, conClass, link_s[i],
                      link_u[i], cli_name(acptr),
-                     (*(cli_serv(acptr))->by) ? cli_serv(acptr)->by : "*",
-                     cli_serv(acptr)->user->username, cli_serv(acptr)->user->host,
+                     acptr2 ? cli_name(acptr2) : "*",
+                     cli_serv(acptr)->user->username,
+                     cli_serv(acptr)->user->host,
                      CurrentTime - cli_lasttime(acptr),
                      CurrentTime - cli_serv(acptr)->timestamp);
-       else
+        } else
          send_reply(sptr, RPL_TRACESERVER, conClass, link_s[i],
                      link_u[i], cli_name(acptr),
                      (*(cli_serv(acptr))->by) ?  cli_serv(acptr)->by : "*", "*",
@@ -286,8 +293,8 @@ void do_trace(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
    */
   if (IsAnOper(sptr) && doall) {
     for (cl = get_class_list(); cl; cl = cl->next) {
-      if (Links(cl) > 0)
-       send_reply(sptr, RPL_TRACECLASS, ConClass(cl), Links(cl));
+      if (Links(cl) > 1)
+       send_reply(sptr, RPL_TRACECLASS, ConClass(cl), Links(cl) - 1);
     }
   }
   send_reply(sptr, RPL_TRACEEND);