ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/contrib/m_change.c
Revision: 344
Committed: Sat Dec 31 09:41:44 2005 UTC (20 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 6716 byte(s)
Log Message:
- Flag the client as being ip-spoofed if setting a new hostname via CHGHOST,
  that way non-opers can't figure out the IP with a simple WHOIS.
  Suggested by adx


File Contents

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

Properties

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