2011-08-13 01:27:52 +00:00
|
|
|
/*
|
2020-10-15 14:51:12 +00:00
|
|
|
* Solanum: a slightly advanced ircd
|
2011-08-13 01:27:52 +00:00
|
|
|
* chmode.c: channel mode management
|
|
|
|
*
|
2014-03-03 04:25:47 +00:00
|
|
|
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
|
|
|
* Copyright (C) 1996-2002 Hybrid Development Team
|
|
|
|
* Copyright (C) 2002-2005 ircd-ratbox development team
|
2011-08-13 01:27:52 +00:00
|
|
|
* Copyright (C) 2005-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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdinc.h"
|
|
|
|
#include "channel.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "hash.h"
|
|
|
|
#include "hook.h"
|
|
|
|
#include "match.h"
|
|
|
|
#include "ircd.h"
|
|
|
|
#include "numeric.h"
|
|
|
|
#include "s_serv.h" /* captab */
|
|
|
|
#include "s_user.h"
|
|
|
|
#include "send.h"
|
|
|
|
#include "whowas.h"
|
|
|
|
#include "s_conf.h" /* ConfigFileEntry, ConfigChannel */
|
|
|
|
#include "s_newconf.h"
|
|
|
|
#include "logger.h"
|
|
|
|
#include "chmode.h"
|
2013-09-10 05:35:56 +00:00
|
|
|
#include "s_assert.h"
|
2016-01-12 04:40:32 +00:00
|
|
|
#include "parse.h"
|
2020-11-05 16:31:57 +00:00
|
|
|
#include "msgbuf.h"
|
2020-11-30 09:24:32 +00:00
|
|
|
#include "packet.h"
|
2011-08-13 01:27:52 +00:00
|
|
|
|
|
|
|
/* bitmasks for error returns, so we send once per call */
|
|
|
|
#define SM_ERR_NOTS 0x00000001 /* No TS on channel */
|
|
|
|
#define SM_ERR_NOOPS 0x00000002 /* No chan ops */
|
|
|
|
#define SM_ERR_UNKNOWN 0x00000004
|
|
|
|
#define SM_ERR_RPL_C 0x00000008
|
|
|
|
#define SM_ERR_RPL_B 0x00000010
|
|
|
|
#define SM_ERR_RPL_E 0x00000020
|
|
|
|
#define SM_ERR_NOTONCHANNEL 0x00000040 /* Not on channel */
|
|
|
|
#define SM_ERR_RPL_I 0x00000100
|
|
|
|
#define SM_ERR_RPL_D 0x00000200
|
|
|
|
#define SM_ERR_NOPRIVS 0x00000400
|
|
|
|
#define SM_ERR_RPL_Q 0x00000800
|
|
|
|
#define SM_ERR_RPL_F 0x00001000
|
|
|
|
#define SM_ERR_MLOCK 0x00002000
|
|
|
|
|
|
|
|
#define MAXMODES_SIMPLE 46 /* a-zA-Z except bqeIov */
|
|
|
|
|
|
|
|
static struct ChModeChange mode_changes[BUFSIZE];
|
|
|
|
static int mode_count;
|
|
|
|
static int mask_pos;
|
|
|
|
static int removed_mask_pos;
|
|
|
|
|
|
|
|
char cflagsbuf[256];
|
|
|
|
char cflagsmyinfo[256];
|
|
|
|
|
|
|
|
int chmode_flags[256];
|
2008-07-27 08:10:48 +00:00
|
|
|
|
2010-12-07 04:57:28 +00:00
|
|
|
extern int h_get_channel_access;
|
|
|
|
|
2008-06-25 03:13:58 +00:00
|
|
|
/* OPTIMIZE ME! -- dwr */
|
2008-06-24 16:45:19 +00:00
|
|
|
void
|
2010-03-31 23:16:16 +00:00
|
|
|
construct_cflags_strings(void)
|
2008-06-24 16:45:19 +00:00
|
|
|
{
|
|
|
|
int i;
|
2008-06-25 03:51:32 +00:00
|
|
|
char *ptr = cflagsbuf;
|
|
|
|
char *ptr2 = cflagsmyinfo;
|
2014-03-03 04:25:47 +00:00
|
|
|
|
2008-06-25 03:51:32 +00:00
|
|
|
*ptr = '\0';
|
|
|
|
*ptr2 = '\0';
|
2008-06-24 16:45:19 +00:00
|
|
|
|
|
|
|
for(i = 0; i < 256; i++)
|
|
|
|
{
|
2020-11-02 23:07:31 +00:00
|
|
|
if (chmode_table[i].set_func != chm_ban &&
|
|
|
|
chmode_table[i].set_func != chm_forward &&
|
|
|
|
chmode_table[i].set_func != chm_throttle &&
|
|
|
|
chmode_table[i].set_func != chm_key &&
|
|
|
|
chmode_table[i].set_func != chm_limit &&
|
|
|
|
chmode_table[i].set_func != chm_op &&
|
|
|
|
chmode_table[i].set_func != chm_voice)
|
2008-06-24 16:45:19 +00:00
|
|
|
{
|
|
|
|
chmode_flags[i] = chmode_table[i].mode_type;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
chmode_flags[i] = 0;
|
|
|
|
}
|
2014-03-03 04:25:47 +00:00
|
|
|
|
2008-06-25 03:51:32 +00:00
|
|
|
switch (chmode_flags[i])
|
|
|
|
{
|
2011-10-24 22:38:27 +00:00
|
|
|
case MODE_FREETARGET:
|
2011-08-13 01:09:13 +00:00
|
|
|
case MODE_DISFORWARD:
|
2011-09-25 14:22:29 +00:00
|
|
|
if(ConfigChannel.use_forward)
|
|
|
|
*ptr++ = (char) i;
|
|
|
|
break;
|
2008-06-25 03:51:32 +00:00
|
|
|
default:
|
|
|
|
if(chmode_flags[i] != 0)
|
|
|
|
{
|
|
|
|
*ptr++ = (char) i;
|
|
|
|
}
|
|
|
|
}
|
2014-03-03 04:25:47 +00:00
|
|
|
|
2008-06-25 03:51:32 +00:00
|
|
|
/* Should we leave orphaned check here? -- dwr */
|
2020-11-02 23:07:31 +00:00
|
|
|
if (chmode_table[i].set_func != NULL &&
|
|
|
|
chmode_table[i].set_func != chm_orphaned)
|
2008-06-25 03:51:32 +00:00
|
|
|
{
|
|
|
|
*ptr2++ = (char) i;
|
|
|
|
}
|
2008-06-24 16:45:19 +00:00
|
|
|
}
|
2014-03-03 04:25:47 +00:00
|
|
|
|
2008-06-25 03:51:32 +00:00
|
|
|
*ptr++ = '\0';
|
|
|
|
*ptr2++ = '\0';
|
2008-06-24 17:26:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* find_umode_slot
|
|
|
|
*
|
|
|
|
* inputs - NONE
|
|
|
|
* outputs - an available cflag bitmask or
|
|
|
|
* 0 if no cflags are available
|
|
|
|
* side effects - NONE
|
|
|
|
*/
|
2010-03-31 23:16:16 +00:00
|
|
|
static unsigned int
|
2008-06-24 17:26:49 +00:00
|
|
|
find_cflag_slot(void)
|
|
|
|
{
|
|
|
|
unsigned int all_cflags = 0, my_cflag = 0, i;
|
|
|
|
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
all_cflags |= chmode_flags[i];
|
|
|
|
|
|
|
|
for (my_cflag = 1; my_cflag && (all_cflags & my_cflag);
|
|
|
|
my_cflag <<= 1);
|
|
|
|
|
|
|
|
return my_cflag;
|
2008-06-24 16:45:19 +00:00
|
|
|
}
|
|
|
|
|
2010-03-31 23:16:16 +00:00
|
|
|
unsigned int
|
|
|
|
cflag_add(char c_, ChannelModeFunc function)
|
|
|
|
{
|
|
|
|
int c = (unsigned char)c_;
|
|
|
|
|
2020-11-02 23:07:31 +00:00
|
|
|
if (chmode_table[c].set_func != NULL &&
|
2010-03-31 23:16:16 +00:00
|
|
|
chmode_table[c].set_func != chm_orphaned)
|
|
|
|
return 0;
|
|
|
|
|
2020-11-08 17:50:17 +00:00
|
|
|
if (chmode_table[c].set_func == NULL)
|
2010-03-31 23:16:16 +00:00
|
|
|
chmode_table[c].mode_type = find_cflag_slot();
|
|
|
|
if (chmode_table[c].mode_type == 0)
|
|
|
|
return 0;
|
|
|
|
chmode_table[c].set_func = function;
|
|
|
|
construct_cflags_strings();
|
|
|
|
return chmode_table[c].mode_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cflag_orphan(char c_)
|
|
|
|
{
|
|
|
|
int c = (unsigned char)c_;
|
|
|
|
|
|
|
|
s_assert(chmode_flags[c] != 0);
|
|
|
|
chmode_table[c].set_func = chm_orphaned;
|
|
|
|
construct_cflags_strings();
|
|
|
|
}
|
|
|
|
|
2010-12-07 06:12:36 +00:00
|
|
|
int
|
2016-01-14 04:16:44 +00:00
|
|
|
get_channel_access(struct Client *source_p, struct Channel *chptr, struct membership *msptr, int dir, const char *modestr)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2010-12-07 04:57:28 +00:00
|
|
|
hook_data_channel_approval moduledata;
|
|
|
|
|
|
|
|
if(!MyClient(source_p))
|
2007-01-25 06:40:21 +00:00
|
|
|
return CHFL_CHANOP;
|
|
|
|
|
2010-12-07 04:57:28 +00:00
|
|
|
moduledata.client = source_p;
|
2016-01-14 04:16:44 +00:00
|
|
|
moduledata.chptr = chptr;
|
2010-12-07 04:57:28 +00:00
|
|
|
moduledata.msptr = msptr;
|
|
|
|
moduledata.target = NULL;
|
2016-01-13 22:56:05 +00:00
|
|
|
moduledata.approved = (msptr != NULL && is_chanop(msptr)) ? CHFL_CHANOP : CHFL_PEON;
|
2015-12-10 07:00:32 +00:00
|
|
|
moduledata.dir = dir;
|
2016-01-12 04:40:32 +00:00
|
|
|
moduledata.modestr = modestr;
|
2011-07-06 17:35:11 +00:00
|
|
|
|
2010-12-07 04:57:28 +00:00
|
|
|
call_hook(h_get_channel_access, &moduledata);
|
|
|
|
|
|
|
|
return moduledata.approved;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
|
2012-06-18 22:33:29 +00:00
|
|
|
/* allow_mode_change()
|
|
|
|
*
|
|
|
|
* Checks if mlock and chanops permit a mode change.
|
|
|
|
*
|
|
|
|
* inputs - client, channel, access level, errors pointer, mode char
|
2016-03-24 18:26:02 +00:00
|
|
|
* outputs - false on failure, true on success
|
2012-06-18 22:33:29 +00:00
|
|
|
* side effects - error message sent on failure
|
|
|
|
*/
|
2016-03-24 18:26:02 +00:00
|
|
|
static bool
|
2012-06-18 22:33:29 +00:00
|
|
|
allow_mode_change(struct Client *source_p, struct Channel *chptr, int alevel,
|
|
|
|
int *errors, char c)
|
|
|
|
{
|
|
|
|
/* If this mode char is locked, don't allow local users to change it. */
|
|
|
|
if (MyClient(source_p) && chptr->mode_lock && strchr(chptr->mode_lock, c))
|
|
|
|
{
|
|
|
|
if (!(*errors & SM_ERR_MLOCK))
|
|
|
|
sendto_one_numeric(source_p,
|
|
|
|
ERR_MLOCKRESTRICTED,
|
|
|
|
form_str(ERR_MLOCKRESTRICTED),
|
|
|
|
chptr->chname,
|
|
|
|
c,
|
|
|
|
chptr->mode_lock);
|
|
|
|
*errors |= SM_ERR_MLOCK;
|
2016-03-24 18:26:02 +00:00
|
|
|
return false;
|
2012-06-18 22:33:29 +00:00
|
|
|
}
|
2016-01-16 07:55:30 +00:00
|
|
|
if(alevel < CHFL_CHANOP)
|
2012-06-18 22:33:29 +00:00
|
|
|
{
|
|
|
|
if(!(*errors & SM_ERR_NOOPS))
|
|
|
|
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
|
|
|
me.name, source_p->name, chptr->chname);
|
|
|
|
*errors |= SM_ERR_NOOPS;
|
2016-03-24 18:26:02 +00:00
|
|
|
return false;
|
2012-06-18 22:33:29 +00:00
|
|
|
}
|
2016-03-24 18:26:02 +00:00
|
|
|
return true;
|
2012-06-18 22:33:29 +00:00
|
|
|
}
|
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
/* add_id()
|
|
|
|
*
|
2011-08-13 00:33:10 +00:00
|
|
|
* inputs - client, channel, id to add, type, forward
|
2016-03-24 18:37:52 +00:00
|
|
|
* outputs - false on failure, true on success
|
2007-01-25 06:40:21 +00:00
|
|
|
* side effects - given id is added to the appropriate list
|
|
|
|
*/
|
2016-03-24 18:37:52 +00:00
|
|
|
bool
|
2011-08-13 00:33:10 +00:00
|
|
|
add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const char *forward,
|
2008-04-01 20:41:52 +00:00
|
|
|
rb_dlink_list * list, long mode_type)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
struct Ban *actualBan;
|
2007-11-07 23:45:14 +00:00
|
|
|
static char who[USERHOST_REPLYLEN];
|
2007-01-25 06:40:21 +00:00
|
|
|
char *realban = LOCAL_COPY(banid);
|
2008-04-01 20:41:52 +00:00
|
|
|
rb_dlink_node *ptr;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2022-04-01 13:26:47 +00:00
|
|
|
/* dont let local clients overflow the banlist */
|
2007-01-25 06:40:21 +00:00
|
|
|
if(MyClient(source_p))
|
|
|
|
{
|
2016-10-28 18:23:21 +00:00
|
|
|
if((rb_dlink_list_length(&chptr->banlist) + rb_dlink_list_length(&chptr->exceptlist) + rb_dlink_list_length(&chptr->invexlist) + rb_dlink_list_length(&chptr->quietlist)) >= (unsigned long)((chptr->mode.mode & MODE_EXLIMIT) ? ConfigChannel.max_bans_large : ConfigChannel.max_bans))
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
sendto_one(source_p, form_str(ERR_BANLISTFULL),
|
|
|
|
me.name, source_p->name, chptr->chname, realban);
|
2016-03-24 18:37:52 +00:00
|
|
|
return false;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-01 13:26:47 +00:00
|
|
|
|
|
|
|
/* don't let anyone set duplicate bans */
|
|
|
|
RB_DLINK_FOREACH(ptr, list->head)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2022-04-01 13:26:47 +00:00
|
|
|
actualBan = ptr->data;
|
|
|
|
if(!irccmp(actualBan->banstr, realban))
|
|
|
|
return false;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(IsPerson(source_p))
|
2016-02-10 01:25:32 +00:00
|
|
|
sprintf(who, "%s!%s@%s", source_p->name, source_p->username, source_p->host);
|
2007-01-25 06:40:21 +00:00
|
|
|
else
|
2008-04-20 04:40:40 +00:00
|
|
|
rb_strlcpy(who, source_p->name, sizeof(who));
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2011-08-13 00:33:10 +00:00
|
|
|
actualBan = allocate_ban(realban, who, forward);
|
2008-04-01 23:53:20 +00:00
|
|
|
actualBan->when = rb_current_time();
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2008-04-01 20:41:52 +00:00
|
|
|
rb_dlinkAdd(actualBan, &actualBan->node, list);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
/* invalidate the can_send() cache */
|
|
|
|
if(mode_type == CHFL_BAN || mode_type == CHFL_QUIET || mode_type == CHFL_EXCEPTION)
|
2016-04-29 23:59:32 +00:00
|
|
|
chptr->bants = rb_current_time();
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2016-03-24 18:37:52 +00:00
|
|
|
return true;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* del_id()
|
|
|
|
*
|
|
|
|
* inputs - channel, id to remove, type
|
2011-08-13 00:33:10 +00:00
|
|
|
* outputs - pointer to ban that was removed, if any
|
|
|
|
* side effects - given id is removed from the appropriate list and returned
|
2007-01-25 06:40:21 +00:00
|
|
|
*/
|
2011-08-13 00:33:10 +00:00
|
|
|
struct Ban *
|
2008-04-01 20:41:52 +00:00
|
|
|
del_id(struct Channel *chptr, const char *banid, rb_dlink_list * list, long mode_type)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2008-04-01 20:41:52 +00:00
|
|
|
rb_dlink_node *ptr;
|
2007-01-25 06:40:21 +00:00
|
|
|
struct Ban *banptr;
|
|
|
|
|
|
|
|
if(EmptyString(banid))
|
2011-08-13 00:33:10 +00:00
|
|
|
return NULL;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2008-04-01 20:43:10 +00:00
|
|
|
RB_DLINK_FOREACH(ptr, list->head)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
banptr = ptr->data;
|
|
|
|
|
|
|
|
if(irccmp(banid, banptr->banstr) == 0)
|
|
|
|
{
|
2008-04-01 20:41:52 +00:00
|
|
|
rb_dlinkDelete(&banptr->node, list);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
/* invalidate the can_send() cache */
|
|
|
|
if(mode_type == CHFL_BAN || mode_type == CHFL_QUIET || mode_type == CHFL_EXCEPTION)
|
2016-04-29 23:59:32 +00:00
|
|
|
chptr->bants = rb_current_time();
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2011-08-13 00:33:10 +00:00
|
|
|
return banptr;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-13 00:33:10 +00:00
|
|
|
return NULL;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check_string()
|
|
|
|
*
|
|
|
|
* input - string to check
|
|
|
|
* output - pointer to 'fixed' string, or "*" if empty
|
|
|
|
* side effects - any white space found becomes \0
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
check_string(char *s)
|
|
|
|
{
|
|
|
|
char *str = s;
|
|
|
|
static char splat[] = "*";
|
|
|
|
if(!(s && *s))
|
|
|
|
return splat;
|
|
|
|
|
|
|
|
for(; *s; ++s)
|
|
|
|
{
|
|
|
|
if(IsSpace(*s))
|
|
|
|
{
|
|
|
|
*s = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* pretty_mask()
|
|
|
|
*
|
|
|
|
* inputs - mask to pretty
|
|
|
|
* outputs - better version of the mask
|
|
|
|
* side effects - mask is chopped to limits, and transformed:
|
|
|
|
* x!y@z => x!y@z
|
|
|
|
* y@z => *!y@z
|
|
|
|
* x!y => x!y@*
|
|
|
|
* x => x!*@*
|
|
|
|
* z.d => *!*@z.d
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
pretty_mask(const char *idmask)
|
|
|
|
{
|
|
|
|
static char mask_buf[BUFSIZE];
|
|
|
|
int old_mask_pos;
|
2014-10-10 21:05:41 +00:00
|
|
|
const char *nick, *user, *host, *forward = NULL;
|
2014-10-17 22:54:34 +00:00
|
|
|
char *t, *at, *ex;
|
2014-10-10 21:05:41 +00:00
|
|
|
int nl, ul, hl, fl;
|
2007-01-25 06:40:21 +00:00
|
|
|
char *mask;
|
2014-10-17 22:54:34 +00:00
|
|
|
size_t masklen;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
mask = LOCAL_COPY(idmask);
|
|
|
|
mask = check_string(mask);
|
|
|
|
collapse(mask);
|
2014-10-17 22:54:34 +00:00
|
|
|
masklen = strlen(mask);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2014-10-10 21:05:41 +00:00
|
|
|
nick = user = host = "*";
|
2014-10-17 22:54:34 +00:00
|
|
|
nl = ul = hl = 1;
|
|
|
|
fl = 0;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2014-10-17 22:54:34 +00:00
|
|
|
if((size_t) BUFSIZE - mask_pos < masklen + 5)
|
2007-01-25 06:40:21 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
old_mask_pos = mask_pos;
|
|
|
|
|
|
|
|
if (*mask == '$')
|
|
|
|
{
|
2014-10-17 22:54:34 +00:00
|
|
|
memcpy(mask_buf + mask_pos, mask, masklen + 1);
|
|
|
|
mask_pos += masklen + 1;
|
2007-01-25 06:40:21 +00:00
|
|
|
t = mask_buf + old_mask_pos + 1;
|
|
|
|
if (*t == '!')
|
|
|
|
*t = '~';
|
|
|
|
if (*t == '~')
|
|
|
|
t++;
|
2016-03-08 01:04:24 +00:00
|
|
|
*t = irctolower(*t);
|
2007-01-25 06:40:21 +00:00
|
|
|
return mask_buf + old_mask_pos;
|
|
|
|
}
|
|
|
|
|
2014-10-17 22:54:34 +00:00
|
|
|
at = ex = NULL;
|
|
|
|
if((t = memchr(mask, '@', masklen)) != NULL)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
at = t;
|
2014-10-17 22:54:34 +00:00
|
|
|
t++;
|
2007-01-25 06:40:21 +00:00
|
|
|
if(*t != '\0')
|
2014-10-17 22:54:34 +00:00
|
|
|
host = t, hl = strlen(t);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2014-10-17 22:54:34 +00:00
|
|
|
if((t = memchr(mask, '!', at - mask)) != NULL)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
ex = t;
|
2014-10-17 22:54:34 +00:00
|
|
|
t++;
|
|
|
|
if(at != t)
|
|
|
|
user = t, ul = at - t;
|
|
|
|
if(ex != mask)
|
|
|
|
nick = mask, nl = ex - mask;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-17 22:54:34 +00:00
|
|
|
if(at != mask)
|
|
|
|
user = mask, ul = at - mask;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
2011-08-13 00:33:10 +00:00
|
|
|
|
2014-10-17 22:54:34 +00:00
|
|
|
if((t = memchr(host, '!', hl)) != NULL ||
|
|
|
|
(t = memchr(host, '$', hl)) != NULL)
|
2011-08-13 00:33:10 +00:00
|
|
|
{
|
2014-10-17 22:54:34 +00:00
|
|
|
t++;
|
|
|
|
if (host + hl != t)
|
|
|
|
forward = t, fl = host + hl - t;
|
|
|
|
hl = t - 1 - host;
|
2011-08-13 00:33:10 +00:00
|
|
|
}
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
2014-10-17 22:54:34 +00:00
|
|
|
else if((t = memchr(mask, '!', masklen)) != NULL)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
ex = t;
|
2014-10-17 22:54:34 +00:00
|
|
|
t++;
|
|
|
|
if(ex != mask)
|
|
|
|
nick = mask, nl = ex - mask;
|
2007-01-25 06:40:21 +00:00
|
|
|
if(*t != '\0')
|
2014-10-17 22:54:34 +00:00
|
|
|
user = t, ul = strlen(t);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
2014-10-17 22:54:34 +00:00
|
|
|
else if(memchr(mask, '.', masklen) != NULL ||
|
|
|
|
memchr(mask, ':', masklen) != NULL)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2014-10-17 22:54:34 +00:00
|
|
|
host = mask, hl = masklen;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-17 22:54:34 +00:00
|
|
|
if(masklen > 0)
|
|
|
|
nick = mask, nl = masklen;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* truncate values to max lengths */
|
2014-10-10 21:05:41 +00:00
|
|
|
if(nl > NICKLEN - 1)
|
|
|
|
nl = NICKLEN - 1;
|
|
|
|
if(ul > USERLEN)
|
|
|
|
ul = USERLEN;
|
|
|
|
if(hl > HOSTLEN)
|
|
|
|
hl = HOSTLEN;
|
|
|
|
if(fl > CHANNELLEN)
|
|
|
|
fl = CHANNELLEN;
|
|
|
|
|
|
|
|
memcpy(mask_buf + mask_pos, nick, nl), mask_pos += nl;
|
|
|
|
mask_buf[mask_pos++] = '!';
|
|
|
|
memcpy(mask_buf + mask_pos, user, ul), mask_pos += ul;
|
|
|
|
mask_buf[mask_pos++] = '@';
|
|
|
|
memcpy(mask_buf + mask_pos, host, hl), mask_pos += hl;
|
|
|
|
if (forward) {
|
|
|
|
mask_buf[mask_pos++] = '$';
|
|
|
|
memcpy(mask_buf + mask_pos, forward, fl), mask_pos += fl;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
2014-10-10 21:05:41 +00:00
|
|
|
mask_buf[mask_pos++] = '\0';
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
return mask_buf + old_mask_pos;
|
|
|
|
}
|
|
|
|
|
2011-12-09 23:40:07 +00:00
|
|
|
/* check_forward()
|
|
|
|
*
|
|
|
|
* input - client, channel to set mode on, target channel name
|
|
|
|
* output - true if forwarding should be allowed
|
|
|
|
* side effects - numeric sent if not allowed
|
|
|
|
*/
|
2016-03-24 18:42:54 +00:00
|
|
|
static bool
|
2011-12-09 23:40:07 +00:00
|
|
|
check_forward(struct Client *source_p, struct Channel *chptr,
|
|
|
|
const char *forward)
|
|
|
|
{
|
2016-06-01 20:00:11 +00:00
|
|
|
struct Channel *targptr = NULL;
|
2011-12-09 23:40:07 +00:00
|
|
|
struct membership *msptr;
|
|
|
|
|
|
|
|
if(!check_channel_name(forward) ||
|
|
|
|
(MyClient(source_p) && (strlen(forward) > LOC_CHANNELLEN || hash_find_resv(forward))))
|
|
|
|
{
|
|
|
|
sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), forward);
|
2016-03-24 18:42:54 +00:00
|
|
|
return false;
|
2011-12-09 23:40:07 +00:00
|
|
|
}
|
|
|
|
/* don't forward to inconsistent target -- jilles */
|
|
|
|
if(chptr->chname[0] == '#' && forward[0] == '&')
|
|
|
|
{
|
|
|
|
sendto_one_numeric(source_p, ERR_BADCHANNAME,
|
|
|
|
form_str(ERR_BADCHANNAME), forward);
|
2016-03-24 18:42:54 +00:00
|
|
|
return false;
|
2011-12-09 23:40:07 +00:00
|
|
|
}
|
|
|
|
if(MyClient(source_p) && (targptr = find_channel(forward)) == NULL)
|
|
|
|
{
|
|
|
|
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
|
|
|
|
form_str(ERR_NOSUCHCHANNEL), forward);
|
2016-03-24 18:42:54 +00:00
|
|
|
return false;
|
2011-12-09 23:40:07 +00:00
|
|
|
}
|
|
|
|
if(MyClient(source_p) && !(targptr->mode.mode & MODE_FREETARGET))
|
|
|
|
{
|
|
|
|
if((msptr = find_channel_membership(targptr, source_p)) == NULL ||
|
2016-01-16 07:55:30 +00:00
|
|
|
get_channel_access(source_p, targptr, msptr, MODE_QUERY, NULL) < CHFL_CHANOP)
|
2011-12-09 23:40:07 +00:00
|
|
|
{
|
|
|
|
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
|
|
|
me.name, source_p->name, targptr->chname);
|
2016-03-24 18:42:54 +00:00
|
|
|
return false;
|
2011-12-09 23:40:07 +00:00
|
|
|
}
|
|
|
|
}
|
2016-03-24 18:42:54 +00:00
|
|
|
return true;
|
2011-12-09 23:40:07 +00:00
|
|
|
}
|
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
/* fix_key()
|
|
|
|
*
|
|
|
|
* input - key to fix
|
|
|
|
* output - the same key, fixed
|
|
|
|
* side effects - anything below ascii 13 is discarded, ':' discarded,
|
|
|
|
* high ascii is dropped to lower half of ascii table
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
fix_key(char *arg)
|
|
|
|
{
|
2016-03-23 23:11:42 +00:00
|
|
|
unsigned char *s, *t, c;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2016-03-23 23:11:42 +00:00
|
|
|
for(s = t = (unsigned char *) arg; (c = *s); s++)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
c &= 0x7f;
|
|
|
|
if(c != ':' && c != ',' && c > ' ')
|
|
|
|
*t++ = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
*t = '\0';
|
|
|
|
return arg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fix_key_remote()
|
|
|
|
*
|
|
|
|
* input - key to fix
|
|
|
|
* ouput - the same key, fixed
|
|
|
|
* side effects - high ascii dropped to lower half of table,
|
|
|
|
* CR/LF/':' are dropped
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
fix_key_remote(char *arg)
|
|
|
|
{
|
2016-03-23 23:11:42 +00:00
|
|
|
unsigned char *s, *t, c;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2016-03-23 23:11:42 +00:00
|
|
|
for(s = t = (unsigned char *) arg; (c = *s); s++)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
c &= 0x7f;
|
|
|
|
if((c != 0x0a) && (c != ':') && (c != ',') && (c != 0x0d) && (c != ' '))
|
|
|
|
*t++ = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
*t = '\0';
|
|
|
|
return arg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
chm_simple(struct Client *source_p, struct Channel *chptr,
|
2020-11-05 16:31:57 +00:00
|
|
|
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2012-06-18 22:33:29 +00:00
|
|
|
if(!allow_mode_change(source_p, chptr, alevel, errors, c))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* setting + */
|
2010-04-30 21:01:21 +00:00
|
|
|
if((dir == MODE_ADD) && !(chptr->mode.mode & mode_type))
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2011-09-25 14:22:29 +00:00
|
|
|
/* if +f is disabled, ignore an attempt to set +QF locally */
|
|
|
|
if(!ConfigChannel.use_forward && MyClient(source_p) &&
|
|
|
|
(c == 'Q' || c == 'F'))
|
|
|
|
return;
|
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
chptr->mode.mode |= mode_type;
|
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_ADD;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
2008-06-24 18:00:41 +00:00
|
|
|
mode_changes[mode_count++].arg = NULL;
|
|
|
|
}
|
2010-04-30 21:01:21 +00:00
|
|
|
else if((dir == MODE_DEL) && (chptr->mode.mode & mode_type))
|
2008-06-24 18:00:41 +00:00
|
|
|
{
|
|
|
|
chptr->mode.mode &= ~mode_type;
|
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_DEL;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count++].arg = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
chm_orphaned(struct Client *source_p, struct Channel *chptr,
|
2020-11-05 16:31:57 +00:00
|
|
|
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
|
2008-06-24 18:00:41 +00:00
|
|
|
{
|
|
|
|
if(MyClient(source_p))
|
|
|
|
return;
|
2014-03-03 04:25:47 +00:00
|
|
|
|
2008-06-24 18:00:41 +00:00
|
|
|
if((dir == MODE_ADD) && !(chptr->mode.mode & mode_type))
|
|
|
|
{
|
|
|
|
chptr->mode.mode |= mode_type;
|
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_ADD;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
2007-01-25 06:40:21 +00:00
|
|
|
mode_changes[mode_count++].arg = NULL;
|
|
|
|
}
|
|
|
|
else if((dir == MODE_DEL) && (chptr->mode.mode & mode_type))
|
|
|
|
{
|
|
|
|
chptr->mode.mode &= ~mode_type;
|
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_DEL;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count++].arg = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-13 22:34:27 +00:00
|
|
|
void
|
|
|
|
chm_hidden(struct Client *source_p, struct Channel *chptr,
|
2020-11-05 16:31:57 +00:00
|
|
|
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
|
2016-01-13 22:34:27 +00:00
|
|
|
{
|
2020-01-04 16:14:34 +00:00
|
|
|
if(MyClient(source_p) && !IsOperGeneral(source_p))
|
2016-01-13 22:34:27 +00:00
|
|
|
{
|
|
|
|
if(!(*errors & SM_ERR_NOPRIVS))
|
|
|
|
sendto_one_numeric(source_p, ERR_NOPRIVILEGES, form_str(ERR_NOPRIVILEGES));
|
|
|
|
*errors |= SM_ERR_NOPRIVS;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(MyClient(source_p) && !IsOperAdmin(source_p))
|
|
|
|
{
|
|
|
|
if(!(*errors & SM_ERR_NOPRIVS))
|
|
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name,
|
|
|
|
source_p->name, "admin");
|
|
|
|
*errors |= SM_ERR_NOPRIVS;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* setting + */
|
|
|
|
if((dir == MODE_ADD) && !(chptr->mode.mode & mode_type))
|
|
|
|
{
|
|
|
|
chptr->mode.mode |= mode_type;
|
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_ADD;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count].mems = ONLY_OPERS;
|
|
|
|
mode_changes[mode_count++].arg = NULL;
|
|
|
|
}
|
|
|
|
else if((dir == MODE_DEL) && (chptr->mode.mode & mode_type))
|
|
|
|
{
|
|
|
|
chptr->mode.mode &= ~mode_type;
|
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_DEL;
|
|
|
|
mode_changes[mode_count].mems = ONLY_OPERS;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count++].arg = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
void
|
|
|
|
chm_staff(struct Client *source_p, struct Channel *chptr,
|
2020-11-05 16:31:57 +00:00
|
|
|
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2020-01-04 16:14:34 +00:00
|
|
|
if(MyClient(source_p) && !IsOper(source_p))
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
if(!(*errors & SM_ERR_NOPRIVS))
|
|
|
|
sendto_one_numeric(source_p, ERR_NOPRIVILEGES, form_str(ERR_NOPRIVILEGES));
|
|
|
|
*errors |= SM_ERR_NOPRIVS;
|
|
|
|
return;
|
|
|
|
}
|
2019-07-07 15:51:03 +00:00
|
|
|
if(MyClient(source_p) && !HasPrivilege(source_p, "oper:cmodes"))
|
2007-12-17 23:24:05 +00:00
|
|
|
{
|
|
|
|
if(!(*errors & SM_ERR_NOPRIVS))
|
|
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name,
|
2019-07-07 15:51:03 +00:00
|
|
|
source_p->name, "cmodes");
|
2007-12-17 23:24:05 +00:00
|
|
|
*errors |= SM_ERR_NOPRIVS;
|
|
|
|
return;
|
|
|
|
}
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
/* setting + */
|
|
|
|
if((dir == MODE_ADD) && !(chptr->mode.mode & mode_type))
|
|
|
|
{
|
|
|
|
chptr->mode.mode |= mode_type;
|
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_ADD;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count++].arg = NULL;
|
|
|
|
}
|
|
|
|
else if((dir == MODE_DEL) && (chptr->mode.mode & mode_type))
|
|
|
|
{
|
|
|
|
chptr->mode.mode &= ~mode_type;
|
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_DEL;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count++].arg = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
chm_ban(struct Client *source_p, struct Channel *chptr,
|
2020-11-05 16:31:57 +00:00
|
|
|
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2020-11-05 16:31:57 +00:00
|
|
|
const char *mask;
|
2014-01-26 10:02:07 +00:00
|
|
|
char *forward;
|
2008-04-01 20:41:52 +00:00
|
|
|
rb_dlink_list *list;
|
|
|
|
rb_dlink_node *ptr;
|
2007-01-25 06:40:21 +00:00
|
|
|
struct Ban *banptr;
|
|
|
|
int errorval;
|
2013-02-21 11:44:16 +00:00
|
|
|
const char *rpl_list_p;
|
|
|
|
const char *rpl_endlist_p;
|
2007-01-25 06:40:21 +00:00
|
|
|
int mems;
|
|
|
|
|
|
|
|
switch (mode_type)
|
|
|
|
{
|
|
|
|
case CHFL_BAN:
|
|
|
|
list = &chptr->banlist;
|
|
|
|
errorval = SM_ERR_RPL_B;
|
2013-02-21 11:44:16 +00:00
|
|
|
rpl_list_p = form_str(RPL_BANLIST);
|
|
|
|
rpl_endlist_p = form_str(RPL_ENDOFBANLIST);
|
2007-01-25 06:40:21 +00:00
|
|
|
mems = ALL_MEMBERS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHFL_EXCEPTION:
|
|
|
|
/* if +e is disabled, allow all but +e locally */
|
2020-11-05 16:31:57 +00:00
|
|
|
if (!ConfigChannel.use_except && MyClient(source_p) && dir == MODE_ADD)
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
list = &chptr->exceptlist;
|
|
|
|
errorval = SM_ERR_RPL_E;
|
2013-02-21 11:44:16 +00:00
|
|
|
rpl_list_p = form_str(RPL_EXCEPTLIST);
|
|
|
|
rpl_endlist_p = form_str(RPL_ENDOFEXCEPTLIST);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
if(ConfigChannel.use_except || (dir == MODE_DEL))
|
|
|
|
mems = ONLY_CHANOPS;
|
|
|
|
else
|
|
|
|
mems = ONLY_SERVERS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHFL_INVEX:
|
|
|
|
/* if +I is disabled, allow all but +I locally */
|
2020-11-05 16:31:57 +00:00
|
|
|
if (!ConfigChannel.use_invex && MyClient(source_p) && dir == MODE_ADD)
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
list = &chptr->invexlist;
|
|
|
|
errorval = SM_ERR_RPL_I;
|
2013-02-21 11:44:16 +00:00
|
|
|
rpl_list_p = form_str(RPL_INVITELIST);
|
|
|
|
rpl_endlist_p = form_str(RPL_ENDOFINVITELIST);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
if(ConfigChannel.use_invex || (dir == MODE_DEL))
|
|
|
|
mems = ONLY_CHANOPS;
|
|
|
|
else
|
|
|
|
mems = ONLY_SERVERS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHFL_QUIET:
|
|
|
|
list = &chptr->quietlist;
|
|
|
|
errorval = SM_ERR_RPL_Q;
|
2013-02-21 11:44:16 +00:00
|
|
|
rpl_list_p = form_str(RPL_QUIETLIST);
|
|
|
|
rpl_endlist_p = form_str(RPL_ENDOFQUIETLIST);
|
2007-01-25 06:40:21 +00:00
|
|
|
mems = ALL_MEMBERS;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2020-11-08 19:30:41 +00:00
|
|
|
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "chm_ban() called with unknown type!");
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if (dir == MODE_QUERY)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
if((*errors & errorval) != 0)
|
|
|
|
return;
|
|
|
|
*errors |= errorval;
|
|
|
|
|
|
|
|
/* non-ops cant see +eI lists.. */
|
2012-06-18 22:33:29 +00:00
|
|
|
/* note that this is still permitted if +e/+I are mlocked. */
|
2016-01-16 07:55:30 +00:00
|
|
|
if(alevel < CHFL_CHANOP && mode_type != CHFL_BAN &&
|
2007-01-25 06:40:21 +00:00
|
|
|
mode_type != CHFL_QUIET)
|
|
|
|
{
|
|
|
|
if(!(*errors & SM_ERR_NOOPS))
|
|
|
|
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
|
|
|
me.name, source_p->name, chptr->chname);
|
|
|
|
*errors |= SM_ERR_NOOPS;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-04-01 20:43:10 +00:00
|
|
|
RB_DLINK_FOREACH(ptr, list->head)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2011-08-13 00:33:10 +00:00
|
|
|
char buf[BANLEN];
|
2007-01-25 06:40:21 +00:00
|
|
|
banptr = ptr->data;
|
2011-08-13 00:33:10 +00:00
|
|
|
if(banptr->forward)
|
2016-02-10 01:25:32 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%s$%s", banptr->banstr, banptr->forward);
|
2011-08-13 00:33:10 +00:00
|
|
|
else
|
|
|
|
rb_strlcpy(buf, banptr->banstr, sizeof(buf));
|
|
|
|
|
2013-02-21 11:44:16 +00:00
|
|
|
sendto_one(source_p, rpl_list_p,
|
2007-01-25 06:40:21 +00:00
|
|
|
me.name, source_p->name, chptr->chname,
|
2011-08-13 00:33:10 +00:00
|
|
|
buf, banptr->who, banptr->when);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
2013-02-21 11:44:16 +00:00
|
|
|
sendto_one(source_p, rpl_endlist_p, me.name, source_p->name, chptr->chname);
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if (!allow_mode_change(source_p, chptr, alevel, errors, c))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
2012-06-18 22:33:29 +00:00
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
/* empty ban, or starts with ':' which messes up s2s, ignore it */
|
2020-11-05 16:31:57 +00:00
|
|
|
if (EmptyString(arg) || *arg == ':')
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if (!MyClient(source_p))
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2020-11-05 16:31:57 +00:00
|
|
|
if (strchr(arg, ' '))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
mask = arg;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
else
|
2020-11-05 16:31:57 +00:00
|
|
|
mask = pretty_mask(arg);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2011-09-25 14:25:17 +00:00
|
|
|
/* we'd have problems parsing this, hyb6 does it too
|
|
|
|
* also make sure it will always fit on a line with channel
|
|
|
|
* name etc.
|
|
|
|
*/
|
2016-03-23 14:33:56 +00:00
|
|
|
if(strlen(mask) > MIN(BANLEN, MODEBUFLEN - 5))
|
2011-12-18 22:24:22 +00:00
|
|
|
{
|
|
|
|
sendto_one_numeric(source_p, ERR_INVALIDBAN,
|
|
|
|
form_str(ERR_INVALIDBAN),
|
2020-11-05 16:31:57 +00:00
|
|
|
chptr->chname, c, arg);
|
2011-09-25 14:25:17 +00:00
|
|
|
return;
|
2011-12-18 22:24:22 +00:00
|
|
|
}
|
2011-09-25 14:25:17 +00:00
|
|
|
|
2011-08-13 00:33:10 +00:00
|
|
|
/* Look for a $ after the first character.
|
|
|
|
* As the first character, it marks an extban; afterwards
|
|
|
|
* it delimits a forward channel.
|
|
|
|
*/
|
|
|
|
if ((forward = strchr(mask+1, '$')) != NULL)
|
|
|
|
{
|
|
|
|
*forward++ = '\0';
|
|
|
|
if (*forward == '\0')
|
|
|
|
forward = NULL;
|
|
|
|
}
|
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
/* if we're adding a NEW id */
|
2020-11-05 16:31:57 +00:00
|
|
|
if (dir == MODE_ADD)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
if (*mask == '$' && MyClient(source_p))
|
|
|
|
{
|
|
|
|
if (!valid_extban(mask, source_p, chptr, mode_type))
|
2011-12-18 22:24:22 +00:00
|
|
|
{
|
|
|
|
sendto_one_numeric(source_p, ERR_INVALIDBAN,
|
|
|
|
form_str(ERR_INVALIDBAN),
|
2020-11-05 16:31:57 +00:00
|
|
|
chptr->chname, c, arg);
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
2011-12-18 22:24:22 +00:00
|
|
|
}
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
|
2011-12-09 23:45:57 +00:00
|
|
|
/* For compatibility, only check the forward channel from
|
|
|
|
* local clients. Accept any forward channel from servers.
|
|
|
|
*/
|
2020-11-05 16:31:57 +00:00
|
|
|
if (forward != NULL && MyClient(source_p))
|
2011-12-09 23:45:57 +00:00
|
|
|
{
|
2011-12-11 15:56:37 +00:00
|
|
|
/* For simplicity and future flexibility, do not
|
|
|
|
* allow '$' in forwarding targets.
|
|
|
|
*/
|
2020-11-05 16:31:57 +00:00
|
|
|
if (!ConfigChannel.use_forward ||
|
2011-12-18 22:24:22 +00:00
|
|
|
strchr(forward, '$') != NULL)
|
|
|
|
{
|
|
|
|
sendto_one_numeric(source_p, ERR_INVALIDBAN,
|
|
|
|
form_str(ERR_INVALIDBAN),
|
2020-11-05 16:31:57 +00:00
|
|
|
chptr->chname, c, arg);
|
2011-12-18 22:24:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* check_forward() sends its own error message */
|
2020-11-05 16:31:57 +00:00
|
|
|
if (!check_forward(source_p, chptr, forward))
|
2011-12-11 15:56:37 +00:00
|
|
|
return;
|
2011-12-09 23:58:08 +00:00
|
|
|
/* Forwards only make sense for bans. */
|
2020-11-05 16:31:57 +00:00
|
|
|
if (mode_type != CHFL_BAN)
|
2011-12-18 22:24:22 +00:00
|
|
|
{
|
|
|
|
sendto_one_numeric(source_p, ERR_INVALIDBAN,
|
|
|
|
form_str(ERR_INVALIDBAN),
|
2020-11-05 16:31:57 +00:00
|
|
|
chptr->chname, c, arg);
|
2011-12-09 23:58:08 +00:00
|
|
|
return;
|
2011-12-18 22:24:22 +00:00
|
|
|
}
|
2011-12-09 23:45:57 +00:00
|
|
|
}
|
2011-09-25 14:22:29 +00:00
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
/* dont allow local clients to overflow the banlist, dont
|
|
|
|
* let remote servers set duplicate bans
|
|
|
|
*/
|
2020-11-05 16:31:57 +00:00
|
|
|
if (!add_id(source_p, chptr, mask, forward, list, mode_type))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if (forward)
|
2011-08-13 00:33:10 +00:00
|
|
|
forward[-1]= '$';
|
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_ADD;
|
|
|
|
mode_changes[mode_count].mems = mems;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count++].arg = mask;
|
|
|
|
}
|
2020-11-05 16:31:57 +00:00
|
|
|
else if (dir == MODE_DEL)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2011-08-13 00:33:10 +00:00
|
|
|
struct Ban *removed;
|
|
|
|
static char buf[BANLEN * MAXMODEPARAMS];
|
|
|
|
int old_removed_mask_pos = removed_mask_pos;
|
2020-11-05 16:31:57 +00:00
|
|
|
if ((removed = del_id(chptr, mask, list, mode_type)) == NULL)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2020-11-05 16:31:57 +00:00
|
|
|
/* mask isn't a valid ban, check arg */
|
|
|
|
if ((removed = del_id(chptr, arg, list, mode_type)) != NULL)
|
|
|
|
mask = arg;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if (removed && removed->forward)
|
2022-06-24 04:38:52 +00:00
|
|
|
removed_mask_pos += snprintf(buf + old_removed_mask_pos, sizeof(buf) - old_removed_mask_pos, "%s$%s", removed->banstr, removed->forward) + 1;
|
2011-08-13 00:33:10 +00:00
|
|
|
else
|
2012-02-06 16:38:10 +00:00
|
|
|
removed_mask_pos += rb_strlcpy(buf + old_removed_mask_pos, mask, sizeof(buf)) + 1;
|
2020-11-05 16:31:57 +00:00
|
|
|
if (removed)
|
2011-08-13 00:33:10 +00:00
|
|
|
{
|
|
|
|
free_ban(removed);
|
|
|
|
removed = NULL;
|
|
|
|
}
|
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_DEL;
|
|
|
|
mode_changes[mode_count].mems = mems;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
2011-08-13 00:33:10 +00:00
|
|
|
mode_changes[mode_count++].arg = buf + old_removed_mask_pos;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
chm_op(struct Client *source_p, struct Channel *chptr,
|
2020-11-05 16:31:57 +00:00
|
|
|
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
struct membership *mstptr;
|
|
|
|
struct Client *targ_p;
|
|
|
|
|
2012-06-18 22:33:29 +00:00
|
|
|
if(!allow_mode_change(source_p, chptr, alevel, errors, c))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* empty nick */
|
2020-11-05 16:31:57 +00:00
|
|
|
if(EmptyString(arg))
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
sendto_one_numeric(source_p, ERR_NOSUCHNICK, form_str(ERR_NOSUCHNICK), "*");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if((targ_p = find_chasing(source_p, arg, NULL)) == NULL)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mstptr = find_channel_membership(chptr, targ_p);
|
|
|
|
|
|
|
|
if(mstptr == NULL)
|
|
|
|
{
|
|
|
|
if(!(*errors & SM_ERR_NOTONCHANNEL) && MyClient(source_p))
|
|
|
|
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
|
2020-11-05 16:31:57 +00:00
|
|
|
form_str(ERR_USERNOTINCHANNEL), arg, chptr->chname);
|
2007-01-25 06:40:21 +00:00
|
|
|
*errors |= SM_ERR_NOTONCHANNEL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dir == MODE_ADD)
|
|
|
|
{
|
2010-12-31 01:43:16 +00:00
|
|
|
if(targ_p == source_p && mstptr->flags & CHFL_CHANOP)
|
|
|
|
return;
|
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_ADD;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count].id = targ_p->id;
|
2014-05-29 14:22:58 +00:00
|
|
|
mode_changes[mode_count++].arg = targ_p->name;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
mstptr->flags |= CHFL_CHANOP;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(MyClient(source_p) && IsService(targ_p))
|
|
|
|
{
|
|
|
|
sendto_one(source_p, form_str(ERR_ISCHANSERVICE),
|
|
|
|
me.name, source_p->name, targ_p->name, chptr->chname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_DEL;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count].id = targ_p->id;
|
2014-05-29 14:22:58 +00:00
|
|
|
mode_changes[mode_count++].arg = targ_p->name;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
mstptr->flags &= ~CHFL_CHANOP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
chm_voice(struct Client *source_p, struct Channel *chptr,
|
2020-11-05 16:31:57 +00:00
|
|
|
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
struct membership *mstptr;
|
|
|
|
struct Client *targ_p;
|
|
|
|
|
2012-06-18 22:33:29 +00:00
|
|
|
if(!allow_mode_change(source_p, chptr, alevel, errors, c))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* empty nick */
|
2020-11-05 16:31:57 +00:00
|
|
|
if(EmptyString(arg))
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
sendto_one_numeric(source_p, ERR_NOSUCHNICK, form_str(ERR_NOSUCHNICK), "*");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if((targ_p = find_chasing(source_p, arg, NULL)) == NULL)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mstptr = find_channel_membership(chptr, targ_p);
|
|
|
|
|
|
|
|
if(mstptr == NULL)
|
|
|
|
{
|
|
|
|
if(!(*errors & SM_ERR_NOTONCHANNEL) && MyClient(source_p))
|
|
|
|
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
|
2020-11-05 16:31:57 +00:00
|
|
|
form_str(ERR_USERNOTINCHANNEL), arg, chptr->chname);
|
2007-01-25 06:40:21 +00:00
|
|
|
*errors |= SM_ERR_NOTONCHANNEL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dir == MODE_ADD)
|
|
|
|
{
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_ADD;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count].id = targ_p->id;
|
2014-05-29 14:22:58 +00:00
|
|
|
mode_changes[mode_count++].arg = targ_p->name;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
mstptr->flags |= CHFL_VOICE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mode_changes[mode_count].letter = 'v';
|
|
|
|
mode_changes[mode_count].dir = MODE_DEL;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count].id = targ_p->id;
|
2014-05-29 14:22:58 +00:00
|
|
|
mode_changes[mode_count++].arg = targ_p->name;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
mstptr->flags &= ~CHFL_VOICE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
chm_limit(struct Client *source_p, struct Channel *chptr,
|
2020-11-05 16:31:57 +00:00
|
|
|
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
static char limitstr[30];
|
|
|
|
int limit;
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if (!allow_mode_change(source_p, chptr, alevel, errors, c))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if (dir == MODE_ADD)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2020-11-05 16:31:57 +00:00
|
|
|
if (EmptyString(arg) || (limit = atoi(arg)) <= 0)
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
2016-02-10 01:25:32 +00:00
|
|
|
sprintf(limitstr, "%d", limit);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_ADD;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count++].arg = limitstr;
|
|
|
|
|
|
|
|
chptr->mode.limit = limit;
|
|
|
|
}
|
2020-11-05 16:31:57 +00:00
|
|
|
else if (dir == MODE_DEL)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
if(!chptr->mode.limit)
|
|
|
|
return;
|
|
|
|
|
|
|
|
chptr->mode.limit = 0;
|
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_DEL;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count++].arg = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
chm_throttle(struct Client *source_p, struct Channel *chptr,
|
2020-11-05 16:31:57 +00:00
|
|
|
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
int joins = 0, timeslice = 0;
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if (!allow_mode_change(source_p, chptr, alevel, errors, c))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if (dir == MODE_ADD)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2020-11-05 16:31:57 +00:00
|
|
|
if (sscanf(arg, "%d:%d", &joins, ×lice) < 2)
|
2016-01-06 01:06:05 +00:00
|
|
|
return;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2016-01-06 01:02:44 +00:00
|
|
|
if(joins <= 0 || timeslice <= 0)
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_ADD;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
2020-11-05 16:31:57 +00:00
|
|
|
mode_changes[mode_count++].arg = arg;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
chptr->mode.join_num = joins;
|
|
|
|
chptr->mode.join_time = timeslice;
|
|
|
|
}
|
|
|
|
else if(dir == MODE_DEL)
|
|
|
|
{
|
|
|
|
if(!chptr->mode.join_num)
|
|
|
|
return;
|
|
|
|
|
|
|
|
chptr->mode.join_num = 0;
|
|
|
|
chptr->mode.join_time = 0;
|
|
|
|
chptr->join_count = 0;
|
|
|
|
chptr->join_delta = 0;
|
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_DEL;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count++].arg = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
chm_forward(struct Client *source_p, struct Channel *chptr,
|
2020-11-05 16:31:57 +00:00
|
|
|
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2011-09-25 14:22:29 +00:00
|
|
|
/* if +f is disabled, ignore local attempts to set it */
|
2020-11-05 16:31:57 +00:00
|
|
|
if (!ConfigChannel.use_forward && MyClient(source_p) && dir == MODE_ADD)
|
2011-09-25 14:22:29 +00:00
|
|
|
return;
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if (dir == MODE_QUERY)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
if (!(*errors & SM_ERR_RPL_F))
|
|
|
|
{
|
|
|
|
if (*chptr->mode.forward == '\0')
|
2007-01-25 07:23:01 +00:00
|
|
|
sendto_one_notice(source_p, ":%s has no forward channel", chptr->chname);
|
2007-01-25 06:40:21 +00:00
|
|
|
else
|
2007-01-25 07:23:01 +00:00
|
|
|
sendto_one_notice(source_p, ":%s forward channel is %s", chptr->chname, chptr->mode.forward);
|
2007-01-25 06:40:21 +00:00
|
|
|
*errors |= SM_ERR_RPL_F;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef FORWARD_OPERONLY
|
2020-11-05 16:31:57 +00:00
|
|
|
if (!allow_mode_change(source_p, chptr, alevel, errors, c))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
#else
|
2020-11-05 16:31:57 +00:00
|
|
|
if (!IsOperGeneral(source_p) && !IsServer(source_p))
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
if(!(*errors & SM_ERR_NOPRIVS))
|
|
|
|
sendto_one_numeric(source_p, ERR_NOPRIVILEGES, form_str(ERR_NOPRIVILEGES));
|
|
|
|
*errors |= SM_ERR_NOPRIVS;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if (dir == MODE_ADD)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2020-11-05 16:31:57 +00:00
|
|
|
if(EmptyString(arg))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
2011-12-09 23:40:07 +00:00
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if(!check_forward(source_p, chptr, arg))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
rb_strlcpy(chptr->mode.forward, arg, sizeof(chptr->mode.forward));
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_ADD;
|
2011-09-25 14:22:29 +00:00
|
|
|
mode_changes[mode_count].mems =
|
|
|
|
ConfigChannel.use_forward ? ALL_MEMBERS : ONLY_SERVERS;
|
2007-01-25 06:40:21 +00:00
|
|
|
mode_changes[mode_count].id = NULL;
|
2020-11-05 16:31:57 +00:00
|
|
|
mode_changes[mode_count++].arg = arg;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
else if(dir == MODE_DEL)
|
|
|
|
{
|
|
|
|
if(!(*chptr->mode.forward))
|
|
|
|
return;
|
|
|
|
|
|
|
|
*chptr->mode.forward = '\0';
|
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_DEL;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count++].arg = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
chm_key(struct Client *source_p, struct Channel *chptr,
|
2020-11-05 16:31:57 +00:00
|
|
|
int alevel, const char *arg, int *errors, int dir, char c, long mode_type)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
char *key;
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if (!allow_mode_change(source_p, chptr, alevel, errors, c))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if (dir == MODE_ADD)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2020-11-05 16:31:57 +00:00
|
|
|
key = LOCAL_COPY(arg);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
if(MyClient(source_p))
|
|
|
|
fix_key(key);
|
|
|
|
else
|
|
|
|
fix_key_remote(key);
|
|
|
|
|
|
|
|
if(EmptyString(key))
|
|
|
|
return;
|
|
|
|
|
|
|
|
s_assert(key[0] != ' ');
|
2008-04-20 04:40:40 +00:00
|
|
|
rb_strlcpy(chptr->mode.key, key, sizeof(chptr->mode.key));
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_ADD;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count++].arg = chptr->mode.key;
|
|
|
|
}
|
|
|
|
else if(dir == MODE_DEL)
|
|
|
|
{
|
|
|
|
static char splat[] = "*";
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if(!(*chptr->mode.key))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* hack time. when we get a +k-k mode, the +k arg is
|
|
|
|
* chptr->mode.key, which the -k sets to \0, so hunt for a
|
|
|
|
* +k when we get a -k, and set the arg to splat. --anfl
|
|
|
|
*/
|
|
|
|
for(i = 0; i < mode_count; i++)
|
|
|
|
{
|
|
|
|
if(mode_changes[i].letter == 'k' && mode_changes[i].dir == MODE_ADD)
|
|
|
|
mode_changes[i].arg = splat;
|
|
|
|
}
|
|
|
|
|
|
|
|
*chptr->mode.key = 0;
|
|
|
|
|
|
|
|
mode_changes[mode_count].letter = c;
|
|
|
|
mode_changes[mode_count].dir = MODE_DEL;
|
|
|
|
mode_changes[mode_count].mems = ALL_MEMBERS;
|
|
|
|
mode_changes[mode_count].id = NULL;
|
|
|
|
mode_changes[mode_count++].arg = "*";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* *INDENT-OFF* */
|
|
|
|
struct ChannelMode chmode_table[256] =
|
|
|
|
{
|
2020-11-05 16:31:57 +00:00
|
|
|
['F'] = {chm_simple, MODE_FREETARGET, 0 },
|
|
|
|
['I'] = {chm_ban, CHFL_INVEX, CHM_QUERYABLE | CHM_OPS_QUERY },
|
|
|
|
['L'] = {chm_staff, MODE_EXLIMIT, 0 },
|
|
|
|
['P'] = {chm_staff, MODE_PERMANENT, 0 },
|
|
|
|
['Q'] = {chm_simple, MODE_DISFORWARD, 0 },
|
|
|
|
['b'] = {chm_ban, CHFL_BAN, CHM_QUERYABLE },
|
|
|
|
['e'] = {chm_ban, CHFL_EXCEPTION, CHM_QUERYABLE | CHM_OPS_QUERY },
|
|
|
|
['f'] = {chm_forward, 0, CHM_ARG_SET | CHM_CAN_QUERY }, /* weird because it's nonstandard and violates isupport */
|
|
|
|
['g'] = {chm_simple, MODE_FREEINVITE, 0 },
|
|
|
|
['i'] = {chm_simple, MODE_INVITEONLY, 0 },
|
|
|
|
['j'] = {chm_throttle, 0, CHM_ARG_SET },
|
|
|
|
['k'] = {chm_key, 0, CHM_QUERYABLE },
|
|
|
|
['l'] = {chm_limit, 0, CHM_ARG_SET },
|
|
|
|
['m'] = {chm_simple, MODE_MODERATED, 0 },
|
|
|
|
['n'] = {chm_simple, MODE_NOPRIVMSGS, 0 },
|
|
|
|
['o'] = {chm_op, 0, CHM_ARGS },
|
|
|
|
['p'] = {chm_simple, MODE_PRIVATE, 0 },
|
|
|
|
['q'] = {chm_ban, CHFL_QUIET, CHM_QUERYABLE },
|
|
|
|
['r'] = {chm_simple, MODE_REGONLY, 0 },
|
|
|
|
['s'] = {chm_simple, MODE_SECRET, 0 },
|
|
|
|
['t'] = {chm_simple, MODE_TOPICLIMIT, 0 },
|
|
|
|
['v'] = {chm_voice, 0, CHM_ARGS },
|
|
|
|
['z'] = {chm_simple, MODE_OPMODERATE, 0 },
|
2007-01-25 06:40:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* *INDENT-ON* */
|
|
|
|
|
|
|
|
/* set_channel_mode()
|
|
|
|
*
|
|
|
|
* inputs - client, source, channel, membership pointer, params
|
2014-03-03 04:25:47 +00:00
|
|
|
* output -
|
2007-01-25 06:40:21 +00:00
|
|
|
* side effects - channel modes/memberships are changed, MODE is issued
|
|
|
|
*
|
|
|
|
* Extensively modified to be hotpluggable, 03/09/06 -- nenolod
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
set_channel_mode(struct Client *client_p, struct Client *source_p,
|
|
|
|
struct Channel *chptr, struct membership *msptr, int parc, const char *parv[])
|
|
|
|
{
|
2020-11-06 14:00:06 +00:00
|
|
|
static char modebuf[BUFSIZE * 2]; /* paranoid case: 2 canonical chars per input char */
|
2007-01-25 06:40:21 +00:00
|
|
|
static char parabuf[BUFSIZE];
|
|
|
|
char *mbuf;
|
|
|
|
char *pbuf;
|
|
|
|
int cur_len, mlen, paralen, paracount, arglen, len;
|
|
|
|
int i, j, flags;
|
2020-11-05 16:31:57 +00:00
|
|
|
int dir = MODE_ADD;
|
2020-11-30 09:24:32 +00:00
|
|
|
bool changes = false;
|
|
|
|
bool privileged_query = false;
|
2007-01-25 06:40:21 +00:00
|
|
|
int parn = 1;
|
|
|
|
int errors = 0;
|
|
|
|
int alevel;
|
|
|
|
const char *ml = parv[0];
|
|
|
|
char c;
|
|
|
|
struct Client *fakesource_p;
|
2016-01-13 22:34:27 +00:00
|
|
|
int flags_list[3] = { ALL_MEMBERS, ONLY_CHANOPS, ONLY_OPERS };
|
2021-01-26 11:22:39 +00:00
|
|
|
int mode_limit = 0;
|
|
|
|
int mode_limit_simple = 0;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
mask_pos = 0;
|
2011-08-13 00:33:10 +00:00
|
|
|
removed_mask_pos = 0;
|
2007-01-25 06:40:21 +00:00
|
|
|
mode_count = 0;
|
|
|
|
|
|
|
|
/* Hide connecting server on netburst -- jilles */
|
|
|
|
if (ConfigServerHide.flatten_links && IsServer(source_p) && !has_id(source_p) && !HasSentEob(source_p))
|
|
|
|
fakesource_p = &me;
|
|
|
|
else
|
|
|
|
fakesource_p = source_p;
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
struct modeset {
|
|
|
|
const struct ChannelMode *cm;
|
|
|
|
const char *arg;
|
|
|
|
int dir;
|
|
|
|
char mode;
|
|
|
|
};
|
2015-12-10 07:00:32 +00:00
|
|
|
|
2021-07-13 14:40:34 +00:00
|
|
|
static struct modeset modesets[MAXMODEPARAMS + MAXMODES_SIMPLE];
|
2020-11-05 16:31:57 +00:00
|
|
|
struct modeset *ms = modesets, *mend;
|
2020-11-06 14:00:06 +00:00
|
|
|
char canon_op = '\0';
|
|
|
|
|
|
|
|
mbuf = modebuf;
|
2020-11-05 16:31:57 +00:00
|
|
|
|
2021-07-13 14:40:34 +00:00
|
|
|
for (ml = parv[0]; *ml != 0 && ms - modesets < ARRAY_SIZE(modesets); ml++)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2020-11-05 16:31:57 +00:00
|
|
|
c = *ml;
|
2007-01-25 06:40:21 +00:00
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case '+':
|
|
|
|
dir = MODE_ADD;
|
|
|
|
break;
|
|
|
|
case '-':
|
|
|
|
dir = MODE_DEL;
|
|
|
|
break;
|
|
|
|
case '=':
|
|
|
|
dir = MODE_QUERY;
|
|
|
|
break;
|
|
|
|
default:
|
2020-11-05 16:31:57 +00:00
|
|
|
{
|
|
|
|
int effective_dir = dir;
|
|
|
|
const struct ChannelMode *cm = &chmode_table[(unsigned char) c];
|
|
|
|
bool use_arg = dir == MODE_ADD ? cm->flags & CHM_ARG_SET :
|
|
|
|
dir == MODE_DEL ? cm->flags & CHM_ARG_DEL :
|
|
|
|
false;
|
2020-11-08 17:50:17 +00:00
|
|
|
if (cm->set_func == NULL)
|
2020-11-05 16:31:57 +00:00
|
|
|
{
|
|
|
|
sendto_one(source_p, form_str(ERR_UNKNOWNMODE), me.name, source_p->name, c);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (use_arg && parn >= parc)
|
|
|
|
{
|
|
|
|
if (!(cm->flags & CHM_CAN_QUERY))
|
|
|
|
{
|
|
|
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "MODE");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
effective_dir = MODE_QUERY;
|
|
|
|
use_arg = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (effective_dir == MODE_QUERY && !(cm->flags & CHM_CAN_QUERY))
|
|
|
|
{
|
|
|
|
/* XXX this currently replicates traditional behaviour and just
|
|
|
|
* does nothing for a query on a mode with no query. would it be
|
|
|
|
* good to send an error here?
|
|
|
|
*/
|
2020-11-06 14:00:06 +00:00
|
|
|
continue;
|
2020-11-05 16:31:57 +00:00
|
|
|
}
|
|
|
|
|
2021-01-26 11:22:39 +00:00
|
|
|
if (MyClient(source_p))
|
|
|
|
{
|
|
|
|
if (use_arg && ++mode_limit > MAXMODEPARAMS)
|
|
|
|
continue;
|
|
|
|
if (!use_arg && ++mode_limit_simple > MAXMODES_SIMPLE)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-11-06 14:00:06 +00:00
|
|
|
char op = effective_dir == MODE_ADD ? '+' :
|
|
|
|
effective_dir == MODE_DEL ? '-' :
|
|
|
|
'=';
|
|
|
|
|
|
|
|
if (op != canon_op)
|
|
|
|
*mbuf++ = canon_op = op;
|
|
|
|
|
|
|
|
*mbuf++ = c;
|
|
|
|
|
2020-11-30 09:24:32 +00:00
|
|
|
if (effective_dir != MODE_QUERY)
|
|
|
|
changes = true;
|
2020-11-05 22:19:00 +00:00
|
|
|
if (effective_dir == MODE_QUERY && cm->flags & CHM_OPS_QUERY)
|
2020-11-30 09:24:32 +00:00
|
|
|
privileged_query = true;
|
2020-11-05 16:31:57 +00:00
|
|
|
|
|
|
|
ms->cm = cm;
|
|
|
|
ms->dir = effective_dir;
|
|
|
|
if (use_arg)
|
|
|
|
ms->arg = parv[parn++];
|
|
|
|
else
|
|
|
|
ms->arg = NULL;
|
|
|
|
ms->mode = c;
|
|
|
|
ms++;
|
|
|
|
}
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-06 14:00:06 +00:00
|
|
|
/* this will happen on something like MODE +-=++-.
|
|
|
|
* we'd have caught that with the if !mode_count
|
|
|
|
* later on, but this saves an override notice
|
|
|
|
*/
|
|
|
|
if (ms == modesets)
|
|
|
|
return;
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
if (parn < parc)
|
|
|
|
{
|
|
|
|
/* XXX we could reject excess params here */
|
|
|
|
}
|
|
|
|
|
2020-11-30 09:24:32 +00:00
|
|
|
/* Finish the flood grace period if we were asked to do anything */
|
|
|
|
if (changes && MyClient(source_p) && !IsFloodDone(source_p))
|
|
|
|
{
|
|
|
|
flood_endgrace(source_p);
|
|
|
|
}
|
|
|
|
|
2020-11-05 16:31:57 +00:00
|
|
|
mend = ms;
|
|
|
|
|
2020-11-06 14:00:06 +00:00
|
|
|
if (parn > 1)
|
|
|
|
{
|
|
|
|
strcpy(mbuf, " ");
|
|
|
|
rb_strlcat(modebuf, reconstruct_parv(parn - 1, parv + 1), sizeof modebuf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*mbuf = '\0';
|
|
|
|
}
|
2020-11-30 09:24:32 +00:00
|
|
|
int access_dir = privileged_query ? MODE_OP_QUERY :
|
|
|
|
changes ? MODE_ADD :
|
|
|
|
MODE_QUERY;
|
2020-11-06 14:00:06 +00:00
|
|
|
alevel = get_channel_access(source_p, chptr, msptr, access_dir, modebuf);
|
2020-11-05 16:31:57 +00:00
|
|
|
|
|
|
|
for (ms = modesets; ms < mend; ms++)
|
|
|
|
{
|
2020-11-08 00:45:12 +00:00
|
|
|
ChannelModeFunc *set_func = ms->cm->set_func;
|
2020-11-05 16:31:57 +00:00
|
|
|
set_func(fakesource_p, chptr, alevel, ms->arg, &errors, ms->dir, ms->mode, ms->cm->mode_type);
|
|
|
|
}
|
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
/* bail out if we have nothing to do... */
|
2020-11-06 14:00:06 +00:00
|
|
|
if (!mode_count)
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
2020-11-06 14:00:06 +00:00
|
|
|
if (IsServer(source_p))
|
2016-02-10 01:25:32 +00:00
|
|
|
mlen = sprintf(modebuf, ":%s MODE %s ", fakesource_p->name, chptr->chname);
|
2007-01-25 06:40:21 +00:00
|
|
|
else
|
2016-02-10 01:25:32 +00:00
|
|
|
mlen = sprintf(modebuf, ":%s!%s@%s MODE %s ",
|
2007-01-25 06:40:21 +00:00
|
|
|
source_p->name, source_p->username,
|
|
|
|
source_p->host, chptr->chname);
|
|
|
|
|
2016-02-06 15:50:17 +00:00
|
|
|
for(j = 0; j < 3; j++)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2020-06-07 16:36:31 +00:00
|
|
|
int send_flags = flags = flags_list[j];
|
2020-09-09 18:06:15 +00:00
|
|
|
const char *priv = NULL;
|
2020-06-07 16:36:31 +00:00
|
|
|
if (flags == ONLY_OPERS)
|
|
|
|
{
|
|
|
|
send_flags = ALL_MEMBERS;
|
|
|
|
priv = "auspex:cmodes";
|
|
|
|
}
|
2007-01-25 06:40:21 +00:00
|
|
|
cur_len = mlen;
|
|
|
|
mbuf = modebuf + mlen;
|
|
|
|
pbuf = parabuf;
|
|
|
|
parabuf[0] = '\0';
|
|
|
|
paracount = paralen = 0;
|
|
|
|
dir = MODE_QUERY;
|
|
|
|
|
|
|
|
for(i = 0; i < mode_count; i++)
|
|
|
|
{
|
|
|
|
if(mode_changes[i].letter == 0 || mode_changes[i].mems != flags)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if(mode_changes[i].arg != NULL)
|
|
|
|
{
|
|
|
|
arglen = strlen(mode_changes[i].arg);
|
|
|
|
|
|
|
|
if(arglen > MODEBUFLEN - 5)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
arglen = 0;
|
|
|
|
|
|
|
|
/* if we're creeping over MAXMODEPARAMSSERV, or over
|
|
|
|
* bufsize (4 == +/-,modechar,two spaces) send now.
|
|
|
|
*/
|
|
|
|
if(mode_changes[i].arg != NULL &&
|
|
|
|
((paracount == MAXMODEPARAMSSERV) ||
|
|
|
|
((cur_len + paralen + arglen + 4) > (BUFSIZE - 3))))
|
|
|
|
{
|
|
|
|
*mbuf = '\0';
|
|
|
|
|
|
|
|
if(cur_len > mlen)
|
2020-06-07 16:36:31 +00:00
|
|
|
sendto_channel_local_priv(IsServer(source_p) ? fakesource_p : source_p,
|
|
|
|
send_flags, priv, chptr, "%s %s", modebuf, parabuf);
|
2007-01-25 06:40:21 +00:00
|
|
|
else
|
|
|
|
continue;
|
|
|
|
|
|
|
|
paracount = paralen = 0;
|
|
|
|
cur_len = mlen;
|
|
|
|
mbuf = modebuf + mlen;
|
|
|
|
pbuf = parabuf;
|
|
|
|
parabuf[0] = '\0';
|
|
|
|
dir = MODE_QUERY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(dir != mode_changes[i].dir)
|
|
|
|
{
|
|
|
|
*mbuf++ = (mode_changes[i].dir == MODE_ADD) ? '+' : '-';
|
|
|
|
cur_len++;
|
|
|
|
dir = mode_changes[i].dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
*mbuf++ = mode_changes[i].letter;
|
|
|
|
cur_len++;
|
|
|
|
|
|
|
|
if(mode_changes[i].arg != NULL)
|
|
|
|
{
|
|
|
|
paracount++;
|
2016-02-10 01:25:32 +00:00
|
|
|
len = sprintf(pbuf, "%s ", mode_changes[i].arg);
|
2007-01-25 06:40:21 +00:00
|
|
|
pbuf += len;
|
|
|
|
paralen += len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(paralen && parabuf[paralen - 1] == ' ')
|
|
|
|
parabuf[paralen - 1] = '\0';
|
|
|
|
|
|
|
|
*mbuf = '\0';
|
|
|
|
if(cur_len > mlen)
|
2020-06-07 16:36:31 +00:00
|
|
|
sendto_channel_local_priv(IsServer(source_p) ? fakesource_p : source_p,
|
|
|
|
send_flags, priv, chptr, "%s %s", modebuf, parabuf);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* only propagate modes originating locally, or if we're hubbing */
|
2008-04-01 20:41:52 +00:00
|
|
|
if(MyClient(source_p) || rb_dlink_list_length(&serv_list) > 1)
|
2007-01-25 06:40:21 +00:00
|
|
|
send_cap_mode_changes(client_p, source_p, chptr, mode_changes, mode_count);
|
|
|
|
}
|
2010-03-08 05:13:39 +00:00
|
|
|
|
|
|
|
/* set_channel_mlock()
|
|
|
|
*
|
|
|
|
* inputs - client, source, channel, params
|
2014-03-03 04:25:47 +00:00
|
|
|
* output -
|
2010-03-08 05:13:39 +00:00
|
|
|
* side effects - channel mlock is changed / MLOCK is propagated
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
set_channel_mlock(struct Client *client_p, struct Client *source_p,
|
2016-03-08 10:52:31 +00:00
|
|
|
struct Channel *chptr, const char *newmlock, bool propagate)
|
2010-03-08 05:13:39 +00:00
|
|
|
{
|
2010-04-30 21:01:21 +00:00
|
|
|
rb_free(chptr->mode_lock);
|
2010-05-02 19:42:46 +00:00
|
|
|
chptr->mode_lock = newmlock ? rb_strdup(newmlock) : NULL;
|
2010-03-08 05:13:39 +00:00
|
|
|
|
2010-08-24 01:22:59 +00:00
|
|
|
if (propagate)
|
|
|
|
{
|
|
|
|
sendto_server(client_p, NULL, CAP_TS6 | CAP_MLOCK, NOCAPS, ":%s MLOCK %ld %s :%s",
|
|
|
|
source_p->id, (long) chptr->channelts, chptr->chname,
|
|
|
|
chptr->mode_lock ? chptr->mode_lock : "");
|
|
|
|
}
|
2010-03-08 05:13:39 +00:00
|
|
|
}
|