]> jfr.im git - solanum.git/blobdiff - ircd/client.c
m_cap: use rn_snprintf_try_append
[solanum.git] / ircd / client.c
index 67824363f6b9e4abef0e368dadacb695430e20c2..a4ee0cac292de11db69543dc75f22290100d256f 100644 (file)
@@ -53,7 +53,6 @@
 #include "sslproc.h"
 #include "wsproc.h"
 #include "s_assert.h"
-#include "batch.h"
 
 #define DEBUG_EXITED_CLIENTS
 
@@ -141,8 +140,8 @@ init_client(void)
 uint32_t
 connid_get(struct Client *client_p)
 {
-       s_assert(MyClient(client_p));
-       if (!MyClient(client_p))
+       s_assert(MyConnect(client_p));
+       if (!MyConnect(client_p))
                return 0;
 
        /* find a connid that is available */
@@ -195,8 +194,10 @@ client_release_connids(struct Client *client_p)
 {
        rb_dlink_node *ptr, *ptr2;
 
-       s_assert(MyClient(client_p));
-       if (!MyClient(client_p))
+       if (client_p->localClient->connids.head)
+               s_assert(MyConnect(client_p));
+
+       if (!MyConnect(client_p))
                return;
 
        RB_DLINK_FOREACH_SAFE(ptr, ptr2, client_p->localClient->connids.head)
@@ -246,7 +247,7 @@ make_client(struct Client *from)
        }
 
        SetUnknown(client_p);
-       strcpy(client_p->username, "unknown");
+       rb_strlcpy(client_p->username, "unknown", sizeof(client_p->username));
 
        return client_p;
 }
@@ -313,9 +314,13 @@ free_local_client(struct Client *client_p)
        if (IsSSL(client_p))
                ssld_decrement_clicount(client_p->localClient->ssl_ctl);
 
+       rb_free(client_p->localClient->cipher_string);
+
        if (IsCapable(client_p, CAP_ZIP))
                ssld_decrement_clicount(client_p->localClient->z_ctl);
 
+       rb_free(client_p->localClient->zipstats);
+
        if (client_p->localClient->ws_ctl != NULL)
                wsockd_decrement_clicount(client_p->localClient->ws_ctl);
 
@@ -323,7 +328,7 @@ free_local_client(struct Client *client_p)
        client_p->localClient = NULL;
 }
 
-void
+static void
 free_client(struct Client *client_p)
 {
        s_assert(NULL != client_p);
@@ -1353,10 +1358,18 @@ exit_remote_client(struct Client *client_p, struct Client *source_p, struct Clie
  */
 
 static int
-exit_unknown_client(struct Client *client_p, struct Client *source_p, struct Client *from,
-                 const char *comment)
+exit_unknown_client(struct Client *client_p, /* The local client originating the
+                                              * exit or NULL, if this exit is
+                                              * generated by this server for
+                                              * internal reasons.
+                                              * This will not get any of the
+                                              * generated messages. */
+               struct Client *source_p,     /* Client exiting */
+               struct Client *from,         /* Client firing off this Exit,
+                                              * never NULL! */
+               const char *comment)
 {
-       authd_abort_client(client_p);
+       authd_abort_client(source_p);
        rb_dlinkDelete(&source_p->localClient->tnode, &unknown_list);
 
        if(!IsIOError(source_p))
@@ -1386,37 +1399,22 @@ exit_remote_server(struct Client *client_p, struct Client *source_p, struct Clie
        static char comment1[(HOSTLEN*2)+2];
        static char newcomment[BUFSIZE];
        struct Client *target_p;
-       struct Batch *batch_p;
 
        if(ConfigServerHide.flatten_links)
-       {
                strcpy(comment1, "*.net *.split");
-
-               /* rb_strdup since they are later freed */
-               batch_p = start_batch(BATCH_NETSPLIT, source_p, 2,
-                       rb_strdup("*.net"), rb_strdup("*.split"));
-       }
        else
        {
                strcpy(comment1, source_p->servptr->name);
                strcat(comment1, " ");
                strcat(comment1, source_p->name);
-
-               batch_p = start_batch(BATCH_NETSPLIT, source_p, 2,
-                       rb_strdup(source_p->servptr->name),
-                       rb_strdup(source_p->name));
        }
        if (IsPerson(from))
                snprintf(newcomment, sizeof(newcomment), "by %s: %s",
                                from->name, comment);
 
-       if(source_p->serv != NULL)
-               remove_dependents(client_p, source_p, from, IsPerson(from) ? newcomment : comment, comment1);
+       remove_dependents(client_p, source_p, from, IsPerson(from) ? newcomment : comment, comment1);
 
-       if(source_p->servptr && source_p->servptr->serv)
-               rb_dlinkDelete(&source_p->lnode, &source_p->servptr->serv->servers);
-       else
-               s_assert(0);
+       rb_dlinkDelete(&source_p->lnode, &source_p->servptr->serv->servers);
 
        rb_dlinkFindDestroy(source_p, &global_serv_list);
        target_p = source_p->from;
@@ -1434,6 +1432,7 @@ exit_remote_server(struct Client *client_p, struct Client *source_p, struct Clie
 
        del_from_client_hash(source_p->name, source_p);
        remove_client_from_list(source_p);
+
        scache_split(source_p->serv->nameinfo);
 
        SetDead(source_p);
@@ -1442,7 +1441,6 @@ exit_remote_server(struct Client *client_p, struct Client *source_p, struct Clie
 #else
        rb_dlinkAddAlloc(source_p, &dead_list);
 #endif
-       finish_batch(batch_p);
        return 0;
 }
 
@@ -1476,7 +1474,6 @@ exit_local_server(struct Client *client_p, struct Client *source_p, struct Clien
        static char comment1[(HOSTLEN*2)+2];
        static char newcomment[BUFSIZE];
        unsigned int sendk, recvk;
-       struct Batch *batch_p;
 
        rb_dlinkDelete(&source_p->localClient->tnode, &serv_list);
        rb_dlinkFindDestroy(source_p, &global_serv_list);
@@ -1507,18 +1504,12 @@ exit_local_server(struct Client *client_p, struct Client *source_p, struct Clien
        close_connection(source_p);
 
        if(ConfigServerHide.flatten_links)
-       {
                strcpy(comment1, "*.net *.split");
-               batch_p = start_batch(BATCH_NETSPLIT, source_p, 2,
-                       rb_strdup("*.net"), rb_strdup("*.split"));
-       }
        else
        {
                strcpy(comment1, source_p->servptr->name);
                strcat(comment1, " ");
                strcat(comment1, source_p->name);
-               batch_p = start_batch(BATCH_NETSPLIT, source_p, 2,
-                       rb_strdup(source_p->servptr->name), rb_strdup(source_p->name));
        }
 
        if(source_p->serv != NULL)
@@ -1540,7 +1531,6 @@ exit_local_server(struct Client *client_p, struct Client *source_p, struct Clien
 
        SetDead(source_p);
        rb_dlinkAddAlloc(source_p, &dead_list);
-       finish_batch(batch_p);
        return 0;
 }