Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Commit time: 2004-12-18 18:07:26 UTC
Modified files:
ChangeLog include/client.h ircd/client.c ircd/m_server.c
Log message:
Move unreg, privs, capab and active fields from struct Client to struct
Connection.
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.522 ircu2.10/ChangeLog:1.523
--- ircu2.10/ChangeLog:1.522 Sat Dec 18 08:26:25 2004
+++ ircu2.10/ChangeLog Sat Dec 18 10:07:14 2004
@@ -1,5 +1,18 @@
2004-12-18 Michael Poole <[EMAIL PROTECTED]>
+ * 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 <[EMAIL PROTECTED]>
+
* ircd/s_user.c (hide_hostmask): Add a missing "break;" to fix bug
#1087461.
Index: ircu2.10/include/client.h
diff -u ircu2.10/include/client.h:1.42 ircu2.10/include/client.h:1.43
--- ircu2.10/include/client.h:1.42 Sat Dec 18 08:26:26 2004
+++ ircu2.10/include/client.h Sat Dec 18 10:07:15 2004
@@ -19,7 +19,7 @@
*/
/** @file
* @brief Structures and functions for handling local clients.
- * @version $Id: client.h,v 1.42 2004/12/18 16:26:26 klmitch Exp $
+ * @version $Id: client.h,v 1.43 2004/12/18 18:07:15 entrope Exp $
*/
#ifndef INCLUDED_client_h
#define INCLUDED_client_h
@@ -212,6 +212,7 @@
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 @@
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 @@
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 @@
/** 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 @@
#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 @@
#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 @@
#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: ircu2.10/ircd/client.c
diff -u ircu2.10/ircd/client.c:1.28 ircu2.10/ircd/client.c:1.29
--- ircu2.10/ircd/client.c:1.28 Fri Dec 10 21:13:43 2004
+++ ircu2.10/ircd/client.c Sat Dec 18 10:07:16 2004
@@ -18,7 +18,7 @@
*/
/** @file
* @brief Implementation of functions for handling local clients.
- * @version $Id: client.c,v 1.28 2004/12/11 05:13:43 klmitch Exp $
+ * @version $Id: client.c,v 1.29 2004/12/18 18:07:16 entrope Exp $
*/
#include "config.h"
@@ -140,6 +140,15 @@
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 @@
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 @@
/* 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: ircu2.10/ircd/m_server.c
diff -u ircu2.10/ircd/m_server.c:1.37 ircu2.10/ircd/m_server.c:1.38
--- ircu2.10/ircd/m_server.c:1.37 Fri Dec 17 14:41:03 2004
+++ ircu2.10/ircd/m_server.c Sat Dec 18 10:07:16 2004
@@ -22,7 +22,7 @@
*/
/** @file
* @brief Handlers for the SERVER command.
- * @version $Id: m_server.c,v 1.37 2004/12/17 22:41:03 entrope Exp $
+ * @version $Id: m_server.c,v 1.38 2004/12/18 18:07:16 entrope Exp $
*/
#include "config.h"
@@ -610,6 +610,8 @@
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. */
----------------------- End of diff -----------------------