Remove shared blocks

This commit is contained in:
Ed Kellett 2020-10-31 15:03:46 +00:00
parent c07751a50d
commit f57d88bc71
17 changed files with 4 additions and 421 deletions

View file

@ -341,11 +341,6 @@ cluster {
flags = kline, tkline, unkline, xline, txline, unxline, resv, tresv, unresv;
};
shared {
oper = "*@*", "*";
flags = all, rehash;
};
secure {
ip = "127.0.0.1";
};

View file

@ -631,12 +631,7 @@ connect "ssl.uplink.com" {
flags = ssl, topicburst;
};
/* cluster {}; servers that we propagate things to automatically.
* NOTE: This does NOT grant them privileges to apply anything locally,
* you must add a seperate shared block for that. Clustering will
* only be done for actions by LOCAL opers, that arent directed
* remotely.
*/
/* cluster {}; servers that we propagate things to automatically. */
cluster {
/* name: the server to share with, this can be a wildcard and may be
* stacked.
@ -669,8 +664,7 @@ cluster {
/* service{}: privileged servers (services). These servers have extra
* privileges such as setting login names on users and introducing clients
* with umode +S (unkickable, hide channels, etc). This does not allow them
* to set bans, you need a separate shared{} for that.
* with umode +S (unkickable, hide channels, etc).
* Do not place normal servers here.
* There may be only one service{} block.
*/
@ -679,59 +673,6 @@ service {
name = "services.int";
};
/* shared {}: users that are allowed to place remote bans on our server.
* NOTE: These are ordered top down. The first one the user@host and server
* matches will be used. Their access will then be decided on that
* block and will not fall back to another block that matches.
*/
shared {
/* oper: the user@host and server the user must be on to set klines.
* The first field must be a user@host, the second field is an
* optional server. These may be stacked.
*/
/* flags: list of what to allow them to place, all the oper lines
* above this (up until another flags entry) will receive these
* flags. This *must* be present.
*
* kline - allow setting perm/temp klines
* tkline - allow setting temp klines
* unkline - allow removing klines
* xline - allow setting perm/temp xlines
* txline - allow setting temp xlines
* unxline - allow removing xlines
* resv - allow setting perm/temp resvs
* tresv - allow setting temp resvs
* unresv - allow removing xlines
* all - allow oper/server to do all of above.
* locops - allow locops - only used for servers who cluster
* rehash - allow rehashing
* dline - allow setting perm/temp dlines
* tdline - allow setting temp dlines
* undline - allow removing dlines
* grant - allow granting operator status
* die - allow remote DIE/RESTART
* module - allow remote module commands
* none - disallow everything
*/
/* allow flame@*.leeh.co.uk on server irc.ircd-ratbox.org and
* allow leeh@*.leeh.co.uk on server ircd.ircd-ratbox.org to kline
*/
oper = "flame@*.leeh.co.uk", "irc.ircd-ratbox.org";
oper = "leeh@*.leeh.co.uk", "ircd.ircd-ratbox.org";
flags = kline;
/* you may forbid certain opers/servers from doing anything */
oper = "irc@vanity.oper", "*";
oper = "*@*", "irc.vanity.server";
oper = "irc@another.vanity.oper", "bigger.vanity.server";
flags = none;
/* or allow everyone to place temp klines */
oper = "*@*";
flags = tkline;
};
/* exempt {}: IPs that are exempt from Dlines and rejectcache. (OLD d:) */
exempt {
ip = "192.0.2.0/24";

View file

@ -80,8 +80,7 @@ ms_locops(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
if(!match(parv[1], me.name))
return;
if(find_shared_conf("*", "*", source_p->servptr->name, SHARED_LOCOPS))
sendto_wallops_flags(UMODE_LOCOPS, source_p, "SLOCOPS - %s", parv[2]);
sendto_wallops_flags(UMODE_LOCOPS, source_p, "SLOCOPS - %s", parv[2]);
}
static void
@ -91,7 +90,6 @@ me_locops(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
if(!IsPerson(source_p))
return;
if(find_shared_conf("*", "*", source_p->servptr->name, SHARED_LOCOPS))
sendto_wallops_flags(UMODE_LOCOPS, source_p, "SLOCOPS - %s", parv[1]);
sendto_wallops_flags(UMODE_LOCOPS, source_p, "SLOCOPS - %s", parv[1]);
}

View file

@ -34,7 +34,6 @@ X f - Shows File Descriptors
* r - Shows resource usage by ircd
X S - Shows ssld processes
* t - Shows generic server stats
* U - Shows shared blocks (Old U: lines)
u - Shows server uptime
^ v - Shows connected servers and brief status information
* x - Shows temporary and global gecos bans

View file

@ -43,7 +43,6 @@
struct ConfItem;
extern rb_dlink_list cluster_conf_list;
extern rb_dlink_list shared_conf_list;
extern rb_dlink_list oper_conf_list;
extern rb_dlink_list hubleaf_conf_list;
extern rb_dlink_list server_conf_list;
@ -131,8 +130,6 @@ struct oper_conf
extern struct remote_conf *make_remote_conf(void);
extern void free_remote_conf(struct remote_conf *);
extern bool find_shared_conf(const char *username, const char *host,
const char *server, int flags);
extern void propagate_generic(struct Client *source_p, const char *command,
const char *target, int cap, const char *format, ...);
extern void cluster_generic(struct Client *, const char *, int cltype,

View file

@ -49,7 +49,6 @@ static struct server_conf *yy_server = NULL;
static rb_dlink_list yy_aconf_list;
static rb_dlink_list yy_oper_list;
static rb_dlink_list yy_shared_list;
static rb_dlink_list yy_cluster_list;
static struct oper_conf *yy_oper = NULL;
@ -380,31 +379,6 @@ static struct mode_table cluster_table[] = {
{ "all", CLUSTER_ALL },
{NULL, 0}
};
static struct mode_table shared_table[] =
{
{ "kline", SHARED_PKLINE|SHARED_TKLINE },
{ "xline", SHARED_PXLINE|SHARED_TXLINE },
{ "resv", SHARED_PRESV|SHARED_TRESV },
{ "dline", SHARED_PDLINE|SHARED_TDLINE },
{ "tdline", SHARED_TDLINE },
{ "pdline", SHARED_PDLINE },
{ "undline", SHARED_UNDLINE },
{ "tkline", SHARED_TKLINE },
{ "unkline", SHARED_UNKLINE },
{ "txline", SHARED_TXLINE },
{ "unxline", SHARED_UNXLINE },
{ "tresv", SHARED_TRESV },
{ "unresv", SHARED_UNRESV },
{ "locops", SHARED_LOCOPS },
{ "rehash", SHARED_REHASH },
{ "grant", SHARED_GRANT },
{ "die", SHARED_DIE },
{ "module", SHARED_MODULE },
{ "all", SHARED_ALL },
{ "none", 0 },
{NULL, 0}
};
/* *INDENT-ON* */
static int
@ -1183,109 +1157,6 @@ conf_set_auth_class(void *data)
yy_aconf->className = rb_strdup(data);
}
/* ok, shared_oper handles the stacking, shared_flags handles adding
* things.. so all we need to do when we start and end a shared block, is
* clean up anything thats been left over.
*/
static int
conf_cleanup_shared(struct TopConf *tc)
{
rb_dlink_node *ptr, *next_ptr;
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head)
{
free_remote_conf(ptr->data);
rb_dlinkDestroy(ptr, &yy_shared_list);
}
if(yy_shared != NULL)
{
free_remote_conf(yy_shared);
yy_shared = NULL;
}
return 0;
}
static void
conf_set_shared_oper(void *data)
{
conf_parm_t *args = data;
const char *username;
char *p;
if(yy_shared != NULL)
free_remote_conf(yy_shared);
yy_shared = make_remote_conf();
if(args->next != NULL)
{
if(CF_TYPE(args->type) != CF_QSTRING)
{
conf_report_error("Ignoring shared::oper -- server is not a qstring");
return;
}
yy_shared->server = rb_strdup(args->v.string);
args = args->next;
}
else
yy_shared->server = rb_strdup("*");
if(CF_TYPE(args->type) != CF_QSTRING)
{
conf_report_error("Ignoring shared::oper -- oper is not a qstring");
return;
}
if((p = strchr(args->v.string, '@')) == NULL)
{
conf_report_error("Ignoring shard::oper -- oper is not a user@host");
return;
}
username = args->v.string;
*p++ = '\0';
if(EmptyString(p))
yy_shared->host = rb_strdup("*");
else
yy_shared->host = rb_strdup(p);
if(EmptyString(username))
yy_shared->username = rb_strdup("*");
else
yy_shared->username = rb_strdup(username);
rb_dlinkAddAlloc(yy_shared, &yy_shared_list);
yy_shared = NULL;
}
static void
conf_set_shared_flags(void *data)
{
conf_parm_t *args = data;
int flags = 0;
rb_dlink_node *ptr, *next_ptr;
if(yy_shared != NULL)
free_remote_conf(yy_shared);
set_modes_from_table(&flags, "flag", shared_table, args);
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, yy_shared_list.head)
{
yy_shared = ptr->data;
yy_shared->flags = flags;
rb_dlinkDestroy(ptr, &yy_shared_list);
rb_dlinkAddTail(yy_shared, &yy_shared->node, &shared_conf_list);
}
yy_shared = NULL;
}
static int
conf_begin_connect(struct TopConf *tc)
{
@ -2904,10 +2775,6 @@ newconf_init()
add_top_conf("auth", conf_begin_auth, conf_end_auth, conf_auth_table);
add_top_conf("shared", conf_cleanup_shared, conf_cleanup_shared, NULL);
add_conf_item("shared", "oper", CF_QSTRING | CF_FLIST, conf_set_shared_oper);
add_conf_item("shared", "flags", CF_STRING | CF_FLIST, conf_set_shared_flags);
add_top_conf("connect", conf_begin_connect, conf_end_connect, conf_connect_table);
add_top_conf("exempt", NULL, NULL, NULL);

View file

@ -46,7 +46,6 @@
#include "logger.h"
#include "dns.h"
rb_dlink_list shared_conf_list;
rb_dlink_list cluster_conf_list;
rb_dlink_list oper_conf_list;
rb_dlink_list hubleaf_conf_list;
@ -82,13 +81,6 @@ clear_s_newconf(void)
rb_dlink_node *ptr;
rb_dlink_node *next_ptr;
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, shared_conf_list.head)
{
/* ptr here is ptr->data->node */
rb_dlinkDelete(ptr, &shared_conf_list);
free_remote_conf(ptr->data);
}
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, cluster_conf_list.head)
{
rb_dlinkDelete(ptr, &cluster_conf_list);
@ -173,31 +165,6 @@ free_remote_conf(struct remote_conf *remote_p)
rb_free(remote_p);
}
bool
find_shared_conf(const char *username, const char *host,
const char *server, int flags)
{
struct remote_conf *shared_p;
rb_dlink_node *ptr;
RB_DLINK_FOREACH(ptr, shared_conf_list.head)
{
shared_p = ptr->data;
if(match(shared_p->username, username) &&
match(shared_p->host, host) &&
match(shared_p->server, server))
{
if(shared_p->flags & flags)
return true;
else
return false;
}
}
return false;
}
void
propagate_generic(struct Client *source_p, const char *command,
const char *target, int cap, const char *format, ...)

