From f768be2cae6867f20836584d8412bee18da5f4a6 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Fri, 17 Dec 2004 22:41:03 +0000 Subject: [PATCH] Make UWorld servers work when not directly connected to them. Fix a channel destruction error that would lead to opless channels. Fix an attempted free() of an uninitialized pointer. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1278 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 18 ++++++++++++++++++ ircd/channel.c | 8 ++++---- ircd/ircd_parser.y | 2 +- ircd/m_server.c | 6 ++++++ ircd/s_conf.c | 18 ++++++++++++++---- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index b366d8b..c03c937 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2004-12-17 Michael Poole + + * ircd/channel.c (sub1_from_channel): Immediately destroy + non-Apass channels when oplevels are enabled; otherwise, they can + stay opless for a considerable period. + (mode_parse_ban): Initialize banstr to NULL so that set_ban_mask() + does not try to free() an invalid pointer. + + * ircd/ircd_parser.y (uworldblock): Put UWorld server name into + aconf->host, not aconf->name. + + * ircd/m_server.c (mr_server, ms_server): Attach CONF_UWORLD items + by host here.. + + * ircd/s_conf.c (conf_check_server): .. rather than by name here. + (attach_conf_uworld): New function to attach CONF_UWORLD items. + (rehash): Use attach_conf_uworld() instead of attaching by name. + 2004-12-15 Michael Poole * ircd/m_topic.c (do_settopic): Allow +k services to set topics on diff --git a/ircd/channel.c b/ircd/channel.c index 4ff88ac..ca5bde2 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -259,13 +259,12 @@ int sub1_from_channel(struct Channel* chptr) * who then will educate them on the use of Apass/upass. */ - if (feature_bool(FEAT_OPLEVELS)) { - if (TStime() - chptr->creationtime < 172800) /* Channel younger than 48 hours? */ + if (!(chptr->mode.mode & MODE_APASS)) /* If no Apass, destroy now. */ + destruct_channel(chptr); + else if (TStime() - chptr->creationtime < 172800) /* Channel younger than 48 hours? */ schedule_destruct_event_1m(chptr); /* Get rid of it in approximately 4-5 minutes */ else schedule_destruct_event_48h(chptr); /* Get rid of it in approximately 48 hours */ - } else - destruct_channel(chptr); return 0; } @@ -2791,6 +2790,7 @@ mode_parse_ban(struct ParseState *state, int *flag_p) newban->next = 0; newban->flags = ((state->dir == MODE_ADD) ? BAN_ADD : BAN_DEL) | (*flag_p == 'b' ? 0 : BAN_EXCEPTION); + newban->banstr = NULL; set_ban_mask(newban, collapse(pretty_mask(t_str))); newban->who = cli_name(state->sptr); newban->when = TStime(); diff --git a/ircd/ircd_parser.y b/ircd/ircd_parser.y index 920cf47..8b38354 100644 --- a/ircd/ircd_parser.y +++ b/ircd/ircd_parser.y @@ -477,7 +477,7 @@ uworldblock: UWORLD '{' uworlditems '}' ';' if (name) { struct ConfItem *aconf = make_conf(CONF_UWORLD); - aconf->name = name; + aconf->host = name; } else { diff --git a/ircd/m_server.c b/ircd/m_server.c index 6efe6bd..934fd3a 100644 --- a/ircd/m_server.c +++ b/ircd/m_server.c @@ -612,6 +612,9 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) cli_serv(cptr)->ghost = ghost; SetServerYXX(cptr, cptr, parv[6]); + /* Attach any necessary UWorld config items. */ + attach_confs_byhost(cptr, host, CONF_UWORLD); + if (*parv[7] == '+') { for (ch = parv[7] + 1; *ch; ch++) switch (*ch) { @@ -733,6 +736,9 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) for numeric nicks ! */ SetServerYXX(cptr, acptr, parv[6]); + /* Attach any necessary UWorld config items. */ + attach_confs_byhost(cptr, host, CONF_UWORLD); + if (*parv[7] == '+') { for (ch = parv[7] + 1; *ch; ch++) switch (*ch) { diff --git a/ircd/s_conf.c b/ircd/s_conf.c index 4fac7b8..2a5e12e 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -734,6 +734,17 @@ yyerror(const char *msg) conf_error = 1; } +/** Attach CONF_UWORLD items to a server and everything attached to it. */ +static void +attach_conf_uworld(struct Client *cptr) +{ + struct DLink *lp; + + attach_confs_byhost(cptr, cli_name(cptr), CONF_UWORLD); + for (lp = cli_serv(cptr)->down; lp; lp = lp->next) + attach_conf_uworld(lp->value.cptr); +} + /** Reload the configuration file. * @param cptr Client that requested rehash (if a signal, &me). * @param sig Type of rehash (0 = oper-requested, 1 = signal, 2 = @@ -818,10 +829,8 @@ int rehash(struct Client *cptr, int sig) for (i = 0; i <= HighestFd; i++) { if ((acptr = LocalClientArray[i])) { assert(!IsMe(acptr)); - if (IsServer(acptr)) { + if (IsServer(acptr)) det_confs_butmask(acptr, ~(CONF_UWORLD | CONF_ILLEGAL)); - attach_confs_byname(acptr, cli_name(acptr), CONF_UWORLD); - } /* Because admin's are getting so uppity about people managing to * get past K/G's etc, we'll "fix" the bug by actually explaining * whats going on. @@ -839,6 +848,8 @@ int rehash(struct Client *cptr, int sig) } } + attach_conf_uworld(&me); + return ret; } @@ -1049,7 +1060,6 @@ int conf_check_server(struct Client *cptr) * attach the Connect block to the client structure for later use. */ attach_conf(cptr, c_conf); - attach_confs_byname(cptr, cli_name(cptr), CONF_UWORLD); if (!irc_in_addr_valid(&c_conf->address.addr)) memcpy(&c_conf->address.addr, &cli_ip(cptr), sizeof(c_conf->address.addr)); -- 2.20.1