Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Commit time: 2005-04-02 02:50:25 UTC
Modified files:
ChangeLog include/handlers.h include/msg.h ircd/m_privs.c
ircd/parse.c
Log message:
Return accurate privilege information for remote opers.
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.583 ircu2.10/ChangeLog:1.584
--- ircu2.10/ChangeLog:1.583 Wed Mar 30 20:05:48 2005
+++ ircu2.10/ChangeLog Fri Apr 1 18:50:12 2005
@@ -1,3 +1,19 @@
+2005-04-01 Michael Poole <[EMAIL PROTECTED]>
+
+ * include/handlers.h (ms_privs): Declare.
+
+ * include/msg.h (TOK_PRIVS): Assign token.
+ (CMD_PRIVS): Define.
+
+ * ircd/m_privs.c: Add doxygen comments and replace the long
+ discussion of m_handler functions with an xref to it.
+ (mo_privs): Forward requests for non-local users
+ to their own server.
+ (ms_privs): Implement.
+
+ * ircd/parse.c (PRIVS): Dispatch to ms_privs when a server sends
+ the message.
+
2005-03-30 Michael Poole <[EMAIL PROTECTED]>
* include/client.h (struct Client): Explain where cli_username
Index: ircu2.10/include/handlers.h
diff -u ircu2.10/include/handlers.h:1.21 ircu2.10/include/handlers.h:1.22
--- ircu2.10/include/handlers.h:1.21 Sat Dec 18 08:26:26 2004
+++ ircu2.10/include/handlers.h Fri Apr 1 18:50:12 2005
@@ -19,7 +19,7 @@
*/
/** @file
* @brief Declarations for all protocol message handler functions.
- * @version $Id: handlers.h,v 1.21 2004/12/18 16:26:26 klmitch Exp $
+ * @version $Id: handlers.h,v 1.22 2005/04/02 02:50:12 entrope Exp $
*/
#ifndef INCLUDED_handlers_h
#define INCLUDED_handlers_h
@@ -207,6 +207,7 @@
extern int ms_ping(struct Client*, struct Client*, int, char*[]);
extern int ms_pong(struct Client*, struct Client*, int, char*[]);
extern int ms_privmsg(struct Client*, struct Client*, int, char*[]);
+extern int ms_privs(struct Client*, struct Client*, int, char*[]);
extern int ms_quit(struct Client*, struct Client*, int, char*[]);
extern int ms_rping(struct Client*, struct Client*, int, char*[]);
extern int ms_rpong(struct Client*, struct Client*, int, char*[]);
Index: ircu2.10/include/msg.h
diff -u ircu2.10/include/msg.h:1.17 ircu2.10/include/msg.h:1.18
--- ircu2.10/include/msg.h:1.17 Sat Dec 18 08:26:26 2004
+++ ircu2.10/include/msg.h Fri Apr 1 18:50:13 2005
@@ -19,7 +19,7 @@
*/
/** @file
* @brief Command and token declarations and structures.
- * @version $Id: msg.h,v 1.17 2004/12/18 16:26:26 klmitch Exp $
+ * @version $Id: msg.h,v 1.18 2005/04/02 02:50:13 entrope Exp $
*/
#ifndef INCLUDED_msg_h
#define INCLUDED_msg_h
@@ -353,7 +353,8 @@
#define TOK_GET "GET"
#define MSG_PRIVS "PRIVS" /* PRIV */
-#define TOK_PRIVS "PRIVS"
+#define TOK_PRIVS "PR"
+#define CMD_PRIVS MSG_PRIVS, TOK_PRIVS
#define MSG_CAP "CAP"
#define TOK_CAP "CAP"
Index: ircu2.10/ircd/m_privs.c
diff -u ircu2.10/ircd/m_privs.c:1.5 ircu2.10/ircd/m_privs.c:1.6
--- ircu2.10/ircd/m_privs.c:1.5 Fri Dec 10 21:13:48 2004
+++ ircu2.10/ircd/m_privs.c Fri Apr 1 18:50:14 2005
@@ -19,66 +19,12 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id: m_privs.c,v 1.5 2004/12/11 05:13:48 klmitch Exp $
*/
-
-/*
- * m_functions execute protocol messages on this server:
- *
- * cptr is always NON-NULL, pointing to a *LOCAL* client
- * structure (with an open socket connected!). This
- * identifies the physical socket where the message
- * originated (or which caused the m_function to be
- * executed--some m_functions may call others...).
- *
- * sptr is the source of the message, defined by the
- * prefix part of the message if present. If not
- * or prefix not found, then sptr==cptr.
- *
- * (!IsServer(cptr)) => (cptr == sptr), because
- * prefixes are taken *only* from servers...
- *
- * (IsServer(cptr))
- * (sptr == cptr) => the message didn't
- * have the prefix.
- *
- * (sptr != cptr && IsServer(sptr) means
- * the prefix specified servername. (?)
- *
- * (sptr != cptr && !IsServer(sptr) means
- * that message originated from a remote
- * user (not local).
- *
- * combining
- *
- * (!IsServer(sptr)) means that, sptr can safely
- * taken as defining the target structure of the
- * message in this server.
- *
- * *Always* true (if 'parse' and others are working correct):
- *
- * 1) sptr->from == cptr (note: cptr->from == cptr)
- *
- * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr
- * *cannot* be a local connection, unless it's
- * actually cptr!). [MyConnect(x) should probably
- * be defined as (x == x->from) --msa ]
- *
- * parc number of variable parameter strings (if zero,
- * parv is allowed to be NULL)
- *
- * parv a NULL terminated list of parameter pointers,
- *
- * parv[0], sender (prefix string), if not present
- * this points to an empty string.
- * parv[1]...parv[parc-1]
- * pointers to additional parameters
- * parv[parc] == NULL, *always*
- *
- * note: it is guaranteed that parv[0]..parv[parc-1] are all
- * non-NULL pointers.
+/** @file
+ * @brief Report operators' privileges to others
+ * @version $Id: m_privs.c,v 1.6 2005/04/02 02:50:14 entrope Exp $
*/
+
#include "config.h"
#include "client.h"
@@ -87,14 +33,17 @@
#include "ircd_log.h"
#include "ircd_reply.h"
#include "ircd_string.h"
+#include "msg.h"
#include "numeric.h"
#include "numnicks.h"
#include "send.h"
-/* #include <assert.h> -- Now using assert in ircd_log.h */
-
-/*
- * mo_privs - report operator privileges
+/** Handle a local operator's privilege query.
+ * @param[in] cptr Client that sent us the message.
+ * @param[in] sptr Original source of message.
+ * @param[in] parc Number of arguments.
+ * @param[in] parv Argument vector.
+ * @see \ref m_functions
*/
int mo_privs(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
{
@@ -109,8 +58,43 @@
for (i = 1; i < parc; i++) {
for (name = ircd_strtok(&p, parv[i], " "); name;
name = ircd_strtok(&p, 0, " ")) {
- if ((acptr = FindUser(name)))
+ if (!(acptr = FindUser(name)))
+ continue;
+ else if (MyUser(acptr))
+ client_report_privs(sptr, acptr);
+ else
+ sendcmdto_one(cptr, CMD_PRIVS, acptr, "%s%s", NumNick(acptr));
+ }
+ }
+
+ return 0;
+}
+
+/** Handle a remote user's privilege query.
+ * @param[in] cptr Client that sent us the message.
+ * @param[in] sptr Original source of message.
+ * @param[in] parc Number of arguments.
+ * @param[in] parv Argument vector.
+ * @see \ref m_functions
+ */
+int ms_privs(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
+{
+ struct Client *acptr;
+ char *numnick, *p = 0;
+ int i;
+
+ if (parc < 2)
+ return protocol_violation(cptr, "PRIVS with no arguments");
+
+ for (i = 1; i < parc; i++) {
+ for (numnick = ircd_strtok(&p, parv[i], " "); numnick;
+ numnick = ircd_strtok(&p, 0, " ")) {
+ if (!(acptr = findNUser(numnick)))
+ continue;
+ else if (MyUser(acptr))
client_report_privs(sptr, acptr);
+ else
+ sendcmdto_one(cptr, CMD_PRIVS, acptr, "%s%s", NumNick(acptr));
}
}
Index: ircu2.10/ircd/parse.c
diff -u ircu2.10/ircd/parse.c:1.49 ircu2.10/ircd/parse.c:1.50
--- ircu2.10/ircd/parse.c:1.49 Sun Mar 20 08:06:29 2005
+++ ircu2.10/ircd/parse.c Fri Apr 1 18:50:15 2005
@@ -19,7 +19,7 @@
*/
/** @file
* @brief Parse input from IRC clients and other servers.
- * @version $Id: parse.c,v 1.49 2005/03/20 16:06:29 entrope Exp $
+ * @version $Id: parse.c,v 1.50 2005/04/02 02:50:15 entrope Exp $
*/
#include "config.h"
@@ -600,7 +600,7 @@
TOK_PRIVS,
0, MAXPARA, MFLG_SLOW, 0, NULL,
/* UNREG, CLIENT, SERVER, OPER, SERVICE */
- { m_unregistered, m_not_oper, m_ignore, mo_privs, m_ignore }
+ { m_unregistered, m_not_oper, ms_privs, mo_privs, m_ignore }
},
{
MSG_ACCOUNT,
----------------------- End of diff -----------------------