]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * ircd-ratbox: A slightly useful ircd. | |
3 | * m_pass.c: Used to send a password for a server or client{} block. | |
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" /* client struct */ | |
4562c604 | 27 | #include "match.h" |
212380e3 AC |
28 | #include "send.h" /* sendto_one */ |
29 | #include "numeric.h" /* ERR_xxx */ | |
30 | #include "ircd.h" /* me */ | |
31 | #include "msg.h" | |
32 | #include "parse.h" | |
33 | #include "modules.h" | |
34 | #include "s_serv.h" | |
35 | #include "hash.h" | |
36 | #include "s_conf.h" | |
37 | ||
d5d35409 | 38 | static const char pass_desc[] = "Provides the PASS command to authenticate clients and servers"; |
212380e3 | 39 | |
3c7d6fcc | 40 | static void mr_pass(struct MsgBuf *, struct Client *, struct Client *, int, const char **); |
eeabf33a | 41 | |
212380e3 | 42 | struct Message pass_msgtab = { |
7baa37a9 | 43 | "PASS", 0, 0, 0, 0, |
212380e3 AC |
44 | {{mr_pass, 2}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg} |
45 | }; | |
46 | ||
47 | mapi_clist_av1 pass_clist[] = { &pass_msgtab, NULL }; | |
eeabf33a | 48 | |
d5d35409 | 49 | DECLARE_MODULE_AV2(pass, NULL, NULL, pass_clist, NULL, NULL, NULL, NULL, pass_desc); |
212380e3 AC |
50 | |
51 | /* | |
52 | * m_pass() - Added Sat, 4 March 1989 | |
53 | * | |
54 | * | |
55 | * mr_pass - PASS message handler | |
212380e3 AC |
56 | * parv[1] = password |
57 | * parv[2] = "TS" if this server supports TS. | |
58 | * parv[3] = optional TS version field -- needed for TS6 | |
59 | */ | |
3c7d6fcc | 60 | static void |
428ca87b | 61 | mr_pass(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) |
212380e3 | 62 | { |
40c1fd47 VY |
63 | char *auth_user, *pass, *buf; |
64 | buf = LOCAL_COPY(parv[1]); | |
55abcbb2 | 65 | |
f51b72de | 66 | if(client_p->localClient->passwd || client_p->localClient->auth_user) |
3c7d6fcc | 67 | return; |
212380e3 | 68 | |
40c1fd47 VY |
69 | if ((pass = strchr(buf, ':')) != NULL) |
70 | { | |
55abcbb2 KB |
71 | *pass++ = '\0'; |
72 | auth_user = buf; | |
40c1fd47 VY |
73 | } |
74 | else | |
75 | { | |
76 | pass = buf; | |
77 | auth_user = NULL; | |
78 | } | |
55abcbb2 | 79 | |
9f1bde26 | 80 | client_p->localClient->passwd = *pass ? rb_strndup(pass, PASSWDLEN) : NULL; |
55abcbb2 | 81 | |
9f1bde26 | 82 | if(auth_user && *auth_user) |
40c1fd47 | 83 | client_p->localClient->auth_user = rb_strndup(auth_user, PASSWDLEN); |
212380e3 AC |
84 | |
85 | /* These are for servers only */ | |
d4b2529a | 86 | if(parc > 2 && client_p->user == NULL && client_p->preClient != NULL) |
212380e3 | 87 | { |
55abcbb2 | 88 | /* |
212380e3 AC |
89 | * It looks to me as if orabidoo wanted to have more |
90 | * than one set of option strings possible here... | |
91 | * i.e. ":AABBTS" as long as TS was the last two chars | |
92 | * however, as we are now using CAPAB, I think we can | |
93 | * safely assume if there is a ":TS" then its a TS server | |
94 | * -Dianora | |
95 | */ | |
96 | if(irccmp(parv[2], "TS") == 0 && client_p->tsinfo == 0) | |
97 | client_p->tsinfo = TS_DOESTS; | |
98 | ||
cda8e9b8 | 99 | if(parc == 5 && atoi(parv[3]) >= 6) |
212380e3 AC |
100 | { |
101 | /* only mark as TS6 if the SID is valid.. */ | |
102 | if(IsDigit(parv[4][0]) && IsIdChar(parv[4][1]) && | |
103 | IsIdChar(parv[4][2]) && parv[4][3] == '\0' && | |
d4b2529a | 104 | EmptyString(client_p->preClient->id)) |
212380e3 AC |
105 | { |
106 | client_p->localClient->caps |= CAP_TS6; | |
d4b2529a | 107 | rb_strlcpy(client_p->preClient->id, parv[4], sizeof(client_p->preClient->id)); |
212380e3 AC |
108 | } |
109 | } | |
110 | } | |
212380e3 | 111 | } |