Add extensions/m_oaccept , a module to allow opers to bypass +gGR with a command.

This commit is contained in:
B.Greenham 2010-03-04 01:40:13 -05:00
parent 5b453fee2a
commit 1fbf6db662
5 changed files with 62 additions and 3 deletions

View File

@ -31,6 +31,7 @@ loadmodule "extensions/ip_cloaking.so";
loadmodule "extensions/m_identify.so";
loadmodule "extensions/m_mkpasswd.so";
#loadmodule "extensions/m_adminwall.so";
#loadmodule "extensions/m_oaccept.so";
#loadmodule "extensions/m_opme.so";
#loadmodule "extensions/m_ojoin.so";
#loadmodule "extensions/m_omode.so";

View File

@ -66,6 +66,7 @@
* /identify support -- m_identify.so
* /mkpassword support -- m_mkpasswd.so
* Send message to all admins network-wide -- m_adminwall.so
* /oaccept - add to target's accept list, oper only -- m_oaccepet.so
* /opme - op self in opless channels, admin only -- m_opme.so
* /ojoin - join despite restrictions, admin only -- m_ojoin.so
* /omode - force modes in channels, admin only -- m_omode.so
@ -98,6 +99,7 @@ loadmodule "extensions/ip_cloaking.so";
loadmodule "extensions/m_identify.so";
loadmodule "extensions/m_mkpasswd.so";
#loadmodule "extensions/m_adminwall.so";
#loadmodule "extensions/m_oaccept.so";
#loadmodule "extensions/m_opme.so";
#loadmodule "extensions/m_ojoin.so";
#loadmodule "extensions/m_omode.so";

View File

@ -54,9 +54,10 @@ SRCS = \
m_42.c \
m_adminwall.c \
m_findforwards.c \
m_force.c \
m_force.c \
m_identify.c \
m_mkpasswd.c \
m_oaccept.c \
m_ojoin.c \
m_olist.c \
m_okick.c \

41
extensions/m_oaccept.c Normal file
View File

@ -0,0 +1,41 @@
#include "stdinc.h"
#include "ircd.h"
#include "client.h"
#include "modules.h"
#include "send.h"
#include "numeric.h"
void mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
struct Message oaccept_msgtab = {
"OACCEPT", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_oaccept, 2}}
};
mapi_clist_av1 oaccept_clist[] = { &oaccept_msgtab, NULL };
DECLARE_MODULE_AV1(omode, NULL, NULL, oaccept_clist, NULL, NULL, "$Id $");
void
mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Metadata *md;
struct Client *target_p;
if(!(target_p = find_client(parv[1])))
{
sendto_one(source_p, form_str(ERR_NOSUCHNICK), parv[1]);
return;
}
/* only allow one OACCEPT entry per user, so if there's an old one clear it */
if(!(md = user_metadata_find(target_p, "OACCEPT")))
user_metadata_delete(target_p, "OACCEPT", 1);
user_metadata_add(target_p, "OACCEPT", source_p->name, 1);
sendto_wallops_flags(UMODE_WALLOP, &me,
"OACCEPT called for %s by %s!%s@%s",
target_p->name,
source_p->name, source_p->username, source_p->host);
}

View File

@ -712,6 +712,7 @@ msg_client(int p_or_n, const char *command,
struct Client *source_p, struct Client *target_p, const char *text)
{
int do_floodcount = 0;
struct Metadata *md;
if(MyClient(source_p))
{
@ -767,13 +768,14 @@ msg_client(int p_or_n, const char *command,
form_str(ERR_NOCTCP),
target_p->name);
}
/* XXX Controversial? allow opers always to send through a +g */
/* If opers want to go through +g, they should load oaccept.*/
else if(!IsServer(source_p) && (IsSetCallerId(target_p) ||
(IsSetSCallerId(target_p) && !has_common_channel(source_p, target_p)) ||
(IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0])))
{
md = user_metadata_find(target_p, "OACCEPT");
/* Here is the anti-flood bot/spambot code -db */
if(accept_message(source_p, target_p) || IsOper(source_p))
if(accept_message(source_p, target_p))
{
add_reply_target(target_p, source_p);
sendto_one(target_p, ":%s!%s@%s %s %s :%s",
@ -781,6 +783,18 @@ msg_client(int p_or_n, const char *command,
source_p->username,
source_p->host, command, target_p->name, text);
}
/* slightly ugly, meh. if anyone can think of a cleaner way to do this, by all means, do it. */
else if(md)
{
if(!strcmp(md->value, source_p->name))
{
add_reply_target(target_p, source_p);
sendto_one(target_p, ":%s!%s@%s %s %s :%s",
source_p->name,
source_p->username,
source_p->host, command, target_p->name, text);
}
}
else if (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0])
{
if (p_or_n != NOTICE)