summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2012-11-17 19:29:07 +0000
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2012-11-17 19:29:07 +0000
commitffa2a03a9ec8f8ae5cfae93cc2fd8b3b7b141e2b (patch)
tree7ebd689508b2538c711c280ae3e89d3b6f3dcf70 /modules
parent18dc52f1e39b3936285248fd81a19d18c290d995 (diff)
- move m_webirc.c from contrib/ to modules/
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/trunk@1659 82007160-df01-0410-b94d-b575c5fd34c7
Diffstat (limited to 'modules')
-rw-r--r--modules/Makefile.am3
-rw-r--r--modules/Makefile.in22
-rw-r--r--modules/m_webirc.c205
3 files changed, 226 insertions, 4 deletions
diff --git a/modules/Makefile.am b/modules/Makefile.am
index e25e3a8..21eadb4 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -61,6 +61,7 @@ modules_LTLIBRARIES = m_accept.la \
m_version.la \
m_wallops.la \
m_watch.la \
+ m_webirc.la \
m_who.la \
m_whois.la \
m_whowas.la \
@@ -123,6 +124,7 @@ m_users_la_LDFLAGS = $(MODULE_FLAGS)
m_version_la_LDFLAGS = $(MODULE_FLAGS)
m_wallops_la_LDFLAGS = $(MODULE_FLAGS)
m_watch_la_LDFLAGS = $(MODULE_FLAGS)
+m_webirc_la_LDFLAGS = $(MODULE_FLAGS)
m_who_la_LDFLAGS = $(MODULE_FLAGS)
m_whois_la_LDFLAGS = $(MODULE_FLAGS)
m_whowas_la_LDFLAGS = $(MODULE_FLAGS)
@@ -184,6 +186,7 @@ m_users_la_SOURCES = m_users.c
m_version_la_SOURCES = m_version.c
m_wallops_la_SOURCES = m_wallops.c
m_watch_la_SOURCES = m_watch.c
+m_webirc_la_SOURCES = m_webirc.c
m_who_la_SOURCES = m_who.c
m_whois_la_SOURCES = m_whois.c
m_whowas_la_SOURCES = m_whowas.c
diff --git a/modules/Makefile.in b/modules/Makefile.in
index 1f6cb89..3b811d6 100644
--- a/modules/Makefile.in
+++ b/modules/Makefile.in
@@ -427,6 +427,12 @@ m_watch_la_OBJECTS = $(am_m_watch_la_OBJECTS)
m_watch_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(m_watch_la_LDFLAGS) $(LDFLAGS) -o $@
+m_webirc_la_LIBADD =
+am_m_webirc_la_OBJECTS = m_webirc.lo
+m_webirc_la_OBJECTS = $(am_m_webirc_la_OBJECTS)
+m_webirc_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(m_webirc_la_LDFLAGS) $(LDFLAGS) -o $@
m_who_la_LIBADD =
am_m_who_la_OBJECTS = m_who.lo
m_who_la_OBJECTS = $(am_m_who_la_OBJECTS)
@@ -491,8 +497,9 @@ SOURCES = $(m_accept_la_SOURCES) $(m_admin_la_SOURCES) \
$(m_user_la_SOURCES) $(m_userhost_la_SOURCES) \
$(m_users_la_SOURCES) $(m_version_la_SOURCES) \
$(m_wallops_la_SOURCES) $(m_watch_la_SOURCES) \
- $(m_who_la_SOURCES) $(m_whois_la_SOURCES) \
- $(m_whowas_la_SOURCES) $(m_xline_la_SOURCES)
+ $(m_webirc_la_SOURCES) $(m_who_la_SOURCES) \
+ $(m_whois_la_SOURCES) $(m_whowas_la_SOURCES) \
+ $(m_xline_la_SOURCES)
DIST_SOURCES = $(m_accept_la_SOURCES) $(m_admin_la_SOURCES) \
$(m_away_la_SOURCES) $(m_cap_la_SOURCES) $(m_capab_la_SOURCES) \
$(m_challenge_la_SOURCES) $(m_close_la_SOURCES) \
@@ -520,8 +527,9 @@ DIST_SOURCES = $(m_accept_la_SOURCES) $(m_admin_la_SOURCES) \
$(m_user_la_SOURCES) $(m_userhost_la_SOURCES) \
$(m_users_la_SOURCES) $(m_version_la_SOURCES) \
$(m_wallops_la_SOURCES) $(m_watch_la_SOURCES) \
- $(m_who_la_SOURCES) $(m_whois_la_SOURCES) \
- $(m_whowas_la_SOURCES) $(m_xline_la_SOURCES)
+ $(m_webirc_la_SOURCES) $(m_who_la_SOURCES) \
+ $(m_whois_la_SOURCES) $(m_whowas_la_SOURCES) \
+ $(m_xline_la_SOURCES)
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
@@ -769,6 +777,7 @@ modules_LTLIBRARIES = m_accept.la \
m_version.la \
m_wallops.la \
m_watch.la \
+ m_webirc.la \
m_who.la \
m_whois.la \
m_whowas.la \
@@ -830,6 +839,7 @@ m_users_la_LDFLAGS = $(MODULE_FLAGS)
m_version_la_LDFLAGS = $(MODULE_FLAGS)
m_wallops_la_LDFLAGS = $(MODULE_FLAGS)
m_watch_la_LDFLAGS = $(MODULE_FLAGS)
+m_webirc_la_LDFLAGS = $(MODULE_FLAGS)
m_who_la_LDFLAGS = $(MODULE_FLAGS)
m_whois_la_LDFLAGS = $(MODULE_FLAGS)
m_whowas_la_LDFLAGS = $(MODULE_FLAGS)
@@ -890,6 +900,7 @@ m_users_la_SOURCES = m_users.c
m_version_la_SOURCES = m_version.c
m_wallops_la_SOURCES = m_wallops.c
m_watch_la_SOURCES = m_watch.c
+m_webirc_la_SOURCES = m_webirc.c
m_who_la_SOURCES = m_who.c
m_whois_la_SOURCES = m_whois.c
m_whowas_la_SOURCES = m_whowas.c
@@ -1074,6 +1085,8 @@ m_wallops.la: $(m_wallops_la_OBJECTS) $(m_wallops_la_DEPENDENCIES) $(EXTRA_m_wal
$(m_wallops_la_LINK) -rpath $(modulesdir) $(m_wallops_la_OBJECTS) $(m_wallops_la_LIBADD) $(LIBS)
m_watch.la: $(m_watch_la_OBJECTS) $(m_watch_la_DEPENDENCIES) $(EXTRA_m_watch_la_DEPENDENCIES)
$(m_watch_la_LINK) -rpath $(modulesdir) $(m_watch_la_OBJECTS) $(m_watch_la_LIBADD) $(LIBS)
+m_webirc.la: $(m_webirc_la_OBJECTS) $(m_webirc_la_DEPENDENCIES) $(EXTRA_m_webirc_la_DEPENDENCIES)
+ $(m_webirc_la_LINK) -rpath $(modulesdir) $(m_webirc_la_OBJECTS) $(m_webirc_la_LIBADD) $(LIBS)
m_who.la: $(m_who_la_OBJECTS) $(m_who_la_DEPENDENCIES) $(EXTRA_m_who_la_DEPENDENCIES)
$(m_who_la_LINK) -rpath $(modulesdir) $(m_who_la_OBJECTS) $(m_who_la_LIBADD) $(LIBS)
m_whois.la: $(m_whois_la_OBJECTS) $(m_whois_la_DEPENDENCIES) $(EXTRA_m_whois_la_DEPENDENCIES)
@@ -1145,6 +1158,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_version.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_wallops.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_watch.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_webirc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_who.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_whois.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_whowas.Plo@am__quote@
diff --git a/modules/m_webirc.c b/modules/m_webirc.c
new file mode 100644
index 0000000..1c6083b
--- /dev/null
+++ b/modules/m_webirc.c
@@ -0,0 +1,205 @@
+/*
+ * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
+ * m_webirc.c: Makes CGI:IRC users appear as coming from their real host
+ *
+ * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
+ * Copyright (C) 2002-2006 ircd-ratbox development team
+ * Copyright (C) 1996-2012 Hybrid Development Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ *
+ * $Id$
+ */
+
+#include "stdinc.h"
+#include "list.h"
+#include "client.h"
+#include "ircd.h"
+#include "numeric.h"
+#include "send.h"
+#include "irc_string.h"
+#include "hash.h"
+#include "parse.h"
+#include "modules.h"
+#include "conf.h"
+#include "hostmask.h"
+
+/*
+ * Usage:
+ *
+ * auth {
+ * user = "webirc@<cgiirc ip>"; # if identd used, put ident username instead
+ * password = "<password>"; # encryption possible
+ * spoof = "webirc."
+ * class = "users";
+ * encrypted = yes; # [Using encryption is highly recommended]
+ * };
+ *
+ * Possible flags:
+ * kline_exempt - k/g lines on the cgiirc ip are ignored
+ * gline_exempt - glines on the cgiirc ip are ignored
+ *
+ * dlines are checked on the cgiirc ip (of course).
+ * k/d/g/x lines, auth blocks, user limits, etc are checked using the
+ * real host/ip.
+ *
+ * The password should be specified unencrypted in webirc_password in
+ * cgiirc.config
+ */
+
+static int
+invalid_hostname(const char *hostname)
+{
+ const char *p = hostname;
+ unsigned int has_sep = 0;
+
+ assert(p != NULL);
+
+ if (*p == '.' || *p == ':')
+ return 1;
+
+ for (; *p; ++p)
+ {
+ if (!IsHostChar(*p))
+ return 1;
+ if (*p == '.' || *p == ':')
+ ++has_sep;
+ }
+
+ return !has_sep;
+}
+
+/*
+ * mr_webirc
+ * parv[0] = sender prefix
+ * parv[1] = password
+ * parv[2] = fake username (we ignore this)
+ * parv[3] = fake hostname
+ * parv[4] = fake ip
+ */
+static void
+mr_webirc(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
+{
+ struct MaskItem *conf = NULL;
+ struct addrinfo hints, *res;
+
+ assert(source_p == client_p);
+
+ if (invalid_hostname(parv[4]))
+ {
+ sendto_one(source_p, ":%s NOTICE %s :CGI:IRC: Invalid IP", me.name,
+ source_p->name[0] ? source_p->name : "*");
+ return;
+ }
+
+ conf = find_address_conf(source_p->host,
+ IsGotId(source_p) ? source_p->username : "webirc",
+ &source_p->localClient->ip,
+ source_p->localClient->aftype, parv[1]);
+ if (conf == NULL || !IsConfClient(conf))
+ return;
+
+ if (!IsConfDoSpoofIp(conf) || irccmp(conf->name, "webirc."))
+ {
+ sendto_one(source_p, ":%s NOTICE %s :Not a CGI:IRC auth block", me.name,
+ source_p->name[0] ? source_p->name : "*");
+ return;
+ }
+
+ if (EmptyString(conf->passwd))
+ {
+ sendto_one(source_p, ":%s NOTICE %s :CGI:IRC auth blocks must have a password",
+ me.name, source_p->name[0] ? source_p->name : "*");
+ return;
+ }
+
+ if (!match_conf_password(parv[1], conf))
+ {
+ sendto_one(source_p, ":%s NOTICE %s :CGI:IRC password incorrect",
+ me.name, source_p->name[0] ? source_p->name : "*");
+ return;
+ }
+
+ memset(&hints, 0, sizeof(hints));
+
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;
+
+ if (getaddrinfo(parv[4], NULL, &hints, &res))
+ {
+
+ sendto_one(source_p, ":%s NOTICE %s :Invalid CGI:IRC IP %s", me.name,
+ source_p->name[0] ? source_p->name : "*", parv[4]);
+ return;
+ }
+
+ assert(res != NULL);
+
+ memcpy(&source_p->localClient->ip, res->ai_addr, res->ai_addrlen);
+ source_p->localClient->ip.ss_len = res->ai_addrlen;
+ source_p->localClient->ip.ss.ss_family = res->ai_family;
+ source_p->localClient->aftype = res->ai_family;
+ freeaddrinfo(res);
+
+ strlcpy(source_p->sockhost, parv[4], sizeof(source_p->sockhost));
+
+ if (strlen(parv[3]) <= HOSTLEN)
+ strlcpy(source_p->host, parv[3], sizeof(source_p->host));
+ else
+ strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host));
+
+ /* Check dlines now, k/glines will be checked on registration */
+ if ((conf = find_dline_conf(&client_p->localClient->ip,
+ client_p->localClient->aftype)))
+ {
+ if (!(conf->type == CONF_EXEMPT))
+ {
+ exit_client(client_p, &me, "D-lined");
+ return;
+ }
+ }
+
+ sendto_one(source_p, ":%s NOTICE %s :CGI:IRC host/IP set to %s %s", me.name,
+ source_p->name[0] ? source_p->name : "*", parv[3], parv[4]);
+}
+
+static struct Message webirc_msgtab = {
+ "WEBIRC", 0, 0, 5, 0, MFLG_SLOW, 0,
+ { mr_webirc, m_ignore, m_ignore, m_ignore, m_ignore, m_ignore }
+};
+
+static void
+module_init(void)
+{
+ mod_add_cmd(&webirc_msgtab);
+}
+
+static void
+module_exit(void)
+{
+ mod_del_cmd(&webirc_msgtab);
+}
+
+struct module module_entry = {
+ .node = { NULL, NULL, NULL },
+ .name = NULL,
+ .version = "$Revision$",
+ .handle = NULL,
+ .modinit = module_init,
+ .modexit = module_exit,
+ .flags = 0
+};