ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_testline.c
Revision: 149
Committed: Sun Oct 16 18:11:50 2005 UTC (20 years, 9 months ago) by db
Content type: text/x-csrc
File size: 7574 byte(s)
Log Message:
 - Fix m_testline.c in HEAD
   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

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

Properties

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