ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_webirc.c
Revision: 3096
Committed: Sat Mar 1 23:31:45 2014 UTC (12 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 4457 byte(s)
Log Message:
- Applied Adam's "Put the command name in parv[0], not prefix name" patch

File Contents

# User Rev Content
1 michael 1262 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 michael 1262 *
4 michael 2820 * Copyright (c) 2012-2014 ircd-hybrid development team
5 michael 1262 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19     * USA
20     */
21    
22 michael 2820 /*! \file m_webirc.c
23     * \brief Includes required functions for processing the WEBIRC command.
24     * \version $Id$
25     */
26    
27 michael 1262 #include "stdinc.h"
28     #include "list.h"
29     #include "client.h"
30     #include "ircd.h"
31     #include "send.h"
32     #include "irc_string.h"
33     #include "parse.h"
34     #include "modules.h"
35 michael 1309 #include "conf.h"
36 michael 1262 #include "hostmask.h"
37 michael 2700 #include "s_user.h"
38 michael 1262
39    
40     /*
41     * mr_webirc
42 michael 3096 * parv[0] = command
43 michael 1262 * parv[1] = password
44     * parv[2] = fake username (we ignore this)
45 michael 2820 * parv[3] = fake hostname
46 michael 1262 * parv[4] = fake ip
47     */
48 michael 2820 static int
49 michael 1262 mr_webirc(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
50     {
51 michael 1632 struct MaskItem *conf = NULL;
52 michael 1262 struct addrinfo hints, *res;
53    
54     assert(source_p == client_p);
55    
56 michael 2700 if (!valid_hostname(parv[3]))
57 michael 1262 {
58 michael 2700 sendto_one(source_p, ":%s NOTICE %s :CGI:IRC: Invalid hostname", me.name,
59 michael 1262 source_p->name[0] ? source_p->name : "*");
60 michael 2820 return 0;
61 michael 1262 }
62    
63 michael 1632 conf = find_address_conf(source_p->host,
64     IsGotId(source_p) ? source_p->username : "webirc",
65     &source_p->localClient->ip,
66     source_p->localClient->aftype, parv[1]);
67     if (conf == NULL || !IsConfClient(conf))
68 michael 2820 return 0;
69 michael 1262
70 michael 1715 if (!IsConfWebIRC(conf))
71 michael 1262 {
72     sendto_one(source_p, ":%s NOTICE %s :Not a CGI:IRC auth block", me.name,
73     source_p->name[0] ? source_p->name : "*");
74 michael 2820 return 0;
75 michael 1262 }
76    
77 michael 1632 if (EmptyString(conf->passwd))
78 michael 1262 {
79     sendto_one(source_p, ":%s NOTICE %s :CGI:IRC auth blocks must have a password",
80     me.name, source_p->name[0] ? source_p->name : "*");
81 michael 2820 return 0;
82 michael 1262 }
83    
84 michael 1632 if (!match_conf_password(parv[1], conf))
85 michael 1262 {
86     sendto_one(source_p, ":%s NOTICE %s :CGI:IRC password incorrect",
87     me.name, source_p->name[0] ? source_p->name : "*");
88 michael 2820 return 0;
89 michael 1262 }
90    
91     memset(&hints, 0, sizeof(hints));
92    
93     hints.ai_family = AF_UNSPEC;
94     hints.ai_socktype = SOCK_STREAM;
95     hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
96    
97     if (getaddrinfo(parv[4], NULL, &hints, &res))
98     {
99    
100     sendto_one(source_p, ":%s NOTICE %s :Invalid CGI:IRC IP %s", me.name,
101     source_p->name[0] ? source_p->name : "*", parv[4]);
102 michael 2820 return 0;
103 michael 1262 }
104    
105     assert(res != NULL);
106    
107     memcpy(&source_p->localClient->ip, res->ai_addr, res->ai_addrlen);
108     source_p->localClient->ip.ss_len = res->ai_addrlen;
109     source_p->localClient->ip.ss.ss_family = res->ai_family;
110     source_p->localClient->aftype = res->ai_family;
111     freeaddrinfo(res);
112    
113     strlcpy(source_p->sockhost, parv[4], sizeof(source_p->sockhost));
114 michael 2700 strlcpy(source_p->host, parv[3], sizeof(source_p->host));
115 michael 1262
116     /* Check dlines now, k/glines will be checked on registration */
117 michael 1632 if ((conf = find_dline_conf(&client_p->localClient->ip,
118     client_p->localClient->aftype)))
119 michael 1262 {
120 michael 1636 if (!(conf->type == CONF_EXEMPT))
121 michael 1262 {
122     exit_client(client_p, &me, "D-lined");
123 michael 2820 return 0;
124 michael 1262 }
125     }
126    
127 michael 2511 AddUMode(source_p, UMODE_WEBIRC);
128 michael 1262 sendto_one(source_p, ":%s NOTICE %s :CGI:IRC host/IP set to %s %s", me.name,
129     source_p->name[0] ? source_p->name : "*", parv[3], parv[4]);
130 michael 2820 return 0;
131 michael 1262 }
132    
133 michael 2820 static struct Message webirc_msgtab =
134     {
135 michael 1689 "WEBIRC", 0, 0, 5, MAXPARA, MFLG_SLOW, 0,
136 michael 2712 { mr_webirc, m_registered, m_ignore, m_ignore, m_registered, m_ignore }
137 michael 1262 };
138    
139     static void
140     module_init(void)
141     {
142     mod_add_cmd(&webirc_msgtab);
143     }
144    
145     static void
146     module_exit(void)
147     {
148     mod_del_cmd(&webirc_msgtab);
149     }
150    
151 michael 2820 struct module module_entry =
152     {
153 michael 1262 .node = { NULL, NULL, NULL },
154     .name = NULL,
155     .version = "$Revision$",
156     .handle = NULL,
157     .modinit = module_init,
158     .modexit = module_exit,
159     .flags = 0
160     };

Properties

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