Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow oper override to set forwards anywhere #281

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions extensions/override.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ static const char override_desc[] =
static void check_umode_change(void *data);
static void hack_channel_access(void *data);
static void hack_can_join(void *data);
static void hack_can_forward(void *data);
static void hack_can_kick(void *data);
static void hack_can_send(void *data);
static void hack_can_invite(void *data);
Expand All @@ -37,6 +38,7 @@ mapi_hfn_list_av1 override_hfnlist[] = {
{ "umode_changed", check_umode_change },
{ "get_channel_access", hack_channel_access, HOOK_HIGHEST },
{ "can_join", hack_can_join, HOOK_HIGHEST },
{ "can_forward", hack_can_forward, HOOK_HIGHEST },
{ "can_kick", hack_can_kick, HOOK_HIGHEST },
{ "can_send", hack_can_send, HOOK_HIGHEST },
{ "can_invite", hack_can_invite, HOOK_HIGHEST },
Expand Down Expand Up @@ -196,6 +198,22 @@ hack_can_join(void *vdata)
}
}

static void
hack_can_forward(void *vdata)
{
hook_data_channel_forward *data = vdata;

if (data->client->umodes & user_modes['p'])
{
update_session_deadline(data->client);
data->approved = 1;

/* the language of this snote is a little confusing imo ~launchd */
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "%s is using oper-override on %s (forced forward from %s)",
get_oper_name(data->client), data->target->chname, data->chptr->chname);
}
}

static void
hack_can_kick(void *vdata)
{
Expand Down
9 changes: 9 additions & 0 deletions include/hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extern int h_new_local_user;
extern int h_new_remote_user;
extern int h_introduce_client;
extern int h_can_kick;
extern int h_can_forward;
extern int h_privmsg_channel;
extern int h_privmsg_user;
extern int h_conf_read_start;
Expand Down Expand Up @@ -90,6 +91,14 @@ typedef struct
int approved;
} hook_data_channel;

typedef struct
{
struct Client *client;
struct Channel *chptr;
struct Channel *target;
int approved;
} hook_data_channel_forward;

typedef struct
{
struct Client *client;
Expand Down
18 changes: 15 additions & 3 deletions ircd/chmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,21 @@ check_forward(struct Client *source_p, struct Channel *chptr,
if((msptr = find_channel_membership(targptr, source_p)) == NULL ||
get_channel_access(source_p, targptr, msptr, MODE_QUERY, NULL) < CHFL_CHANOP)
{
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
me.name, source_p->name, targptr->chname);
return false;
hook_data_channel_forward hookdata;

hookdata.client = source_p;
hookdata.chptr = chptr;
hookdata.target = targptr;
hookdata.approved = 0;

call_hook(h_can_forward, &hookdata);

if (!hookdata.approved)
{
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
me.name, source_p->name, targptr->chname);
return false;
}
}
}
return true;
Expand Down
2 changes: 2 additions & 0 deletions ircd/hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ int h_new_local_user;
int h_new_remote_user;
int h_introduce_client;
int h_can_kick;
int h_can_forward;
int h_privmsg_user;
int h_privmsg_channel;
int h_conf_read_start;
Expand All @@ -91,6 +92,7 @@ init_hook(void)
h_new_remote_user = register_hook("new_remote_user");
h_introduce_client = register_hook("introduce_client");
h_can_kick = register_hook("can_kick");
h_can_forward = register_hook("can_forward");
h_privmsg_user = register_hook("privmsg_user");
h_privmsg_channel = register_hook("privmsg_channel");
h_conf_read_start = register_hook("conf_read_start");
Expand Down