View file

@ -92,13 +92,6 @@ mo_die(struct MsgBuf *msgbuf_p __unused, struct Client *client_p __unused, struc
static void
me_die(struct MsgBuf *msgbuf_p __unused, struct Client *client_p __unused, struct Client *source_p, int parc, const char *parv[])
{
if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_DIE))
{
sendto_one_notice(source_p, ":*** You do not have an appropriate shared block to "
"remotely shut down this server.");
return;
}
do_die(source_p, parv[1]);
}

View file

@ -111,13 +111,6 @@ mo_modload(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
static void
me_modload(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
{
if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE))
{
sendto_one_notice(source_p, ":*** You do not have an appropriate shared block "
"to load modules on this server.");
return;
}
do_modload(source_p, parv[1]);
}
@ -147,13 +140,6 @@ mo_modunload(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so
static void
me_modunload(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
{
if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE))
{
sendto_one_notice(source_p, ":*** You do not have an appropriate shared block "
"to load modules on this server.");
return;
}
do_modunload(source_p, parv[1]);
}
@ -182,13 +168,6 @@ mo_modreload(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so
static void
me_modreload(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
{
if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE))
{
sendto_one_notice(source_p, ":*** You do not have an appropriate shared block "
"to load modules on this server.");
return;
}
do_modreload(source_p, parv[1]);
}
@ -217,13 +196,6 @@ mo_modlist(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
static void
me_modlist(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
{
if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE))
{
sendto_one_notice(source_p, ":*** You do not have an appropriate shared block "
"to load modules on this server.");
return;
}
do_modlist(source_p, parv[1]);
}
@ -252,13 +224,6 @@ mo_modrestart(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *s
static void
me_modrestart(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
{
if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE))
{
sendto_one_notice(source_p, ":*** You do not have an appropriate shared block "
"to load modules on this server.");
return;
}
do_modrestart(source_p);
}

