]> jfr.im git - irc/rqf/shadowircd.git/blame - extensions/m_webirc.c
Disallow mIRC italics in channel names when disable_fake_channels
[irc/rqf/shadowircd.git] / extensions / m_webirc.c
CommitLineData
212380e3 1/*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_webirc.c: Makes CGI:IRC users appear as coming from their real host
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2006 ircd-ratbox development team
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 *
212380e3 24 */
25/* Usage:
26 * auth {
27 * user = "webirc@<cgiirc ip>"; # if identd used, put ident username instead
28 * password = "<password>"; # encryption possible
82e5490f 29 * spoof = "webirc.";
212380e3 30 * class = "users";
31 * };
32 * Possible flags:
33 * encrypted - password is encrypted (recommended)
c6525f80 34 * kline_exempt - klines on the cgiirc ip are ignored
212380e3 35 * dlines are checked on the cgiirc ip (of course).
d5a432fa 36 * k/d/x lines, auth blocks, user limits, etc are checked using the
212380e3 37 * real host/ip.
38 * The password should be specified unencrypted in webirc_password in
39 * cgiirc.config
40 */
41
42#include "stdinc.h"
43#include "client.h" /* client struct */
13ae2f4b 44#include "match.h"
212380e3 45#include "hostmask.h"
46#include "send.h" /* sendto_one */
47#include "numeric.h" /* ERR_xxx */
48#include "ircd.h" /* me */
49#include "msg.h"
50#include "parse.h"
51#include "modules.h"
52#include "s_serv.h"
53#include "hash.h"
54#include "s_conf.h"
477bbce4 55#include "reject.h"
212380e3 56
57static int mr_webirc(struct Client *, struct Client *, int, const char **);
58
59struct Message webirc_msgtab = {
60 "WEBIRC", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
4636e5cb 61 {{mr_webirc, 5}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg}
212380e3 62};
63
64mapi_clist_av1 webirc_clist[] = { &webirc_msgtab, NULL };
65DECLARE_MODULE_AV1(webirc, NULL, NULL, webirc_clist, NULL, NULL, "$Revision: 20702 $");
66
67/*
68 * mr_webirc - webirc message handler
212380e3 69 * parv[1] = password
70 * parv[2] = fake username (we ignore this)
71 * parv[3] = fake hostname
72 * parv[4] = fake ip
73 */
74static int
75mr_webirc(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
76{
77 struct ConfItem *aconf;
78 const char *encr;
79
80 if (!strchr(parv[4], '.') && !strchr(parv[4], ':'))
81 {
82 sendto_one(source_p, "NOTICE * :Invalid IP");
83 return 0;
84 }
85
86 aconf = find_address_conf(client_p->host, client_p->sockhost,
d1edae8d 87 IsGotId(client_p) ? client_p->username : "webirc",
212380e3 88 IsGotId(client_p) ? client_p->username : "webirc",
89 (struct sockaddr *) &client_p->localClient->ip,
969a1ae6 90 client_p->localClient->ip.ss_family, NULL);
212380e3 91 if (aconf == NULL || !(aconf->status & CONF_CLIENT))
92 return 0;
a0f4c418 93 if (!IsConfDoSpoofIp(aconf) || irccmp(aconf->info.name, "webirc."))
212380e3 94 {
95 /* XXX */
96 sendto_one(source_p, "NOTICE * :Not a CGI:IRC auth block");
97 return 0;
98 }
99 if (EmptyString(aconf->passwd))
100 {
101 sendto_one(source_p, "NOTICE * :CGI:IRC auth blocks must have a password");
102 return 0;
103 }
104
105 if (EmptyString(parv[1]))
106 encr = "";
107 else if (IsConfEncrypted(aconf))
f24b187a 108 encr = rb_crypt(parv[1], aconf->passwd);
212380e3 109 else
110 encr = parv[1];
111
112 if (strcmp(encr, aconf->passwd))
113 {
114 sendto_one(source_p, "NOTICE * :CGI:IRC password incorrect");
115 return 0;
116 }
117
d1edae8d 118
907468c4 119 rb_strlcpy(source_p->sockhost, parv[4], sizeof(source_p->sockhost));
d1edae8d 120
212380e3 121 if(strlen(parv[3]) <= HOSTLEN)
907468c4 122 rb_strlcpy(source_p->host, parv[3], sizeof(source_p->host));
212380e3 123 else
907468c4 124 rb_strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host));
d1edae8d 125
9879cd59 126 rb_inet_pton_sock(parv[4], (struct sockaddr *)&source_p->localClient->ip);
212380e3 127
d5a432fa 128 /* Check dlines now, klines will be checked on registration */
21c9d815
VY
129 if((aconf = find_dline((struct sockaddr *)&source_p->localClient->ip,
130 source_p->localClient->ip.ss_family)))
212380e3 131 {
132 if(!(aconf->status & CONF_EXEMPTDLINE))
133 {
134 exit_client(client_p, source_p, &me, "D-lined");
135 return 0;
136 }
137 }
138
139 sendto_one(source_p, "NOTICE * :CGI:IRC host/IP set to %s %s", parv[3], parv[4]);
140 return 0;
141}