Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Mon, 16 Apr 2001 19:45:08 +0000 (19:45 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Mon, 16 Apr 2001 19:45:08 +0000 (19:45 +0000)
Log message:

Implementation of WALLUSERS and the various oper restrictions.  These are
currently not switchable, but it would be trivial to make them switchable
through the features subsystem; future enhancements may do just that.

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@412 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/handlers.h
include/msg.h
ircd/Makefile.in
ircd/m_admin.c
ircd/m_desynch.c
ircd/m_wallops.c
ircd/m_wallusers.c [new file with mode: 0644]
ircd/parse.c
ircd/send.c

index 893eb71248ef2b3c1201475419f5d4889623ee41..a8a5ab07bdbc6590a3c35054102171b3fe515d2b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2001-04-16  Kevin L. Mitchell  <klmitch@mit.edu>
+
+       * ircd/m_admin.c: must include ircd.h to declare "me"; must
+       include hash.h to declare FindUser()
+
+       * ircd/m_wallusers.c: implementation of WALLUSERS
+
+       * ircd/m_desynch.c (ms_desynch): only send DESYNCHs to opers
+
+       * ircd/m_wallops.c: only send WALLOPS to opers
+
+       * ircd/parse.c: add WALLUSERS command to parser table
+
+       * include/handlers.h: declare wallusers handlers
+
+       * include/msg.h: add WALLUSERS command
+
+       * ircd/send.c (sendcmdto_flag_butone): if FLAGS_OPER is or'd with
+       flag, send only to appropriate opers
+
 2001-03-13 Joseph Bongaarts <foxxe@wtfs.net>
        * ircd/os_openbsd.c: Tweaked the openbsd hack a bit.
        
index d76b2d313108ec80431023a8f8802333f8e1c38f..3f5cb1bae11cbd1cc947f1f994eafa18f3c5d86b 100644 (file)
@@ -158,6 +158,7 @@ extern int mo_stats(struct Client*, struct Client*, int, char*[]);
 extern int mo_trace(struct Client*, struct Client*, int, char*[]);
 extern int mo_uping(struct Client*, struct Client*, int, char*[]);
 extern int mo_wallops(struct Client*, struct Client*, int, char*[]);
+extern int mo_wallusers(struct Client*, struct Client*, int, char*[]);
 extern int mr_error(struct Client*, struct Client*, int, char*[]);
 extern int mr_pong(struct Client*, struct Client*, int, char*[]);
 extern int mr_server(struct Client*, struct Client*, int, char*[]);
@@ -206,6 +207,7 @@ extern int ms_uping(struct Client*, struct Client*, int, char*[]);
 extern int ms_version(struct Client*, struct Client*, int, char*[]);
 extern int ms_wallchops(struct Client*, struct Client*, int, char*[]);
 extern int ms_wallops(struct Client*, struct Client*, int, char*[]);
+extern int ms_wallusers(struct Client*, struct Client*, int, char*[]);
 
 
 #endif /* INCLUDED_handlers_h */
index 66c5bb5739621ecf1e325c1728a2b2802a9c2c80..a41acc13ab90bdb75c6965372aad53f4e2beda23 100644 (file)
@@ -154,6 +154,10 @@ struct Client;
 #define TOK_WALLOPS             "WA"
 #define CMD_WALLOPS            MSG_WALLOPS, TOK_WALLOPS
 
+#define MSG_WALLUSERS           "WALLUSERS"     /* WALL */
+#define TOK_WALLUSERS           "WU"
+#define CMD_WALLUSERS          MSG_WALLUSERS, TOK_WALLUSERS
+
 #define MSG_DESYNCH             "DESYNCH"       /* DESY */
 #define TOK_DESYNCH             "DS"
 #define CMD_DESYNCH            MSG_DESYNCH, TOK_DESYNCH
index da39d2ed573fb1f139a2586440aea047ab60ac05..c5adb7fd0a2229b5385d0d16a6880151c77dec31 100644 (file)
@@ -152,6 +152,7 @@ SRC = \
        m_version.c \
        m_wallchops.c \
        m_wallops.c \
+       m_wallusers.c \
        m_who.c \
        m_whois.c \
        m_whowas.c \
index a6bbcce070d32bf5ee137997a448f37d908cbb71..d7d3a8b596149afd7cf1010ae145e27c1a8ad2db 100644 (file)
@@ -88,6 +88,8 @@
 #include "handlers.h"
 #endif /* 0 */
 #include "client.h"
+#include "hash.h"
+#include "ircd.h"
 #include "ircd_reply.h"
 #include "msg.h"
 #include "numeric.h"
index dcb7e22fad99d61f5a2541062f8f5d19b27a00d1..a0e99d047ab6afaaf192ccae2a278cc9c28329fa 100644 (file)
 int ms_desynch(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
   if (parc >= 2)
-    sendcmdto_flag_butone(sptr, CMD_DESYNCH, cptr, FLAGS_DEBUG, ":%s",
-                         parv[parc - 1]);
+    sendcmdto_flag_butone(sptr, CMD_DESYNCH, cptr, FLAGS_DEBUG | FLAGS_OPER,
+                         ":%s", parv[parc - 1]);
   else
     need_more_params(sptr,"DESYNCH");                  
 
index 865fed8625b27f22c0328ba3cd8a9741cad68d29..d71f7e02d601adea24823010455a12d2fb080b76 100644 (file)
@@ -109,7 +109,8 @@ int ms_wallops(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (EmptyString(message))
     return need_more_params(sptr, "WALLOPS");
 
-  sendcmdto_flag_butone(sptr, CMD_WALLOPS, cptr, FLAGS_WALLOP, ":%s", message);
+  sendcmdto_flag_butone(sptr, CMD_WALLOPS, cptr, FLAGS_WALLOP | FLAGS_OPER,
+                       ":%s", message);
   return 0;
 }
 
@@ -125,37 +126,7 @@ int mo_wallops(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (EmptyString(message))
     return need_more_params(sptr, "WALLOPS");
 
-  sendcmdto_flag_butone(sptr, CMD_WALLOPS, 0, FLAGS_WALLOP, ":%s", message);
+  sendcmdto_flag_butone(sptr, CMD_WALLOPS, 0, FLAGS_WALLOP | FLAGS_OPER,
+                       ":%s", message);
   return 0;
 }
-
-  
-#if 0
-/*
- * m_wallops
- *
- * Writes to all +w users currently online
- *
- * parv[0] = sender prefix
- * parv[1] = message text
- */
-int m_wallops(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
-{
-  char *message;
-
-  message = parc > 1 ? parv[1] : 0;
-
-  if (BadPtr(message))
-    return need_more_params(sptr, "WALLOPS");
-
-  if (!IsAnOper(sptr))
-  {
-    sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); /* XXX DEAD */
-    return 0;
-  }
-  sendto_ops_butone(IsServer(cptr) ? cptr : 0, sptr, /* XXX DEAD */
-      ":%s WALLOPS :%s", parv[0], message);
-  return 0;
-}
-#endif /* 0 */
-
diff --git a/ircd/m_wallusers.c b/ircd/m_wallusers.c
new file mode 100644 (file)
index 0000000..e23eb73
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * IRC - Internet Relay Chat, ircd/m_wallusers.c
+ * Copyright (C) 1990 Jarkko Oikarinen and
+ *                    University of Oulu, Computing Center
+ *
+ * See file AUTHORS in IRC package for additional names of
+ * the programmers.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 1, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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_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.
+ */
+#if 0
+/*
+ * No need to include handlers.h here the signatures must match
+ * and we don't need to force a rebuild of all the handlers everytime
+ * we add a new one to the list. --Bleep
+ */
+#include "handlers.h"
+#endif /* 0 */
+#include "client.h"
+#include "ircd_reply.h"
+#include "ircd_string.h"
+#include "msg.h"
+#include "numeric.h"
+#include "send.h"
+
+#include <assert.h>
+
+
+/*
+ * ms_wallusers - server message handler
+ */
+int ms_wallusers(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
+{
+  char *message;
+
+  message = parc > 1 ? parv[1] : 0;
+
+  /*
+   * XXX - PROTOCOL ERROR (shouldn't happen)
+   */
+  if (EmptyString(message))
+    return need_more_params(sptr, "WALLUSERS");
+
+  sendcmdto_flag_butone(sptr, CMD_WALLUSERS, cptr, FLAGS_WALLOP, ":%s",
+                       message);
+  return 0;
+}
+
+/*
+ * mo_wallusers - oper message handler
+ */
+int mo_wallusers(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
+{
+  char *message;
+
+  message = parc > 1 ? parv[1] : 0;
+
+  if (EmptyString(message))
+    return need_more_params(sptr, "WALLUSERS");
+
+  sendcmdto_flag_butone(sptr, CMD_WALLUSERS, 0, FLAGS_WALLOP, ":%s", message);
+  return 0;
+}
+
index 152ef99d02797fbee893434da702cd837a4e1aa5..09cdaf8dbe17f551c438ed26cfae8fd218ea36ea 100644 (file)
@@ -181,6 +181,13 @@ struct Message msgtab[] = {
     /* UNREG, CLIENT, SERVER, OPER, SERVICE */
     { m_unregistered, m_not_oper, ms_wallops, mo_wallops, m_ignore }
   },
+  {
+    MSG_WALLUSERS,
+    TOK_WALLUSERS,
+    0, MAXPARA, MFLG_SLOW, 0,
+    /* UNREG, CLIENT, SERVER, OPER, SERVICE */
+    { m_unregistered, m_not_oper, ms_wallusers, mo_wallusers, m_ignore }
+  },
   {
     MSG_DESYNCH,
     TOK_DESYNCH,
index 8361dcc63e81447b37c6cfce4fd5bf950505fb5e..2c9fb7bc346ddfcc2d39dacf5492259c47aa011c 100644 (file)
@@ -474,6 +474,12 @@ void sendcmdto_flag_butone(struct Client *from, const char *cmd,
   struct Client *cptr;
   struct MsgBuf *user_mb;
   struct MsgBuf *serv_mb;
+  unsigned int oper_fl = 0;
+
+  if (flag & FLAGS_OPER) {
+    flag &= ~FLAGS_OPER;
+    oper_fl++;
+  }
 
   vd.vd_format = pattern;
 
@@ -491,6 +497,7 @@ void sendcmdto_flag_butone(struct Client *from, const char *cmd,
   sentalong_marker++;
   for (cptr = GlobalClientList; cptr; cptr = cli_next(cptr)) {
     if (cli_from(cptr) == one || IsServer(cptr) || !(cli_flags(cptr) & flag) ||
+       (MyConnect(cptr) && oper_fl && !IsAnOper(cptr)) ||
        cli_fd(cli_from(cptr)) < 0 ||
        sentalong[cli_fd(cli_from(cptr))] == sentalong_marker)
       continue; /* skip it */