/[svn]/ircd-hybrid-8/contrib/m_change.c
ViewVC logotype

Contents of /ircd-hybrid-8/contrib/m_change.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1575 - (show annotations)
Thu Oct 18 14:27:36 2012 UTC (7 years, 9 months ago) by michael
File MIME type: text/x-chdr
File size: 7353 byte(s)
- contrib/m_change.c,ip_cloaking.c: CHGHOST/CHGIDENT didn't update bancache. Fixed

1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_change.c: Allows changing user/host/real of connected clients.
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 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "client.h"
27 #include "ircd.h"
28 #include "irc_string.h"
29 #include "numeric.h"
30 #include "fdlist.h"
31 #include "s_bsd.h"
32 #include "conf.h"
33 #include "log.h"
34 #include "s_serv.h"
35 #include "send.h"
36 #include "parse.h"
37 #include "modules.h"
38 #include "s_user.h"
39 #include "hash.h"
40 #include "userhost.h"
41 #include "channel_mode.h"
42
43
44 static void
45 mo_chgident(struct Client *client_p, struct Client *source_p,
46 int parc, char *parv[])
47 {
48 struct Client *target_p = NULL;
49
50 if (MyClient(source_p) && !HasUMode(source_p, UMODE_ADMIN))
51 {
52 sendto_one(source_p, form_str(ERR_NOPRIVS),
53 me.name, source_p->name, "CHGIDENT");
54 return;
55 }
56
57 if (EmptyString(parv[2]))
58 {
59 parv[2] = parv[1];
60 target_p = source_p;
61
62 if (!IsClient(target_p))
63 return;
64 }
65 else {
66 target_p = hash_find_client(parv[1]);
67
68 if (target_p == NULL || !IsClient(target_p))
69 {
70 sendto_one(source_p, form_str(ERR_NOSUCHNICK),
71 me.name, source_p->name, parv[1]);
72 return;
73 }
74 }
75
76 if (strlen(parv[2]) > USERLEN || !*parv[2] || !valid_username(parv[2]))
77 {
78 sendto_one(source_p, ":%s NOTICE %s :Invalid username",
79 me.name, source_p->name);
80 return;
81 }
82
83 if (IsUserHostIp(target_p))
84 delete_user_host(target_p->username, target_p->host, !MyConnect(target_p));
85
86 strlcpy(target_p->username, parv[2], sizeof(target_p->username));
87
88 add_user_host(target_p->username, target_p->host, !MyConnect(target_p));
89 SetUserHost(target_p);
90
91 if (MyClient(source_p))
92 {
93 sendto_server(client_p, NOCAPS, NOCAPS, ":%s ENCAP * CHGIDENT %s %s",
94 source_p->name, target_p->name, parv[2]);
95 sendto_one(source_p, ":%s NOTICE %s :%s changed to %s@%s",
96 me.name, source_p->name, target_p->name, target_p->username,
97 target_p->host);
98 }
99
100 if (MyClient(target_p))
101 {
102 if (IsClient(source_p))
103 sendto_one(target_p, ":%s NOTICE %s :You are now %s@%s",
104 me.name, target_p->name, target_p->username, target_p->host);
105
106 clear_ban_cache_client(target_p);
107 }
108 }
109
110 static void
111 mo_chghost(struct Client *client_p, struct Client *source_p,
112 int parc, char *parv[])
113 {
114 struct Client *target_p = NULL;
115
116 if (MyClient(source_p) && !HasUMode(source_p, UMODE_ADMIN))
117 {
118 sendto_one(source_p, form_str(ERR_NOPRIVS),
119 me.name, source_p->name, "CHGHOST");
120 return;
121 }
122
123 if (EmptyString(parv[2]))
124 {
125 parv[2] = parv[1];
126 target_p = source_p;
127
128 if (!IsClient(target_p))
129 return;
130 }
131 else {
132 target_p = hash_find_client(parv[1]);
133
134 if (target_p == NULL || !IsClient(target_p))
135 {
136 sendto_one(source_p, form_str(ERR_NOSUCHNICK),
137 me.name, source_p->name, parv[1]);
138 return;
139 }
140 }
141
142 if (strlen(parv[2]) > HOSTLEN || !*parv[2] || !valid_hostname(parv[2]))
143 {
144 sendto_one(source_p, ":%s NOTICE %s :Invalid hostname",
145 me.name, source_p->name);
146 return;
147 }
148
149 if (IsUserHostIp(target_p))
150 delete_user_host(target_p->username, target_p->host, !MyConnect(target_p));
151
152 strlcpy(target_p->host, parv[2], sizeof(target_p->host));
153 SetIPSpoof(target_p);
154
155 add_user_host(target_p->username, target_p->host, !MyConnect(target_p));
156 SetUserHost(target_p);
157
158 if (MyClient(source_p))
159 {
160 sendto_server(client_p, NOCAPS, NOCAPS, ":%s ENCAP * CHGHOST %s %s",
161 source_p->name, target_p->name, parv[2]);
162 sendto_one(source_p, ":%s NOTICE %s :%s changed to %s@%s",
163 me.name, source_p->name, target_p->name, target_p->username,
164 target_p->host);
165 }
166
167 if (MyClient(target_p))
168 {
169 if (IsClient(source_p))
170 sendto_one(target_p, ":%s NOTICE %s :You are now %s@%s",
171 me.name, target_p->name, target_p->username, target_p->host);
172 clear_ban_cache_client(target_p);
173 }
174 }
175
176 static void
177 mo_chgname(struct Client *client_p, struct Client *source_p,
178 int parc, char *parv[])
179 {
180 struct Client *target_p = NULL;
181
182 if (MyClient(source_p) && !HasUMode(source_p, UMODE_ADMIN))
183 {
184 sendto_one(source_p, form_str(ERR_NOPRIVS),
185 me.name, source_p->name, "CHGNAME");
186 return;
187 }
188
189 if (EmptyString(parv[2]))
190 {
191 parv[2] = parv[1];
192 target_p = source_p;
193 }
194 else if ((target_p = hash_find_client(parv[1])) == NULL)
195 {
196 sendto_one(source_p, form_str(ERR_NOSUCHNICK),
197 me.name, source_p->name, parv[1]);
198 return;
199 }
200
201 if (strlen(parv[2]) > REALLEN || !*parv[2])
202 {
203 sendto_one(source_p, ":%s NOTICE %s :Invalid realname",
204 me.name, source_p->name);
205 return;
206 }
207
208 if (parc > 3 && MyClient(source_p))
209 sendto_one(source_p, ":%s NOTICE %s :Warning -- too many parameters "
210 "for CHGNAME. You are probably missing a : before the new "
211 "IRC name.", me.name, source_p->name);
212
213 strlcpy(target_p->info, parv[2], sizeof(target_p->info));
214
215 if (MyClient(source_p))
216 {
217 sendto_server(client_p, NOCAPS, NOCAPS, ":%s ENCAP * CHGNAME %s :%s",
218 source_p->name, target_p->name, parv[2]);
219 sendto_one(source_p, ":%s NOTICE %s :%s realname changed to [%s]",
220 me.name, source_p->name, target_p->name, target_p->info);
221 }
222
223 if (MyClient(target_p) && IsClient(source_p))
224 sendto_one(target_p, ":%s NOTICE %s :Your realname is now [%s]",
225 me.name, target_p->name, target_p->info);
226 }
227
228 static struct Message chgident_msgtab = {
229 "CHGIDENT", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
230 {m_unregistered, m_not_oper, mo_chgident, mo_chgident, mo_chgident, m_ignore}
231 };
232
233 static struct Message chghost_msgtab = {
234 "CHGHOST", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
235 {m_unregistered, m_not_oper, mo_chghost, mo_chghost, mo_chghost, m_ignore}
236 };
237
238 static struct Message chgname_msgtab = {
239 "CHGNAME", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
240 {m_unregistered, m_not_oper, mo_chgname, mo_chgname, mo_chgname, m_ignore}
241 };
242
243 static void
244 module_init(void)
245 {
246 mod_add_cmd(&chgident_msgtab);
247 mod_add_cmd(&chghost_msgtab);
248 mod_add_cmd(&chgname_msgtab);
249 }
250
251 static void
252 module_exit(void)
253 {
254 mod_del_cmd(&chgname_msgtab);
255 mod_del_cmd(&chghost_msgtab);
256 mod_del_cmd(&chgident_msgtab);
257 }
258
259 struct module module_entry = {
260 .node = { NULL, NULL, NULL },
261 .name = NULL,
262 .version = "$Revision$",
263 .handle = NULL,
264 .modinit = module_init,
265 .modexit = module_exit,
266 .flags = 0
267 };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28