Committer  : entrope
CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Commit time: 2006-07-25 03:27:28 UTC

Modified files:
     ChangeLog include/client.h include/s_conf.h include/struct.h
     ircd/ircd_parser.y ircd/m_gline.c ircd/m_mode.c ircd/m_server.c
     ircd/s_conf.c ircd/s_serv.c ircd/s_stats.c

Log message:

Separate UWorld handling out from struct ConfItem.

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.810 ircu2.10/ChangeLog:1.811
--- ircu2.10/ChangeLog:1.810    Mon Jul 24 17:21:57 2006
+++ ircu2.10/ChangeLog  Mon Jul 24 20:27:18 2006
@@ -1,5 +1,42 @@
 2006-07-24  Michael Poole <[EMAIL PROTECTED]>
 
+       * include/client.h (cli_uworld): New macro.
+
+       * include/s_conf.h (CONF_UWORLD): Delete.
+       (update_uworld_flags): New function.
+       (conf_make_uworld): New function.
+       (stats_uworld): New function.
+
+       * include/struct.h (struct Server): Add new "flags" field.
+       (SFLAG_UWORLD): New macro.
+
+       * ircd/ircd_parser.y (uworldname): Use conf_make_uworld().
+       (uworldblock): New production, using conf_make_uworld().
+
+       * ircd/m_gline.c (ms_gline): Use cli_uworld() to check UWorld status.
+
+       * ircd/m_mode.c (ms_mode): Use cli_uworld() to check UWorld status.
+
+       * ircd/m_server.c (check_loop_and_lh): Remove redundant UWorld check.
+       (mr_server): Use update_uworld_flags() to update a server's UWorld 
status.
+       (ms_server): Likewise.
+
+       * ircd/s_conf.c (uworlds): New static variable.
+       (attach_conf_uworld): Delete function.
+       (update_uworld_flags): New function.
+       (conf_erase_uworld_list): New function.
+       (conf_make_uworld): New function.
+       (stats_uworld): New function.
+       (rehash): Call conf_erase_uworld_list().  Remove CONF_UWORLD
+       reference.  Call update_uworld_flags(&me) after rehash.
+
+       * ircd/s_serv.c (server_estab): Remove CONF_UWORLD reference.
+
+       * ircd/s_stats.c (statsinfo): Point /stats U to stats_uworld().
+       (stats_configured_links): Remove CONF_UWORLD handling.
+
+2006-07-24  Michael Poole <[EMAIL PROTECTED]>
+
        * ircd/umkpasswd.c (parse_arguments): Exit rather than abort when
        encountering an invalid argument.
        (main): Exit rather than abort when not given a mechanism.
Index: ircu2.10/include/client.h
diff -u ircu2.10/include/client.h:1.51 ircu2.10/include/client.h:1.52
--- ircu2.10/include/client.h:1.51      Mon Jul 17 15:52:11 2006
+++ ircu2.10/include/client.h   Mon Jul 24 20:27:18 2006
@@ -19,7 +19,7 @@
  */
 /** @file
  * @brief Structures and functions for handling local clients.
- * @version $Id: client.h,v 1.51 2006/07/17 22:52:11 entrope Exp $
+ * @version $Id: client.h,v 1.52 2006/07/25 03:27:18 entrope Exp $
  */
 #ifndef INCLUDED_client_h
 #define INCLUDED_client_h
@@ -284,6 +284,8 @@
 #define cli_user(cli)          ((cli)->cli_user)
 /** Get Server structure for client, if client is a server. */
 #define cli_serv(cli)          ((cli)->cli_serv)
+/** Return true if client has uworld privileges. */
+#define cli_uworld(cli)         (cli_serv(cli) && (cli_serv(cli)->flags & 
SFLAG_UWORLD))
 /** Get Whowas link for client. */
 #define cli_whowas(cli)                ((cli)->cli_whowas)
 /** Get client numnick. */
