Commits

James Sanderson  committed b018af3

Initial commit

  • Participants

Comments (0)

Files changed (3)

+#
+# Makefile.in for ircd/unsupported
+#
+# $Id: Makefile.in 3478 2007-05-24 15:10:06Z jilles $
+#
+CC		= @CC@
+RM		= @RM@
+SED             = @SED@
+LEX		= @LEX@
+LEXLIB		= @LEXLIB@
+CFLAGS		= @IRC_CFLAGS@ -DIRCD_PREFIX=\"@prefix@\"
+PICFLAGS	= @PICFLAGS@
+MKDEP		= @MKDEP@
+INSTALL		= @INSTALL@
+INSTALL_PROGRAM	= @INSTALL_PROGRAM@
+INSTALL_DATA	= @INSTALL_DATA@
+INSTALL_SUID    = @INSTALL_PROGRAM@ -o root -m 4755
+SHELL		= /bin/sh
+AUTOMODULEDIR	= @moduledir@/unsupported
+
+SSL_LIBS	= @SSL_LIBS@
+SSL_INCLUDES	= @SSL_INCLUDES@
+
+IRCDLIBS	= @LIBS@ $(SSL_LIBS)
+
+INCLUDES	= -I. -I../include -I../libcharybdis -I../libratbox/include $(SSL_INCLUDES)
+CPPFLAGS	= ${INCLUDES} @CPPFLAGS@
+
+SRCS =                          \
+  m_clearchan.c			\
+  m_force.c			\
+  sno_channeljoin.c		\
+  m_chgident.c			\
+  m_chgboth.c			\
+  m_chgnick.c
+
+OBJS = ${SRCS:.c=.so}
+
+default:	build
+build: all
+all: $(OBJS)
+
+install: all
+	-@if test ! -d $(DESTDIR)$(AUTOMODULEDIR); then \
+                mkdir $(DESTDIR)$(AUTOMODULEDIR); \
+        fi
+	@echo "Installing modules into $(DESTDIR)$(AUTOMODULEDIR) .."
+	@for file in $(OBJS); do \
+		$(INSTALL_DATA) $$file $(DESTDIR)$(AUTOMODULEDIR); \
+	done
+
+.SUFFIXES: .so
+
+.c.so:
+	${CC} ${PICFLAGS}  ${CPPFLAGS} ${CFLAGS} $< -o $@
+
+.PHONY: depend clean distclean
+depend:
+	@${MKDEP} ${CPPFLAGS} ${SRCS} > .depend
+	@sed s/\\\.o/\\\.so/ < .depend > .depend.tmp
+	@sed -e '/^# DO NOT DELETE THIS LINE/,$$d' <Makefile >Makefile.depend
+	@echo '# DO NOT DELETE THIS LINE!!!' >>Makefile.depend
+	@echo '# make depend needs it.' >>Makefile.depend
+	@cat .depend.tmp >>Makefile.depend
+	@mv Makefile.depend Makefile
+	@rm -f .depend.tmp .depend
+
+clean:
+	${RM} -f *.so *~ 
+
+distclean: clean
+	${RM} -f Makefile
+
+/*
+ * Copyright (c) 2005 William Pitcock <nenolod -at- nenolod.net>
+ * and Jilles Tjoelker <jilles -at- stack.nl>
+ * All rights reserved.
+ *
+ * Redistribution in both source and binary forms are permitted
+ * provided that the above copyright notice remains unchanged.
+ *
+ * m_chgboth.c: A module to change ident and host at the same
+ * time, resulting in less channel spam if both need to be
+ * changed at the same time
+ * 
+ * Based heavily on m_chghost.c from the Charybdis IRCd
+ */
+
+#define ENABLE_OPER_CHGHOST
+
+#include "stdinc.h"
+#include "send.h"
+#include "channel.h"
+#include "client.h"
+#include "common.h"
+#include "config.h"
+#include "ircd.h"
+#include "numeric.h"
+#include "s_conf.h"
+#include "s_newconf.h"
+#include "s_serv.h"
+#include "s_user.h"
+#include "hash.h"
+#include "msg.h"
+#include "parse.h"
+#include "modules.h"
+#include "whowas.h"
+#include "monitor.h"
+
+static int ms_chgboth(struct Client *, struct Client *, int, const char **);
+static int me_chgboth(struct Client *, struct Client *, int, const char **);
+static int mo_chgboth(struct Client *, struct Client *, int, const char **);
+
+struct Message chgboth_msgtab = {
+	"CHGBOTH", 0, 0, 0, MFLG_SLOW,
+	{mg_ignore, mg_not_oper, {ms_chgboth, 4}, {ms_chgboth, 4}, {me_chgboth, 4}, {mo_chgboth, 4}}
+};
+
+mapi_clist_av1 chgboth_clist[] = { &chgboth_msgtab, NULL };
+
+DECLARE_MODULE_AV1(chgboth, NULL, NULL, chgboth_clist, NULL, NULL, "$Revision: 3424 $");
+
+/* clean_host()
+ *
+ * input	- host to check
+ * output	- 0 if erroneous, else 0
+ * side effects -
+ */
+static int
+clean_thing(const char *host)
+{
+	int len = 0;
+	const char *last_slash = 0;
+	
+	if (*host == '\0' || *host == ':')
+		return 0;
+
+	for(; *host; host++)
+	{
+		len++;
+
+		if(!IsHostChar(*host))
+			return 0;
+		if(*host == '/')
+			last_slash = host;
+	}
+
+	if(len > HOSTLEN)
+		return 0;
+
+	if(last_slash && IsDigit(last_slash[1]))
+		return 0;
+
+	return 1;
+}
+
+static int
+do_chgboth(struct Client *source_p, struct Client *target_p,
+		const char *newuser, const char *newhost, int is_encap)
+{
+	if (!clean_thing(newhost))
+	{
+		sendto_realops_snomask(SNO_GENERAL, is_encap ? L_ALL : L_NETWIDE, "%s attempted to change hostname for %s to %s (invalid)",
+				IsServer(source_p) ? source_p->name : get_oper_name(source_p),
+				target_p->name, newhost);
+		/* sending this remotely may disclose important
+		 * routing information -- jilles */
+		if (is_encap ? MyClient(target_p) : !ConfigServerHide.flatten_links)
+			sendto_one_notice(target_p, ":*** Notice -- %s attempted to change your hostname to %s (invalid)",
+					source_p->name, newhost);
+		return 0;
+	}
+	if (!clean_thing(newuser))
+	{
+		sendto_realops_snomask(SNO_GENERAL, is_encap ? L_ALL : L_NETWIDE, "%s attempted to change ident for %s to %s (invalid)",
+				IsServer(source_p) ? source_p->name : get_oper_name(source_p),
+				target_p->name, newuser);
+		/* sending this remotely may disclose important
+		 * routing information -- jilles */
+		if (is_encap ? MyClient(target_p) : !ConfigServerHide.flatten_links)
+			sendto_one_notice(target_p, ":*** Notice -- %s attempted to change your ident to %s (invalid)",
+					source_p->name, newuser);
+		return 0;
+	}
+	
+	change_nick_user_host(target_p, target_p->name, newuser, newhost, 0, "Changing host and ident");
+	if (irccmp(target_p->host, target_p->orighost))
+	{
+		SetDynSpoof(target_p);
+		if (MyClient(target_p))
+			sendto_one_numeric(target_p, RPL_HOSTHIDDEN, "%s :is now your hidden host (set by %s)", target_p->host, source_p->name);
+	}
+	else
+	{
+		ClearDynSpoof(target_p);
+		if (MyClient(target_p))
+			sendto_one_numeric(target_p, RPL_HOSTHIDDEN, "%s :hostname reset by %s", target_p->host, source_p->name);
+	}
+	if (MyClient(source_p)) {
+		sendto_one_notice(source_p, ":Changed hostname for %s to %s", target_p->name, target_p->host);
+		sendto_one_notice(source_p, ":Changed ident for %s to %s", target_p->name, newuser);
+	}
+	if (!IsServer(source_p) && !IsService(source_p)) {
+		sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s changed hostname for %s to %s", get_oper_name(source_p), target_p->name, target_p->host);
+		sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s changed ident for %s to %s", get_oper_name(source_p), target_p->name, newuser);
+	}
+	return 1;
+}
+
+/*
+ * ms_chgboth
+ * parv[1] = target
+ * parv[2] = host
+ */
+static int
+ms_chgboth(struct Client *client_p, struct Client *source_p,
+	int parc, const char *parv[])
+{
+	struct Client *target_p;
+
+	if (!(target_p = find_person(parv[1])))
+		return -1;
+
+	if (do_chgboth(source_p, target_p, parv[2], parv[3], 0))
+	{
+		sendto_server(client_p, NULL,
+			CAP_EUID | CAP_TS6, NOCAPS, ":%s CHGBOTH %s %s %s",
+			use_id(source_p), use_id(target_p), parv[2], parv[3]);
+		sendto_server(client_p, NULL,
+			CAP_TS6, CAP_EUID, ":%s ENCAP * CHGBOTH %s %s :%s",
+			use_id(source_p), use_id(target_p), parv[2], parv[3]);
+	}
+
+	return 0;
+}
+
+/*
+ * me_chgboth
+ * parv[1] = target
+ * parv[2] = host
+ */
+static int
+me_chgboth(struct Client *client_p, struct Client *source_p,
+	int parc, const char *parv[])
+{
+	struct Client *target_p;
+
+	if (!(target_p = find_person(parv[1])))
+		return -1;
+
+	do_chgboth(source_p, target_p, parv[2], parv[3], 1);
+
+	return 0;
+}
+
+/*
+ * mo_chgboth
+ * parv[1] = target
+ * parv[2] = host
+ */
+/* Disable this because of the abuse potential -- jilles
+ * No, make it toggleable via ./configure. --nenolod
+ */
+static int
+mo_chgboth(struct Client *client_p, struct Client *source_p,
+	int parc, const char *parv[])
+{
+	struct Client *target_p;
+
+	if(!IsOperAdmin(source_p))
+	{
+		sendto_one(source_p, form_str(ERR_NOPRIVS),
+			   me.name, source_p->name, "admin");
+		return 0;
+	}
+
+	if (!(target_p = find_named_person(parv[1])))
+	{
+		sendto_one_numeric(source_p, ERR_NOSUCHNICK,
+				form_str(ERR_NOSUCHNICK), parv[1]);
+		return 0;
+	}
+
+	if(IsService(target_p))
+	{
+		sendto_one_notice(source_p, ":%s is part of services", parv[1]);
+		return 0;
+	}
+
+	if (!clean_thing(parv[2]))
+	{
+		sendto_one_notice(source_p, ":Ident %s is invalid", parv[2]);
+		return 0;
+	}
+	
+	if (!clean_thing(parv[3]))
+	{
+		sendto_one_notice(source_p, ":Hostname %s is invalid", parv[3]);
+		return 0;
+	}
+
+	do_chgboth(source_p, target_p, parv[2], parv[3], 0);
+
+	sendto_server(NULL, NULL,
+		CAP_EUID | CAP_TS6, NOCAPS, ":%s CHGBOTH %s %s %s",
+		use_id(source_p), use_id(target_p), parv[2], parv[3]);
+	sendto_server(NULL, NULL,
+		CAP_TS6, CAP_EUID, ":%s ENCAP * CHGBOTH %s %s :%s",
+		use_id(source_p), use_id(target_p), parv[2], parv[3]);
+
+	return 0;
+}
+

