From e118f2d431fd01bc87c0b8073886c95120a75711 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 13 Jan 2016 16:52:56 -0600 Subject: [PATCH] extensions/chm_operpeace: new module which disallows kicking of operators on select channels --- doc/ircd.conf.example | 1 + doc/reference.conf | 2 ++ extensions/Makefile.am | 1 + extensions/Makefile.in | 58 +++++++++++++++++++-------------- extensions/chm_operpeace.c | 66 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 104 insertions(+), 24 deletions(-) create mode 100644 extensions/chm_operpeace.c diff --git a/doc/ircd.conf.example b/doc/ircd.conf.example index ff51240c..2a45554f 100755 --- a/doc/ircd.conf.example +++ b/doc/ircd.conf.example @@ -13,6 +13,7 @@ #loadmodule "extensions/chm_operonly_compat.la"; #loadmodule "extensions/chm_quietunreg_compat.la"; #loadmodule "extensions/chm_sslonly_compat.la"; +#loadmodule "extensions/chm_operpeace.la"; #loadmodule "extensions/createauthonly.la"; #loadmodule "extensions/extb_account.la"; #loadmodule "extensions/extb_canjoin.la"; diff --git a/doc/reference.conf b/doc/reference.conf index 80b5f9ca..82f42b94 100755 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -50,6 +50,7 @@ * Emulates channel mode +-O (oper only) (+-iI $o) -- chm_operonly_compat.la * Emulates channel mode +-R (quiet unreg) (+-q $~a) -- chm_quietunreg_compat.la * Emulates channel mode +-S (ssl only) (+-b $~z) -- chm_sslonly_compat.la + * Channel mode +-M (disallow KICK on IRC ops) -- chm_operpeace.la * Restrict channel creation to logged in users -- createauthonly.la * Account bans (+b $a[:mask]) -- extb_account.la * Banned from another channel (+b $j:mask) -- extb_canjoin.la @@ -82,6 +83,7 @@ #loadmodule "extensions/chm_operonly_compat.la"; #loadmodule "extensions/chm_quietunreg_compat.la"; #loadmodule "extensions/chm_sslonly_compat.la"; +#loadmodule "extensions/chm_operpeace.la"; #loadmodule "extensions/createauthonly.la"; #loadmodule "extensions/extb_account.la"; #loadmodule "extensions/extb_canjoin.la"; diff --git a/extensions/Makefile.am b/extensions/Makefile.am index b24de7c2..20c12e61 100644 --- a/extensions/Makefile.am +++ b/extensions/Makefile.am @@ -10,6 +10,7 @@ extension_LTLIBRARIES = \ chm_operonly.la \ chm_operonly_compat.la \ chm_nonotice.la \ + chm_operpeace.la \ chm_quietunreg_compat.la \ chm_sslonly.la \ chm_sslonly_compat.la \ diff --git a/extensions/Makefile.in b/extensions/Makefile.in index e2c769be..43929a35 100644 --- a/extensions/Makefile.in +++ b/extensions/Makefile.in @@ -149,6 +149,9 @@ chm_operonly_la_OBJECTS = chm_operonly.lo chm_operonly_compat_la_LIBADD = chm_operonly_compat_la_SOURCES = chm_operonly_compat.c chm_operonly_compat_la_OBJECTS = chm_operonly_compat.lo +chm_operpeace_la_LIBADD = +chm_operpeace_la_SOURCES = chm_operpeace.c +chm_operpeace_la_OBJECTS = chm_operpeace.lo chm_quietunreg_compat_la_LIBADD = chm_quietunreg_compat_la_SOURCES = chm_quietunreg_compat.c chm_quietunreg_compat_la_OBJECTS = chm_quietunreg_compat.lo @@ -352,35 +355,37 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = chm_adminonly.c chm_nonotice.c chm_operonly.c \ - chm_operonly_compat.c chm_quietunreg_compat.c chm_sslonly.c \ - chm_sslonly_compat.c createauthonly.c createoperonly.c \ - example_module.c extb_account.c extb_canjoin.c extb_channel.c \ - extb_combi.c extb_extgecos.c extb_hostmask.c extb_oper.c \ - extb_realname.c extb_server.c extb_ssl.c extb_usermode.c \ - force_user_invis.c hide_uncommon_channels.c hurt.c \ - ip_cloaking.c ip_cloaking_3.0.c ip_cloaking_4.0.c \ - ip_cloaking_old.c m_42.c m_adminwall.c m_extendchans.c \ - m_findforwards.c m_identify.c m_mkpasswd.c m_ojoin.c m_okick.c \ - m_omode.c m_opme.c m_remove.c m_roleplay.c m_sendbans.c \ - m_webirc.c no_kill_services.c no_locops.c no_oper_invis.c \ - override.c restrict-unauthenticated.c sno_channelcreate.c \ + chm_operonly_compat.c chm_operpeace.c chm_quietunreg_compat.c \ + chm_sslonly.c chm_sslonly_compat.c createauthonly.c \ + createoperonly.c example_module.c extb_account.c \ + extb_canjoin.c extb_channel.c extb_combi.c extb_extgecos.c \ + extb_hostmask.c extb_oper.c extb_realname.c extb_server.c \ + extb_ssl.c extb_usermode.c force_user_invis.c \ + hide_uncommon_channels.c hurt.c ip_cloaking.c \ + ip_cloaking_3.0.c ip_cloaking_4.0.c ip_cloaking_old.c m_42.c \ + m_adminwall.c m_extendchans.c m_findforwards.c m_identify.c \ + m_mkpasswd.c m_ojoin.c m_okick.c m_omode.c m_opme.c m_remove.c \ + m_roleplay.c m_sendbans.c m_webirc.c no_kill_services.c \ + no_locops.c no_oper_invis.c override.c \ + restrict-unauthenticated.c sno_channelcreate.c \ sno_farconnect.c sno_globalkline.c sno_globalnickchange.c \ sno_globaloper.c sno_whois.c spy_admin_notice.c \ spy_info_notice.c spy_links_notice.c spy_motd_notice.c \ spy_stats_notice.c spy_stats_p_notice.c spy_trace_notice.c DIST_SOURCES = chm_adminonly.c chm_nonotice.c chm_operonly.c \ - chm_operonly_compat.c chm_quietunreg_compat.c chm_sslonly.c \ - chm_sslonly_compat.c createauthonly.c createoperonly.c \ - example_module.c extb_account.c extb_canjoin.c extb_channel.c \ - extb_combi.c extb_extgecos.c extb_hostmask.c extb_oper.c \ - extb_realname.c extb_server.c extb_ssl.c extb_usermode.c \ - force_user_invis.c hide_uncommon_channels.c hurt.c \ - ip_cloaking.c ip_cloaking_3.0.c ip_cloaking_4.0.c \ - ip_cloaking_old.c m_42.c m_adminwall.c m_extendchans.c \ - m_findforwards.c m_identify.c m_mkpasswd.c m_ojoin.c m_okick.c \ - m_omode.c m_opme.c m_remove.c m_roleplay.c m_sendbans.c \ - m_webirc.c no_kill_services.c no_locops.c no_oper_invis.c \ - override.c restrict-unauthenticated.c sno_channelcreate.c \ + chm_operonly_compat.c chm_operpeace.c chm_quietunreg_compat.c \ + chm_sslonly.c chm_sslonly_compat.c createauthonly.c \ + createoperonly.c example_module.c extb_account.c \ + extb_canjoin.c extb_channel.c extb_combi.c extb_extgecos.c \ + extb_hostmask.c extb_oper.c extb_realname.c extb_server.c \ + extb_ssl.c extb_usermode.c force_user_invis.c \ + hide_uncommon_channels.c hurt.c ip_cloaking.c \ + ip_cloaking_3.0.c ip_cloaking_4.0.c ip_cloaking_old.c m_42.c \ + m_adminwall.c m_extendchans.c m_findforwards.c m_identify.c \ + m_mkpasswd.c m_ojoin.c m_okick.c m_omode.c m_opme.c m_remove.c \ + m_roleplay.c m_sendbans.c m_webirc.c no_kill_services.c \ + no_locops.c no_oper_invis.c override.c \ + restrict-unauthenticated.c sno_channelcreate.c \ sno_farconnect.c sno_globalkline.c sno_globalnickchange.c \ sno_globaloper.c sno_whois.c spy_admin_notice.c \ spy_info_notice.c spy_links_notice.c spy_motd_notice.c \ @@ -599,6 +604,7 @@ extension_LTLIBRARIES = \ chm_operonly.la \ chm_operonly_compat.la \ chm_nonotice.la \ + chm_operpeace.la \ chm_quietunreg_compat.la \ chm_sslonly.la \ chm_sslonly_compat.la \ @@ -737,6 +743,9 @@ chm_operonly.la: $(chm_operonly_la_OBJECTS) $(chm_operonly_la_DEPENDENCIES) $(EX chm_operonly_compat.la: $(chm_operonly_compat_la_OBJECTS) $(chm_operonly_compat_la_DEPENDENCIES) $(EXTRA_chm_operonly_compat_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) -rpath $(extensiondir) $(chm_operonly_compat_la_OBJECTS) $(chm_operonly_compat_la_LIBADD) $(LIBS) +chm_operpeace.la: $(chm_operpeace_la_OBJECTS) $(chm_operpeace_la_DEPENDENCIES) $(EXTRA_chm_operpeace_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) -rpath $(extensiondir) $(chm_operpeace_la_OBJECTS) $(chm_operpeace_la_LIBADD) $(LIBS) + chm_quietunreg_compat.la: $(chm_quietunreg_compat_la_OBJECTS) $(chm_quietunreg_compat_la_DEPENDENCIES) $(EXTRA_chm_quietunreg_compat_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) -rpath $(extensiondir) $(chm_quietunreg_compat_la_OBJECTS) $(chm_quietunreg_compat_la_LIBADD) $(LIBS) @@ -915,6 +924,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chm_nonotice.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chm_operonly.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chm_operonly_compat.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chm_operpeace.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chm_quietunreg_compat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chm_sslonly.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chm_sslonly_compat.Plo@am__quote@ diff --git a/extensions/chm_operpeace.c b/extensions/chm_operpeace.c new file mode 100644 index 00000000..aaa40dc8 --- /dev/null +++ b/extensions/chm_operpeace.c @@ -0,0 +1,66 @@ +/* + * Do not allow operators to be kicked from +M channels. + * -- kaniini + */ + +#include "stdinc.h" +#include "modules.h" +#include "hook.h" +#include "client.h" +#include "ircd.h" +#include "send.h" +#include "hash.h" +#include "s_conf.h" +#include "s_user.h" +#include "s_serv.h" +#include "numeric.h" +#include "privilege.h" +#include "s_newconf.h" +#include "chmode.h" + +static void hdl_can_kick(hook_data_channel_approval *); + +mapi_hfn_list_av1 chm_operpeace_hfnlist[] = { + { "can_kick", (hookfn) hdl_can_kick }, + { NULL, NULL } +}; + +static unsigned int mymode; + +static int +_modinit(void) +{ + mymode = cflag_add('M', chm_hidden); + if (mymode == 0) + return -1; + + return 0; +} + +static void +_moddeinit(void) +{ + cflag_orphan('M'); +} + +DECLARE_MODULE_AV1(chm_operpeace, _modinit, _moddeinit, NULL, NULL, chm_operpeace_hfnlist, "$Revision$"); + +static void +hdl_can_kick(hook_data_channel_approval *data) +{ + struct Client *source_p = data->client; + struct Client *who = data->target; + struct Channel *chptr = data->chptr; + + if(IsOper(source_p)) + return; + + if((chptr->mode.mode & mymode) && IsOper(who)) + { + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s attempted to kick %s from %s (which is +M)", + source_p->name, who->name, chptr->chname); + sendto_one_numeric(source_p, ERR_ISCHANSERVICE, "%s %s :Cannot kick IRC operators from that channel.", + who->name, chptr->chname); + data->approved = 0; + } +}