Index: ircu2.10/include/s_conf.h
diff -u ircu2.10/include/s_conf.h:1.35 ircu2.10/include/s_conf.h:1.36
--- ircu2.10/include/s_conf.h:1.35      Wed Jun 28 17:41:28 2006
+++ ircu2.10/include/s_conf.h   Mon Jul 24 20:27:18 2006
@@ -1,6 +1,6 @@
 /** @file s_conf.h
  * @brief ircd configuration file API.
- * @version $Id: s_conf.h,v 1.35 2006/06/29 00:41:28 entrope Exp $
+ * @version $Id: s_conf.h,v 1.36 2006/07/25 03:27:18 entrope Exp $
  */
 #ifndef INCLUDED_s_conf_h
 #define INCLUDED_s_conf_h
@@ -30,7 +30,6 @@
 #define CONF_CLIENT             0x0002     /**< ConfItem describes a Client 
block */
 #define CONF_SERVER             0x0004     /**< ConfItem describes a Connect 
block */
 #define CONF_OPERATOR           0x0020     /**< ConfItem describes an Operator 
block */
-#define CONF_UWORLD             0x8000     /**< ConfItem describes a Uworld 
server */
 
 #define CONF_AUTOCONNECT        0x0001     /**< Autoconnect to a server */
 
@@ -175,6 +174,10 @@
 extern struct ConfItem* find_conf_byname(struct SLink* lp, const char *name, 
int statmask);
 extern struct ConfItem* conf_find_server(const char* name);
 
+extern void update_uworld_flags(struct Client *cptr);
+extern void conf_make_uworld(char *name);
+extern void stats_uworld(struct Client* to, const struct StatDesc* sd, char* 
param);
+
 extern void det_confs_butmask(struct Client *cptr, int mask);
 extern enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct 
ConfItem *aconf);
 extern struct ConfItem* find_conf_exact(const char* name, struct Client *cptr, 
int statmask);
Index: ircu2.10/include/struct.h
diff -u ircu2.10/include/struct.h:1.10 ircu2.10/include/struct.h:1.11
--- ircu2.10/include/struct.h:1.10      Sun Jul 23 19:08:33 2006
+++ ircu2.10/include/struct.h   Mon Jul 24 20:27:18 2006
@@ -20,7 +20,7 @@
  */
 /** @file
  * @brief Structure definitions for users and servers.
- * @version $Id: struct.h,v 1.10 2006/07/24 02:08:33 entrope Exp $
+ * @version $Id: struct.h,v 1.11 2006/07/25 03:27:18 entrope Exp $
  */
 #ifndef INCLUDED_struct_h
 #define INCLUDED_struct_h
@@ -54,6 +54,7 @@
   unsigned short  prot;         /**< Major protocol */
   unsigned int    nn_mask;      /**< Number of clients supported by server, 
minus 1 */
   char          nn_capacity[4]; /**< Numeric representation of server capacity 
*/
+  int             flags;        /**< Server flags (SFLAG_*) */
 
   int            asll_rtt;      /**< AsLL round-trip time */
   int            asll_to;       /**< AsLL upstream lag */
@@ -63,6 +64,8 @@
   char by[NICKLEN + 1];         /**< Numnick of client who requested the link 
*/
 };
 
