Add oper-override (modehacking only) as a module.
I think if you are going to kick someone from a channel.
This commit is contained in:
parent
749d8c11dd
commit
429cf1b74f
4 changed files with 188 additions and 0 deletions
|
@ -30,6 +30,7 @@
|
|||
#loadmodule "extensions/sno_globalkline.so";
|
||||
#loadmodule "extensions/sno_globaloper.so";
|
||||
#loadmodule "extensions/sno_whois.so";
|
||||
#loadmodule "extensions/override.so";
|
||||
|
||||
/*
|
||||
* IP cloaking extensions: use ip_cloaking_4.0
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
* Remote k/d/x line active notices -- sno_globalkline.so
|
||||
* Remote oper up notices -- sno_globaloper.so
|
||||
* /whois notifications (snomask +W) -- sno_whois.so
|
||||
* Oper-override (modehacking only) -- override.so
|
||||
*/
|
||||
#loadmodule "extensions/chm_adminonly.so";
|
||||
#loadmodule "extensions/chm_operonly.so";
|
||||
|
@ -95,6 +96,7 @@
|
|||
#loadmodule "extensions/sno_globalkline.so";
|
||||
#loadmodule "extensions/sno_globaloper.so";
|
||||
#loadmodule "extensions/sno_whois.so";
|
||||
#loadmodule "extensions/override.so";
|
||||
|
||||
/* serverinfo {}: Contains information about the server. (OLD M:) */
|
||||
serverinfo {
|
||||
|
|
|
@ -49,6 +49,7 @@ SRCS = \
|
|||
ip_cloaking_old.c \
|
||||
ip_cloaking_3.0.c \
|
||||
ip_cloaking_4.0.c \
|
||||
override.c \
|
||||
sno_farconnect.c \
|
||||
sno_globalkline.c \
|
||||
sno_globaloper.c \
|
||||
|
|
184
extensions/override.c
Normal file
184
extensions/override.c
Normal file
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
* oper-override for charybdis.
|
||||
*
|
||||
* adds usermode +p and has a timer event that is iterated over to disable
|
||||
* usermode +p after a while...
|
||||
*
|
||||
* you need to have oper:override permission on the opers you want to be
|
||||
* able to use this extension.
|
||||
*/
|
||||
|
||||
#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"
|
||||
|
||||
static void check_umode_change(void *data);
|
||||
static void hack_channel_access(void *data);
|
||||
|
||||
mapi_hfn_list_av1 override_hfnlist[] = {
|
||||
{ "umode_changed", (hookfn) check_umode_change },
|
||||
{ "get_channel_access", (hookfn) hack_channel_access },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
#define IsOperOverride(x) (HasPrivilege((x), "oper:override"))
|
||||
|
||||
struct OverrideSession {
|
||||
rb_dlink_node node;
|
||||
|
||||
struct Client *client;
|
||||
time_t deadline;
|
||||
};
|
||||
|
||||
rb_dlink_list overriding_opers = { NULL, NULL, 0 };
|
||||
|
||||
static void
|
||||
update_session_deadline(struct Client *source_p, struct OverrideSession *session_p)
|
||||
{
|
||||
if (session_p == NULL)
|
||||
{
|
||||
rb_dlink_node *n;
|
||||
|
||||
RB_DLINK_FOREACH(n, overriding_opers.head)
|
||||
{
|
||||
struct OverrideSession *s = n->data;
|
||||
|
||||
if (s->client == source_p)
|
||||
{
|
||||
session_p = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (session_p == NULL)
|
||||
{
|
||||
session_p = rb_malloc(sizeof(struct OverrideSession));
|
||||
session_p->client = source_p;
|
||||
}
|
||||
|
||||
session_p->deadline = rb_current_time() + 1800;
|
||||
|
||||
rb_dlinkDelete(&session_p->node, &overriding_opers);
|
||||
rb_dlinkAdd(session_p, &session_p->node, &overriding_opers);
|
||||
}
|
||||
|
||||
static void
|
||||
expire_override_deadlines(void *unused)
|
||||
{
|
||||
rb_dlink_node *n, *tn;
|
||||
|
||||
RB_DLINK_FOREACH_SAFE(n, tn, overriding_opers.head)
|
||||
{
|
||||
struct OverrideSession *session_p = n->data;
|
||||
|
||||
if (session_p->deadline > rb_current_time())
|
||||
break;
|
||||
else if (session_p->deadline < rb_current_time())
|
||||
{
|
||||
const char *parv[4] = {session_p->client->name, session_p->client->name, "-p", NULL};
|
||||
user_mode(session_p->client, session_p->client, 3, parv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
check_umode_change(void *vdata)
|
||||
{
|
||||
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
|
||||
struct Client *source_p = data->client;
|
||||
|
||||
if (!MyClient(source_p))
|
||||
return;
|
||||
|
||||
/* didn't change +p umode, we don't need to do anything */
|
||||
if (!((data->oldumodes ^ source_p->umodes) & user_modes['p']))
|
||||
return;
|
||||
|
||||
if (!IsOperOverride(source_p))
|
||||
{
|
||||
source_p->umodes &= ~user_modes['p'];
|
||||
return;
|
||||
}
|
||||
|
||||
if (source_p->umodes & user_modes['p'])
|
||||
{
|
||||
update_session_deadline(source_p, NULL);
|
||||
|
||||
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has enabled oper-override (+p)",
|
||||
get_oper_name(source_p));
|
||||
}
|
||||
else if (!(source_p->umodes & user_modes['p']))
|
||||
{
|
||||
rb_dlink_node *n, *tn;
|
||||
|
||||
RB_DLINK_FOREACH_SAFE(n, tn, overriding_opers.head)
|
||||
{
|
||||
struct OverrideSession *session_p = n->data;
|
||||
|
||||
if (session_p->client != source_p)
|
||||
continue;
|
||||
|
||||
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s has disabled oper-override (+p)",
|
||||
get_oper_name(session_p->client));
|
||||
|
||||
rb_dlinkDelete(n, &overriding_opers);
|
||||
rb_free(session_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
hack_channel_access(void *vdata)
|
||||
{
|
||||
hook_data_channel_approval *data = (hook_data_channel_approval *) vdata;
|
||||
|
||||
if (data->approved == CHFL_CHANOP)
|
||||
return;
|
||||
|
||||
if (data->client->umodes & user_modes['p'])
|
||||
{
|
||||
update_session_deadline(data->client, NULL);
|
||||
data->approved = CHFL_CHANOP;
|
||||
|
||||
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s is using oper-override on %s (modehacking)",
|
||||
get_oper_name(data->client), data->chptr->chname);
|
||||
}
|
||||
}
|
||||
|
||||
struct ev_entry *expire_override_deadlines_ev = NULL;
|
||||
|
||||
static int
|
||||
_modinit(void)
|
||||
{
|
||||
/* add the usermode to the available slot */
|
||||
user_modes['p'] = find_umode_slot();
|
||||
construct_umodebuf();
|
||||
|
||||
expire_override_deadlines_ev = rb_event_add("expire_override_deadlines", expire_override_deadlines, NULL, 60);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_moddeinit(void)
|
||||
{
|
||||
/* disable the umode and remove it from the available list */
|
||||
user_modes['p'] = 0;
|
||||
construct_umodebuf();
|
||||
|
||||
rb_event_delete(expire_override_deadlines_ev);
|
||||
}
|
||||
|
||||
DECLARE_MODULE_AV1(override, _modinit, _moddeinit, NULL, NULL,
|
||||
override_hfnlist, "$Revision: 3526 $");
|
Loading…
Reference in a new issue