View file

@ -195,11 +195,6 @@ me_dline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
if(!IsPerson(source_p))
return;
if(!find_shared_conf(source_p->username, source_p->host,
source_p->servptr->name,
tdline_time > 0 ? SHARED_TDLINE : SHARED_PDLINE))
return;
apply_dline(source_p, parv[2], tdline_time, LOCAL_COPY(parv[3]));
check_dlines();
@ -211,10 +206,6 @@ me_undline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
if(!IsPerson(source_p))
return;
if(!find_shared_conf(source_p->username, source_p->host,
source_p->servptr->name, SHARED_UNDLINE))
return;
apply_undline(source_p, parv[1]);
}

View file

@ -75,14 +75,6 @@ me_grant(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
return;
}
if(!find_shared_conf(source_p->username, source_p->host,
source_p->servptr->name, SHARED_GRANT))
{
sendto_one(source_p, ":%s NOTICE %s :You don't have an appropriate shared"
"block to grant privilege on this server.", me.name, source_p->name);
return;
}
do_grant(source_p, target_p, parv[2]);
}

View file

@ -283,11 +283,6 @@ handle_remote_kline(struct Client *source_p, int tkline_time,
struct ConfItem *aconf = NULL;
char *oper_reason;
if(!find_shared_conf(source_p->username, source_p->host,
source_p->servptr->name,
(tkline_time > 0) ? SHARED_TKLINE : SHARED_PKLINE))
return;
if(!valid_user_host(source_p, user, host))
return;
@ -469,10 +464,6 @@ handle_remote_unkline(struct Client *source_p, const char *user, const char *hos
{
struct ConfItem *aconf;
if(!find_shared_conf(source_p->username, source_p->host,
source_p->servptr->name, SHARED_UNKLINE))
return;
aconf = find_exact_conf_by_address(host, CONF_KILL, user);
if(aconf == NULL)
{

View file

@ -408,9 +408,5 @@ me_rehash(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
if (!IsPerson(source_p))
return;
if (!find_shared_conf(source_p->username, source_p->host,
source_p->servptr->name, SHARED_REHASH))
return;
do_rehash(source_p, parc > 1 ? parv[1] : NULL);
}

View file

@ -94,13 +94,6 @@ mo_restart(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
static void
me_restart(struct MsgBuf *msgbuf_p __unused, struct Client *client_p __unused, struct Client *source_p, int parc, const char *parv[])
{
if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_DIE))
{
sendto_one_notice(source_p, ":*** You do not have an appropriate shared block to "
"remotely restart this server.");
return;
}
do_restart(source_p, parv[1]);
}

View file

@ -193,12 +193,6 @@ parse_resv(struct Client *source_p, const char *name, const char *reason, int te
{
struct ConfItem *aconf;
if(!MyClient(source_p) &&
!find_shared_conf(source_p->username, source_p->host,
source_p->servptr->name,
(temp_time > 0) ? SHARED_TRESV : SHARED_PRESV))
return;
if(IsChannelName(name))
{
if(hash_find_resv(name))
@ -489,13 +483,7 @@ me_unresv(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
static void
handle_remote_unresv(struct Client *source_p, const char *name)
{
if(!find_shared_conf(source_p->username, source_p->host,
source_p->servptr->name, SHARED_UNRESV))
return;
remove_resv(source_p, name, 0);
return;
}
static void

View file

@ -120,7 +120,6 @@ static void stats_ssld(struct Client *);
static void stats_usage(struct Client *);
static void stats_tstats(struct Client *);
static void stats_uptime(struct Client *);
static void stats_shared(struct Client *);
static void stats_servers(struct Client *);
static void stats_tgecos(struct Client *);
static void stats_gecos(struct Client *);
@ -183,7 +182,6 @@ static struct stats_cmd stats_cmd_table[256] = {
['t'] = HANDLER_NORM(stats_tstats, false, "oper:general"),
['T'] = HANDLER_NORM(stats_tstats, false, "oper:general"),
['u'] = HANDLER_NORM(stats_uptime, false, NULL),
['U'] = HANDLER_NORM(stats_shared, false, "oper:general"),
['v'] = HANDLER_NORM(stats_servers, false, NULL),
['V'] = HANDLER_NORM(stats_servers, false, NULL),
['x'] = HANDLER_NORM(stats_tgecos, false, "oper:general"),
@ -1095,85 +1093,6 @@ stats_uptime (struct Client *source_p)
Count.totalrestartcount);
}
struct shared_flags
{
int flag;
char letter;
};
static struct shared_flags shared_flagtable[] =
{
{ SHARED_PKLINE, 'K' },
{ SHARED_TKLINE, 'k' },
{ SHARED_UNKLINE, 'U' },
{ SHARED_PXLINE, 'X' },
{ SHARED_TXLINE, 'x' },
{ SHARED_UNXLINE, 'Y' },
{ SHARED_PRESV, 'Q' },
{ SHARED_TRESV, 'q' },
{ SHARED_UNRESV, 'R' },
{ SHARED_LOCOPS, 'L' },
{ SHARED_REHASH, 'H' },
{ SHARED_TDLINE, 'd' },
{ SHARED_PDLINE, 'D' },
{ SHARED_UNDLINE, 'E' },
{ SHARED_GRANT, 'G' },
{ SHARED_DIE, 'I' },
{ 0, '\0'}
};
static void
stats_shared (struct Client *source_p)
{
struct remote_conf *shared_p;
rb_dlink_node *ptr;
char buf[sizeof(shared_flagtable)/sizeof(shared_flagtable[0])];
char *p;
int i;
RB_DLINK_FOREACH(ptr, shared_conf_list.head)
{
shared_p = ptr->data;
p = buf;
*p++ = 'c';
for(i = 0; shared_flagtable[i].flag != 0; i++)
{
if(shared_p->flags & shared_flagtable[i].flag)
*p++ = shared_flagtable[i].letter;
}
*p = '\0';
sendto_one_numeric(source_p, RPL_STATSULINE,
form_str(RPL_STATSULINE),
shared_p->server, shared_p->username,
shared_p->host, buf);
}
RB_DLINK_FOREACH(ptr, cluster_conf_list.head)
{
shared_p = ptr->data;
p = buf;
*p++ = 'C';
for(i = 0; shared_flagtable[i].flag != 0; i++)
{
if(shared_p->flags & shared_flagtable[i].flag)
*p++ = shared_flagtable[i].letter;
}
*p = '\0';
sendto_one_numeric(source_p, RPL_STATSULINE,
form_str(RPL_STATSULINE),
shared_p->server, "*", "*", buf);
}
}
/* stats_servers()
*

View file

@ -215,11 +215,6 @@ handle_remote_xline(struct Client *source_p, int temp_time, const char *name, co
{
struct ConfItem *aconf;
if(!find_shared_conf(source_p->username, source_p->host,
source_p->servptr->name,
(temp_time > 0) ? SHARED_TXLINE : SHARED_PXLINE))
return;
if(!valid_xline(source_p, name, reason))
return;
@ -447,10 +442,6 @@ me_unxline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
static void
handle_remote_unxline(struct Client *source_p, const char *name)
{
if(!find_shared_conf(source_p->username, source_p->host,
source_p->servptr->name, SHARED_UNXLINE))
return;
remove_xline(source_p, name, false);
}