]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * ircd-ratbox: A slightly useful ircd. | |
3 | * m_user.c: Sends username information. | |
4 | * | |
5 | * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center | |
6 | * Copyright (C) 1996-2002 Hybrid Development Team | |
7 | * Copyright (C) 2002-2005 ircd-ratbox development team | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
22 | * USA | |
212380e3 AC |
23 | */ |
24 | ||
25 | #include "stdinc.h" | |
26 | #include "client.h" | |
4562c604 | 27 | #include "match.h" |
212380e3 AC |
28 | #include "ircd.h" |
29 | #include "numeric.h" | |
30 | #include "s_user.h" | |
31 | #include "send.h" | |
32 | #include "s_conf.h" | |
33 | #include "msg.h" | |
34 | #include "parse.h" | |
35 | #include "modules.h" | |
77d3d2db | 36 | #include "s_assert.h" |
212380e3 | 37 | |
4855e957 | 38 | static const char user_desc[] = |
ae5695cd | 39 | "Provides the USER command to register a new connection"; |
212380e3 | 40 | |
3c7d6fcc | 41 | static void mr_user(struct MsgBuf *, struct Client *, struct Client *, int, const char **); |
eeabf33a | 42 | |
212380e3 | 43 | struct Message user_msgtab = { |
7baa37a9 | 44 | "USER", 0, 0, 0, 0, |
212380e3 AC |
45 | {{mr_user, 5}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg} |
46 | }; | |
47 | ||
48 | mapi_clist_av1 user_clist[] = { &user_msgtab, NULL }; | |
4855e957 | 49 | DECLARE_MODULE_AV2(user, NULL, NULL, user_clist, NULL, NULL, NULL, NULL, user_desc); |
212380e3 | 50 | |
3c7d6fcc EM |
51 | static void do_local_user(struct Client *client_p, struct Client *source_p, |
52 | const char *username, const char *realname); | |
212380e3 AC |
53 | |
54 | /* mr_user() | |
55 | * parv[1] = username (login name, account) | |
56 | * parv[2] = client host name (ignored) | |
57 | * parv[3] = server host name (ignored) | |
58 | * parv[4] = users gecos | |
59 | */ | |
3c7d6fcc | 60 | static void |
428ca87b | 61 | mr_user(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 AC |
62 | { |
63 | static char buf[BUFSIZE]; | |
64 | char *p; | |
65 | ||
66 | if (strlen(client_p->id) == 3) | |
67 | { | |
68 | exit_client(client_p, client_p, client_p, "Mixing client and server protocol"); | |
3c7d6fcc | 69 | return; |
212380e3 AC |
70 | } |
71 | ||
f51b72de | 72 | if(source_p->flags & FLAGS_SENTUSER) |
3c7d6fcc | 73 | return; |
f51b72de | 74 | |
212380e3 AC |
75 | if((p = strchr(parv[1], '@'))) |
76 | *p = '\0'; | |
77 | ||
5203cba5 | 78 | snprintf(buf, sizeof(buf), "%s %s", parv[2], parv[3]); |
637c4932 | 79 | rb_free(source_p->localClient->fullcaps); |
47a03750 | 80 | source_p->localClient->fullcaps = rb_strdup(buf); |
212380e3 AC |
81 | |
82 | do_local_user(client_p, source_p, parv[1], parv[4]); | |
212380e3 AC |
83 | } |
84 | ||
3c7d6fcc | 85 | static void |
212380e3 AC |
86 | do_local_user(struct Client *client_p, struct Client *source_p, |
87 | const char *username, const char *realname) | |
88 | { | |
212380e3 AC |
89 | s_assert(NULL != source_p); |
90 | s_assert(source_p->username != username); | |
91 | ||
2d537cae | 92 | make_user(source_p); |
212380e3 | 93 | |
f51b72de | 94 | source_p->flags |= FLAGS_SENTUSER; |
212380e3 | 95 | |
f427c8b0 | 96 | rb_strlcpy(source_p->info, realname, sizeof(source_p->info)); |
212380e3 AC |
97 | |
98 | if(!IsGotId(source_p)) | |
f427c8b0 | 99 | rb_strlcpy(source_p->username, username, sizeof(source_p->username)); |
212380e3 AC |
100 | |
101 | if(source_p->name[0]) | |
102 | { | |
103 | /* NICK already received, now I have USER... */ | |
3c7d6fcc | 104 | register_local_user(client_p, source_p); |
212380e3 | 105 | } |
212380e3 | 106 | } |