[srvx-commits] CVS: services/src chanserv.c,1.362,1.363 modcmd.c,1.56,1.57 modcmd.h,1.17,1.18 modcmd
Brought to you by:
entrope
|
From: Entrope <en...@us...> - 2003-07-12 03:48:42
|
Update of /cvsroot/srvx/services/src
In directory sc8-pr-cvs1:/tmp/cvs-serv3733/src
Modified Files:
chanserv.c modcmd.c modcmd.h modcmd.help
Log Message:
get rid of sChannels by locking all registered channels
fix lame handling of suspended channels in various commands (and their
associated perverted requirement flags)
add modcmd flag to allow users to use REGCHAN commands on suspended channels
Index: chanserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/chanserv.c,v
retrieving revision 1.362
retrieving revision 1.363
diff -C2 -r1.362 -r1.363
*** chanserv.c 12 Jul 2003 03:19:18 -0000 1.362
--- chanserv.c 12 Jul 2003 03:48:37 -0000 1.363
***************
*** 31,34 ****
--- 31,35 ----
/* ChanServ options */
#define KEY_SUPPORT_CHANNEL "support_channel"
+ #define KEY_SUPPORT_CHANNEL_MODES "support_channel_modes"
#define KEY_DB_BACKUP_FREQ "db_backup_freq"
#define KEY_INFO_DELAY "info_delay"
***************
*** 420,424 ****
struct userNode *chanserv;
dict_t note_types;
- static dict_t sChannels;
static dict_t plain_dnrs, mask_dnrs, handle_dnrs;
static struct log_type *CS_LOG;
--- 421,424 ----
***************
*** 1212,1219 ****
channel->channel = cNode;
! if(cNode)
! {
! cNode->channel_info = channel;
! }
registered_channels++;
--- 1212,1217 ----
channel->channel = cNode;
! LockChannel(cNode);
! cNode->channel_info = channel;
registered_channels++;
***************
*** 1472,1483 ****
struct suspended *suspended, *next_suspended;
- /* Remove the channel from sChannels if the channel is
- currently suspended (channel->suspended may be non-
- NULL if the channel has a suspension history). */
- if(IsSuspended(channel))
- {
- dict_remove(sChannels, channel->suspended->name);
- }
-
for(suspended = channel->suspended; suspended; suspended = next_suspended)
{
--- 1470,1473 ----
***************
*** 1496,1500 ****
}
! if(channel->channel) channel->channel->channel_info = NULL;
if(channel->notes) dict_delete(channel->notes);
--- 1486,1491 ----
}
! channel->channel->channel_info = NULL;
! UnlockChannel(channel->channel);
if(channel->notes) dict_delete(channel->notes);
***************
*** 1866,1871 ****
else
{
- struct suspended *suspended;
-
if((argc < 2) || !IsCSChannelName(argv[1]))
{
--- 1857,1860 ----
***************
*** 1880,1889 ****
}
- if((suspended = dict_find(sChannels, argv[1], NULL)))
- {
- chanserv_notice(user, CSMSG_SUSPENDED_REASON, argv[1], suspended->reason);
- return 0;
- }
-
new_channel = 1;
chan_name = argv[1];
--- 1869,1872 ----
***************
*** 1966,2000 ****
char reason[MAXLEN];
struct chanData *cData;
- struct suspended *sChan;
struct userData *uData;
unsigned int suspended, confirm;
! if(channel)
! {
! cData = channel->channel_info;
! name = channel->name;
! confirm = 1;
!
! if(!cData)
! {
! reply(CSMSG_NOT_REGISTERED, name);
! return 0;
! }
! }
! else if((argc > 1) && IsCSChannelName(argv[1]))
! {
! sChan = dict_find(sChannels, argv[1], NULL);
! if(!sChan)
! {
! reply(CSMSG_NOT_REGISTERED, argv[1]);
! return 0;
! }
! cData = sChan->cData;
! name = sChan->name;
! confirm = 2;
! }
! else
{
! reply(MSG_NOT_CHANNEL_NAME);
return 0;
}
--- 1949,1961 ----
char reason[MAXLEN];
struct chanData *cData;
struct userData *uData;
unsigned int suspended, confirm;
! cData = channel->channel_info;
! name = channel->name;
! confirm = 1;
! if(!cData)
{
! reply(CSMSG_NOT_REGISTERED, name);
return 0;
}
***************
*** 4249,4255 ****
struct userData *uData;
struct chanData *cData;
- struct suspended *sChan;
struct do_not_register *dnr;
- const char *chan_name;
enum userLevel access;
struct note *note;
--- 4210,4214 ----
***************
*** 4257,4289 ****
int privileged;
! if(channel)
! {
! cData = channel->channel_info;
! chan_name = channel->name;
! if(!cData)
! {
! reply(CSMSG_NOT_REGISTERED, chan_name);
! return 0;
! }
! sChan = cData->suspended;
! }
! else if((argc > 1) && IsCSChannelName(argv[1]))
! {
! sChan = dict_find(sChannels, argv[1], NULL);
! if(!sChan)
! {
! reply(CSMSG_NOT_REGISTERED, argv[1]);
! return 0;
! }
! cData = sChan->cData;
! chan_name = sChan->name;
! }
! else
! {
! reply(MSG_NOT_CHANNEL_NAME);
! return 0;
! }
!
! chanserv_notice(user, CSMSG_CHANNEL_INFO, chan_name);
uData = GetChannelUser(cData, user->handle_info);
--- 4216,4222 ----
int privileged;
! (void)argv;
! cData = channel->channel_info;
! chanserv_notice(user, CSMSG_CHANNEL_INFO, channel->name);
uData = GetChannelUser(cData, user->handle_info);
***************
*** 4336,4340 ****
if(privileged)
{
! if((dnr = chanserv_is_dnr(chan_name, NULL)))
{
chanserv_notice(user, CSMSG_DNR_INFO, dnr->chan_name, dnr->setter, dnr->reason);
--- 4269,4273 ----
if(privileged)
{
! if((dnr = chanserv_is_dnr(channel->name, NULL)))
{
chanserv_notice(user, CSMSG_DNR_INFO, dnr->chan_name, dnr->setter, dnr->reason);
***************
*** 4345,4349 ****
{
struct suspended *suspended;
! chanserv_notice(user, (IsSuspended(cData) ? CSMSG_CHANNEL_SUSPENDED : CSMSG_CHANNEL_HISTORY), chan_name);
for(suspended = cData->suspended; suspended; suspended = suspended->previous)
{
--- 4278,4282 ----
{
struct suspended *suspended;
! chanserv_notice(user, (IsSuspended(cData) ? CSMSG_CHANNEL_SUSPENDED : CSMSG_CHANNEL_HISTORY), channel->name);
for(suspended = cData->suspended; suspended; suspended = suspended->previous)
{
***************
*** 4353,4358 ****
else if(IsSuspended(cData))
{
! chanserv_notice(user, CSMSG_CHANNEL_SUSPENDED, chan_name);
! show_suspension_info(user, sChan);
}
return 1;
--- 4286,4291 ----
else if(IsSuspended(cData))
{
! chanserv_notice(user, CSMSG_CHANNEL_SUSPENDED, channel->name);
! show_suspension_info(user, cData->suspended);
}
return 1;
***************
*** 4674,4706 ****
unsigned int arg = 1;
! if(channel)
! {
! cData = channel->channel_info;
! if(!cData)
! {
! reply(CSMSG_NOT_REGISTERED, channel->name);
! return 0;
! }
! }
! else if((argc > arg) && IsCSChannelName(argv[arg]))
! {
! struct suspended *sChan = dict_find(sChannels, argv[arg], NULL);
! if(!sChan)
! {
! reply(CSMSG_NOT_REGISTERED, argv[arg]);
! return 0;
! }
! arg++;
! cData = sChan->cData;
! }
! else
! {
! reply(MSG_NOT_CHANNEL_NAME);
! return 0;
! }
!
! if (IsSuspended(cData) && !IsHelping(user))
{
! reply(CSMSG_NOTE_SUSPENDED);
return 0;
}
--- 4607,4614 ----
unsigned int arg = 1;
! cData = channel->channel_info;
! if(!cData)
{
! reply(CSMSG_NOT_REGISTERED, channel->name);
return 0;
}
***************
*** 4880,4888 ****
if(!suspended->expires || (now < suspended->expires)) suspended->revoked = now;
! dict_remove(sChannels, suspended->name);
! channel = AddChannel(suspended->name, now, NULL, NULL);
AddChannelUser(chanserv, channel);
AddChannelOp(1, &chanserv, channel, chanserv, 1);
- channel->channel_info = suspended->cData;
suspended->cData->channel = channel;
suspended->cData->flags &= ~CHANNEL_SUSPENDED;
--- 4788,4794 ----
if(!suspended->expires || (now < suspended->expires)) suspended->revoked = now;
! channel = suspended->cData->channel;
AddChannelUser(chanserv, channel);
AddChannelOp(1, &chanserv, channel, chanserv, 1);
suspended->cData->channel = channel;
suspended->cData->flags &= ~CHANNEL_SUSPENDED;
***************
*** 4943,4947 ****
/* Mark the channel as suspended, then part. */
channel->channel_info->flags |= CHANNEL_SUSPENDED;
- dict_insert(sChannels, suspended->name, suspended);
DelChannelUser(chanserv, channel, suspended->reason, 0);
chanserv_notice(user, CSMSG_SUSPENDED, suspended->name);
--- 4849,4852 ----
***************
*** 4957,4961 ****
char message[MAXLEN];
! if(!(suspended = dict_find(sChannels, argv[1], NULL)))
{
chanserv_notice(user, CSMSG_NOT_SUSPENDED, argv[1]);
--- 4862,4866 ----
char message[MAXLEN];
! if(!IsSuspended(channel->channel_info))
{
chanserv_notice(user, CSMSG_NOT_SUSPENDED, argv[1]);
***************
*** 6165,6177 ****
char info[MAXLEN];
- /* Reinitialize the channel if it has become active. */
- if(!channel->channel_info && (channel->members.used < 3))
- {
- struct suspended *suspended = dict_find(sChannels, channel->name, NULL);
- if(!suspended) return 0;
- channel->channel_info = suspended->cData;
- suspended->cData->channel = channel;
- }
-
if(IsLocal(user) || !channel->channel_info || IsSuspended(channel->channel_info))
{
--- 6070,6073 ----
***************
*** 6407,6417 ****
(void)reason;
cData = channel->channel_info;
! if(!cData) return;
! if(channel->members.used == 0)
! {
! cData->channel = NULL;
! return;
! }
! if(IsSuspended(cData) || IsLocal(user)) return;
if((cData->flags & CHANNEL_DYNAMIC_LIMIT) && !channel->join_flooded)
--- 6303,6307 ----
(void)reason;
cData = channel->channel_info;
! if(!cData || IsSuspended(cData) || IsLocal(user)) return;
if((cData->flags & CHANNEL_DYNAMIC_LIMIT) && !channel->join_flooded)
***************
*** 6608,6612 ****
if(str)
{
! chanserv_conf.support_channel = AddChannel(str, now, "+nt", NULL);
AddChannelUser(chanserv, chanserv_conf.support_channel);
AddChannelOp(1, &chanserv, chanserv_conf.support_channel, chanserv, 0);
--- 6498,6504 ----
if(str)
{
! const char *str2 = database_get_data(conf_node, KEY_SUPPORT_CHANNEL_MODES, RECDB_QSTRING);
! if(!str2) str2 = "+nt";
! chanserv_conf.support_channel = AddChannel(str, now, str2, NULL);
AddChannelUser(chanserv, chanserv_conf.support_channel);
AddChannelOp(1, &chanserv, chanserv_conf.support_channel, chanserv, 0);
***************
*** 6940,6961 ****
}
if(num_flags & CHANNEL_SUSPENDED)
{
suspended->name = strdup(key);
- dict_insert(sChannels, suspended->name, suspended);
if(suspended->expires > now)
{
timeq_add(suspended->expires, chanserv_expire_suspension, suspended);
}
- cNode = NULL;
}
else
{
- cNode = AddChannel(key, now, NULL, NULL);
- if(!cNode)
- {
- log_module(CS_LOG, LOG_ERROR, "Unable to create registered channel %s.", key);
- return 0;
- }
AddChannelUser(chanserv, cNode);
AddChannelOp(1, &chanserv, cNode, chanserv, 0);
--- 6832,6851 ----
}
+ cNode = AddChannel(key, now, NULL, NULL);
+ if(!cNode)
+ {
+ log_module(CS_LOG, LOG_ERROR, "Unable to create registered channel %s.", key);
+ return 0;
+ }
if(num_flags & CHANNEL_SUSPENDED)
{
suspended->name = strdup(key);
if(suspended->expires > now)
{
timeq_add(suspended->expires, chanserv_expire_suspension, suspended);
}
}
else
{
AddChannelUser(chanserv, cNode);
AddChannelOp(1, &chanserv, cNode, chanserv, 0);
***************
*** 7281,7285 ****
unreg_part_func(handle_part);
while(channelList) unregister_channel(channelList);
- dict_delete(sChannels);
dict_delete(handle_dnrs);
dict_delete(plain_dnrs);
--- 7171,7174 ----
***************
*** 7322,7326 ****
reg_unreg_func(handle_unreg);
- sChannels = dict_new();
handle_dnrs = dict_new();
dict_set_free_data(handle_dnrs, free);
--- 7211,7214 ----
***************
*** 7337,7345 ****
DEFINE_COMMAND(move, 1, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_REGCHAN, "template", "register", NULL);
DEFINE_COMMAND(csuspend, 2, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_REGCHAN, "flags", "+helping", NULL);
! DEFINE_COMMAND(cunsuspend, 2, MODCMD_REQUIRE_AUTHED, "flags", "+helping", NULL);
DEFINE_COMMAND(createnote, 5, 0, "access", "800", NULL);
DEFINE_COMMAND(removenote, 2, 0, "access", "800", NULL);
! DEFINE_COMMAND(unregister, 1, MODCMD_REQUIRE_AUTHED|MODCMD_ACCEPT_CHANNEL, "flags", "+loghostmask", NULL);
DEFINE_COMMAND(merge, 2, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_REGCHAN, "access", "owner", NULL);
--- 7225,7233 ----
DEFINE_COMMAND(move, 1, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_REGCHAN, "template", "register", NULL);
DEFINE_COMMAND(csuspend, 2, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_REGCHAN, "flags", "+helping", NULL);
! DEFINE_COMMAND(cunsuspend, 2, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_REGCHAN, "flags", "+helping", NULL);
DEFINE_COMMAND(createnote, 5, 0, "access", "800", NULL);
DEFINE_COMMAND(removenote, 2, 0, "access", "800", NULL);
! DEFINE_COMMAND(unregister, 1, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_REGCHAN, "flags", "+loghostmask", NULL);
DEFINE_COMMAND(merge, 2, MODCMD_REQUIRE_AUTHED|MODCMD_REQUIRE_REGCHAN, "access", "owner", NULL);
***************
*** 7400,7404 ****
DEFINE_COMMAND(olist, 1, MODCMD_REQUIRE_REGCHAN, "flags", "+nolog,+joinable", NULL);
DEFINE_COMMAND(plist, 1, MODCMD_REQUIRE_REGCHAN, "flags", "+nolog,+joinable", NULL);
! DEFINE_COMMAND(info, 1, MODCMD_ACCEPT_CHANNEL, "flags", "+nolog,+joinable", NULL);
DEFINE_COMMAND(seen, 2, MODCMD_REQUIRE_REGCHAN, "flags", "+nolog,+joinable", NULL);
DEFINE_COMMAND(names, 1, MODCMD_REQUIRE_REGCHAN, "flags", "+nolog,+joinable", NULL);
--- 7288,7292 ----
DEFINE_COMMAND(olist, 1, MODCMD_REQUIRE_REGCHAN, "flags", "+nolog,+joinable", NULL);
DEFINE_COMMAND(plist, 1, MODCMD_REQUIRE_REGCHAN, "flags", "+nolog,+joinable", NULL);
! DEFINE_COMMAND(info, 1, MODCMD_REQUIRE_REGCHAN, "flags", "+nolog,+joinable", NULL);
DEFINE_COMMAND(seen, 2, MODCMD_REQUIRE_REGCHAN, "flags", "+nolog,+joinable", NULL);
DEFINE_COMMAND(names, 1, MODCMD_REQUIRE_REGCHAN, "flags", "+nolog,+joinable", NULL);
Index: modcmd.c
===================================================================
RCS file: /cvsroot/srvx/services/src/modcmd.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -r1.56 -r1.57
*** modcmd.c 7 Jul 2003 16:29:33 -0000 1.56
--- modcmd.c 12 Jul 2003 03:48:37 -0000 1.57
***************
*** 125,128 ****
--- 125,129 ----
{ "chanuser", MODCMD_REQUIRE_CHANUSER },
{ "disabled", MODCMD_DISABLED },
+ { "ignore_csuspend", MODCMD_IGNORE_CSUSPEND },
{ "joinable", MODCMD_REQUIRE_JOINABLE },
{ "keepbound", MODCMD_KEEP_BOUND },
***************
*** 454,467 ****
}
if (flags & MODCMD_REQUIRE_REGCHAN) {
! if (!channel) {
! /* XXX: could maybe figure out better way to handle this case */
! if (options & SVCCMD_NOISY) send_message(user, bot, MSG_INVALID_CHANNEL);
! return 0;
! } else if (!channel->channel_info) {
if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_CHAN_NOT_REGISTERED, channel->name);
return 0;
! } else if (IsSuspended(channel->channel_info)) {
! if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_CHAN_SUSPENDED, channel->name, channel->channel_info->suspended->reason);
! return 0;
}
}
--- 455,468 ----
}
if (flags & MODCMD_REQUIRE_REGCHAN) {
! if (!channel->channel_info) {
if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_CHAN_NOT_REGISTERED, channel->name);
return 0;
! } else if (IsSuspended(channel->channel_info) && !(flags & MODCMD_IGNORE_CSUSPEND)) {
! /* allow security-override users to always ignore channel suspensions, but flag it as a staff command */
! if (!HANDLE_FLAGGED(user->handle_info, HELPING)) {
! if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_CHAN_SUSPENDED, channel->name, channel->channel_info->suspended->reason);
! return 0;
! }
! rflags |= ACTION_STAFF;
}
}
***************
*** 536,540 ****
if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_MUST_BE_HELPING);
rflags |= ACTION_STAFF;
- return 0;
}
if (cmd->min_opserv_level > 0) {
--- 537,540 ----
Index: modcmd.h
===================================================================
RCS file: /cvsroot/srvx/services/src/modcmd.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** modcmd.h 7 Jul 2003 16:29:33 -0000 1.17
--- modcmd.h 12 Jul 2003 03:48:37 -0000 1.18
***************
*** 51,54 ****
--- 51,55 ----
#define MODCMD_NO_DEFAULT_BIND 0x020
#define MODCMD_LOG_HOSTMASK 0x040
+ #define MODCMD_IGNORE_CSUSPEND 0x080
/* Requirement (access control) flags */
#define MODCMD_REQUIRE_AUTHED 0x001000
Index: modcmd.help
===================================================================
RCS file: /cvsroot/srvx/services/src/modcmd.help,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** modcmd.help 2 Jan 2003 01:22:23 -0000 1.9
--- modcmd.help 12 Jul 2003 03:48:37 -0000 1.10
***************
*** 44,47 ****
--- 44,48 ----
" DISABLED Command is disabled",
" HELPING Require that the user have security override enabled",
+ " IGNORE_CSUSPEND Allow a +REGCHAN command to work even if the channel is suspended",
" JOINABLE Require that the user have $C access to the channel, be in the channel, or be network staff to use the command",
" KEEPBOUND Do not let the last instance of the command be removed",
|