2007-01-25 07:40:21 +01:00
|
|
|
/*
|
|
|
|
* Charybdis: an advanced Internet Relay Chat Daemon(ircd).
|
|
|
|
* m_omode.c: allows oper mode hacking
|
|
|
|
*
|
|
|
|
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
|
|
|
* Copyright (C) 1996-2002 Hybrid Development Team
|
|
|
|
* Copyright (C) 2002-2004 ircd-ratbox development team
|
|
|
|
* Copyright (C) 2006 Charybdis development team
|
|
|
|
*
|
|
|
|
* 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 2 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*/
|
|
|
|
|
2016-08-13 05:05:54 +02:00
|
|
|
using namespace ircd;
|
|
|
|
|
2016-03-09 08:29:41 +01:00
|
|
|
static const char omode_desc[] = "Allow admins to forcibly change modes on channels with the OMODE command";
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void mo_omode(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
struct Message omode_msgtab = {
|
2016-02-19 23:42:40 +01:00
|
|
|
"OMODE", 0, 0, 0, 0,
|
2007-01-25 07:40:21 +01:00
|
|
|
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_omode, 3}}
|
|
|
|
};
|
|
|
|
|
|
|
|
mapi_clist_av1 omode_clist[] = { &omode_msgtab, NULL };
|
|
|
|
|
2016-03-07 10:40:51 +01:00
|
|
|
DECLARE_MODULE_AV2(omode, NULL, NULL, omode_clist, NULL, NULL, NULL, NULL, omode_desc);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* mo_omode - MODE command handler
|
|
|
|
* parv[1] - channel
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
mo_omode(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-18 07:33:38 +02:00
|
|
|
chan::chan *chptr = NULL;
|
|
|
|
chan::membership *msptr;
|
2007-01-25 07:40:21 +01:00
|
|
|
char params[512];
|
|
|
|
int i;
|
|
|
|
int wasonchannel;
|
|
|
|
|
|
|
|
/* admins only */
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!IsOperAdmin(&source))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, form_str(ERR_NOPRIVS), me.name, source.name, "admin");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Now, try to find the channel in question */
|
2016-08-19 01:53:12 +02:00
|
|
|
if(!rfc1459::is_chan_prefix(parv[1][0]) || !chan::valid_name(parv[1]))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, ERR_BADCHANNAME,
|
2007-01-25 07:40:21 +01:00
|
|
|
form_str(ERR_BADCHANNAME), parv[1]);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-20 04:51:37 +02:00
|
|
|
chptr = chan::get(parv[1], std::nothrow);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(chptr == NULL)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, ERR_NOSUCHCHANNEL,
|
2007-01-25 07:40:21 +01:00
|
|
|
form_str(ERR_NOSUCHCHANNEL), parv[1]);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Now know the channel exists */
|
2016-08-23 02:37:07 +02:00
|
|
|
msptr = get(chptr->members, source, std::nothrow);
|
2007-01-25 07:40:21 +01:00
|
|
|
wasonchannel = msptr != NULL;
|
|
|
|
|
|
|
|
if (is_chanop(msptr))
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":Use a normal MODE you idiot");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
params[0] = '\0';
|
|
|
|
for (i = 2; i < parc; i++)
|
|
|
|
{
|
|
|
|
if (i != 2)
|
2008-04-20 06:44:04 +02:00
|
|
|
rb_strlcat(params, " ", sizeof params);
|
|
|
|
rb_strlcat(params, parv[i], sizeof params);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-24 00:25:09 +02:00
|
|
|
sendto_wallops_flags(umode::WALLOP, &me,
|
2007-01-25 07:40:21 +01:00
|
|
|
"OMODE called for [%s] [%s] by %s!%s@%s",
|
2016-08-23 02:37:07 +02:00
|
|
|
parv[1], params, source.name, source.username, source.host);
|
2007-01-25 07:40:21 +01:00
|
|
|
ilog(L_MAIN, "OMODE called for [%s] [%s] by %s",
|
2016-08-23 02:37:07 +02:00
|
|
|
parv[1], params, get_oper_name(&source));
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
if(chptr->name[0] != '&')
|
2014-03-03 05:25:47 +01:00
|
|
|
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
|
2007-01-25 07:40:21 +01:00
|
|
|
":%s WALLOPS :OMODE called for [%s] [%s] by %s!%s@%s",
|
2016-08-23 02:37:07 +02:00
|
|
|
me.name, parv[1], params, source.name, source.username,
|
|
|
|
source.host);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
#if 0
|
2016-08-23 02:37:07 +02:00
|
|
|
set_channel_mode(&client, source.servptr, chptr, msptr,
|
2007-01-25 07:40:21 +01:00
|
|
|
parc - 2, parv + 2);
|
|
|
|
#else
|
2016-08-23 02:37:07 +02:00
|
|
|
if (parc == 4 && !strcmp(parv[2], "+o") && !irccmp(parv[3], source.name))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
/* Opping themselves */
|
|
|
|
if (!wasonchannel)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_numeric(&source, ERR_USERNOTINCHANNEL,
|
2016-08-18 07:33:38 +02:00
|
|
|
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->name.c_str());
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
2016-08-18 07:33:38 +02:00
|
|
|
sendto_channel_local(chan::ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
|
2016-08-23 02:37:07 +02:00
|
|
|
me.name, parv[1], source.name);
|
2007-01-25 07:40:21 +01:00
|
|
|
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
|
|
|
|
":%s TMODE %ld %s +o %s",
|
|
|
|
me.id, (long) chptr->channelts, parv[1],
|
2016-08-23 02:37:07 +02:00
|
|
|
source.id);
|
2016-08-18 07:33:38 +02:00
|
|
|
msptr->flags |= chan::CHANOP;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Hack it so set_channel_mode() will accept */
|
|
|
|
if (wasonchannel)
|
2016-08-18 07:33:38 +02:00
|
|
|
msptr->flags |= chan::CHANOP;
|
2007-01-25 07:40:21 +01:00
|
|
|
else
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
add(*chptr, source, chan::CHANOP);
|
|
|
|
msptr = get(chptr->members, source, std::nothrow);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
2016-08-23 02:37:07 +02:00
|
|
|
set_channel_mode(&client, &source, chptr, msptr,
|
2007-01-25 07:40:21 +01:00
|
|
|
parc - 2, parv + 2);
|
|
|
|
/* We know they were not opped before and they can't have opped
|
|
|
|
* themselves as set_channel_mode() does not allow that
|
|
|
|
* -- jilles */
|
|
|
|
if (wasonchannel)
|
2016-08-18 07:33:38 +02:00
|
|
|
msptr->flags &= ~chan::CHANOP;
|
2007-01-25 07:40:21 +01:00
|
|
|
else
|
2016-08-20 02:32:26 +02:00
|
|
|
del(*chptr, get_client(*msptr));
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|