ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.2/modules/m_testline.c
Revision: 150
Committed: Sun Oct 16 18:14:43 2005 UTC (18 years, 6 months ago) by db
Content type: text/x-csrc
File size: 7645 byte(s)
Log Message:
 - backport fix from HEAD to fix m_testline.c on 7.2
   This bug is old. The code was missing a test for a kline conf and the
   sendto to print that kline out, in the case where it was a kline against
   and IP. i.e. foo@ip.ip.ip.ip it would work in the case where it was
   a kline against a dns.


File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_testline.c: Tests a hostmask to see what will happen to it.
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 "handlers.h"
27 #include "client.h"
28 #include "common.h"
29 #include "irc_string.h"
30 #include "ircd_defs.h"
31 #include "ircd.h"
32 #include "restart.h"
33 #include "s_conf.h"
34 #include "send.h"
35 #include "msg.h"
36 #include "hostmask.h"
37 #include "numeric.h"
38 #include "parse.h"
39 #include "resv.h"
40 #include "hash.h"
41 #include "modules.h"
42
43 static void mo_testline(struct Client*, struct Client*, int, char**);
44 static void mo_testgecos(struct Client*, struct Client*, int, char**);
45
46 struct Message testline_msgtab = {
47 "TESTLINE", 0, 0, 0, 0, MFLG_SLOW, 0,
48 {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testline, m_ignore}
49 };
50
51 struct Message testgecos_msgtab = {
52 "TESTGECOS", 0, 0, 0, 0, MFLG_SLOW, 0,
53 {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testgecos, m_ignore}
54 };
55
56 #ifndef STATIC_MODULES
57 void
58 _modinit(void)
59 {
60 mod_add_cmd(&testline_msgtab);
61 mod_add_cmd(&testgecos_msgtab);
62 }
63
64 void
65 _moddeinit(void)
66 {
67 mod_del_cmd(&testline_msgtab);
68 mod_del_cmd(&testgecos_msgtab);
69 }
70
71 const char *_version = "$Revision$";
72 #endif
73
74 /* mo_testline()
75 *
76 * inputs - pointer to physical connection request is coming from
77 * - pointer to source connection request is coming from
78 * - parc arg count
79 * - parv actual arguments
80 *
81 * output - NONE
82 * side effects - command to test I/K lines on server
83 *
84 * i.e. /quote testline user@host,ip [password]
85 *
86 */
87 static void
88 mo_testline(struct Client *client_p, struct Client *source_p,
89 int parc, char *parv[])
90 {
91 char *orig_parv1;
92 char *given_name;
93 char *given_host = NULL;
94 struct ConfItem *conf;
95 struct AccessItem *aconf;
96 struct irc_ssaddr ip;
97 int host_mask;
98 int t;
99 int matches = 0;
100 char userhost[HOSTLEN + USERLEN + 2];
101
102 if (parc < 2 || EmptyString(parv[1]))
103 {
104 sendto_one(source_p, ":%s NOTICE %s :usage: user@host|ip [password]",
105 me.name, source_p->name);
106 return;
107 }
108
109 given_name = parv[1];
110
111 if (IsChanPrefix(*given_name)) /* Might be channel resv */
112 {
113 struct ResvChannel *chptr;
114
115 chptr = match_find_resv(given_name);
116 if (chptr != NULL)
117 {
118 sendto_one(source_p,
119 form_str(RPL_TESTLINE),
120 me.name, source_p->name,
121 'Q', 0, chptr->name,
122 chptr->reason ? chptr->reason : "No reason", "" );
123 return;
124 }
125 }
126
127 DupString(orig_parv1,parv[1]);
128 split_nuh(given_name, NULL, &given_name, &given_host);
129
130 t = parse_netmask(given_host, &ip, &host_mask);
131
132 if (t != HM_HOST)
133 {
134 aconf = find_dline_conf(&ip,
135 #ifdef IPV6
136 (t == HM_IPV6) ? AF_INET6 : AF_INET
137 #else
138 AF_INET
139 #endif
140 );
141 if (aconf != NULL)
142 {
143 conf = unmap_conf_item(aconf);
144
145 if (aconf->status & CONF_EXEMPTDLINE)
146 {
147 sendto_one(source_p,
148 ":%s NOTICE %s :Exempt D-line host [%s] reason [%s]",
149 me.name, source_p->name, aconf->host, aconf->reason);
150 ++matches;
151 }
152 else
153 {
154 sendto_one(source_p,
155 form_str(RPL_TESTLINE),
156 me.name, source_p->name,
157 IsConfTemporary(aconf) ? 'd' : 'D',
158 IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
159 : 0L,
160 aconf->host, aconf->reason, aconf->oper_reason);
161 ++matches;
162 }
163 }
164 }
165
166 aconf = find_kline_conf(given_host, given_name, &ip, t);
167 if ((aconf != NULL) && (aconf->status & CONF_KILL))
168 {
169 snprintf(userhost, sizeof(userhost), "%s@%s", aconf->user, aconf->host);
170 sendto_one(source_p, form_str(RPL_TESTLINE),
171 me.name, source_p->name,
172 IsConfTemporary(aconf) ? 'k' : 'K',
173 IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
174 : 0L,
175 userhost,
176 aconf->passwd ? aconf->passwd : "No reason",
177 aconf->oper_reason ? aconf->oper_reason : "");
178 ++matches;
179 }
180
181
182 if (t != HM_HOST)
183 aconf = find_address_conf(given_host, given_name, &ip,
184 #ifdef IPV6
185 (t == HM_IPV6) ? AF_INET6 : AF_INET,
186 #else
187 AF_INET,
188 #endif
189 parv[2]);
190 else
191 aconf = find_address_conf(given_host, given_name, NULL, 0, parv[2]);
192
193 if (aconf != NULL)
194 {
195 conf = unmap_conf_item(aconf);
196
197 snprintf(userhost, sizeof(userhost), "%s@%s", aconf->user, aconf->host);
198
199 if (aconf->status & CONF_CLIENT)
200 {
201 sendto_one(source_p, form_str(RPL_TESTLINE),
202 me.name, source_p->name,
203 'I', 0L, userhost,
204 aconf->class_ptr ? aconf->class_ptr->name : "<default>", "");
205 ++matches;
206 }
207 else if (aconf->status & CONF_KILL)
208 {
209 sendto_one(source_p, form_str(RPL_TESTLINE),
210 me.name, source_p->name,
211 IsConfTemporary(aconf) ? 'k' : 'K',
212 IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
213 : 0L,
214 userhost, aconf->passwd ? aconf->passwd : "No reason",
215 aconf->oper_reason ? aconf->oper_reason : "");
216 ++matches;
217 }
218 }
219
220 conf = find_matching_name_conf(NRESV_TYPE, given_name, NULL, NULL, 0);
221
222 if (conf != NULL)
223 {
224 struct MatchItem *mconf;
225 mconf = (struct MatchItem *)map_to_conf(conf);
226
227 sendto_one(source_p, form_str(RPL_TESTLINE),
228 me.name, source_p->name,
229 'Q', 0L,
230 conf->name,
231 mconf->reason ? mconf->reason : "No reason",
232 mconf->oper_reason ? mconf->oper_reason : "");
233 ++matches;
234 }
235
236 if (matches == 0)
237 sendto_one(source_p, form_str(RPL_NOTESTLINE),
238 me.name, source_p->name, orig_parv1);
239
240 MyFree(given_host);
241 MyFree(given_name);
242 MyFree(orig_parv1);
243 }
244
245 /* mo_testgecos()
246 *
247 * inputs - pointer to physical connection request is coming from
248 * - pointer to source connection request is coming from
249 * - parc arg count
250 * - parv actual arguments
251 *
252 * output - always 0
253 * side effects - command to test X lines on server
254 *
255 * i.e. /quote testgecos gecos
256 *
257 */
258 static void
259 mo_testgecos(struct Client *client_p, struct Client *source_p,
260 int parc, char *parv[])
261 {
262 struct ConfItem *conf = NULL;
263 struct MatchItem *xconf = NULL;
264 const char *gecos_name = NULL;
265
266 if (parc < 2 || EmptyString(parv[1]))
267 {
268 sendto_one(source_p, ":%s NOTICE %s :usage: gecos",
269 me.name, source_p->name);
270 return;
271 }
272
273 gecos_name = parv[1];
274
275 if ((conf = find_matching_name_conf(XLINE_TYPE, gecos_name, NULL, NULL, 0))
276 != NULL)
277 {
278 xconf = (struct MatchItem *)map_to_conf(conf);
279 sendto_one(source_p, form_str(RPL_TESTLINE),
280 me.name, source_p->name, 'X', 0L,
281 conf->name, xconf->reason ? xconf->reason : "X-lined",
282 xconf->oper_reason ? xconf->oper_reason : "");
283 }
284 else
285 sendto_one(source_p, form_str(RPL_NOTESTLINE),
286 me.name, source_p->name, parv[1]);
287 }

Properties

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