2007-01-25 06:40:21 +00:00
|
|
|
/* modules/m_xline.c
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2010-01-07 23:19:03 +00:00
|
|
|
* $Id$
|
2007-01-25 06:40:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdinc.h"
|
|
|
|
#include "send.h"
|
|
|
|
#include "channel.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "class.h"
|
|
|
|
#include "ircd.h"
|
|
|
|
#include "numeric.h"
|
2008-04-03 02:52:01 +00:00
|
|
|
#include "logger.h"
|
2007-01-25 06:40:21 +00:00
|
|
|
#include "s_serv.h"
|
|
|
|
#include "whowas.h"
|
2008-04-20 05:47:38 +00:00
|
|
|
#include "match.h"
|
2007-01-25 06:40:21 +00:00
|
|
|
#include "hash.h"
|
|
|
|
#include "msg.h"
|
|
|
|
#include "parse.h"
|
|
|
|
#include "modules.h"
|
|
|
|
#include "s_conf.h"
|
|
|
|
#include "s_newconf.h"
|
2007-12-08 20:54:51 +00:00
|
|
|
#include "reject.h"
|
2010-01-07 23:19:03 +00:00
|
|
|
#include "bandbi.h"
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
static int mo_xline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
|
|
|
|
static int ms_xline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
|
|
|
|
static int me_xline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
|
2010-01-07 23:19:03 +00:00
|
|
|
static int mo_unxline(struct Client *client_p, struct Client *source_p, int parc,
|
|
|
|
const char *parv[]);
|
|
|
|
static int ms_unxline(struct Client *client_p, struct Client *source_p, int parc,
|
|
|
|
const char *parv[]);
|
|
|
|
static int me_unxline(struct Client *client_p, struct Client *source_p, int parc,
|
|
|
|
const char *parv[]);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
struct Message xline_msgtab = {
|
|
|
|
"XLINE", 0, 0, 0, MFLG_SLOW,
|
|
|
|
{mg_unreg, mg_not_oper, {ms_xline, 5}, {ms_xline, 5}, {me_xline, 5}, {mo_xline, 3}}
|
|
|
|
};
|
2010-01-07 23:19:03 +00:00
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
struct Message unxline_msgtab = {
|
|
|
|
"UNXLINE", 0, 0, 0, MFLG_SLOW,
|
|
|
|
{mg_unreg, mg_not_oper, {ms_unxline, 3}, {ms_unxline, 3}, {me_unxline, 2}, {mo_unxline, 2}}
|
|
|
|
};
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
mapi_clist_av1 xline_clist[] = { &xline_msgtab, &unxline_msgtab, NULL };
|
|
|
|
|
|
|
|
DECLARE_MODULE_AV1(xline, NULL, NULL, xline_clist, NULL, NULL, "$Revision$");
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
static int valid_xline(struct Client *, const char *, const char *);
|
|
|
|
static void apply_xline(struct Client *client_p, const char *name,
|
2007-01-25 06:40:21 +00:00
|
|
|
const char *reason, int temp_time);
|
|
|
|
static void propagate_xline(struct Client *source_p, const char *target,
|
2010-01-07 23:19:03 +00:00
|
|
|
int temp_time, const char *name, const char *type, const char *reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
static void cluster_xline(struct Client *source_p, int temp_time,
|
2010-01-07 23:19:03 +00:00
|
|
|
const char *name, const char *reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
static void handle_remote_xline(struct Client *source_p, int temp_time,
|
|
|
|
const char *name, const char *reason);
|
|
|
|
static void handle_remote_unxline(struct Client *source_p, const char *name);
|
|
|
|
|
2007-11-30 22:35:14 +00:00
|
|
|
static void remove_xline(struct Client *source_p, const char *name);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* m_xline()
|
|
|
|
*
|
|
|
|
* parv[1] - thing to xline
|
|
|
|
* parv[2] - optional type/reason
|
|
|
|
* parv[3] - reason
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
mo_xline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
|
|
|
{
|
|
|
|
struct ConfItem *aconf;
|
|
|
|
const char *name;
|
|
|
|
const char *reason;
|
|
|
|
const char *target_server = NULL;
|
|
|
|
int temp_time;
|
|
|
|
int loc = 1;
|
|
|
|
|
|
|
|
if(!IsOperXline(source_p))
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "xline");
|
2007-01-25 06:40:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-07 23:19:03 +00:00
|
|
|
if(parc >= loc + 2 && !irccmp(parv[loc], "ON"))
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
if(!IsOperRemoteBan(source_p))
|
|
|
|
{
|
|
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS),
|
2010-01-07 23:19:03 +00:00
|
|
|
me.name, source_p->name, "remoteban");
|
2007-01-25 06:40:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
target_server = parv[loc + 1];
|
2007-01-25 06:40:21 +00:00
|
|
|
loc += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(parc <= loc || EmptyString(parv[loc]))
|
|
|
|
{
|
|
|
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
|
2010-01-07 23:19:03 +00:00
|
|
|
me.name, source_p->name, "XLINE");
|
2007-01-25 06:40:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
reason = parv[loc];
|
|
|
|
|
|
|
|
if(target_server != NULL)
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
propagate_xline(source_p, target_server, temp_time, name, "2", reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
if(!match(target_server, me.name))
|
|
|
|
return 0;
|
|
|
|
}
|
2008-04-01 20:18:48 +00:00
|
|
|
else if(rb_dlink_list_length(&cluster_conf_list) > 0)
|
2010-01-07 23:19:03 +00:00
|
|
|
cluster_xline(source_p, temp_time, name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
if((aconf = find_xline_mask(name)) != NULL)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
sendto_one(source_p, ":%s NOTICE %s :[%s] already X-Lined by [%s] - %s",
|
2010-01-07 23:19:03 +00:00
|
|
|
me.name, source_p->name, name, aconf->name, aconf->passwd);
|
2007-01-25 06:40:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
if(!valid_xline(source_p, name, reason))
|
2007-01-25 06:40:21 +00:00
|
|
|
return 0;
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
apply_xline(source_p, name, reason, temp_time);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ms_xline()
|
|
|
|
*
|
|
|
|
* handles a remote xline
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ms_xline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
/* parv[0] parv[1] parv[2] parv[3] parv[4]
|
|
|
|
* oper target serv xline type reason
|
2007-01-25 06:40:21 +00:00
|
|
|
*/
|
|
|
|
propagate_xline(source_p, parv[1], 0, parv[2], parv[3], parv[4]);
|
|
|
|
|
|
|
|
if(!IsPerson(source_p))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* destined for me? */
|
|
|
|
if(!match(parv[1], me.name))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
handle_remote_xline(source_p, 0, parv[2], parv[4]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
me_xline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
|
|
|
{
|
|
|
|
/* time name type :reason */
|
|
|
|
if(!IsPerson(source_p))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
handle_remote_xline(source_p, atoi(parv[1]), parv[2], parv[4]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-01-07 23:19:03 +00:00
|
|
|
handle_remote_xline(struct Client *source_p, int temp_time, const char *name, const char *reason)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
struct ConfItem *aconf;
|
|
|
|
|
|
|
|
if(!find_shared_conf(source_p->username, source_p->host,
|
2010-01-07 23:19:03 +00:00
|
|
|
source_p->servptr->name,
|
|
|
|
(temp_time > 0) ? SHARED_TXLINE : SHARED_PXLINE))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
if(!valid_xline(source_p, name, reason))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* already xlined */
|
2007-11-25 17:18:07 +00:00
|
|
|
if((aconf = find_xline_mask(name)) != NULL)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one_notice(source_p, ":[%s] already X-Lined by [%s] - %s", name, aconf->name,
|
|
|
|
aconf->passwd);
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
apply_xline(source_p, name, reason, temp_time);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* valid_xline()
|
|
|
|
*
|
2010-01-07 23:19:03 +00:00
|
|
|
* inputs - client xlining, gecos, reason and whether to warn
|
2007-01-25 06:40:21 +00:00
|
|
|
* outputs -
|
|
|
|
* side effects - checks the xline for validity, erroring if needed
|
|
|
|
*/
|
|
|
|
static int
|
2010-01-07 23:19:03 +00:00
|
|
|
valid_xline(struct Client *source_p, const char *gecos, const char *reason)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
if(EmptyString(reason))
|
|
|
|
{
|
|
|
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
|
2010-01-07 23:19:03 +00:00
|
|
|
get_id(&me, source_p), get_id(source_p, source_p), "XLINE");
|
2009-05-08 12:27:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
if(strchr(reason, ':') != NULL)
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one_notice(source_p, ":Invalid character ':' in comment");
|
2007-01-25 06:40:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strchr(reason, '"'))
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one_notice(source_p, ":Invalid character '\"' in comment");
|
2007-01-25 06:40:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!valid_wild_card_simple(gecos))
|
|
|
|
{
|
|
|
|
sendto_one_notice(source_p,
|
|
|
|
":Please include at least %d non-wildcard "
|
|
|
|
"characters with the xline",
|
|
|
|
ConfigFileEntry.min_nonwildcard_simple);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-01-07 23:19:03 +00:00
|
|
|
apply_xline(struct Client *source_p, const char *name, const char *reason, int temp_time)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
struct ConfItem *aconf;
|
|
|
|
|
|
|
|
aconf = make_conf();
|
|
|
|
aconf->status = CONF_XLINE;
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
if(strstr(name, "\\s"))
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
char *tmp = LOCAL_COPY(name);
|
2009-05-08 11:40:09 +00:00
|
|
|
char *orig = tmp;
|
2010-01-07 23:19:03 +00:00
|
|
|
char *new = tmp;
|
|
|
|
|
2009-05-08 11:40:09 +00:00
|
|
|
while(*orig)
|
|
|
|
{
|
|
|
|
if(*orig == '\\' && *(orig + 1) != '\0')
|
|
|
|
{
|
|
|
|
if(*(orig + 1) == 's')
|
|
|
|
{
|
|
|
|
*new++ = ' ';
|
2010-01-07 23:19:03 +00:00
|
|
|
orig += 2;
|
2009-05-08 11:40:09 +00:00
|
|
|
}
|
|
|
|
/* otherwise skip that and the escaped
|
|
|
|
* character after it, so we dont mistake
|
|
|
|
* \\s as \s --fl
|
|
|
|
*/
|
|
|
|
else
|
2010-01-07 23:19:03 +00:00
|
|
|
{
|
2009-05-08 11:40:09 +00:00
|
|
|
*new++ = *orig++;
|
|
|
|
*new++ = *orig++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*new++ = *orig++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*new = '\0';
|
2010-01-07 23:19:03 +00:00
|
|
|
aconf->name = rb_strdup(tmp);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
2010-01-07 23:19:03 +00:00
|
|
|
else
|
|
|
|
aconf->name = rb_strdup(name);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
aconf->passwd = rb_strdup(reason);
|
|
|
|
collapse(aconf->name);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
if(temp_time > 0)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
aconf->hold = rb_current_time() + temp_time;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
|
|
|
"%s added temporary %d min. X-Line for [%s] [%s]",
|
|
|
|
get_oper_name(source_p), temp_time / 60,
|
|
|
|
aconf->name, reason);
|
|
|
|
ilog(L_KLINE, "X %s %d %s %s",
|
|
|
|
get_oper_name(source_p), temp_time / 60, name, reason);
|
|
|
|
sendto_one_notice(source_p, ":Added temporary %d min. X-Line [%s]",
|
|
|
|
temp_time / 60, aconf->name);
|
|
|
|
}
|
|
|
|
else
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s added X-Line for [%s] [%s]",
|
|
|
|
get_oper_name(source_p), aconf->name, aconf->passwd);
|
|
|
|
sendto_one_notice(source_p, ":Added X-Line for [%s] [%s]",
|
|
|
|
aconf->name, aconf->passwd);
|
|
|
|
|
|
|
|
bandb_add(BANDB_XLINE, source_p, aconf->host, NULL, reason, NULL, 0);
|
|
|
|
ilog(L_KLINE, "X %s 0 %s %s", get_oper_name(source_p), name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
2010-01-07 23:19:03 +00:00
|
|
|
|
|
|
|
rb_dlinkAddAlloc(aconf, &xline_conf_list);
|
|
|
|
check_xlines();
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
static void
|
2007-01-25 06:40:21 +00:00
|
|
|
propagate_xline(struct Client *source_p, const char *target,
|
2010-01-07 23:19:03 +00:00
|
|
|
int temp_time, const char *name, const char *type, const char *reason)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
if(!temp_time)
|
|
|
|
{
|
|
|
|
sendto_match_servs(source_p, target, CAP_CLUSTER, NOCAPS,
|
2010-01-07 23:19:03 +00:00
|
|
|
"XLINE %s %s %s :%s", target, name, type, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
sendto_match_servs(source_p, target, CAP_ENCAP, CAP_CLUSTER,
|
2010-01-07 23:19:03 +00:00
|
|
|
"ENCAP %s XLINE %d %s 2 :%s", target, temp_time, name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
sendto_match_servs(source_p, target, CAP_ENCAP, NOCAPS,
|
2010-01-07 23:19:03 +00:00
|
|
|
"ENCAP %s XLINE %d %s %s :%s",
|
|
|
|
target, temp_time, name, type, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
2010-01-07 23:19:03 +00:00
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
static void
|
2010-01-07 23:19:03 +00:00
|
|
|
cluster_xline(struct Client *source_p, int temp_time, const char *name, const char *reason)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
struct remote_conf *shared_p;
|
2008-04-01 20:18:48 +00:00
|
|
|
rb_dlink_node *ptr;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2008-04-01 20:18:48 +00:00
|
|
|
RB_DLINK_FOREACH(ptr, cluster_conf_list.head)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
shared_p = ptr->data;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
sendto_match_servs(source_p, shared_p->server, CAP_CLUSTER, NOCAPS,
|
2010-01-07 23:19:03 +00:00
|
|
|
"XLINE %s %s 2 :%s", shared_p->server, name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
sendto_match_servs(source_p, shared_p->server, CAP_ENCAP, CAP_CLUSTER,
|
2010-01-07 23:19:03 +00:00
|
|
|
"ENCAP %s XLINE 0 %s 2 :%s",
|
|
|
|
shared_p->server, name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
else if(shared_p->flags & SHARED_TXLINE)
|
|
|
|
sendto_match_servs(source_p, shared_p->server, CAP_ENCAP, NOCAPS,
|
2010-01-07 23:19:03 +00:00
|
|
|
"ENCAP %s XLINE %d %s 2 :%s",
|
|
|
|
shared_p->server, temp_time, name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mo_unxline()
|
|
|
|
*
|
|
|
|
* parv[1] - thing to unxline
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
mo_unxline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
|
|
|
{
|
|
|
|
if(!IsOperXline(source_p))
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "xline");
|
2007-01-25 06:40:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(parc == 4 && !(irccmp(parv[2], "ON")))
|
|
|
|
{
|
|
|
|
if(!IsOperRemoteBan(source_p))
|
|
|
|
{
|
|
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS),
|
2010-01-07 23:19:03 +00:00
|
|
|
me.name, source_p->name, "remoteban");
|
2007-01-25 06:40:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
propagate_generic(source_p, "UNXLINE", parv[3], CAP_CLUSTER, "%s", parv[1]);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
if(match(parv[3], me.name) == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
2008-04-01 20:18:48 +00:00
|
|
|
else if(rb_dlink_list_length(&cluster_conf_list))
|
2010-01-07 23:19:03 +00:00
|
|
|
cluster_generic(source_p, "UNXLINE", SHARED_UNXLINE, CAP_CLUSTER, "%s", parv[1]);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
remove_xline(source_p, parv[1]);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ms_unxline()
|
|
|
|
*
|
|
|
|
* handles a remote unxline
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ms_unxline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
/* parv[0] parv[1] parv[2]
|
|
|
|
* oper target server gecos
|
2007-01-25 06:40:21 +00:00
|
|
|
*/
|
2010-01-07 23:19:03 +00:00
|
|
|
propagate_generic(source_p, "UNXLINE", parv[1], CAP_CLUSTER, "%s", parv[2]);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
if(!match(parv[1], me.name))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if(!IsPerson(source_p))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
handle_remote_unxline(source_p, parv[2]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
me_unxline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
|
|
|
{
|
|
|
|
/* name */
|
|
|
|
if(!IsPerson(source_p))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
handle_remote_unxline(source_p, parv[1]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
handle_remote_unxline(struct Client *source_p, const char *name)
|
|
|
|
{
|
|
|
|
if(!find_shared_conf(source_p->username, source_p->host,
|
2010-01-07 23:19:03 +00:00
|
|
|
source_p->servptr->name, SHARED_UNXLINE))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
remove_xline(source_p, name);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-30 22:35:14 +00:00
|
|
|
static void
|
2007-11-30 13:10:24 +00:00
|
|
|
remove_xline(struct Client *source_p, const char *name)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
struct ConfItem *aconf;
|
2008-04-01 20:18:48 +00:00
|
|
|
rb_dlink_node *ptr;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2008-04-01 20:18:48 +00:00
|
|
|
RB_DLINK_FOREACH(ptr, xline_conf_list.head)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
aconf = ptr->data;
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
if(!irccmp(aconf->name, name))
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
if(!aconf->hold)
|
2007-11-30 13:10:24 +00:00
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
bandb_del(BANDB_XLINE, aconf->host, NULL);
|
|
|
|
|
|
|
|
sendto_one_notice(source_p, ":X-Line for [%s] is removed", aconf->host);
|
|
|
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
|
|
|
"%s has removed the X-Line for: [%s]",
|
|
|
|
get_oper_name(source_p), aconf->host);
|
|
|
|
ilog(L_KLINE, "UX %s %s", get_oper_name(source_p), aconf->host);
|
2007-11-30 13:10:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one_notice(source_p, ":X-Line for [%s] is removed", name);
|
2007-11-30 13:10:24 +00:00
|
|
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
2010-01-07 23:19:03 +00:00
|
|
|
"%s has removed the temporary X-Line for: [%s]",
|
|
|
|
get_oper_name(source_p), name);
|
|
|
|
ilog(L_KLINE, "UX %s %s", get_oper_name(source_p), name);
|
2007-11-30 13:10:24 +00:00
|
|
|
}
|
2010-01-07 23:19:03 +00:00
|
|
|
|
2007-12-08 20:54:51 +00:00
|
|
|
remove_reject_mask(aconf->name, NULL);
|
2007-01-25 06:40:21 +00:00
|
|
|
free_conf(aconf);
|
2008-04-01 20:54:08 +00:00
|
|
|
rb_dlinkDestroy(ptr, &xline_conf_list);
|
2007-11-30 22:35:14 +00:00
|
|
|
return;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one_notice(source_p, ":No X-Line for %s", name);
|
2007-11-30 13:10:24 +00:00
|
|
|
|
2007-11-30 22:35:14 +00:00
|
|
|
return;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|