]> jfr.im git - solanum.git/blobdiff - modules/m_trace.c
make VERSION not include sid (#118)
[solanum.git] / modules / m_trace.c
index 239b224d025209c8912bc09126c494951ef999a0..a634635be32f84e02a1fb37b227a635f8640c96d 100644 (file)
@@ -27,7 +27,6 @@
 #include "hook.h"
 #include "client.h"
 #include "hash.h"
-#include "common.h"
 #include "hash.h"
 #include "match.h"
 #include "ircd.h"
 #include "parse.h"
 #include "modules.h"
 
-static int m_trace(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static const char trace_desc[] =
+       "Provides the TRACE command to trace the route to a client or server";
+
+static void m_trace(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
 
 static void trace_spy(struct Client *, struct Client *);
 
@@ -56,7 +58,7 @@ mapi_hlist_av1 trace_hlist[] = {
        { "doing_trace",        &doing_trace_hook },
        { NULL, NULL }
 };
-DECLARE_MODULE_AV2(trace, NULL, NULL, trace_clist, trace_hlist, NULL, NULL, NULL, NULL);
+DECLARE_MODULE_AV2(trace, NULL, NULL, trace_clist, trace_hlist, NULL, NULL, NULL, trace_desc);
 
 static void count_downlinks(struct Client *server_p, int *pservcount, int *pusercount);
 static int report_this_status(struct Client *source_p, struct Client *target_p);
@@ -67,14 +69,14 @@ static const char *empty_sockhost = "255.255.255.255";
  * m_trace
  *      parv[1] = servername
  */
-static int
+static void
 m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        struct Client *target_p = NULL;
        struct Class *cltmp;
        const char *tname;
-       int doall = 0;
-       int cnt = 0, wilds, dow;
+       bool doall = false, wilds, dow;
+       int cnt = 0;
        rb_dlink_node *ptr;
 
        if(parc > 1)
@@ -85,7 +87,7 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
                {
                        if(hunt_server(client_p, source_p, ":%s TRACE %s :%s", 2, parc, parv) !=
                                        HUNTED_ISME)
-                               return 0;
+                               return;
                }
        }
        else
@@ -123,7 +125,7 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
                        /* giving this out with flattened links defeats the
                         * object --fl
                         */
-                       if(IsOper(source_p) || IsExemptShide(source_p) ||
+                       if(IsOperGeneral(source_p) || IsExemptShide(source_p) ||
                           !ConfigServerHide.flatten_links)
                                sendto_one_numeric(source_p, RPL_TRACELINK,
                                                   form_str(RPL_TRACELINK),
@@ -131,27 +133,27 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
                                                   ac2ptr ? ac2ptr->name : tname,
                                                   ac2ptr ? ac2ptr->from->name : "EEK!");
 
-                       return 0;
+                       return;
                }
 
                case HUNTED_ISME:
                        break;
 
                default:
-                       return 0;
+                       return;
                }
        }
 
        if(match(tname, me.name))
        {
-               doall = 1;
+               doall = true;
        }
        /* if theyre tracing our SID, we need to move tname to our name so
         * we dont give the sid in ENDOFTRACE
         */
        else if(!MyClient(source_p) && !strcmp(tname, me.id))
        {
-               doall = 1;
+               doall = true;
                tname = me.name;
        }
 
@@ -159,7 +161,7 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
        dow = wilds || doall;
 
        /* specific trace */
-       if(dow == 0)
+       if(!dow)
        {
                if(MyClient(source_p) || parc > 2)
                        target_p = find_named_person(tname);
@@ -179,7 +181,7 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
 
                sendto_one_numeric(source_p, RPL_ENDOFTRACE,
                                   form_str(RPL_ENDOFTRACE), tname);
-               return 0;
+               return;
        }
 
        trace_spy(source_p, NULL);
@@ -202,6 +204,9 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
                        if(!doall && wilds && (match(tname, target_p->name) == 0))
                                continue;
 
+                       if(!SeesOper(target_p, source_p))
+                               continue;
+
                        report_this_status(source_p, target_p);
                }
 
@@ -220,7 +225,7 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
 
                sendto_one_numeric(source_p, RPL_ENDOFTRACE,
                                   form_str(RPL_ENDOFTRACE), tname);
-               return 0;
+               return;
        }
 
        /* source_p is opered */
@@ -231,14 +236,14 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
                target_p = ptr->data;
 
                /* dont show invisible users to remote opers */
-               if(IsInvisible(target_p) && dow && !MyConnect(source_p) && !IsOper(target_p))
+               if(IsInvisible(target_p) && dow && !MyConnect(source_p) && !SeesOper(target_p, source_p))
                        continue;
 
                if(!doall && wilds && !match(tname, target_p->name))
                        continue;
 
                /* remote opers may not see invisible normal users */
-               if(dow && !MyConnect(source_p) && !IsOper(target_p) &&
+               if(dow && !MyConnect(source_p) && !SeesOper(target_p, source_p) &&
                                IsInvisible(target_p))
                        continue;
 
@@ -278,7 +283,7 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
                 */
                sendto_one_numeric(source_p, RPL_ENDOFTRACE,
                                   form_str(RPL_ENDOFTRACE), tname);
-               return 0;
+               return;
        }
 
        if(doall)
@@ -295,8 +300,6 @@ m_trace(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
        }
 
        sendto_one_numeric(source_p, RPL_ENDOFTRACE, form_str(RPL_ENDOFTRACE), tname);
-
-       return 0;
 }
 
 /*
@@ -379,8 +382,8 @@ report_this_status(struct Client *source_p, struct Client *target_p)
        case STAT_CLIENT:
                {
                        sendto_one_numeric(source_p,
-                                       IsOper(target_p) ? RPL_TRACEOPERATOR : RPL_TRACEUSER,
-                                       IsOper(target_p) ? form_str(RPL_TRACEOPERATOR) : form_str(RPL_TRACEUSER),
+                                       SeesOper(target_p, source_p) ? RPL_TRACEOPERATOR : RPL_TRACEUSER,
+                                       SeesOper(target_p, source_p) ? form_str(RPL_TRACEOPERATOR) : form_str(RPL_TRACEUSER),
                                        class_name, name,
                                        show_ip(source_p, target_p) ? ip : empty_sockhost,
                                        (unsigned long)(rb_current_time() - target_p->localClient->lasttime),