From 28caceba334f33f9081b49be95e39211d3eda802 Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Mon, 13 Aug 2018 20:53:04 +0100 Subject: [PATCH] m_pass: store unverified SID in preClient for use in m_server --- include/client.h | 2 ++ modules/core/m_server.c | 33 ++++++++++++++++++--------------- modules/m_pass.c | 6 +++--- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/include/client.h b/include/client.h index d67c1e84..b5ea0c52 100644 --- a/include/client.h +++ b/include/client.h @@ -302,6 +302,8 @@ struct PreClient struct Blacklist *dnsbl_listed; /* first dnsbl where it's listed */ struct rb_sockaddr_storage lip; /* address of our side of the connection */ + + char id[IDLEN]; /* UID/SID, unique on the network (unverified) */ }; struct ListClient diff --git a/modules/core/m_server.c b/modules/core/m_server.c index f78c64b2..0ebffa58 100644 --- a/modules/core/m_server.c +++ b/modules/core/m_server.c @@ -282,22 +282,25 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char return 0; } - 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); + 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 0; + sendto_one(client_p, "ERROR :SID already exists."); + exit_client(client_p, client_p, client_p, "SID Exists"); + return 0; + } else { + rb_strlcpy(client_p->id, client_p->preClient->id, sizeof(client_p->id)); + } } /* diff --git a/modules/m_pass.c b/modules/m_pass.c index e7cc7cd3..9525332a 100644 --- a/modules/m_pass.c +++ b/modules/m_pass.c @@ -82,7 +82,7 @@ mr_pass(struct Client *client_p, struct Client *source_p, int parc, const char * 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 @@ -100,10 +100,10 @@ mr_pass(struct Client *client_p, struct Client *source_p, int parc, const char * /* 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; - strcpy(client_p->id, parv[4]); + rb_strlcpy(client_p->preClient->id, parv[4], sizeof(client_p->preClient->id)); } } }