From: Kevin L. Mitchell Date: Mon, 16 Apr 2001 19:45:08 +0000 (+0000) Subject: Author: Kev X-Git-Url: http://git.pk910.de/?a=commitdiff_plain;h=07a0f72be3fe8b86abdf5e05313ddb87666e6bda;p=ircu2.10.12-pk.git Author: Kev 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 --- diff --git a/ChangeLog b/ChangeLog index 893eb71..a8a5ab0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2001-04-16 Kevin L. Mitchell + + * 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 * ircd/os_openbsd.c: Tweaked the openbsd hack a bit. diff --git a/include/handlers.h b/include/handlers.h index d76b2d3..3f5cb1b 100644 --- a/include/handlers.h +++ b/include/handlers.h @@ -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 */ diff --git a/include/msg.h b/include/msg.h index 66c5bb5..a41acc1 100644 --- a/include/msg.h +++ b/include/msg.h @@ -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 diff --git a/ircd/Makefile.in b/ircd/Makefile.in index da39d2e..c5adb7f 100644 --- a/ircd/Makefile.in +++ b/ircd/Makefile.in @@ -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 \ diff --git a/ircd/m_admin.c b/ircd/m_admin.c index a6bbcce..d7d3a8b 100644 --- a/ircd/m_admin.c +++ b/ircd/m_admin.c @@ -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" diff --git a/ircd/m_desynch.c b/ircd/m_desynch.c index dcb7e22..a0e99d0 100644 --- a/ircd/m_desynch.c +++ b/ircd/m_desynch.c @@ -112,8 +112,8 @@ 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"); diff --git a/ircd/m_wallops.c b/ircd/m_wallops.c index 865fed8..d71f7e0 100644 --- a/ircd/m_wallops.c +++ b/ircd/m_wallops.c @@ -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 index 0000000..e23eb73 --- /dev/null +++ b/ircd/m_wallusers.c @@ -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 + + +/* + * 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; +} + diff --git a/ircd/parse.c b/ircd/parse.c index 152ef99..09cdaf8 100644 --- a/ircd/parse.c +++ b/ircd/parse.c @@ -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, diff --git a/ircd/send.c b/ircd/send.c index 8361dcc..2c9fb7b 100644 --- a/ircd/send.c +++ b/ircd/send.c @@ -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 */