2007-01-25 07:40:21 +01:00
|
|
|
/*
|
|
|
|
* ircd-ratbox: A slightly useful ircd.
|
|
|
|
* m_user.c: Sends username information.
|
|
|
|
*
|
|
|
|
* 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 09:43:11 +01:00
|
|
|
static const char user_desc[] =
|
2016-03-07 09:53:16 +01:00
|
|
|
"Provides the USER command to register a new connection";
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void mr_user(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 user_msgtab = {
|
2016-02-19 23:42:40 +01:00
|
|
|
"USER", 0, 0, 0, 0,
|
2007-01-25 07:40:21 +01:00
|
|
|
{{mr_user, 5}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg}
|
|
|
|
};
|
|
|
|
|
|
|
|
mapi_clist_av1 user_clist[] = { &user_msgtab, NULL };
|
2016-03-07 09:43:11 +01:00
|
|
|
DECLARE_MODULE_AV2(user, NULL, NULL, user_clist, NULL, NULL, NULL, NULL, user_desc);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void do_local_user(client::client &client, client::client &source,
|
2016-03-09 08:37:03 +01:00
|
|
|
const char *username, const char *realname);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/* mr_user()
|
|
|
|
* parv[1] = username (login name, account)
|
|
|
|
* parv[2] = client host name (ignored)
|
|
|
|
* parv[3] = server host name (ignored)
|
|
|
|
* parv[4] = users gecos
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
mr_user(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
static char buf[BUFSIZE];
|
|
|
|
char *p;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
if (strlen(client.id) == 3)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
exit_client(&client, &client, &client, "Mixing client and server protocol");
|
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(source.flags & client::flags::SENTUSER)
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2015-02-13 23:07:02 +01:00
|
|
|
|
2016-07-13 07:17:21 +02:00
|
|
|
if((p = (char *)strchr(parv[1], '@')))
|
2007-01-25 07:40:21 +01:00
|
|
|
*p = '\0';
|
|
|
|
|
2016-02-10 02:25:32 +01:00
|
|
|
snprintf(buf, sizeof(buf), "%s %s", parv[2], parv[3]);
|
2016-08-23 02:37:07 +02:00
|
|
|
rb_free(source.localClient->fullcaps);
|
|
|
|
source.localClient->fullcaps = rb_strdup(buf);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
do_local_user(client, source, parv[1], parv[4]);
|
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
|
|
|
do_local_user(client::client &client, client::client &source,
|
2007-01-25 07:40:21 +01:00
|
|
|
const char *username, const char *realname)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
s_assert(NULL != &source);
|
|
|
|
s_assert(source.username != username);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
make_user(source);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
source.flags |= client::flags::SENTUSER;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
rb_strlcpy(source.info, realname, sizeof(source.info));
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!is_got_id(source))
|
2016-08-23 02:37:07 +02:00
|
|
|
rb_strlcpy(source.username, username, sizeof(source.username));
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
if(source.name[0])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
/* NICK already received, now I have USER... */
|
2016-08-23 02:37:07 +02:00
|
|
|
register_local_user(&client, &source);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|