]> jfr.im git - irc/charybdis-ircd/charybdis.git/commitdiff
m_pass: store unverified SID in preClient for use in m_server
authorSimon Arlott <sa.me.uk>
Mon, 13 Aug 2018 19:53:04 +0000 (20:53 +0100)
committerSimon Arlott <sa.me.uk>
Wed, 15 Aug 2018 21:48:15 +0000 (22:48 +0100)
include/client.h
modules/core/m_server.c
modules/m_pass.c

index 8ab93ce4ac87e95a3d9b59f1e2cef222af5e19b7..b32710c9aa156fba198e114beba8e7bce67951e7 100644 (file)
@@ -316,6 +316,8 @@ struct PreClient
        struct AuthClient auth;
 
        struct rb_sockaddr_storage lip; /* address of our side of the connection */
+
+       char id[IDLEN]; /* UID/SID, unique on the network (unverified) */
 };
 
 struct ListClient
index 1a05ac0bb10e75ac39e82ca778b28182170c1c78..850a67d8d0d90eccc3d8650341f62df594d21ea8 100644 (file)
@@ -296,22 +296,25 @@ mr_server(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
                return;
        }
 
-       if(has_id(client_p) && (target_p = find_id(client_p->id)) != NULL)
-       {
-               sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
-                                    "Attempt to re-introduce SID %s from %s%s (already in use by %s)",
-                                    client_p->id,
-                                    EmptyString(client_p->name) ? name : "",
-                                    client_p->name, target_p->name);
-               ilog(L_SERVER, "Attempt to re-introduce SID %s from %s%s (already in use by %s)",
-                               client_p->id,
-                               EmptyString(client_p->name) ? name : "",
-                               log_client_name(client_p, SHOW_IP),
-                               target_p->name);
-
-               sendto_one(client_p, "ERROR :SID already exists.");
-               exit_client(client_p, client_p, client_p, "SID Exists");
-               return;
+       if (client_p->preClient && !EmptyString(client_p->preClient->id)) {
+               if ((target_p = find_id(client_p->preClient->id)) != NULL) {
+                       sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) ? L_NETWIDE : L_ALL,
+                                       "Attempt to re-introduce SID %s from %s%s (already in use by %s)",
+                                       client_p->preClient->id,
+                                       EmptyString(client_p->name) ? name : "",
+                                       client_p->name, target_p->name);
+                       ilog(L_SERVER, "Attempt to re-introduce SID %s from %s%s (already in use by %s)",
+                                       client_p->preClient->id,
+                                       EmptyString(client_p->name) ? name : "",
+                                       log_client_name(client_p, SHOW_IP),
+                                       target_p->name);
+
+                       sendto_one(client_p, "ERROR :SID already exists.");
+                       exit_client(client_p, client_p, client_p, "SID Exists");
+                       return;
+               } else {
+                       rb_strlcpy(client_p->id, client_p->preClient->id, sizeof(client_p->id));
+               }
        }
 
        /*
index 36398055e3a0a1a903d944e05f75197707f0cf06..d0009de8f78035ec2a7d3b60ecd5a4dcc90af656 100644 (file)
@@ -83,7 +83,7 @@ mr_pass(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
                client_p->localClient->auth_user = rb_strndup(auth_user, PASSWDLEN);
 
        /* These are for servers only */
-       if(parc > 2 && client_p->user == NULL)
+       if(parc > 2 && client_p->user == NULL && client_p->preClient != NULL)
        {
                /*
                 * It looks to me as if orabidoo wanted to have more
@@ -101,10 +101,10 @@ mr_pass(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
                        /* only mark as TS6 if the SID is valid.. */
                        if(IsDigit(parv[4][0]) && IsIdChar(parv[4][1]) &&
                           IsIdChar(parv[4][2]) && parv[4][3] == '\0' &&
-                          EmptyString(client_p->id))
+                          EmptyString(client_p->preClient->id))
                        {
                                client_p->localClient->caps |= CAP_TS6;
-                               rb_strlcpy(client_p->id, parv[4], sizeof(client_p->id));
+                               rb_strlcpy(client_p->preClient->id, parv[4], sizeof(client_p->preClient->id));
                        }
                }
        }