]> jfr.im git - irc/rqf/shadowircd.git/blame - extensions/m_webirc.c
Add OPERHOST to the help for SET.
[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 *
477bbce4 24 * $Id: m_webirc.c 3458 2007-05-18 19:51:22Z jilles $
212380e3 25 */
26/* Usage:
27 * auth {
28 * user = "webirc@<cgiirc ip>"; # if identd used, put ident username instead
29 * password = "<password>"; # encryption possible
82e5490f 30 * spoof = "webirc.";
212380e3 31 * class = "users";
32 * };
33 * Possible flags:
34 * encrypted - password is encrypted (recommended)
c6525f80 35 * kline_exempt - klines on the cgiirc ip are ignored
212380e3 36 * dlines are checked on the cgiirc ip (of course).
d5a432fa 37 * k/d/x lines, auth blocks, user limits, etc are checked using the
212380e3 38 * real host/ip.
39 * The password should be specified unencrypted in webirc_password in
40 * cgiirc.config
41 */
42
43#include "stdinc.h"
44#include "client.h" /* client struct */
13ae2f4b 45#include "match.h"
212380e3 46#include "hostmask.h"
47#include "send.h" /* sendto_one */
48#include "numeric.h" /* ERR_xxx */
49#include "ircd.h" /* me */
50#include "msg.h"
51#include "parse.h"
52#include "modules.h"
53#include "s_serv.h"
54#include "hash.h"
55#include "s_conf.h"
477bbce4 56#include "reject.h"
212380e3 57
58static int mr_webirc(struct Client *, struct Client *, int, const char **);
59
60struct Message webirc_msgtab = {
61 "WEBIRC", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
4636e5cb 62 {{mr_webirc, 5}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg}
212380e3 63};
64
65mapi_clist_av1 webirc_clist[] = { &webirc_msgtab, NULL };
66DECLARE_MODULE_AV1(webirc, NULL, NULL, webirc_clist, NULL, NULL, "$Revision: 20702 $");
67
68/*
69 * mr_webirc - webirc message handler
212380e3 70 * parv[1] = password
71 * parv[2] = fake username (we ignore this)
72 * parv[3] = fake hostname
73 * parv[4] = fake ip
74 */
75static int
76mr_webirc(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
77{
78 struct ConfItem *aconf;
79 const char *encr;
80
81 if (!strchr(parv[4], '.') && !strchr(parv[4], ':'))
82 {
83 sendto_one(source_p, "NOTICE * :Invalid IP");
84 return 0;
85 }
86
87 aconf = find_address_conf(client_p->host, client_p->sockhost,
d1edae8d 88 IsGotId(client_p) ? client_p->username : "webirc",
212380e3 89 IsGotId(client_p) ? client_p->username : "webirc",
90 (struct sockaddr *) &client_p->localClient->ip,
969a1ae6 91 client_p->localClient->ip.ss_family, NULL);
212380e3 92 if (aconf == NULL || !(aconf->status & CONF_CLIENT))
93 return 0;
a0f4c418 94 if (!IsConfDoSpoofIp(aconf) || irccmp(aconf->info.name, "webirc."))
212380e3 95 {
96 /* XXX */
97 sendto_one(source_p, "NOTICE * :Not a CGI:IRC auth block");
98 return 0;
99 }
100 if (EmptyString(aconf->passwd))
101 {
102 sendto_one(source_p, "NOTICE * :CGI:IRC auth blocks must have a password");
103 return 0;
104 }
105
106 if (EmptyString(parv[1]))
107 encr = "";
108 else if (IsConfEncrypted(aconf))
f24b187a 109 encr = rb_crypt(parv[1], aconf->passwd);
212380e3 110 else
111 encr = parv[1];
112
113 if (strcmp(encr, aconf->passwd))
114 {
115 sendto_one(source_p, "NOTICE * :CGI:IRC password incorrect");
116 return 0;
117 }
118
d1edae8d 119
907468c4 120 rb_strlcpy(source_p->sockhost, parv[4], sizeof(source_p->sockhost));
d1edae8d 121
212380e3 122 if(strlen(parv[3]) <= HOSTLEN)
907468c4 123 rb_strlcpy(source_p->host, parv[3], sizeof(source_p->host));
212380e3 124 else
907468c4 125 rb_strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host));
d1edae8d 126
9879cd59 127 rb_inet_pton_sock(parv[4], (struct sockaddr *)&source_p->localClient->ip);
212380e3 128
d5a432fa 129 /* Check dlines now, klines will be checked on registration */
21c9d815
VY
130 if((aconf = find_dline((struct sockaddr *)&source_p->localClient->ip,
131 source_p->localClient->ip.ss_family)))
212380e3 132 {
133 if(!(aconf->status & CONF_EXEMPTDLINE))
134 {
135 exit_client(client_p, source_p, &me, "D-lined");
136 return 0;
137 }
138 }
139
140 sendto_one(source_p, "NOTICE * :CGI:IRC host/IP set to %s %s", parv[3], parv[4]);
141 return 0;
142}