]> jfr.im git - solanum.git/blobdiff - modules/m_etrace.c
ircd: get_channel_access(): do not derive channel pointer from membership
[solanum.git] / modules / m_etrace.c
index be65ab66ca3fb8fcb665be939451858cec90f1b5..614f54d967f94cc79dd6325bc44e0675ba5e7d74 100644 (file)
@@ -49,6 +49,8 @@
 #include "msg.h"
 #include "parse.h"
 #include "modules.h"
+#include "logger.h"
+#include "supported.h"
 
 static int mo_etrace(struct Client *, struct Client *, int, const char **);
 static int me_etrace(struct Client *, struct Client *, int, const char **);
@@ -68,8 +70,22 @@ struct Message masktrace_msgtab = {
        {mg_ignore, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_masktrace, 2}}
 };
 
+static int
+_modinit(void)
+{
+    add_isupport("ETRACE", isupport_string, "");
+
+    return 0;
+}
+
+static void
+_moddeinit(void)
+{
+    delete_isupport("ETRACE");
+}
+
 mapi_clist_av1 etrace_clist[] = { &etrace_msgtab, &chantrace_msgtab, &masktrace_msgtab, NULL };
-DECLARE_MODULE_AV1(etrace, NULL, NULL, etrace_clist, NULL, NULL, "$Revision: 3161 $");
+DECLARE_MODULE_AV1(etrace, _modinit, _moddeinit, etrace_clist, NULL, NULL, "$Revision: 3161 $");
 
 static void do_etrace(struct Client *source_p, int ipv4, int ipv6);
 static void do_etrace_full(struct Client *source_p);
@@ -80,7 +96,6 @@ static const char *spoofed_sockhost = "0";
 
 /*
  * m_etrace
- *      parv[0] = sender prefix
  *      parv[1] = options [or target]
  *     parv[2] = [target]
  */
