1 |
adx |
30 |
/* |
2 |
|
|
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
|
|
* m_pass.c: Used to send a password for a server or client{} block. |
4 |
|
|
* |
5 |
|
|
* Copyright (C) 2002 by the past and present ircd coders, and others. |
6 |
|
|
* |
7 |
|
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU General Public License as published by |
9 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
10 |
|
|
* (at your option) any later version. |
11 |
|
|
* |
12 |
|
|
* This program is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with this program; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
|
|
* USA |
21 |
|
|
* |
22 |
knight |
31 |
* $Id$ |
23 |
adx |
30 |
*/ |
24 |
|
|
|
25 |
|
|
#include "stdinc.h" |
26 |
|
|
#include "client.h" /* client struct */ |
27 |
|
|
#include "irc_string.h" |
28 |
|
|
#include "send.h" /* sendto_one */ |
29 |
|
|
#include "numeric.h" /* ERR_xxx */ |
30 |
|
|
#include "ircd.h" /* me */ |
31 |
|
|
#include "parse.h" |
32 |
|
|
#include "modules.h" |
33 |
|
|
#include "s_serv.h" |
34 |
michael |
573 |
#include "s_user.h" |
35 |
adx |
30 |
|
36 |
|
|
|
37 |
|
|
/* |
38 |
|
|
* m_pass() - Added Sat, 4 March 1989 |
39 |
|
|
* |
40 |
|
|
* |
41 |
|
|
* mr_pass - PASS message handler |
42 |
|
|
* parv[0] = sender prefix |
43 |
|
|
* parv[1] = password |
44 |
|
|
* parv[2] = optional extra version information |
45 |
|
|
*/ |
46 |
|
|
static void |
47 |
|
|
mr_pass(struct Client *client_p, struct Client *source_p, |
48 |
|
|
int parc, char *parv[]) |
49 |
|
|
{ |
50 |
|
|
char *password = parv[1]; |
51 |
|
|
|
52 |
michael |
1230 |
assert(client_p == source_p); |
53 |
|
|
|
54 |
adx |
30 |
if (EmptyString(password)) |
55 |
|
|
{ |
56 |
michael |
1230 |
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, |
57 |
|
|
source_p->name[0] ? source_p->name : "*", "PASS"); |
58 |
adx |
30 |
return; |
59 |
|
|
} |
60 |
|
|
|
61 |
michael |
1230 |
MyFree(source_p->localClient->passwd); |
62 |
adx |
30 |
if (strlen(password) > PASSWDLEN) |
63 |
|
|
password[PASSWDLEN] = '\0'; |
64 |
michael |
1230 |
DupString(source_p->localClient->passwd, password); |
65 |
adx |
30 |
|
66 |
|
|
if (parc > 2) |
67 |
|
|
{ |
68 |
|
|
/* It looks to me as if orabidoo wanted to have more |
69 |
|
|
* than one set of option strings possible here... |
70 |
|
|
* i.e. ":AABBTS" as long as TS was the last two chars |
71 |
|
|
* however, as we are now using CAPAB, I think we can |
72 |
|
|
* safely assume if there is a ":TS" then its a TS server |
73 |
|
|
* -Dianora |
74 |
|
|
*/ |
75 |
michael |
1230 |
if (!irccmp(parv[2], "TS") && source_p->tsinfo == 0) |
76 |
|
|
source_p->tsinfo = TS_DOESTS; |
77 |
adx |
30 |
} |
78 |
|
|
|
79 |
|
|
/* only do this stuff if we are doing ts6 */ |
80 |
michael |
1115 |
if (parc > 4) |
81 |
adx |
30 |
{ |
82 |
michael |
573 |
if (atoi(parv[3]) >= 6 && valid_sid(parv[4])) |
83 |
adx |
30 |
{ |
84 |
michael |
1230 |
strlcpy(source_p->id, parv[4], sizeof(source_p->id)); |
85 |
|
|
SetCapable(source_p, CAP_TS6); |
86 |
adx |
30 |
} |
87 |
|
|
} |
88 |
|
|
} |
89 |
michael |
1230 |
|
90 |
|
|
static struct Message pass_msgtab = { |
91 |
|
|
"PASS", 0, 0, 2, MAXPARA, MFLG_SLOW | MFLG_UNREG, 0, |
92 |
|
|
{ mr_pass, m_registered, m_ignore, m_ignore, m_registered, mr_pass } |
93 |
|
|
}; |
94 |
|
|
|
95 |
|
|
static void |
96 |
|
|
module_init(void) |
97 |
|
|
{ |
98 |
|
|
mod_add_cmd(&pass_msgtab); |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
static void |
102 |
|
|
module_exit(void) |
103 |
|
|
{ |
104 |
|
|
mod_del_cmd(&pass_msgtab); |
105 |
|
|
} |
106 |
|
|
|
107 |
|
|
struct module module_entry = { |
108 |
|
|
.node = { NULL, NULL, NULL }, |
109 |
|
|
.name = NULL, |
110 |
|
|
.version = "$Revision$", |
111 |
|
|
.handle = NULL, |
112 |
|
|
.modinit = module_init, |
113 |
|
|
.modexit = module_exit, |
114 |
|
|
.flags = 0 |
115 |
|
|
}; |