+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.
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*[]);
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 */
#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
m_version.c \
m_wallchops.c \
m_wallops.c \
+ m_wallusers.c \
m_who.c \
m_whois.c \
m_whowas.c \
#include "handlers.h"
#endif /* 0 */
#include "client.h"
+#include "hash.h"
+#include "ircd.h"
#include "ircd_reply.h"
#include "msg.h"
#include "numeric.h"
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");
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;
}
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 */
-
--- /dev/null
+/*
+ * 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;
+}
+
/* 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,
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;
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 */