@@ -134,7 +149,7 @@ me_etrace(struct Client *client_p, struct Client *source_p, int parc, const char
        if((target_p = find_person(parv[1])) && MyClient(target_p))
                do_single_etrace(source_p, target_p);
 
-        sendto_one_numeric(source_p, RPL_ENDOFTRACE, form_str(RPL_ENDOFTRACE), 
+        sendto_one_numeric(source_p, RPL_ENDOFTRACE, form_str(RPL_ENDOFTRACE),
                                target_p ? target_p->name : parv[1]);
 
        return 0;
@@ -158,8 +173,8 @@ do_etrace(struct Client *source_p, int ipv4, int ipv6)
 #endif
 
                sendto_one(source_p, form_str(RPL_ETRACE),
-                          me.name, source_p->name, 
-                          IsOper(target_p) ? "Oper" : "User", 
+                          me.name, source_p->name,
+                          IsOper(target_p) ? "Oper" : "User",
                           get_client_class(target_p),
                           target_p->name, target_p->username, target_p->host,
                           show_ip(source_p, target_p) ? target_p->sockhost : "255.255.255.255",
@@ -197,17 +212,17 @@ do_single_etrace(struct Client *source_p, struct Client *target_p)
         */
        if(!show_ip(source_p, target_p))
                sendto_one(source_p, form_str(RPL_ETRACEFULL),
-                               me.name, source_p->name, 
+                               me.name, source_p->name,
                                IsOper(target_p) ? "Oper" : "User",
                                get_client_class(target_p),
-                               target_p->name, target_p->username, target_p->host, 
+                               target_p->name, target_p->username, target_p->host,
                                "255.255.255.255", "<hidden> <hidden>", target_p->info);
        else
                sendto_one(source_p, form_str(RPL_ETRACEFULL),
-                               me.name, source_p->name, 
+                               me.name, source_p->name,
                                IsOper(target_p) ? "Oper" : "User",
                                get_client_class(target_p),
-                               target_p->name, target_p->username, 
+                               target_p->name, target_p->username,
                                target_p->host, target_p->sockhost,
                                target_p->localClient->fullcaps, target_p->info);
 }
@@ -269,7 +284,7 @@ m_chantrace(struct Client *client_p, struct Client *source_p, int parc, const ch
                        sockhost = target_p->sockhost;
 
                sendto_one(source_p, form_str(RPL_ETRACE),
-                               me.name, source_p->name, 
+                               me.name, source_p->name,
                                IsOper(target_p) ? "Oper" : "User",
                                /* class field -- pretend its server.. */
                                target_p->servptr->name,
@@ -288,52 +303,14 @@ match_masktrace(struct Client *source_p, rb_dlink_list *list,
 {
        struct Client *target_p;
        rb_dlink_node *ptr;
-       const char *sockhost;   
-       char *mangle_gecos = NULL;
-       
-       if(gecos != NULL)
-       {
-               if(strstr(gecos, "\\s"))
-               {
-                       char *tmp = LOCAL_COPY(gecos);
-                       char *orig = tmp;
-                       char *new = tmp;
-                       while(*orig)
-                       {
-                               if(*orig == '\\' && *(orig + 1) != '\0')
-                                       {
-                                       if(*(orig + 1) == 's')
-                                       {
-                                               *new++ = ' ';
-                                               orig += 2;   
-                                       }
-                                       /* otherwise skip that and the escaped
-                                        * character after it, so we dont mistake
-                                        * \\s as \s --fl
-                                        */
-                                       else
-                                       {   
-                                               *new++ = *orig++;
-                                               *new++ = *orig++;
-                                       }
-                               }
-                               else
-                                       *new++ = *orig++;
-                       }
-       
-                       *new = '\0';
-                       mangle_gecos = LOCAL_COPY(tmp);
-               }
-               else
-                       mangle_gecos = LOCAL_COPY(gecos);
-       }
+       const char *sockhost;
 
        RB_DLINK_FOREACH(ptr, list->head)
        {
                target_p = ptr->data;
                if(!IsPerson(target_p))
                        continue;
-               
+
                if(EmptyString(target_p->sockhost))
                        sockhost = empty_sockhost;
                else if(!show_ip(source_p, target_p))
@@ -349,11 +326,11 @@ match_masktrace(struct Client *source_p, rb_dlink_list *list,
                        if(name != NULL && !match(name, target_p->name))
                                continue;
 
-                       if(mangle_gecos != NULL && !match_esc(mangle_gecos, target_p->info))
+                       if(gecos != NULL && !match_esc(gecos, target_p->info))
                                continue;
-                       
+
                        sendto_one(source_p, form_str(RPL_ETRACE),
-                               me.name, source_p->name, 
+                               me.name, source_p->name,
                                IsOper(target_p) ? "Oper" : "User",
                                /* class field -- pretend its server.. */
                                target_p->servptr->name,
@@ -364,15 +341,15 @@ match_masktrace(struct Client *source_p, rb_dlink_list *list,
 }
 
 static int
-mo_masktrace(struct Client *client_p, struct Client *source_p, int parc, 
+mo_masktrace(struct Client *client_p, struct Client *source_p, int parc,
        const char *parv[])
 {
        char *name, *username, *hostname, *gecos;
        const char *mask;
        int operspy = 0;
 
-       mask = parv[1]; 
-       name = LOCAL_COPY(parv[1]);     
+       mask = parv[1];
+       name = LOCAL_COPY(parv[1]);
        collapse(name);
 
        if(IsOperSpy(source_p) && parv[1][0] == '!')
@@ -380,15 +357,15 @@ mo_masktrace(struct Client *client_p, struct Client *source_p, int parc,
                name++;
                mask++;
                operspy = 1;
-       }               
-       
+       }
+
        if(parc > 2 && !EmptyString(parv[2]))
        {
                gecos = LOCAL_COPY(parv[2]);
                collapse_esc(gecos);
        } else
                gecos = NULL;
-       
+
 
        if((hostname = strchr(name, '@')) == NULL)
        {
@@ -397,7 +374,7 @@ mo_masktrace(struct Client *client_p, struct Client *source_p, int parc,
        }
 
        *hostname++ = '\0';
-       
+
        if((username = strchr(name, '!')) == NULL)
        {
                username = name;
@@ -410,7 +387,7 @@ mo_masktrace(struct Client *client_p, struct Client *source_p, int parc,
                sendto_one_notice(source_p, ":Invalid parameters");
                return 0;
        }
-                       
+
        if(operspy) {
                if (!ConfigFileEntry.operspy_dont_care_user_info)
                {
@@ -419,14 +396,14 @@ mo_masktrace(struct Client *client_p, struct Client *source_p, int parc,
                        if(!EmptyString(gecos)) {
                                rb_strlcat(buf, " ", sizeof(buf));
                                rb_strlcat(buf, gecos, sizeof(buf));
-                       }               
+                       }
 
-                       report_operspy(source_p, "MASKTRACE", buf);     
+                       report_operspy(source_p, "MASKTRACE", buf);
                }
-               match_masktrace(source_p, &global_client_list, username, hostname, name, gecos);                
+               match_masktrace(source_p, &global_client_list, username, hostname, name, gecos);
        } else
                match_masktrace(source_p, &lclient_list, username, hostname, name, gecos);
 
-       sendto_one_numeric(source_p, RPL_ENDOFTRACE, form_str(RPL_ENDOFTRACE), me.name); 
+       sendto_one_numeric(source_p, RPL_ENDOFTRACE, form_str(RPL_ENDOFTRACE), me.name);
        return 0;
 }