| 1 |
/*
|
| 2 |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
|
| 3 |
* m_opme.c: Regains ops on opless channels
|
| 4 |
*
|
| 5 |
* Copyright (C) 2002 by the past and present ircd coders, and others.
|
| 6 |
*
|
| 7 |
* This program is free software; you can redistribute it and/or modify
|
| 8 |
* it under the terms of the GNU General Public License as published by
|
| 9 |
* the Free Software Foundation; either version 2 of the License, or
|
| 10 |
* (at your option) any later version.
|
| 11 |
*
|
| 12 |
* This program is distributed in the hope that it will be useful,
|
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
* GNU General Public License for more details.
|
| 16 |
*
|
| 17 |
* You should have received a copy of the GNU General Public License
|
| 18 |
* along with this program; if not, write to the Free Software
|
| 19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
| 20 |
* USA
|
| 21 |
*
|
| 22 |
* $Id: m_opme.c 801 2006-08-30 16:54:25Z adx $
|
| 23 |
*/
|
| 24 |
|
| 25 |
#include "stdinc.h"
|
| 26 |
#include "handlers.h"
|
| 27 |
#include "channel.h"
|
| 28 |
#include "channel_mode.h"
|
| 29 |
#include "client.h"
|
| 30 |
#include "ircd.h"
|
| 31 |
#include "numeric.h"
|
| 32 |
#include "server.h"
|
| 33 |
#include "send.h"
|
| 34 |
#include "whowas.h"
|
| 35 |
#include "hash.h"
|
| 36 |
#include "msg.h"
|
| 37 |
#include "parse.h"
|
| 38 |
#include "conf/modules.h"
|
| 39 |
#include "common.h"
|
| 40 |
#include "user.h"
|
| 41 |
|
| 42 |
// Change to #define to allow /OPME use on any channel, even if it's not opless
|
| 43 |
#undef NO_OPLESS_CHECK
|
| 44 |
|
| 45 |
static void mo_opme(struct Client *, struct Client *, int, char *[]);
|
| 46 |
|
| 47 |
struct Message opme_msgtab = {
|
| 48 |
"OPME", 0, 0, 2, 0, MFLG_SLOW, 0,
|
| 49 |
{ m_unregistered, m_not_oper, m_ignore, m_ignore, mo_opme, m_ignore }
|
| 50 |
};
|
| 51 |
|
| 52 |
INIT_MODULE(m_opme, "$Revision: 801 $")
|
| 53 |
{
|
| 54 |
mod_add_cmd(&opme_msgtab);
|
| 55 |
}
|
| 56 |
|
| 57 |
CLEANUP_MODULE
|
| 58 |
{
|
| 59 |
mod_del_cmd(&opme_msgtab);
|
| 60 |
}
|
| 61 |
|
| 62 |
static int
|
| 63 |
chan_is_opless(const struct Channel *const chptr)
|
| 64 |
{
|
| 65 |
#ifndef NO_OPLESS_CHECK
|
| 66 |
const dlink_node *ptr = NULL;
|
| 67 |
|
| 68 |
DLINK_FOREACH(ptr, chptr->members.head)
|
| 69 |
if (((struct Membership *)ptr->data)->flags & CHFL_CHANOP)
|
| 70 |
return 0;
|
| 71 |
#endif
|
| 72 |
|
| 73 |
return 1;
|
| 74 |
}
|
| 75 |
|
| 76 |
/*! \brief OPME command handler (called for operators only)
|
| 77 |
*
|
| 78 |
* \param client_p Pointer to allocated Client struct with physical connection
|
| 79 |
* to this server, i.e. with an open socket connected.
|
| 80 |
* \param source_p Pointer to allocated Client struct from which the message
|
| 81 |
* originally comes from. This can be a local or remote client.
|
| 82 |
* \param parc Integer holding the number of supplied arguments.
|
| 83 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
|
| 84 |
* pointers.
|
| 85 |
* \note Valid arguments for this command are:
|
| 86 |
* - parv[0] = sender prefix
|
| 87 |
* - parv[1] = channel name
|
| 88 |
*/
|
| 89 |
static void
|
| 90 |
mo_opme(struct Client *client_p, struct Client *source_p,
|
| 91 |
int parc, char *parv[])
|
| 92 |
{
|
| 93 |
struct Channel *chptr = NULL;
|
| 94 |
struct Membership *member = NULL;
|
| 95 |
|
| 96 |
if (!IsAdmin(source_p))
|
| 97 |
{
|
| 98 |
sendto_one(source_p, form_str(ERR_NOPRIVILEGES),
|
| 99 |
me.name, source_p->name);
|
| 100 |
return;
|
| 101 |
}
|
| 102 |
|
| 103 |
if ((chptr = hash_find_channel(parv[1])) == NULL)
|
| 104 |
{
|
| 105 |
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), me.name,
|
| 106 |
source_p->name, parv[1]);
|
| 107 |
return;
|
| 108 |
}
|
| 109 |
|
| 110 |
if ((member = find_channel_link(source_p, chptr)) == NULL)
|
| 111 |
{
|
| 112 |
sendto_one(source_p, form_str(ERR_NOTONCHANNEL), me.name,
|
| 113 |
source_p->name, chptr->chname);
|
| 114 |
return;
|
| 115 |
}
|
| 116 |
|
| 117 |
if (!chan_is_opless(chptr))
|
| 118 |
{
|
| 119 |
sendto_one(source_p, ":%s NOTICE %s :%s Channel is not opless",
|
| 120 |
me.name, source_p->name, chptr->chname);
|
| 121 |
return;
|
| 122 |
}
|
| 123 |
|
| 124 |
AddMemberFlag(member, CHFL_CHANOP);
|
| 125 |
|
| 126 |
if (*parv[1] == '&')
|
| 127 |
sendto_wallops_flags(UMODE_LOCOPS, &me, "OPME called for [%s] by %s",
|
| 128 |
chptr->chname, get_oper_name(source_p));
|
| 129 |
else
|
| 130 |
{
|
| 131 |
sendto_wallops_flags(UMODE_WALLOP, &me, "OPME called for [%s] by %s",
|
| 132 |
chptr->chname, get_oper_name(source_p));
|
| 133 |
sendto_server(NULL, source_p, NULL, NOCAPS, NOCAPS,
|
| 134 |
":%s WALLOPS :OPME called for [%s] by %s",
|
| 135 |
me.name, chptr->chname, get_oper_name(source_p));
|
| 136 |
}
|
| 137 |
|
| 138 |
ilog(L_NOTICE, "OPME called for [%s] by %s",
|
| 139 |
chptr->chname, get_oper_name(source_p));
|
| 140 |
|
| 141 |
sendto_server(NULL, source_p, chptr, CAP_TS6, NOCAPS,
|
| 142 |
":%s PART %s", ID(source_p), chptr->chname);
|
| 143 |
sendto_server(NULL, source_p, chptr, NOCAPS, CAP_TS6,
|
| 144 |
":%s PART %s", source_p->name, chptr->chname);
|
| 145 |
sendto_server(NULL, source_p, chptr, CAP_TS6, NOCAPS,
|
| 146 |
":%s SJOIN %lu %s + :@%s",
|
| 147 |
me.id, (unsigned long)chptr->channelts,
|
| 148 |
chptr->chname, ID(source_p));
|
| 149 |
sendto_server(NULL, source_p, chptr, NOCAPS, CAP_TS6,
|
| 150 |
":%s SJOIN %lu %s + :@%s",
|
| 151 |
me.name, (unsigned long)chptr->channelts,
|
| 152 |
chptr->chname, source_p->name);
|
| 153 |
|
| 154 |
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s MODE %s +o %s",
|
| 155 |
me.name, chptr->chname, source_p->name);
|
| 156 |
}
|