+#define SFLAG_UWORLD         0x0001  /**< Server has UWorld privileges */
+
 /** Describes a user on the network. */
 struct User {
   struct Client*     server;         /**< client structure of server */
Index: ircu2.10/ircd/ircd_parser.y
diff -u ircu2.10/ircd/ircd_parser.y:1.67 ircu2.10/ircd/ircd_parser.y:1.68
--- ircu2.10/ircd/ircd_parser.y:1.67    Sun Jul 23 17:29:17 2006
+++ ircu2.10/ircd/ircd_parser.y Mon Jul 24 20:27:18 2006
@@ -17,7 +17,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  *  USA.
- * $Id: ircd_parser.y,v 1.67 2006/07/24 00:29:17 entrope Exp $
+ * $Id: ircd_parser.y,v 1.68 2006/07/25 03:27:18 entrope Exp $
  */
 %{
 
@@ -599,9 +599,15 @@
 uworldname: NAME '=' QSTRING ';'
 {
   if (permitted(BLOCK_UWORLD, 0))
-    make_conf(CONF_UWORLD)->host = $3;
+    conf_make_uworld($3);
 };
 
+uworldblock: UWORLD QSTRING ';'
+{
+  if (permitted(BLOCK_UWORLD, 1))
+    conf_make_uworld($2);
+}
+
 operblock: OPER '{' operitems '}' ';'
 {
   struct ConfItem *aconf = NULL;
Index: ircu2.10/ircd/m_gline.c
diff -u ircu2.10/ircd/m_gline.c:1.30 ircu2.10/ircd/m_gline.c:1.31
--- ircu2.10/ircd/m_gline.c:1.30        Sun Jul 23 11:04:21 2006
+++ ircu2.10/ircd/m_gline.c     Mon Jul 24 20:27:18 2006
@@ -20,7 +20,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: m_gline.c,v 1.30 2006/07/23 18:04:21 entrope Exp $
+ * $Id: m_gline.c,v 1.31 2006/07/25 03:27:18 entrope Exp $
  */
 
 #include "config.h"
@@ -89,7 +89,7 @@
 
   if ((parc == 3 && *mask == '-') || parc == 5)
   {
-    if (!find_conf_byhost(cli_confs(cptr), cli_name(sptr), CONF_UWORLD))
+    if (!cli_uworld(sptr))
       return need_more_params(sptr, "GLINE");
 
     flags |= GLINE_FORCE;
Index: ircu2.10/ircd/m_mode.c
diff -u ircu2.10/ircd/m_mode.c:1.19 ircu2.10/ircd/m_mode.c:1.20
--- ircu2.10/ircd/m_mode.c:1.19 Tue Jul  4 12:44:38 2006
+++ ircu2.10/ircd/m_mode.c      Mon Jul 24 20:27:18 2006
@@ -20,7 +20,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: m_mode.c,v 1.19 2006/07/04 19:44:38 entrope Exp $
+ * $Id: m_mode.c,v 1.20 2006/07/25 03:27:18 entrope Exp $
  */
 
 #include "config.h"
@@ -140,7 +140,7 @@
     return set_user_mode(cptr, sptr, parc, parv);
 
   if (IsServer(sptr)) {
-    if (find_conf_byhost(cli_confs(cptr), cli_name(sptr), CONF_UWORLD))
+    if (cli_uworld(sptr))
       modebuf_init(&mbuf, sptr, cptr, chptr,
                   (MODEBUF_DEST_CHANNEL | /* Send mode to clients */
                    MODEBUF_DEST_SERVER  | /* Send mode to servers */
Index: ircu2.10/ircd/m_server.c
diff -u ircu2.10/ircd/m_server.c:1.44 ircu2.10/ircd/m_server.c:1.45
--- ircu2.10/ircd/m_server.c:1.44       Sun Jul 23 11:04:22 2006
+++ ircu2.10/ircd/m_server.c    Mon Jul 24 20:27:18 2006
@@ -22,7 +22,7 @@
  */
 /** @file
  * @brief Handlers for the SERVER command.
- * @version $Id: m_server.c,v 1.44 2006/07/23 18:04:22 entrope Exp $
+ * @version $Id: m_server.c,v 1.45 2006/07/25 03:27:18 entrope Exp $
  */
 
 #include "config.h"
@@ -211,11 +211,9 @@
       return exit_client_msg(cptr, cptr, &me,
                              "Nickname %s already exists!", host);
     /*
-     * Our new server might be a juped server,
-     * or someone trying abuse a second Uworld:
+     * Our new server might be a juped server:
      */
-    else if (IsServer(acptr) && (0 == ircd_strncmp(cli_info(acptr), "JUPE", 4) 
||
-        find_conf_byhost(cli_confs(cptr), cli_name(acptr), CONF_UWORLD)))
+    else if (IsServer(acptr) && (0 == ircd_strncmp(cli_info(acptr), "JUPE", 
4)))
     {
       if (!IsServer(sptr))
         return exit_client(cptr, sptr, &me, cli_info(acptr));
@@ -626,9 +624,7 @@
   memset(cli_privs(cptr), 255, sizeof(struct Privs));
   ClrPriv(cptr, PRIV_SET);
   SetServerYXX(cptr, cptr, parv[6]);
-
-  /* Attach any necessary UWorld config items. */
-  attach_confs_byhost(cptr, host, CONF_UWORLD);
+  update_uworld_flags(cptr);
 
   if (*parv[7] == '+')
     set_server_flags(cptr, parv[7] + 1);
@@ -740,9 +736,7 @@
   /* Use cptr, because we do protocol 9 -> 10 translation
      for numeric nicks ! */
   SetServerYXX(cptr, acptr, parv[6]);
-
-  /* Attach any necessary UWorld config items. */
-  attach_confs_byhost(cptr, host, CONF_UWORLD);
+  update_uworld_flags(cptr);
 
   if (*parv[7] == '+')
     set_server_flags(acptr, parv[7] + 1);
Index: ircu2.10/ircd/s_conf.c
diff -u ircu2.10/ircd/s_conf.c:1.92 ircu2.10/ircd/s_conf.c:1.93
--- ircu2.10/ircd/s_conf.c:1.92 Sun Jul 23 11:04:22 2006
+++ ircu2.10/ircd/s_conf.c      Mon Jul 24 20:27:18 2006
@@ -19,7 +19,7 @@
  */
 /** @file
  * @brief ircd configuration file driver
- * @version $Id: s_conf.c,v 1.92 2006/07/23 18:04:22 entrope Exp $
+ * @version $Id: s_conf.c,v 1.93 2006/07/25 03:27:18 entrope Exp $
  */
 #include "config.h"
 
@@ -891,15 +891,75 @@
     fprintf(stderr, "Config warning on line %d: %s\n", yylineno, warn_buffer);
 }
 
-/** Attach CONF_UWORLD items to a server and everything attached to it. */
-static void
-attach_conf_uworld(struct Client *cptr)
+/** List of server names with UWorld privileges. */
+static struct SLink *uworlds;
+
+/** Update the UWorld status flag for a server and every server behind it.
+ * @param[in] cptr The server to check against UWorld.
+ */
+void
+update_uworld_flags(struct Client *cptr)
 {
   struct DLink *lp;
+  struct SLink *sp;
+
+  assert(cli_serv(cptr) != NULL);
+
+  for (sp = uworlds; sp; sp = sp->next)
+    if (0 == ircd_strcmp(cli_name(cptr), sp->value.cp))
+      break;
+
+  if (sp)
+    cli_serv(cptr)->flags |= SFLAG_UWORLD;
+  else
+    cli_serv(cptr)->flags &= ~SFLAG_UWORLD;
 
-  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);
+    update_uworld_flags(lp->value.cptr);
+}
+
+/** Empty the list of known UWorld servers. */
+static void
+conf_erase_uworld_list(void)
+{
+  struct SLink *sp;
+
+  while (uworlds)
+  {
+    sp = uworlds;
+    uworlds = sp->next;
+    MyFree(sp->value.cp);
+    free_link(sp);
+  }
+
+  update_uworld_flags(&me);
+}
+
+/** Record the name of a server having UWorld privileges.
+ * @param[in] name Privileged server's name.
+ */
+void conf_make_uworld(char *name)
+{
+  struct SLink *sp;
+
+  sp = make_link();
+  sp->value.cp = name;
+  sp->next = uworlds;
+  uworlds = sp;
+}
+
+/** Send a list of UWorld servers.
+ * @param[in] to Client requesting statistics.
+ * @param[in] sd Stats descriptor for request (ignored).
+ * @param[in] param Extra parameter from user (ignored).
+ */
+void
+stats_uworld(struct Client* to, const struct StatDesc* sd, char* param)
+{
+  struct SLink *sp;
+
+  for (sp = uworlds; sp; sp = sp->next)
+    send_reply(to, RPL_STATSULINE, sp->value.cp);
 }
 
 /** Free all memory associated with service mapping \a smap.
@@ -973,6 +1033,7 @@
       free_conf(tmp2);
     }
   }
+  conf_erase_uworld_list();
   conf_erase_crule_list();
   conf_erase_deny_list();
   motd_clear();
@@ -1018,7 +1079,7 @@
     if ((acptr = LocalClientArray[i])) {
       assert(!IsMe(acptr));
       if (IsServer(acptr))
-        det_confs_butmask(acptr, ~(CONF_UWORLD | CONF_ILLEGAL));
+        det_confs_butmask(acptr, ~(CONF_ILLEGAL));
       /* 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.
@@ -1036,7 +1097,7 @@
     }
   }
 
-  attach_conf_uworld(&me);
+  update_uworld_flags(&me);
 
   return ret;
 }
Index: ircu2.10/ircd/s_serv.c
diff -u ircu2.10/ircd/s_serv.c:1.42 ircu2.10/ircd/s_serv.c:1.43
--- ircu2.10/ircd/s_serv.c:1.42 Sun Jul 23 11:04:22 2006
+++ ircu2.10/ircd/s_serv.c      Mon Jul 24 20:27:18 2006
@@ -22,7 +22,7 @@
  */
 /** @file
  * @brief Miscellaneous server support functions.
- * @version $Id: s_serv.c,v 1.42 2006/07/23 18:04:22 entrope Exp $
+ * @version $Id: s_serv.c,v 1.43 2006/07/25 03:27:18 entrope Exp $
  */
 #include "config.h"
 
@@ -134,7 +134,7 @@
                  *(cli_info(&me)) ? cli_info(&me) : "IRCers United");
   }
 
-  det_confs_butmask(cptr, CONF_SERVER | CONF_UWORLD);
+  det_confs_butmask(cptr, CONF_SERVER);
 
   if (!IsHandshake(cptr))
     hAddClient(cptr);
Index: ircu2.10/ircd/s_stats.c
diff -u ircu2.10/ircd/s_stats.c:1.50 ircu2.10/ircd/s_stats.c:1.51
--- ircu2.10/ircd/s_stats.c:1.50        Thu Jun  1 08:59:19 2006
+++ ircu2.10/ircd/s_stats.c     Mon Jul 24 20:27:18 2006
@@ -63,7 +63,7 @@
 /** @file
  * @brief Report configuration lines and other statistics from this
  * server.
- * @version $Id: s_stats.c,v 1.50 2006/06/01 15:59:19 klmitch Exp $
+ * @version $Id: s_stats.c,v 1.51 2006/07/25 03:27:18 entrope Exp $
  *
  * Note: The info is reported in the order the server uses
  *       it--not reversed as in ircd.conf!
@@ -171,7 +171,7 @@
     tstats, 0,
     "Local connection statistics (Total SND/RCV, etc)." },
   { 'U', "uworld", (STAT_FLAG_OPERFEAT | STAT_FLAG_CASESENS), 
FEAT_HIS_STATS_UWORLD,
-    stats_configured_links, CONF_UWORLD,
+    stats_uworld, 0,
     "Service server information." },
   { 'u', "uptime", (STAT_FLAG_OPERFEAT | STAT_FLAG_CASESENS), 
FEAT_HIS_STATS_UPTIME,
     stats_uptime, 0,
@@ -228,9 +228,7 @@
       maximum = tmp->maximum;
       port = tmp->address.port;
 
-      if (tmp->status & CONF_UWORLD)
-       send_reply(sptr, RPL_STATSULINE, host);
-      else if (tmp->status & CONF_SERVER)
+      if (tmp->status & CONF_SERVER)
        send_reply(sptr, RPL_STATSCLINE, name, port, maximum, hub_limit, 
get_conf_class(tmp));
       else if (tmp->status & CONF_CLIENT)
         send_reply(sptr, RPL_STATSILINE,
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches

Reply via email to