2 * ircd-ratbox: A slightly useful ircd.
3 * m_pass.c: Used to send a password for a server or client{} block.
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
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.
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.
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
24 * $Id: m_pass.c 3550 2007-08-09 06:47:26Z nenolod $
28 #include "client.h" /* client struct */
30 #include "send.h" /* sendto_one */
31 #include "numeric.h" /* ERR_xxx */
32 #include "ircd.h" /* me */
40 static int mr_pass(struct Client
*, struct Client
*, int, const char **);
42 struct Message pass_msgtab
= {
43 "PASS", 0, 0, 0, MFLG_SLOW
| MFLG_UNREG
,
44 {{mr_pass
, 2}, mg_reg
, mg_ignore
, mg_ignore
, mg_ignore
, mg_reg
}
47 mapi_clist_av1 pass_clist
[] = { &pass_msgtab
, NULL
};
48 DECLARE_MODULE_AV1(pass
, NULL
, NULL
, pass_clist
, NULL
, NULL
, "$Revision: 3550 $");
51 * m_pass() - Added Sat, 4 March 1989
54 * mr_pass - PASS message handler
55 * parv[0] = sender prefix
57 * parv[2] = "TS" if this server supports TS.
58 * parv[3] = optional TS version field -- needed for TS6
61 mr_pass(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
63 char *auth_user
, *pass
, *buf
;
64 buf
= LOCAL_COPY(parv
[1]);
66 if(client_p
->localClient
->passwd
)
68 memset(client_p
->localClient
->passwd
, 0,
69 strlen(client_p
->localClient
->passwd
));
70 rb_free(client_p
->localClient
->passwd
);
73 client_p
->localClient
->passwd
= rb_strndup(parv
[1], PASSWDLEN
);
75 if ((pass
= strchr(buf
, ':')) != NULL
)
86 client_p
->localClient
->passwd
= rb_strndup(pass
, PASSWDLEN
);
89 client_p
->localClient
->auth_user
= rb_strndup(auth_user
, PASSWDLEN
);
91 /* These are for servers only */
92 if(parc
> 2 && client_p
->user
== NULL
)
95 * It looks to me as if orabidoo wanted to have more
96 * than one set of option strings possible here...
97 * i.e. ":AABBTS" as long as TS was the last two chars
98 * however, as we are now using CAPAB, I think we can
99 * safely assume if there is a ":TS" then its a TS server
102 if(irccmp(parv
[2], "TS") == 0 && client_p
->tsinfo
== 0)
103 client_p
->tsinfo
= TS_DOESTS
;
105 /* kludge, if we're not using ts6, dont ever mark a server
106 * as TS6 capable, that way we'll never send them TS6 data.
108 if(parc
== 5 && atoi(parv
[3]) >= 6)
110 /* only mark as TS6 if the SID is valid.. */
111 if(IsDigit(parv
[4][0]) && IsIdChar(parv
[4][1]) &&
112 IsIdChar(parv
[4][2]) && parv
[4][3] == '\0' &&
113 EmptyString(client_p
->id
))
115 client_p
->localClient
->caps
|= CAP_TS6
;
116 strcpy(client_p
->id
, parv
[4]);