2007-01-25 07:40:21 +01:00
|
|
|
/* modules/m_xline.c
|
2014-03-03 05:25:47 +01:00
|
|
|
*
|
2007-01-25 07:40:21 +01:00
|
|
|
* Copyright (C) 2002-2003 Lee Hardy <lee@leeh.co.uk>
|
|
|
|
* Copyright (C) 2002-2005 ircd-ratbox development team
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* 1.Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
* 2.Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3.The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
|
|
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2016-08-13 05:05:54 +02:00
|
|
|
using namespace ircd;
|
|
|
|
|
2016-03-09 08:29:41 +01:00
|
|
|
static const char xline_desc[] =
|
|
|
|
"Provides management of GECOS bans via (UN)XLINE command";
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void mo_xline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[]);
|
|
|
|
static void ms_xline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[]);
|
|
|
|
static void me_xline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[]);
|
|
|
|
static void mo_unxline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc,
|
2010-01-08 00:19:03 +01:00
|
|
|
const char *parv[]);
|
2016-08-23 02:37:07 +02:00
|
|
|
static void ms_unxline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc,
|
2010-01-08 00:19:03 +01:00
|
|
|
const char *parv[]);
|
2016-08-23 02:37:07 +02:00
|
|
|
static void me_unxline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc,
|
2010-01-08 00:19:03 +01:00
|
|
|
const char *parv[]);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static bool valid_xline(client::client &, const char *, const char *);
|
|
|
|
static void apply_xline(client::client &client, const char *name,
|
2016-03-09 09:00:40 +01:00
|
|
|
const char *reason, int temp_time, bool propagated);
|
2016-08-23 02:37:07 +02:00
|
|
|
static void propagate_xline(client::client &source, const char *target,
|
2010-01-08 00:19:03 +01:00
|
|
|
int temp_time, const char *name, const char *type, const char *reason);
|
2016-08-23 02:37:07 +02:00
|
|
|
static void cluster_xline(client::client &source, int temp_time,
|
2010-01-08 00:19:03 +01:00
|
|
|
const char *name, const char *reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void handle_remote_xline(client::client &source, int temp_time,
|
2007-01-25 07:40:21 +01:00
|
|
|
const char *name, const char *reason);
|
2016-08-23 02:37:07 +02:00
|
|
|
static void handle_remote_unxline(client::client &source, const char *name);
|
|
|
|
static void remove_xline(client::client &source, const char *name,
|
2016-03-09 09:00:40 +01:00
|
|
|
bool propagated);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-03-09 08:29:41 +01:00
|
|
|
struct Message xline_msgtab = {
|
|
|
|
"XLINE", 0, 0, 0, 0,
|
|
|
|
{mg_unreg, mg_not_oper, {ms_xline, 5}, {ms_xline, 5}, {me_xline, 5}, {mo_xline, 3}}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Message unxline_msgtab = {
|
|
|
|
"UNXLINE", 0, 0, 0, 0,
|
|
|
|
{mg_unreg, mg_not_oper, {ms_unxline, 3}, {ms_unxline, 3}, {me_unxline, 2}, {mo_unxline, 2}}
|
|
|
|
};
|
|
|
|
|
|
|
|
mapi_clist_av1 xline_clist[] = { &xline_msgtab, &unxline_msgtab, NULL };
|
|
|
|
|
|
|
|
DECLARE_MODULE_AV2(xline, NULL, NULL, xline_clist, NULL, NULL, NULL, NULL, xline_desc);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/* m_xline()
|
|
|
|
*
|
|
|
|
* parv[1] - thing to xline
|
|
|
|
* parv[2] - optional type/reason
|
|
|
|
* parv[3] - reason
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
mo_xline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
struct ConfItem *aconf;
|
|
|
|
const char *name;
|
|
|
|
const char *reason;
|
|
|
|
const char *target_server = NULL;
|
|
|
|
int temp_time;
|
|
|
|
int loc = 1;
|
2016-03-09 09:00:40 +01:00
|
|
|
bool propagated = ConfigFileEntry.use_propagated_bans;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!IsOperXline(&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, "xline");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if((temp_time = valid_temp_time(parv[loc])) >= 0)
|
|
|
|
loc++;
|
|
|
|
/* we just set temp_time to -1! */
|
|
|
|
else
|
|
|
|
temp_time = 0;
|
|
|
|
|
|
|
|
name = parv[loc];
|
|
|
|
loc++;
|
|
|
|
|
|
|
|
/* XLINE <gecos> ON <server> :<reason> */
|
2010-01-08 00:19:03 +01:00
|
|
|
if(parc >= loc + 2 && !irccmp(parv[loc], "ON"))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!IsOperRemoteBan(&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, "remoteban");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2010-01-08 00:19:03 +01:00
|
|
|
target_server = parv[loc + 1];
|
2007-01-25 07:40:21 +01:00
|
|
|
loc += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(parc <= loc || EmptyString(parv[loc]))
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, form_str(ERR_NEEDMOREPARAMS),
|
|
|
|
me.name, source.name, "XLINE");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
reason = parv[loc];
|
|
|
|
|
|
|
|
if(target_server != NULL)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
propagate_xline(source, target_server, temp_time, name, "2", reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(!match(target_server, me.name))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2010-03-16 23:05:50 +01:00
|
|
|
|
|
|
|
/* Set as local-only. */
|
2016-03-09 09:00:40 +01:00
|
|
|
propagated = false;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
2010-03-16 23:05:50 +01:00
|
|
|
else if(!propagated && rb_dlink_list_length(&cluster_conf_list) > 0)
|
2016-08-23 02:37:07 +02:00
|
|
|
cluster_xline(source, temp_time, name, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2010-01-08 00:19:03 +01:00
|
|
|
if((aconf = find_xline_mask(name)) != NULL)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, ":%s NOTICE %s :[%s] already X-Lined by [%s] - %s",
|
|
|
|
me.name, source.name, name, aconf->host, aconf->passwd);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!valid_xline(source, name, reason))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2010-03-16 23:05:50 +01:00
|
|
|
if(propagated && temp_time == 0)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":Cannot set a permanent global ban");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2010-03-16 23:05:50 +01:00
|
|
|
}
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
apply_xline(source, name, reason, temp_time, propagated);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ms_xline()
|
|
|
|
*
|
|
|
|
* handles a remote xline
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
ms_xline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2010-01-08 00:19:03 +01:00
|
|
|
/* parv[0] parv[1] parv[2] parv[3] parv[4]
|
|
|
|
* oper target serv xline type reason
|
2007-01-25 07:40:21 +01:00
|
|
|
*/
|
2016-08-23 02:37:07 +02:00
|
|
|
propagate_xline(source, parv[1], 0, parv[2], parv[3], parv[4]);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!is_person(source))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/* destined for me? */
|
|
|
|
if(!match(parv[1], me.name))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
handle_remote_xline(source, 0, parv[2], parv[4]);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
me_xline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
/* time name type :reason */
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!is_person(source))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
handle_remote_xline(source, atoi(parv[1]), parv[2], parv[4]);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
handle_remote_xline(client::client &source, int temp_time, const char *name, const char *reason)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
struct ConfItem *aconf;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!find_shared_conf(source.username, source.host,
|
|
|
|
source.servptr->name,
|
2010-01-08 00:19:03 +01:00
|
|
|
(temp_time > 0) ? SHARED_TXLINE : SHARED_PXLINE))
|
2007-01-25 07:40:21 +01:00
|
|
|
return;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!valid_xline(source, name, reason))
|
2007-01-25 07:40:21 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* already xlined */
|
2007-11-25 18:18:07 +01:00
|
|
|
if((aconf = find_xline_mask(name)) != NULL)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":[%s] already X-Lined by [%s] - %s", name, aconf->host,
|
2010-01-08 00:19:03 +01:00
|
|
|
aconf->passwd);
|
2007-01-25 07:40:21 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
apply_xline(source, name, reason, temp_time, false);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* valid_xline()
|
|
|
|
*
|
2010-01-08 00:19:03 +01:00
|
|
|
* inputs - client xlining, gecos, reason and whether to warn
|
2007-01-25 07:40:21 +01:00
|
|
|
* outputs -
|
|
|
|
* side effects - checks the xline for validity, erroring if needed
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static bool
|
2016-08-23 02:37:07 +02:00
|
|
|
valid_xline(client::client &source, const char *gecos, const char *reason)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
if(EmptyString(reason))
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, form_str(ERR_NEEDMOREPARAMS),
|
|
|
|
get_id(&me, &source), get_id(&source, &source), "XLINE");
|
2016-03-09 08:37:03 +01:00
|
|
|
return false;
|
2009-05-08 14:27:30 +02:00
|
|
|
}
|
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
if(!valid_wild_card_simple(gecos))
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source,
|
2007-01-25 07:40:21 +01:00
|
|
|
":Please include at least %d non-wildcard "
|
|
|
|
"characters with the xline",
|
|
|
|
ConfigFileEntry.min_nonwildcard_simple);
|
2016-03-09 08:37:03 +01:00
|
|
|
return false;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
return true;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-08-23 02:37:07 +02:00
|
|
|
apply_xline(client::client &source, const char *name, const char *reason, int temp_time, bool propagated)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
struct ConfItem *aconf;
|
|
|
|
|
|
|
|
aconf = make_conf();
|
|
|
|
aconf->status = CONF_XLINE;
|
2010-02-28 00:46:56 +01:00
|
|
|
aconf->created = rb_current_time();
|
2010-01-08 18:13:47 +01:00
|
|
|
aconf->host = rb_strdup(name);
|
2010-01-08 00:19:03 +01:00
|
|
|
aconf->passwd = rb_strdup(reason);
|
2010-01-08 01:14:15 +01:00
|
|
|
collapse(aconf->host);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
aconf->info.oper = operhash_add(get_oper_name(&source));
|
2010-03-01 01:23:22 +01:00
|
|
|
|
2010-03-16 23:05:50 +01:00
|
|
|
if(propagated)
|
|
|
|
{
|
|
|
|
aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
|
|
|
|
aconf->hold = rb_current_time() + temp_time;
|
|
|
|
aconf->lifetime = aconf->hold;
|
|
|
|
|
|
|
|
replace_old_ban(aconf);
|
|
|
|
rb_dlinkAddAlloc(aconf, &prop_bans);
|
|
|
|
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-03-16 23:05:50 +01:00
|
|
|
"%s added global %d min. X-Line for [%s] [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), temp_time / 60,
|
2010-03-16 23:05:50 +01:00
|
|
|
aconf->host, reason);
|
|
|
|
ilog(L_KLINE, "X %s %d %s %s",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), temp_time / 60, name, reason);
|
|
|
|
sendto_one_notice(&source, ":Added global %d min. X-Line [%s]",
|
2010-03-16 23:05:50 +01:00
|
|
|
temp_time / 60, aconf->host);
|
|
|
|
sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
|
|
|
|
":%s BAN X * %s %lu %d %d * :%s",
|
2016-08-23 02:37:07 +02:00
|
|
|
source.id, aconf->host,
|
2010-03-16 23:05:50 +01:00
|
|
|
(unsigned long)aconf->created,
|
|
|
|
(int)(aconf->hold - aconf->created),
|
|
|
|
(int)(aconf->lifetime - aconf->created),
|
|
|
|
reason);
|
|
|
|
}
|
|
|
|
else if(temp_time > 0)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2010-01-08 00:19:03 +01:00
|
|
|
aconf->hold = rb_current_time() + temp_time;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-01-08 00:19:03 +01:00
|
|
|
"%s added temporary %d min. X-Line for [%s] [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), temp_time / 60,
|
2010-01-08 01:14:15 +01:00
|
|
|
aconf->host, reason);
|
2010-01-08 00:19:03 +01:00
|
|
|
ilog(L_KLINE, "X %s %d %s %s",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), temp_time / 60, name, reason);
|
|
|
|
sendto_one_notice(&source, ":Added temporary %d min. X-Line [%s]",
|
2010-01-08 01:14:15 +01:00
|
|
|
temp_time / 60, aconf->host);
|
2010-01-08 00:19:03 +01:00
|
|
|
}
|
|
|
|
else
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL, "%s added X-Line for [%s] [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), aconf->host, aconf->passwd);
|
|
|
|
sendto_one_notice(&source, ":Added X-Line for [%s] [%s]",
|
2010-01-08 01:14:15 +01:00
|
|
|
aconf->host, aconf->passwd);
|
2010-01-08 00:19:03 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
bandb_add(BANDB_XLINE, &source, aconf->host, NULL, aconf->passwd, NULL, 0);
|
|
|
|
ilog(L_KLINE, "X %s 0 %s %s", get_oper_name(&source), name, aconf->passwd);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
2010-01-08 00:19:03 +01:00
|
|
|
|
|
|
|
rb_dlinkAddAlloc(aconf, &xline_conf_list);
|
2016-08-22 03:57:43 +02:00
|
|
|
client::check_xlines();
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2010-01-08 00:19:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
propagate_xline(client::client &source, const char *target,
|
2010-01-08 00:19:03 +01:00
|
|
|
int temp_time, const char *name, const char *type, const char *reason)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
if(!temp_time)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_match_servs(&source, target, CAP_CLUSTER, NOCAPS,
|
2010-01-08 00:19:03 +01:00
|
|
|
"XLINE %s %s %s :%s", target, name, type, reason);
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_match_servs(&source, target, CAP_ENCAP, CAP_CLUSTER,
|
2010-01-08 00:19:03 +01:00
|
|
|
"ENCAP %s XLINE %d %s 2 :%s", target, temp_time, name, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_match_servs(&source, target, CAP_ENCAP, NOCAPS,
|
2010-01-08 00:19:03 +01:00
|
|
|
"ENCAP %s XLINE %d %s %s :%s",
|
|
|
|
target, temp_time, name, type, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
2010-01-08 00:19:03 +01:00
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
cluster_xline(client::client &source, int temp_time, const char *name, const char *reason)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
struct remote_conf *shared_p;
|
2008-04-01 22:18:48 +02:00
|
|
|
rb_dlink_node *ptr;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2008-04-01 22:18:48 +02:00
|
|
|
RB_DLINK_FOREACH(ptr, cluster_conf_list.head)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-07-13 07:17:21 +02:00
|
|
|
shared_p = (remote_conf *)ptr->data;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/* old protocol cant handle temps, and we dont really want
|
|
|
|
* to convert them to perm.. --fl
|
|
|
|
*/
|
|
|
|
if(!temp_time)
|
|
|
|
{
|
|
|
|
if(!(shared_p->flags & SHARED_PXLINE))
|
|
|
|
continue;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_match_servs(&source, shared_p->server, CAP_CLUSTER, NOCAPS,
|
2010-01-08 00:19:03 +01:00
|
|
|
"XLINE %s %s 2 :%s", shared_p->server, name, reason);
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_match_servs(&source, shared_p->server, CAP_ENCAP, CAP_CLUSTER,
|
2010-01-08 00:19:03 +01:00
|
|
|
"ENCAP %s XLINE 0 %s 2 :%s",
|
|
|
|
shared_p->server, name, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else if(shared_p->flags & SHARED_TXLINE)
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_match_servs(&source, shared_p->server, CAP_ENCAP, NOCAPS,
|
2010-01-08 00:19:03 +01:00
|
|
|
"ENCAP %s XLINE %d %s 2 :%s",
|
|
|
|
shared_p->server, temp_time, name, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mo_unxline()
|
|
|
|
*
|
|
|
|
* parv[1] - thing to unxline
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
mo_unxline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-03-09 09:00:40 +01:00
|
|
|
bool propagated = true;
|
2010-03-16 23:05:50 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!IsOperXline(&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, "xline");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(parc == 4 && !(irccmp(parv[2], "ON")))
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!IsOperRemoteBan(&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, "remoteban");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
propagate_generic(&source, "UNXLINE", parv[3], CAP_CLUSTER, "%s", parv[1]);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(match(parv[3], me.name) == 0)
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2010-03-16 23:05:50 +01:00
|
|
|
|
2016-03-09 09:00:40 +01:00
|
|
|
propagated = false;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
2010-03-16 23:05:50 +01:00
|
|
|
/* cluster{} moved to remove_xline */
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
remove_xline(source, parv[1], propagated);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ms_unxline()
|
|
|
|
*
|
|
|
|
* handles a remote unxline
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
ms_unxline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2010-01-08 00:19:03 +01:00
|
|
|
/* parv[0] parv[1] parv[2]
|
|
|
|
* oper target server gecos
|
2007-01-25 07:40:21 +01:00
|
|
|
*/
|
2016-08-23 02:37:07 +02:00
|
|
|
propagate_generic(&source, "UNXLINE", parv[1], CAP_CLUSTER, "%s", parv[2]);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(!match(parv[1], me.name))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!is_person(source))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
handle_remote_unxline(source, parv[2]);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
me_unxline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
/* name */
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!is_person(source))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
handle_remote_unxline(source, parv[1]);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
handle_remote_unxline(client::client &source, const char *name)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!find_shared_conf(source.username, source.host,
|
|
|
|
source.servptr->name, SHARED_UNXLINE))
|
2007-01-25 07:40:21 +01:00
|
|
|
return;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
remove_xline(source, name, false);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2007-11-30 23:35:14 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
remove_xline(client::client &source, const char *name, bool propagated)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
struct ConfItem *aconf;
|
2008-04-01 22:18:48 +02:00
|
|
|
rb_dlink_node *ptr;
|
2014-09-21 15:02:43 +02:00
|
|
|
time_t now;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2008-04-01 22:18:48 +02:00
|
|
|
RB_DLINK_FOREACH(ptr, xline_conf_list.head)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-07-13 07:17:21 +02:00
|
|
|
aconf = (ConfItem *)ptr->data;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2010-01-08 01:14:15 +01:00
|
|
|
if(!irccmp(aconf->host, name))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2010-03-16 23:05:50 +01:00
|
|
|
if(aconf->lifetime)
|
|
|
|
{
|
|
|
|
if(!propagated)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":Cannot remove global X-Line %s on specific servers", name);
|
2010-03-16 23:05:50 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ptr = rb_dlinkFind(aconf, &prop_bans);
|
|
|
|
if(ptr == NULL)
|
|
|
|
return;
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":X-Line for [%s] is removed", name);
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-03-16 23:05:50 +01:00
|
|
|
"%s has removed the global X-Line for: [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), name);
|
|
|
|
ilog(L_KLINE, "UX %s %s", get_oper_name(&source), name);
|
2014-09-21 15:02:43 +02:00
|
|
|
now = rb_current_time();
|
|
|
|
if(aconf->created < now)
|
|
|
|
aconf->created = now;
|
2010-03-16 23:05:50 +01:00
|
|
|
else
|
|
|
|
aconf->created++;
|
|
|
|
aconf->hold = aconf->created;
|
|
|
|
operhash_delete(aconf->info.oper);
|
2016-08-23 02:37:07 +02:00
|
|
|
aconf->info.oper = operhash_add(get_oper_name(&source));
|
2010-03-16 23:05:50 +01:00
|
|
|
aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
|
|
|
|
sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
|
|
|
|
":%s BAN X * %s %lu %d %d * :*",
|
2016-08-23 02:37:07 +02:00
|
|
|
source.id, aconf->host,
|
2010-03-16 23:05:50 +01:00
|
|
|
(unsigned long)aconf->created,
|
|
|
|
0,
|
|
|
|
(int)(aconf->lifetime - aconf->created));
|
|
|
|
remove_reject_mask(aconf->host, NULL);
|
2014-09-21 15:02:43 +02:00
|
|
|
deactivate_conf(aconf, ptr, now);
|
2010-03-16 23:05:50 +01:00
|
|
|
return;
|
|
|
|
}
|
2010-03-27 16:09:26 +01:00
|
|
|
else if(propagated && rb_dlink_list_length(&cluster_conf_list))
|
2016-08-23 02:37:07 +02:00
|
|
|
cluster_generic(&source, "UNXLINE", SHARED_UNXLINE, CAP_CLUSTER, "%s", name);
|
2010-01-08 00:19:03 +01:00
|
|
|
if(!aconf->hold)
|
2007-11-30 14:10:24 +01:00
|
|
|
{
|
2010-01-08 00:19:03 +01:00
|
|
|
bandb_del(BANDB_XLINE, aconf->host, NULL);
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":X-Line for [%s] is removed", aconf->host);
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-01-08 00:19:03 +01:00
|
|
|
"%s has removed the X-Line for: [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), aconf->host);
|
|
|
|
ilog(L_KLINE, "UX %s %s", get_oper_name(&source), aconf->host);
|
2007-11-30 14:10:24 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":X-Line for [%s] is removed", name);
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-01-08 00:19:03 +01:00
|
|
|
"%s has removed the temporary X-Line for: [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), name);
|
|
|
|
ilog(L_KLINE, "UX %s %s", get_oper_name(&source), name);
|
2007-11-30 14:10:24 +01:00
|
|
|
}
|
2010-01-08 00:19:03 +01:00
|
|
|
|
2010-01-08 01:14:15 +01:00
|
|
|
remove_reject_mask(aconf->host, NULL);
|
2007-01-25 07:40:21 +01:00
|
|
|
free_conf(aconf);
|
2008-04-01 22:54:08 +02:00
|
|
|
rb_dlinkDestroy(ptr, &xline_conf_list);
|
2007-11-30 23:35:14 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-27 16:09:26 +01:00
|
|
|
if(propagated && rb_dlink_list_length(&cluster_conf_list))
|
2016-08-23 02:37:07 +02:00
|
|
|
cluster_generic(&source, "UNXLINE", SHARED_UNXLINE, CAP_CLUSTER, "%s", name);
|
2010-03-16 23:05:50 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":No X-Line for %s", name);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|