2007-01-25 07:40:21 +01:00
|
|
|
/*
|
|
|
|
* ircd-ratbox: A slightly useful ircd.
|
|
|
|
* m_pass.c: Used to send a password for a server or client{} block.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
|
|
|
* Copyright (C) 1996-2002 Hybrid Development Team
|
|
|
|
* Copyright (C) 2002-2005 ircd-ratbox development team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*/
|
|
|
|
|
2016-08-13 05:05:54 +02:00
|
|
|
using namespace ircd;
|
|
|
|
|
2016-03-07 08:47:40 +01:00
|
|
|
static const char pass_desc[] = "Provides the PASS command to authenticate clients and servers";
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void mr_pass(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
2016-03-09 08:29:41 +01:00
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
struct Message pass_msgtab = {
|
2016-02-19 23:42:40 +01:00
|
|
|
"PASS", 0, 0, 0, 0,
|
2007-01-25 07:40:21 +01:00
|
|
|
{{mr_pass, 2}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg}
|
|
|
|
};
|
|
|
|
|
|
|
|
mapi_clist_av1 pass_clist[] = { &pass_msgtab, NULL };
|
2016-03-09 08:29:41 +01:00
|
|
|
|
2016-03-07 08:47:40 +01:00
|
|
|
DECLARE_MODULE_AV2(pass, NULL, NULL, pass_clist, NULL, NULL, NULL, NULL, pass_desc);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* m_pass() - Added Sat, 4 March 1989
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* mr_pass - PASS message handler
|
|
|
|
* parv[1] = password
|
|
|
|
* parv[2] = "TS" if this server supports TS.
|
|
|
|
* parv[3] = optional TS version field -- needed for TS6
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
mr_pass(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2008-06-26 08:18:58 +02:00
|
|
|
char *auth_user, *pass, *buf;
|
|
|
|
buf = LOCAL_COPY(parv[1]);
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
if(client.localClient->passwd || client.localClient->auth_user)
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2008-06-26 08:18:58 +02:00
|
|
|
if ((pass = strchr(buf, ':')) != NULL)
|
|
|
|
{
|
2014-03-03 05:25:47 +01:00
|
|
|
*pass++ = '\0';
|
|
|
|
auth_user = buf;
|
2008-06-26 08:18:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pass = buf;
|
|
|
|
auth_user = NULL;
|
|
|
|
}
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
client.localClient->passwd = *pass ? rb_strndup(pass, PASSWDLEN) : NULL;
|
2014-03-03 05:25:47 +01:00
|
|
|
|
2008-08-29 21:47:51 +02:00
|
|
|
if(auth_user && *auth_user)
|
2016-08-23 02:37:07 +02:00
|
|
|
client.localClient->auth_user = rb_strndup(auth_user, PASSWDLEN);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/* These are for servers only */
|
2016-08-23 02:37:07 +02:00
|
|
|
if(parc > 2 && client.user == NULL)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2014-03-03 05:25:47 +01:00
|
|
|
/*
|
2007-01-25 07:40:21 +01:00
|
|
|
* It looks to me as if orabidoo wanted to have more
|
|
|
|
* than one set of option strings possible here...
|
|
|
|
* i.e. ":AABBTS" as long as TS was the last two chars
|
|
|
|
* however, as we are now using CAPAB, I think we can
|
|
|
|
* safely assume if there is a ":TS" then its a TS server
|
|
|
|
* -Dianora
|
|
|
|
*/
|
2016-08-23 02:37:07 +02:00
|
|
|
if(irccmp(parv[2], "TS") == 0 && client.tsinfo == 0)
|
|
|
|
client.tsinfo = TS_DOESTS;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2007-08-09 08:47:26 +02:00
|
|
|
if(parc == 5 && atoi(parv[3]) >= 6)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
/* only mark as TS6 if the SID is valid.. */
|
2016-08-16 11:12:01 +02:00
|
|
|
if(rfc1459::is_digit(parv[4][0]) &&
|
|
|
|
rfc1459::is_id(parv[4][1]) &&
|
|
|
|
rfc1459::is_id(parv[4][2]) &&
|
|
|
|
parv[4][3] == '\0' &&
|
2016-08-23 02:37:07 +02:00
|
|
|
EmptyString(client.id))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
client.localClient->caps |= CAP_TS6;
|
|
|
|
rb_strlcpy(client.id, parv[4], sizeof(client.id));
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|