2007-01-25 07:40:21 +01:00
|
|
|
/* modules/m_signon.c
|
|
|
|
* Copyright (C) 2006 Michael Tharp <gxti@partiallystapled.com>
|
|
|
|
* Copyright (C) 2006 charybdis development team
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* 1.Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
* 2.Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3.The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
|
|
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2016-08-13 05:05:54 +02:00
|
|
|
using namespace ircd;
|
|
|
|
|
2016-03-09 08:29:41 +01:00
|
|
|
static const char signon_desc[] = "Provides account login/logout support for services";
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void me_svslogin(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
|
|
|
static void ms_signon(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void send_signon(client::client *, client::client &, const char *, const char *, const char *, unsigned int, const char *);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
struct Message svslogin_msgtab = {
|
2016-02-19 23:42:40 +01:00
|
|
|
"SVSLOGIN", 0, 0, 0, 0,
|
2007-01-25 07:40:21 +01:00
|
|
|
{mg_ignore, mg_ignore, mg_ignore, mg_ignore, {me_svslogin, 6}, mg_ignore}
|
|
|
|
};
|
|
|
|
struct Message signon_msgtab = {
|
2016-02-19 23:42:40 +01:00
|
|
|
"SIGNON", 0, 0, 0, 0,
|
2007-01-25 07:40:21 +01:00
|
|
|
{mg_ignore, mg_ignore, {ms_signon, 6}, mg_ignore, mg_ignore, mg_ignore}
|
|
|
|
};
|
|
|
|
|
2014-03-03 05:25:47 +01:00
|
|
|
mapi_clist_av1 signon_clist[] = {
|
2007-01-25 07:40:21 +01:00
|
|
|
&svslogin_msgtab, &signon_msgtab, NULL
|
|
|
|
};
|
|
|
|
|
2016-03-07 09:05:28 +01:00
|
|
|
DECLARE_MODULE_AV2(signon, NULL, NULL, signon_clist, NULL, NULL, NULL, NULL, signon_desc);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
#define NICK_VALID 1
|
|
|
|
#define USER_VALID 2
|
|
|
|
#define HOST_VALID 4
|
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
static bool
|
2007-01-25 07:40:21 +01:00
|
|
|
clean_username(const char *username)
|
|
|
|
{
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
for (; *username; username++)
|
|
|
|
{
|
|
|
|
len++;
|
|
|
|
|
2016-08-16 11:12:01 +02:00
|
|
|
if(!rfc1459::is_user(*username))
|
2016-03-09 08:37:03 +01:00
|
|
|
return false;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(len > USERLEN)
|
2016-03-09 08:37:03 +01:00
|
|
|
return false;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
return true;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
static bool
|
2007-01-25 07:40:21 +01:00
|
|
|
clean_host(const char *host)
|
|
|
|
{
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
for (; *host; host++)
|
|
|
|
{
|
|
|
|
len++;
|
|
|
|
|
2016-08-16 11:12:01 +02:00
|
|
|
if(!rfc1459::is_host(*host))
|
2016-03-09 08:37:03 +01:00
|
|
|
return false;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(len > HOSTLEN)
|
2016-03-09 08:37:03 +01:00
|
|
|
return false;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
return true;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
me_svslogin(struct MsgBuf *msgbuf_p, client::client &client, client::client &source,
|
2007-01-25 07:40:21 +01:00
|
|
|
int parc, const char *parv[])
|
|
|
|
{
|
2016-08-22 03:57:43 +02:00
|
|
|
client::client *target_p, *exist_p;
|
2007-01-25 07:40:21 +01:00
|
|
|
char nick[NICKLEN+1], login[NICKLEN+1];
|
|
|
|
char user[USERLEN+1], host[HOSTLEN+1];
|
|
|
|
int valid = 0;
|
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!(source.flags & client::flags::SERVICE))
|
2012-05-21 19:27:02 +02:00
|
|
|
{
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2016-08-23 02:37:07 +02:00
|
|
|
"Non-service server %s attempting to execute services-only command SVSLOGIN", source.name);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2012-05-21 19:27:02 +02:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if((target_p = find_client(parv[1])) == NULL)
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!my(*target_p) && !is_unknown(*target_p))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
if(client::clean_nick(parv[2], 0))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2008-04-20 06:40:40 +02:00
|
|
|
rb_strlcpy(nick, parv[2], NICKLEN + 1);
|
2007-01-25 07:40:21 +01:00
|
|
|
valid |= NICK_VALID;
|
|
|
|
}
|
|
|
|
else if(*target_p->name)
|
2008-04-20 06:40:40 +02:00
|
|
|
rb_strlcpy(nick, target_p->name, NICKLEN + 1);
|
2007-01-25 07:40:21 +01:00
|
|
|
else
|
|
|
|
strcpy(nick, "*");
|
|
|
|
|
|
|
|
if(clean_username(parv[3]))
|
|
|
|
{
|
2008-04-20 06:40:40 +02:00
|
|
|
rb_strlcpy(user, parv[3], USERLEN + 1);
|
2007-01-25 07:40:21 +01:00
|
|
|
valid |= USER_VALID;
|
|
|
|
}
|
|
|
|
else
|
2008-04-20 06:40:40 +02:00
|
|
|
rb_strlcpy(user, target_p->username, USERLEN + 1);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(clean_host(parv[4]))
|
|
|
|
{
|
2008-04-20 06:40:40 +02:00
|
|
|
rb_strlcpy(host, parv[4], HOSTLEN + 1);
|
2007-01-25 07:40:21 +01:00
|
|
|
valid |= HOST_VALID;
|
|
|
|
}
|
|
|
|
else
|
2008-04-20 06:40:40 +02:00
|
|
|
rb_strlcpy(host, target_p->host, HOSTLEN + 1);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(*parv[5] == '*')
|
|
|
|
{
|
|
|
|
if(target_p->user)
|
2016-08-22 03:57:43 +02:00
|
|
|
rb_strlcpy(login, suser(ircd::user(*target_p)).c_str(), NICKLEN + 1);
|
2007-01-25 07:40:21 +01:00
|
|
|
else
|
|
|
|
login[0] = '\0';
|
|
|
|
}
|
|
|
|
else if(!strcmp(parv[5], "0"))
|
|
|
|
login[0] = '\0';
|
|
|
|
else
|
2008-04-20 06:40:40 +02:00
|
|
|
rb_strlcpy(login, parv[5], NICKLEN + 1);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/* Login (mostly) follows nick rules. */
|
2016-08-22 03:57:43 +02:00
|
|
|
if(*login && !client::clean_nick(login, 0))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
if((exist_p = client::find_person(nick)) && target_p != exist_p)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
char buf[BUFSIZE];
|
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(my(*exist_p))
|
2007-01-25 07:40:21 +01:00
|
|
|
sendto_one(exist_p, ":%s KILL %s :(Nickname regained by services)",
|
|
|
|
me.name, exist_p->name);
|
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
exist_p->flags |= client::flags::KILLED;
|
2007-01-25 07:40:21 +01:00
|
|
|
kill_client_serv_butone(NULL, exist_p, "%s (Nickname regained by services)",
|
|
|
|
me.name);
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::SKILL, L_ALL,
|
2011-06-25 15:56:22 +02:00
|
|
|
"Nick collision due to SVSLOGIN on %s",
|
|
|
|
nick);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-02-10 02:25:32 +01:00
|
|
|
snprintf(buf, sizeof(buf), "Killed (%s (Nickname regained by services))",
|
2007-01-25 07:40:21 +01:00
|
|
|
me.name);
|
|
|
|
exit_client(NULL, exist_p, &me, buf);
|
2016-03-09 08:37:03 +01:00
|
|
|
}
|
2016-08-23 04:33:36 +02:00
|
|
|
else if((exist_p = find_client(nick)) && is_unknown(*exist_p) && exist_p != target_p)
|
2016-03-09 08:37:03 +01:00
|
|
|
{
|
2007-01-25 07:40:21 +01:00
|
|
|
exit_client(NULL, exist_p, &me, "Overridden");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*login)
|
|
|
|
{
|
|
|
|
/* Strip leading digits, unless it's purely numeric. */
|
|
|
|
const char *p = login;
|
2016-08-16 11:12:01 +02:00
|
|
|
while(rfc1459::is_digit(*p))
|
2007-01-25 07:40:21 +01:00
|
|
|
p++;
|
|
|
|
if(!*p)
|
|
|
|
p = login;
|
|
|
|
|
|
|
|
sendto_one(target_p, form_str(RPL_LOGGEDIN), me.name, EmptyString(target_p->name) ? "*" : target_p->name,
|
|
|
|
nick, user, host, p, p);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sendto_one(target_p, form_str(RPL_LOGGEDOUT), me.name, EmptyString(target_p->name) ? "*" : target_p->name,
|
|
|
|
nick, user, host);
|
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(is_unknown(*target_p))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
if(valid & NICK_VALID)
|
2016-05-15 05:57:16 +02:00
|
|
|
rb_strlcpy(target_p->preClient->spoofnick, nick, sizeof(target_p->preClient->spoofnick));
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(valid & USER_VALID)
|
2016-05-15 05:57:16 +02:00
|
|
|
rb_strlcpy(target_p->preClient->spoofuser, user, sizeof(target_p->preClient->spoofuser));
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(valid & HOST_VALID)
|
2016-05-15 05:57:16 +02:00
|
|
|
rb_strlcpy(target_p->preClient->spoofhost, host, sizeof(target_p->preClient->spoofhost));
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
make_user(*target_p);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-01 23:29:32 +02:00
|
|
|
char note[NICKLEN + 10];
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
send_signon(NULL, *target_p, nick, user, host, rb_current_time(), login);
|
2008-04-01 23:29:32 +02:00
|
|
|
|
2016-02-10 02:25:32 +01:00
|
|
|
snprintf(note, NICKLEN + 10, "Nick: %s", target_p->name);
|
2008-04-01 23:29:32 +02:00
|
|
|
rb_note(target_p->localClient->F, note);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
ms_signon(struct MsgBuf *msgbuf_p, client::client &client, client::client &source,
|
2007-01-25 07:40:21 +01:00
|
|
|
int parc, const char *parv[])
|
|
|
|
{
|
2016-08-22 03:57:43 +02:00
|
|
|
client::client *target_p;
|
2007-01-25 07:40:21 +01:00
|
|
|
int newts, sameuser;
|
|
|
|
char login[NICKLEN+1];
|
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
if(!client::clean_nick(parv[1], 0))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2008-04-04 17:54:37 +02:00
|
|
|
ServerStats.is_kill++;
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::DEBUG, L_ALL,
|
2007-01-25 07:40:21 +01:00
|
|
|
"Bad Nick from SIGNON: %s From: %s(via %s)",
|
2016-08-23 02:37:07 +02:00
|
|
|
parv[1], source.servptr->name, client.name);
|
|
|
|
/* if &source has an id, kill_client_serv_butone() will
|
|
|
|
* send a kill to &client, otherwise do it here */
|
|
|
|
if (!has_id(&source))
|
|
|
|
sendto_one(&client, ":%s KILL %s :%s (Bad nickname from SIGNON)",
|
|
|
|
get_id(&me, &client), parv[1], me.name);
|
|
|
|
kill_client_serv_butone(&client, &source, "%s (Bad nickname from SIGNON)",
|
2007-01-25 07:40:21 +01:00
|
|
|
me.name);
|
2016-08-23 04:33:36 +02:00
|
|
|
source.flags |= client::flags::KILLED;
|
2016-08-23 02:37:07 +02:00
|
|
|
exit_client(NULL, &source, &me, "Bad nickname from SIGNON");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!clean_username(parv[2]) || !clean_host(parv[3]))
|
|
|
|
{
|
2008-04-04 17:54:37 +02:00
|
|
|
ServerStats.is_kill++;
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::DEBUG, L_ALL,
|
2007-01-25 07:40:21 +01:00
|
|
|
"Bad user@host from SIGNON: %s@%s From: %s(via %s)",
|
2016-08-23 02:37:07 +02:00
|
|
|
parv[2], parv[3], source.servptr->name, client.name);
|
|
|
|
/* if &source has an id, kill_client_serv_butone() will
|
|
|
|
* send a kill to &client, otherwise do it here */
|
|
|
|
if (!has_id(&source))
|
|
|
|
sendto_one(&client, ":%s KILL %s :%s (Bad user@host from SIGNON)",
|
|
|
|
get_id(&me, &client), parv[1], me.name);
|
|
|
|
kill_client_serv_butone(&client, &source, "%s (Bad user@host from SIGNON)",
|
2007-01-25 07:40:21 +01:00
|
|
|
me.name);
|
2016-08-23 04:33:36 +02:00
|
|
|
source.flags |= client::flags::KILLED;
|
2016-08-23 02:37:07 +02:00
|
|
|
exit_client(NULL, &source, &me, "Bad user@host from SIGNON");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
newts = atol(parv[4]);
|
|
|
|
|
|
|
|
if(!strcmp(parv[5], "0"))
|
|
|
|
login[0] = '\0';
|
|
|
|
else if(*parv[5] != '*')
|
|
|
|
{
|
2016-08-22 03:57:43 +02:00
|
|
|
if (client::clean_nick(parv[5], 0))
|
2008-04-20 06:40:40 +02:00
|
|
|
rb_strlcpy(login, parv[5], NICKLEN + 1);
|
2007-01-25 07:40:21 +01:00
|
|
|
else
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
2014-02-28 15:48:07 +01:00
|
|
|
else
|
|
|
|
login[0] = '\0';
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
target_p = find_named_client(parv[1]);
|
2016-08-23 02:37:07 +02:00
|
|
|
if(target_p != NULL && target_p != &source)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
/* In case of collision, follow NICK rules. */
|
|
|
|
/* XXX this is duplicated code and does not do SAVE */
|
2016-08-23 04:33:36 +02:00
|
|
|
if(is_unknown(*target_p))
|
2007-01-25 07:40:21 +01:00
|
|
|
exit_client(NULL, target_p, &me, "Overridden");
|
|
|
|
else
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!newts || !target_p->tsinfo || (newts == target_p->tsinfo) || !source.user)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2007-01-25 07:40:21 +01:00
|
|
|
"Nick change collision from SIGNON from %s to %s(%s <- %s)(both killed)",
|
2016-08-23 02:37:07 +02:00
|
|
|
source.name, target_p->name, target_p->from->name,
|
|
|
|
client.name);
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2008-04-04 17:54:37 +02:00
|
|
|
ServerStats.is_kill++;
|
2007-01-25 07:40:21 +01:00
|
|
|
sendto_one_numeric(target_p, ERR_NICKCOLLISION,
|
|
|
|
form_str(ERR_NICKCOLLISION), target_p->name);
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
kill_client_serv_butone(NULL, &source, "%s (Nick change collision)", me.name);
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2008-04-04 17:54:37 +02:00
|
|
|
ServerStats.is_kill++;
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
kill_client_serv_butone(NULL, target_p, "%s (Nick change collision)", me.name);
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
target_p->flags |= client::flags::KILLED;
|
2007-01-25 07:40:21 +01:00
|
|
|
exit_client(NULL, target_p, &me, "Nick collision(new)");
|
2016-08-23 04:33:36 +02:00
|
|
|
source.flags |= client::flags::KILLED;
|
2016-08-23 02:37:07 +02:00
|
|
|
exit_client(&client, &source, &me, "Nick collision(old)");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sameuser = !irccmp(target_p->username, source.username) &&
|
|
|
|
!irccmp(target_p->host, source.host);
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
if((sameuser && newts < target_p->tsinfo) ||
|
|
|
|
(!sameuser && newts > target_p->tsinfo))
|
|
|
|
{
|
|
|
|
if(sameuser)
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2007-01-25 07:40:21 +01:00
|
|
|
"Nick change collision from SIGNON from %s to %s(%s <- %s)(older killed)",
|
2016-08-23 02:37:07 +02:00
|
|
|
source.name, target_p->name,
|
|
|
|
target_p->from->name, client.name);
|
2007-01-25 07:40:21 +01:00
|
|
|
else
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2007-01-25 07:40:21 +01:00
|
|
|
"Nick change collision from SIGNON from %s to %s(%s <- %s)(newer killed)",
|
2016-08-23 02:37:07 +02:00
|
|
|
source.name, target_p->name,
|
|
|
|
target_p->from->name, client.name);
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2008-04-04 17:54:37 +02:00
|
|
|
ServerStats.is_kill++;
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
sendto_one_numeric(target_p, ERR_NICKCOLLISION,
|
|
|
|
form_str(ERR_NICKCOLLISION), target_p->name);
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
/* kill the client issuing the nickchange */
|
2016-08-23 02:37:07 +02:00
|
|
|
kill_client_serv_butone(&client, &source,
|
2007-01-25 07:40:21 +01:00
|
|
|
"%s (Nick change collision)", me.name);
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
source.flags |= client::flags::KILLED;
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
if(sameuser)
|
2016-08-23 02:37:07 +02:00
|
|
|
exit_client(&client, &source, &me, "Nick collision(old)");
|
2007-01-25 07:40:21 +01:00
|
|
|
else
|
2016-08-23 02:37:07 +02:00
|
|
|
exit_client(&client, &source, &me, "Nick collision(new)");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(sameuser)
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2007-01-25 07:40:21 +01:00
|
|
|
"Nick collision from SIGNON on %s(%s <- %s)(older killed)",
|
|
|
|
target_p->name, target_p->from->name,
|
2016-08-23 02:37:07 +02:00
|
|
|
client.name);
|
2007-01-25 07:40:21 +01:00
|
|
|
else
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2007-01-25 07:40:21 +01:00
|
|
|
"Nick collision from SIGNON on %s(%s <- %s)(newer killed)",
|
|
|
|
target_p->name, target_p->from->name,
|
2016-08-23 02:37:07 +02:00
|
|
|
client.name);
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
sendto_one_numeric(target_p, ERR_NICKCOLLISION,
|
|
|
|
form_str(ERR_NICKCOLLISION), target_p->name);
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
/* kill the client who existed before hand */
|
2016-08-23 02:37:07 +02:00
|
|
|
kill_client_serv_butone(&client, target_p,
|
2007-01-25 07:40:21 +01:00
|
|
|
"%s (Nick collision)", me.name);
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2008-04-04 17:54:37 +02:00
|
|
|
ServerStats.is_kill++;
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
target_p->flags |= client::flags::KILLED;
|
2016-08-23 02:37:07 +02:00
|
|
|
(void) exit_client(&client, target_p, &me, "Nick collision");
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
send_signon(&client, source, parv[1], parv[2], parv[3], newts, login);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
send_signon(client::client *client, client::client &target,
|
2016-08-22 03:57:43 +02:00
|
|
|
const char *nick, const char *username, const char *host,
|
2007-01-25 07:40:21 +01:00
|
|
|
unsigned int newts, const char *login)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_server(client, NULL, CAP_TS6, NOCAPS, ":%s SIGNON %s %s %s %ld %s",
|
|
|
|
use_id(&target), nick, username, host,
|
|
|
|
long(target.tsinfo), *login ? login : "0");
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
suser(user(target)) = login;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
change_nick_user_host(&target, nick, username, host, newts, "Signing %s (%s)", *login ? "in" : "out", nick);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|