Move unreg, privs, capab and active fields from struct Client to struct Connection.
authorMichael Poole <mdpoole@troilus.org>
Sat, 18 Dec 2004 18:07:16 +0000 (18:07 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sat, 18 Dec 2004 18:07:16 +0000 (18:07 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1285 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/client.h
ircd/client.c
ircd/m_server.c

index 038041e75864a6907f49dd2dc7165d63b29a1d6b..c02fdcc6801ecde32141b1b95eef23c29daa9967 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2004-12-18  Michael Poole <mdpoole@troilus.org>
+
+       * include/client.h: Move unreg, privs, capab and active fields
+       from struct Client to struct Connection since that is how they
+       are really associated.  Adjust macros to match.
+       (SetPriv, ClrPriv): New macros.
+
+       * ircd/client.c (client_set_privs): Exit earlier for remote
+       clients.  Adjust macro use to correspond.
+
+       * ircd/m_server.c (mr_server): Grant all privileges except
+       PRIV_SET to peer servers.
+
 2004-12-18  Michael Poole <mdpoole@troilus.org>
 
        * ircd/s_user.c (hide_hostmask): Add a missing "break;" to fix bug
index 7b97409d5fa12dd4fe7d4a0ffc519b3bf579f33a..42881b140efc14d36bc42446e5ad42cbcbac22b7 100644 (file)
@@ -212,6 +212,7 @@ struct Connection
   struct DNSReply*    con_dns_reply; /**< DNS reply received during client
                                        registration. */
   struct ListingArgs* con_listing;   /**< Current LIST status. */
+  unsigned long       con_unreg;     /**< Indicate what still needs to be done */
   unsigned int        con_max_sendq; /**< cached max send queue for client */
   unsigned int        con_ping_freq; /**< cached ping freq */
   unsigned short      con_lastsq;    /**< # 2k blocks when sendqueued
@@ -230,6 +231,9 @@ struct Connection
                                       client */
   struct Timer        con_proc;      /**< process latent messages from
                                       client */
+  struct Privs        con_privs;     /**< Oper privileges */
+  struct CapSet       con_capab;     /**< Client capabilities */
+  struct CapSet       con_active;    /**< Active client capabilities */
   struct AuthRequest* con_auth;      /**< auth request for client */
   struct IAuthRequest* con_iauth;    /**< iauth request for client */
 };
@@ -256,10 +260,6 @@ struct Client {
   unsigned int   cli_hopcount;    /**< number of servers to this 0 = local */
   struct irc_in_addr cli_ip;      /**< Real IP of client */
   short          cli_status;      /**< Client type */
-  struct Privs   cli_privs;       /**< Oper privileges */
-  struct CapSet  cli_capab;       /**< Client capabilities */
-  struct CapSet  cli_active;      /**< Active client capabilities */
-  unsigned long  cli_unreg;       /**< Indicate what still needs to be done */
   char cli_name[HOSTLEN + 1];     /**< Unique name of the client, nick or host */
   char cli_username[USERLEN + 1]; /**< username here now for auth stuff */
   char cli_info[REALLEN + 1];     /**< Free form additional client information */
@@ -318,13 +318,13 @@ struct Client {
 /** Return non-zero if the client is local. */
 #define cli_local(cli)          (cli_from(cli) == cli)
 /** Get oper privileges for client. */
-#define cli_privs(cli)         ((cli)->cli_privs)
+#define cli_privs(cli)         con_privs(cli_connect(cli))
 /** Get client capabilities for client */
-#define cli_capab(cli)         (&((cli)->cli_capab))
+#define cli_capab(cli)         con_capab(cli_connect(cli))
 /** Get active client capabilities for client */
-#define cli_active(cli)                (&((cli)->cli_active))
+#define cli_active(cli)                con_active(cli_connect(cli))
 /** Get flags for remaining registration tasks */
-#define cli_unreg(cli)         ((cli)->cli_unreg)
+#define cli_unreg(cli)         con_unreg(cli_connect(cli))
 /** Get client name. */
 #define cli_name(cli)          ((cli)->cli_name)
 /** Get client username (ident). */
@@ -451,6 +451,8 @@ struct Client {
 #define con_dns_reply(con)     ((con)->con_dns_reply)
 /** Get the LIST status for the connection. */
 #define con_listing(con)       ((con)->con_listing)
+/** Get remining steps before registration completes. */
+#define con_unreg(con)          ((con)->con_unreg)
 /** Get the maximum permitted SendQ size for the connection. */
 #define con_max_sendq(con)     ((con)->con_max_sendq)
 /** Get the ping frequency for the connection. */
@@ -471,6 +473,12 @@ struct Client {
 #define con_socket(con)                ((con)->con_socket)
 /** Get the Timer for processing more data from the connection. */
 #define con_proc(con)          ((con)->con_proc)
+/** Get the oper privilege set for the connection. */
+#define con_privs(con)          (&(con)->con_privs)
+/** Get the peer's capabilities for the connection. */
+#define con_capab(con)          (&(con)->con_capab)
+/** Get the active capabilities for the connection. */
+#define con_active(con)         (&(con)->con_active)
 /** Get the auth request for the connection. */
 #define con_auth(con)          ((con)->con_auth)
 /** Get the iauth request for the connection. */
@@ -734,7 +742,11 @@ struct Client {
 #define SNO_NOISY (SNO_SERVKILL|SNO_UNAUTH)
 
 /** Test whether a privilege has been granted to a client. */
-#define HasPriv(cli, priv)  FlagHas(&cli_privs(cli), priv)
+#define HasPriv(cli, priv)  FlagHas(cli_privs(cli), priv)
+/** Grant a privilege to a client. */
+#define SetPriv(cli, priv)  FlagSet(cli_privs(cli), priv)
+/** Revoke a privilege from a client. */
+#define ClrPriv(cli, priv)  FlagClr(cli_privs(cli), priv)
 
 /** Test whether a client has a capability */
 #define HasCap(cli, cap)    CapHas(cli_capab(cli), (cap))
index 6860d0cb759ff0ac76db84748f9a8476b90721b6..e8bf6c9b3b4362cd94d4d4d08d83524cd3fe9002 100644 (file)
@@ -140,6 +140,15 @@ client_set_privs(struct Client *client, struct ConfItem *oper)
   struct Privs *source, *defaults;
   enum Priv priv;
 
+  if (!MyConnect(client))
+    return;
+
+  /* Clear out client's privileges. */
+  memset(cli_privs(client), 0, sizeof(struct Privs));
+
+  if (!IsAnOper(client) || !oper)
+      return;
+
   if (!privs_defaults_set)
   {
     memset(&privs_global, -1, sizeof(privs_global));
@@ -158,21 +167,6 @@ client_set_privs(struct Client *client, struct ConfItem *oper)
     FlagSet(&privs_local, PRIV_FORCE_LOCAL_OPMODE);
     privs_defaults_set = 1;
   }
-  memset(&(cli_privs(client)), 0, sizeof(struct Privs));
-
-  if (!IsAnOper(client))
-    return;
-  else if (!MyConnect(client))
-  {
-    memset(&(cli_privs(client)), 255, sizeof(struct Privs));
-    FlagClr(&(cli_privs(client)), PRIV_SET);
-    return;
-  }
-  else if (oper == NULL)
-    return;
-
-  /* Clear out client's privileges. */
-  memset(&cli_privs(client), 0, sizeof(struct Privs));
 
   /* Decide whether to use global or local oper defaults. */
   if (FlagHas(&oper->privs_dirty, PRIV_PROPAGATE))
@@ -199,23 +193,23 @@ client_set_privs(struct Client *client, struct ConfItem *oper)
 
     /* Set it if necessary (privileges were already cleared). */
     if (FlagHas(source, priv))
-      FlagSet(&cli_privs(client), priv);
+      SetPriv(client, priv);
   }
 
   /* This should be handled in the config, but lets be sure... */
-  if (FlagHas(&cli_privs(client), PRIV_PROPAGATE))
+  if (HasPriv(client, PRIV_PROPAGATE))
   {
     /* force propagating opers to display */
-    FlagSet(&cli_privs(client), PRIV_DISPLAY);
+    SetPriv(client, PRIV_DISPLAY);
   }
   else
   {
     /* if they don't propagate oper status, prevent desyncs */
-    FlagClr(&cli_privs(client), PRIV_KILL);
-    FlagClr(&cli_privs(client), PRIV_GLINE);
-    FlagClr(&cli_privs(client), PRIV_JUPE);
-    FlagClr(&cli_privs(client), PRIV_OPMODE);
-    FlagClr(&cli_privs(client), PRIV_BADCHAN);
+    ClrPriv(client, PRIV_KILL);
+    ClrPriv(client, PRIV_GLINE);
+    ClrPriv(client, PRIV_JUPE);
+    ClrPriv(client, PRIV_OPMODE);
+    ClrPriv(client, PRIV_BADCHAN);
   }
 }
 
index 934fd3accb643081762d35eaa4cee414a33ff37f..7d57cd57057d6300da523e7535f4ff9c7210d0ba 100644 (file)
@@ -610,6 +610,8 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   cli_serv(cptr)->timestamp = timestamp;
   cli_serv(cptr)->prot = prot;
   cli_serv(cptr)->ghost = ghost;
+  memset(cli_privs(cptr), 255, sizeof(struct Privs));
+  ClrPriv(cptr, PRIV_SET);
   SetServerYXX(cptr, cptr, parv[6]);
 
   /* Attach any necessary UWorld config items. */