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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 564 - (show annotations)
Sun Apr 23 15:35:58 2006 UTC (14 years, 2 months ago) by michael
File MIME type: text/x-chdr
File size: 6741 byte(s)
- Allow servers to CHGHOST.  This is mainly to fix an issue with
  ip_cloaking module

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 /* List of ircd includes from ../include/ */
26 #include "stdinc.h"
27 #include "handlers.h"
28 #include "client.h"
29 #include "common.h" /* FALSE bleah */
30 #include "ircd.h"
31 #include "irc_string.h"
32 #include "numeric.h"
33 #include "fdlist.h"
34 #include "s_bsd.h"
35 #include "s_conf.h"
36 #include "s_log.h"
37 #include "s_serv.h"
38 #include "send.h"
39 #include "msg.h"
40 #include "parse.h"
41 #include "modules.h"
42 #include "s_user.h"
43 #include "hash.h"
44
45 static void mo_chgident(struct Client *, struct Client *, int, char *[]);
46 static void mo_chghost(struct Client *, struct Client *, int, char *[]);
47 static void mo_chgname(struct Client *, struct Client *, int, char *[]);
48
49 struct Message chgident_msgtab = {
50 "CHGIDENT", 0, 0, 2, 0, MFLG_SLOW, 0,
51 {m_unregistered, m_not_oper, mo_chgident, mo_chgident, mo_chgident, m_ignore}
52 };
53
54 struct Message chghost_msgtab = {
55 "CHGHOST", 0, 0, 2, 0, MFLG_SLOW, 0,
56 {m_unregistered, m_not_oper, mo_chghost, mo_chghost, mo_chghost, m_ignore}
57 };
58
59 struct Message chgname_msgtab = {
60 "CHGNAME", 0, 0, 2, 0, MFLG_SLOW, 0,
61 {m_unregistered, m_not_oper, mo_chgname, mo_chgname, mo_chgname, m_ignore}
62 };
63
64 #ifndef STATIC_MODULES
65 void
66 _modinit(void)
67 {
68 mod_add_cmd(&chgident_msgtab);
69 mod_add_cmd(&chghost_msgtab);
70 mod_add_cmd(&chgname_msgtab);
71 }
72
73 void
74 _moddeinit(void)
75 {
76 mod_del_cmd(&chgname_msgtab);
77 mod_del_cmd(&chghost_msgtab);
78 mod_del_cmd(&chgident_msgtab);
79 }
80
81 const char *_version = "$Revision$";
82 #endif
83
84 static void
85 mo_chgident(struct Client *client_p, struct Client *source_p,
86 int parc, char *parv[])
87 {
88 struct Client *target_p = NULL;
89
90 if (MyClient(source_p) && !IsOperAdmin(source_p))
91 {
92 sendto_one(source_p, form_str(ERR_NOPRIVS),
93 me.name, parv[0], "CHGIDENT");
94 return;
95 }
96
97 if (EmptyString(parv[2]))
98 {
99 parv[2] = parv[1];
100
101 target_p = source_p;
102 if (!IsClient(target_p))
103 return;
104 }
105 else {
106 target_p = find_client(parv[1]);
107
108 if (target_p == NULL || !IsClient(target_p))
109 {
110 sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, parv[0], parv[1]);
111 return;
112 }
113 }
114
115 if (strlen(parv[2]) > USERLEN || !*parv[2] || !valid_username(parv[2]))
116 {
117 sendto_one(source_p, ":%s NOTICE %s :Invalid username", me.name, parv[0]);
118 return;
119 }
120
121 strcpy(target_p->username, parv[2]);
122
123 if (MyClient(source_p))
124 {
125 sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
126 ":%s ENCAP * CHGIDENT %s %s",
127 parv[0], target_p->name, parv[2]);
128 sendto_one(source_p, ":%s NOTICE %s :%s changed to %s@%s",
129 me.name, parv[0], target_p->name, target_p->username,
130 target_p->host);
131 }
132
133 if (MyConnect(target_p) && IsClient(source_p))
134 sendto_one(target_p, ":%s NOTICE %s :You are now %s@%s",
135 me.name, target_p->name, target_p->username, target_p->host);
136 }
137
138 static void
139 mo_chghost(struct Client *client_p, struct Client *source_p,
140 int parc, char *parv[])
141 {
142 struct Client *target_p = NULL;
143
144 if (MyClient(source_p) && !IsOperAdmin(source_p))
145 {
146 sendto_one(source_p, form_str(ERR_NOPRIVS),
147 me.name, parv[0], "CHGHOST");
148 return;
149 }
150
151 if (EmptyString(parv[2]))
152 {
153 parv[2] = parv[1];
154
155 target_p = source_p;
156 if (!IsClient(target_p))
157 return;
158 }
159 else {
160 target_p = find_client(parv[1]);
161 if (target_p == NULL || !IsClient(target_p))
162 {
163 sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, parv[0], parv[1]);
164 return;
165 }
166 }
167
168 if (strlen(parv[2]) > HOSTLEN || !*parv[2] || !valid_hostname(parv[2]))
169 {
170 sendto_one(source_p, ":%s NOTICE %s :Invalid hostname", me.name, parv[0]);
171 return;
172 }
173
174 strcpy(target_p->host, parv[2]);
175 SetIPSpoof(target_p);
176
177 if (MyClient(source_p))
178 {
179 sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
180 ":%s ENCAP * CHGHOST %s %s",
181 parv[0], target_p->name, parv[2]);
182 sendto_one(source_p, ":%s NOTICE %s :%s changed to %s@%s",
183 me.name, parv[0], target_p->name, target_p->username,
184 target_p->host);
185 }
186
187 if (MyConnect(target_p) && IsClient(source_p))
188 sendto_one(target_p, ":%s NOTICE %s :You are now %s@%s",
189 me.name, target_p->name, target_p->username, target_p->host);
190 }
191
192 static void
193 mo_chgname(struct Client *client_p, struct Client *source_p,
194 int parc, char *parv[])
195 {
196 struct Client *target_p = NULL;
197
198 if (MyClient(source_p) && !IsOperAdmin(source_p))
199 {
200 sendto_one(source_p, form_str(ERR_NOPRIVS),
201 me.name, parv[0], "CHGNAME");
202 return;
203 }
204
205 if (EmptyString(parv[2]))
206 {
207 parv[2] = parv[1];
208 target_p = source_p;
209 }
210 else if ((target_p = find_client(parv[1])) == NULL)
211 {
212 sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, parv[0], parv[1]);
213 return;
214 }
215
216 if (strlen(parv[2]) > REALLEN || !*parv[2])
217 {
218 sendto_one(source_p, ":%s NOTICE %s :Invalid realname", me.name, parv[0]);
219 return;
220 }
221
222 if (parc > 3 && MyClient(source_p))
223 sendto_one(source_p, ":%s NOTICE %s :Warning -- too many parameters "
224 "for CHGNAME. You are probably missing a : before the new "
225 "IRC name.", me.name, parv[0]);
226
227 strcpy(target_p->info, parv[2]);
228
229 if (MyClient(source_p))
230 {
231 sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT,
232 ":%s ENCAP * CHGNAME %s :%s",
233 parv[0], target_p->name, parv[2]);
234 sendto_one(source_p, ":%s NOTICE %s :%s realname changed to [%s]",
235 me.name, parv[0], target_p->name, target_p->info);
236 }
237
238 if (MyClient(target_p) && IsClient(source_p))
239 sendto_one(target_p, ":%s NOTICE %s :Your realname is now [%s]",
240 me.name, target_p->name, target_p->info);
241 }

Properties

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

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