File m_chgident.c

+/*
+ * Copyright (c) 2005 William Pitcock <nenolod -at- nenolod.net>
+ * and Jilles Tjoelker <jilles -at- stack.nl>
+ * All rights reserved.
+ *
+ * Redistribution in both source and binary forms are permitted
+ * provided that the above copyright notice remains unchanged.
+ *
+ * m_chgident.c: A module to change ident (/username) dynamically
+ * 
+ * Based heavily on m_chghost.c from the Charybdis IRCd
+ */
+
+#include "stdinc.h"
+#include "send.h"
+#include "channel.h"
+#include "client.h"
+#include "common.h"
+#include "config.h"
+#include "ircd.h"
+#include "numeric.h"
+#include "s_conf.h"
+#include "s_newconf.h"
+#include "s_serv.h"
+#include "s_user.h"
+#include "hash.h"
+#include "msg.h"
+#include "parse.h"
+#include "modules.h"
+#include "whowas.h"
+#include "monitor.h"
+
+static int ms_chgident(struct Client *, struct Client *, int, const char **);
+static int me_chgident(struct Client *, struct Client *, int, const char **);
+static int mo_chgident(struct Client *, struct Client *, int, const char **);
+
+struct Message chgident_msgtab = {
+	"CHGIDENT", 0, 0, 0, MFLG_SLOW,
+	{mg_ignore, mg_not_oper, {ms_chgident, 3}, {ms_chgident, 3}, {me_chgident, 3}, {mo_chgident, 3}}
+};
+
+mapi_clist_av1 chgident_clist[] = { &chgident_msgtab, NULL };
+
+DECLARE_MODULE_AV1(chgident, NULL, NULL, chgident_clist, NULL, NULL, "$Revision: 3424 $");
+
+/* clean_host()
+ *
+ * input	- host to check
+ * output	- 0 if erroneous, else 0
+ * side effects -
+ */
+static int
+clean_ident(const char *host)
+{
+	int len = 0;
+	const char *last_slash = 0;
+	
+	if (*host == '\0' || *host == ':')
+		return 0;
+
+	for(; *host; host++)
+	{
+		len++;
+
+		if(!IsHostChar(*host))
+			return 0;
+		if(*host == '/')
+			last_slash = host;
+	}
+
+	if(len > HOSTLEN)
+		return 0;
+
+	if(last_slash && IsDigit(last_slash[1]))
+		return 0;
+
+	return 1;
+}
+
+static int
+do_chgident(struct Client *source_p, struct Client *target_p,
+		const char *newhost, int is_encap)
+{
+	if (!clean_ident(newhost))
+	{
+		sendto_realops_snomask(SNO_GENERAL, is_encap ? L_ALL : L_NETWIDE, "%s attempted to change ident for %s to %s (invalid)",
+				IsServer(source_p) ? source_p->name : get_oper_name(source_p),
+				target_p->name, newhost);
+		return 0;
+	}
+	change_nick_user_host(target_p, target_p->name, newhost, target_p->host, 0, "Changing ident");
+	if (MyClient(source_p))
+		sendto_one_notice(source_p, ":Changed ident for %s to %s", target_p->name, newhost);
+	if (!IsServer(source_p) && !IsService(source_p))
+		sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s changed ident for %s to %s", get_oper_name(source_p), target_p->name, newhost);
+	return 1;
+}
+
+/*
+ * ms_chghost
+ * parv[1] = target
+ * parv[2] = host
+ */
+static int
+ms_chgident(struct Client *client_p, struct Client *source_p,
+	int parc, const char *parv[])
+{
+	struct Client *target_p;
+
+	if (!(target_p = find_person(parv[1])))
+		return -1;
+
+	if (do_chgident(source_p, target_p, parv[2], 0))
+	{
+		sendto_server(client_p, NULL,
+			CAP_EUID | CAP_TS6, NOCAPS, ":%s CHGIDENT %s %s",
+			use_id(source_p), use_id(target_p), parv[2]);
+		sendto_server(client_p, NULL,
+			CAP_TS6, CAP_EUID, ":%s ENCAP * CHGIDENT %s :%s",
+			use_id(source_p), use_id(target_p), parv[2]);
+	}
+
+	return 0;
+}
+
+/*
+ * me_chghost
+ * parv[1] = target
+ * parv[2] = host
+ */
+static int
+me_chgident(struct Client *client_p, struct Client *source_p,
+	int parc, const char *parv[])
+{
+	struct Client *target_p;
+
+	if (!(target_p = find_person(parv[1])))
+		return -1;
+
+	do_chgident(source_p, target_p, parv[2], 1);
+
+	return 0;
+}
+
+/*
+ * mo_chghost
+ * parv[1] = target
+ * parv[2] = host
+ */
+/* Disable this because of the abuse potential -- jilles
+ * No, make it toggleable via ./configure. --nenolod
+ */
+static int
+mo_chgident(struct Client *client_p, struct Client *source_p,
+	int parc, const char *parv[])
+{
+	struct Client *target_p;
+
+	if(!IsOperAdmin(source_p))
+	{
+		sendto_one(source_p, form_str(ERR_NOPRIVS),
+			   me.name, source_p->name, "admin");
+		return 0;
+	}
+
+	if (!(target_p = find_named_person(parv[1])))
+	{
+		sendto_one_numeric(source_p, ERR_NOSUCHNICK,
+				form_str(ERR_NOSUCHNICK), parv[1]);
+		return 0;
+	}
+
+	if(IsService(target_p))
+	{
+		sendto_one_notice(source_p, ":%s is part of services", parv[1]);
+		return 0;
+	}
+
+	if (!clean_ident(parv[2]))
+	{
+		sendto_one_notice(source_p, ":Ident %s is invalid", parv[2]);
+		return 0;
+	}
+
+	do_chgident(source_p, target_p, parv[2], 0);
+
+	sendto_server(NULL, NULL,
+		CAP_EUID | CAP_TS6, NOCAPS, ":%s CHGIDENT %s %s",
+		use_id(source_p), use_id(target_p), parv[2]);
+	sendto_server(NULL, NULL,
+		CAP_TS6, CAP_EUID, ":%s ENCAP * CHGIDENT %s :%s",
+		use_id(source_p), use_id(target_p), parv[2]);
+
+	return 0;
+}
+