Make UWorld servers work when not directly connected to them. Fix a
authorMichael Poole <mdpoole@troilus.org>
Fri, 17 Dec 2004 22:41:03 +0000 (22:41 +0000)
committerMichael Poole <mdpoole@troilus.org>
Fri, 17 Dec 2004 22:41:03 +0000 (22:41 +0000)
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
ircd/channel.c
ircd/ircd_parser.y
ircd/m_server.c
ircd/s_conf.c

index b366d8bf121d4a50c62df7588f1a53c75e0fc0c7..c03c93781522c72944b0c527fd56c9b9d6ffd27e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2004-12-17  Michael Poole <mdpoole@troilus.org>
+
+       * 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 <mdpoole@troilus.org>
 
        * ircd/m_topic.c (do_settopic): Allow +k services to set topics on
index 4ff88acaa1b759a8d96098d44390b685982c01a2..ca5bde22d19e59f39918ccf08504dc0a477ee6cc 100644 (file)
@@ -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();
index 920cf473db9f94b0ba6c889a90e9c7eb91527198..8b383548c469deb253c3d6c3c6421af4ad579a9e 100644 (file)
@@ -477,7 +477,7 @@ uworldblock: UWORLD '{' uworlditems '}' ';'
  if (name)
  {
   struct ConfItem *aconf = make_conf(CONF_UWORLD);
-  aconf->name = name;
+  aconf->host = name;
  }
  else
  {
index 6efe6bd37c7074fdb98dfdc97c30c78f35f56ab8..934fd3accb643081762d35eaa4cee414a33ff37f 100644 (file)
@@ -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) {
index 4fac7b83aaf8bda1caa85f64cb07ffa8f7ef6d47..2a5e12ea60a2582a4f951552e104deb57f760e82 100644 (file)
@@ -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));