Skip to content

Commit

Permalink
move privset extban to $O and add $o extban for oper name
Browse files Browse the repository at this point in the history
  • Loading branch information
jesopo committed Jan 1, 2022
1 parent 5a1b54f commit 2c287e3
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 8 deletions.
3 changes: 2 additions & 1 deletion extensions/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ extension_LTLIBRARIES = \
extb_canjoin.la \
extb_channel.la \
extb_hostmask.la \
extb_oper.la \
extb_operpriv.la \
extb_opername.la \
extb_server.la \
extb_ssl.la \
extb_realname.la \
Expand Down
43 changes: 43 additions & 0 deletions extensions/extb_opername.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Oper name extban type: matches oper names
* -- jilles
*/

#include "stdinc.h"
#include "modules.h"
#include "client.h"
#include "privilege.h"
#include "s_newconf.h"
#include "ircd.h"

static const char extb_desc[] = "Oper name ($o) extban type";

static int _modinit(void);
static void _moddeinit(void);
static int eb_opername(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type);

DECLARE_MODULE_AV2(extb_opername, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc);

static int
_modinit(void)
{
extban_table['o'] = eb_opername;

return 0;
}

static void
_moddeinit(void)
{
extban_table['o'] = NULL;
}

static int eb_opername(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type)
{

if (data != NULL)
return match(client_p->user->opername, data)? EXTBAN_MATCH : EXTBAN_NOMATCH;
return IsOper(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
}

15 changes: 8 additions & 7 deletions extensions/extb_oper.c → extensions/extb_operpriv.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Oper extban type: matches opers
* Oper priv extban type: matches oper privs and privsets
* -- jilles
*/

Expand All @@ -10,29 +10,29 @@
#include "s_newconf.h"
#include "ircd.h"

static const char extb_desc[] = "Oper ($o) extban type";
static const char extb_desc[] = "Oper privilege ($O) extban type";

static int _modinit(void);
static void _moddeinit(void);
static int eb_oper(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type);
static int eb_operpriv(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type);

DECLARE_MODULE_AV2(extb_oper, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc);
DECLARE_MODULE_AV2(extb_operpriv, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc);

static int
_modinit(void)
{
extban_table['o'] = eb_oper;
extban_table['O'] = eb_operpriv;

This comment has been minimized.

Copy link
@jillest

jillest Jan 1, 2022

Contributor

This cannot be used since channel bans are case insensitive and the code changes the extban letter to lowercase before looking it up in extban_table.


return 0;
}

static void
_moddeinit(void)
{
extban_table['o'] = NULL;
extban_table['O'] = NULL;
}

static int eb_oper(const char *data, struct Client *client_p,
static int eb_operpriv(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type)
{

Expand All @@ -51,3 +51,4 @@ static int eb_oper(const char *data, struct Client *client_p,

return IsOper(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
}

0 comments on commit 2c287e3

Please sign in to comment.