[srvx-commits] CVS: services/src chanserv.c,1.298,1.299 modcmd.c,1.33,1.34 modcmd.h,1.10,1.11 nickse
Brought to you by:
entrope
|
From: Entrope <en...@us...> - 2002-10-28 02:01:50
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv15924/src
Modified Files:
chanserv.c modcmd.c modcmd.h nickserv.c opserv.c
Log Message:
remove modcmd template system; just clone requirements when making a new command
add new flag to svccmd_can_invoke
add callbacks for unbinding commands (so Byte can "?unbind ChanServ set\ nodelete")
do not expire channels that still have a master-or-above in the channel
Index: chanserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/chanserv.c,v
retrieving revision 1.298
retrieving revision 1.299
diff -C2 -r1.298 -r1.299
*** chanserv.c 26 Oct 2002 22:50:53 -0000 1.298
--- chanserv.c 28 Oct 2002 02:01:45 -0000 1.299
***************
*** 1427,1431 ****
--- 1427,1433 ----
struct chanData *channel, *next;
struct chanNode *save;
+ struct userData *user;
char delay[INTERVALLEN], reason[INTERVALLEN + 64];
+ int suspended;
(void)data;
***************
*** 1437,1460 ****
next = channel->next;
! if(IsProtected(channel))
! {
! continue;
! }
!
! if((now - channel->visited) > chanserv_conf.channel_expire_delay)
! {
! int suspended = IsSuspended(channel);
! log(CS_LOG, LOG_INFO, "(%s) Channel registration expired.\n", (suspended ? channel->suspended->name : channel->channel->name));
!
! /* Because we have a chanData * and not a chanNode *, save
! the chanNode *, then call unregister_channel(). */
! save = channel->channel;
! unregister_channel(channel);
!
! if(!suspended)
! {
! DelChannelUser(chanserv, save, reason, 0);
! }
! }
}
--- 1439,1459 ----
next = channel->next;
! /* See if the channel can be expired. */
! if((now - channel->visited) <= chanserv_conf.channel_expire_delay) continue;
! if(IsProtected(channel)) continue;
!
! /* Make sure there are no high-ranking users still in the channel. */
! for(user=channel->users; user; user=user->next)
! {
! if(user->access >= ulMaster) break;
! }
! if(user) continue;
!
! /* Unregister the channel */
! suspended = IsSuspended(channel);
! log(CS_LOG, LOG_INFO, "(%s) Channel registration expired.\n", (suspended ? channel->suspended->name : channel->channel->name));
! save = channel->channel;
! unregister_channel(channel);
! if(!suspended) DelChannelUser(chanserv, save, reason, 0);
}
***************
*** 5414,5417 ****
--- 5413,5426 ----
static struct svccmd_list set_shows_list;
+ static void
+ handle_svccmd_unbind(struct svccmd *target) {
+ unsigned int ii;
+ for (ii=0; ii<set_shows_list.used; ++ii) {
+ if (target == set_shows_list.list[ii]) {
+ set_shows_list.used = 0;
+ }
+ }
+ }
+
static CHANSERV_FUNC(cmd_set)
{
***************
*** 5435,5439 ****
if(!subcmd)
{
! log(CS_LOG, LOG_ERROR, "Unable to find set option %s.\n", name);
continue;
}
--- 5444,5448 ----
if(!subcmd)
{
! log(CS_LOG, LOG_ERROR, "Unable to find set option \"%s\".\n", name);
continue;
}
***************
*** 5445,5452 ****
{
chanserv_notice(user, CSMSG_CHANNEL_OPTIONS);
- /* Do this so options are presented in a consistent order. */
for(ii = 0; ii < set_shows_list.used; ii++)
{
! set_shows_list.list[ii]->command->func(user, channel, 1, argv+1, set_shows_list.list[ii]);
}
return 1;
--- 5454,5461 ----
{
chanserv_notice(user, CSMSG_CHANNEL_OPTIONS);
for(ii = 0; ii < set_shows_list.used; ii++)
{
! subcmd = set_shows_list.list[ii];
! subcmd->command->func(user, channel, 1, argv+1, subcmd);
}
return 1;
***************
*** 7094,7097 ****
--- 7103,7107 ----
dict_set_free_data(mask_dnrs, free);
+ reg_svccmd_unbind_func(handle_svccmd_unbind);
chanserv_module = module_register("ChanServ", CS_LOG, "chanserv.help", chanserv_expand_variable);
DEFINE_COMMAND(register, 1, MODCMD_REQUIRE_AUTHED, "flags", "+acceptchan,+helping", NULL);
Index: modcmd.c
===================================================================
RCS file: /cvsroot/srvx/services/src/modcmd.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -r1.33 -r1.34
*** modcmd.c 26 Oct 2002 22:51:40 -0000 1.33
--- modcmd.c 28 Oct 2002 02:01:47 -0000 1.34
***************
*** 73,77 ****
#define MCMSG_NEED_AUTHED "You must be authenticated with $N."
#define MCMSG_IS_TOY "$b%s$b is a toy command."
- #define MCMSG_INHERITED_REQS "Some of the above requirements may have been inherited from the %s requirements."
#define MCMSG_END_REQUIREMENTS "End of requirements for $b%s$b."
#define MSMSG_ALREADY_HELPING "You already have security override enabled."
--- 73,76 ----
***************
*** 93,97 ****
};
[...1001 lines suppressed...]
free(ptempl->base);
free(ptempl);
}
-
- in_setup = 0;
}
--- 1820,1832 ----
/* Only overwrite the current template if we have a valid template. */
if (!strcmp(ptempl->base, "*")) {
! /* Do nothing. */
} else if ((svccmd = svccmd_resolve_name(ptempl->cmd, ptempl->base))) {
! svccmd_copy_rules(ptempl->cmd, svccmd);
} else {
! assert(ptempl->cmd->parent);
! log(MAIN_LOG, LOG_ERROR, "Unable to resolve template name %s for command %s in service %s.\n", ptempl->base, ptempl->cmd->name, ptempl->cmd->parent->bot->nick);
}
free(ptempl->base);
free(ptempl);
}
}
Index: modcmd.h
===================================================================
RCS file: /cvsroot/srvx/services/src/modcmd.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** modcmd.h 18 Sep 2002 14:50:19 -0000 1.10
--- modcmd.h 28 Oct 2002 02:01:47 -0000 1.11
***************
*** 86,94 ****
* need "extra" data.
*
! * When checking to see if a user may invoke a command, the "template"
! * chain is followed, and the user must meet all the requirements
! * before the command is executed. As an exception, for the "staff"
! * permission checks (oper/network helper/support helper), any one is
! * sufficient to permit the command usage.
*/
--- 86,93 ----
* need "extra" data.
*
! * The user must meet all the requirements (in flags, access levels,
! * etc.) before the command is executed. As an exception, for the
! * "staff" permission checks (oper/network helper/support helper), any
! * one is sufficient to permit the command usage.
*/
***************
*** 107,111 ****
struct modcmd *command; /* what is the implementation? */
struct string_list alias; /* if it's a complicated binding, what is the expansion? */
- struct svccmd *template; /* where we look for permissions? */
unsigned int uses; /* how many times was this command used? */
float weight; /* how much should it count against the command policer? */
--- 106,109 ----
***************
*** 158,165 ****
struct svccmd *service_bind_modcmd(struct service *service, struct modcmd *cmd, const char *name);
- /* Alter a configurable parameter for a command. On success, return
- * non-zero; on failure, report to user why it failed and return zero.
- */
- int svccmd_configure(struct svccmd *cmd, struct userNode *user, struct userNode *bot, const char *param, const char *value);
/* Send help for a command to a user. */
int svccmd_send_help(struct userNode *user, struct userNode *bot, struct svccmd *cmd);
--- 156,159 ----
***************
*** 167,175 ****
int svccmd_send_help_2(struct userNode *user, struct service *service, const char *topic);
/* Check whether a user may invoke a command or not. If they can,
! * return non-zero. If they cannot, tell them why not and return 0.
*/
! int svccmd_can_invoke(struct userNode *user, struct userNode *bot, struct svccmd *cmd, struct chanNode *channel, unsigned int server_qualified);
/* Execute a command. Returns non-zero on success. */
int svccmd_invoke_argv(struct userNode *user, struct service *service, struct chanNode *channel, unsigned int argc, unsigned char *argv[], unsigned int server_qualified);
/* Initialize the module command subsystem. */
--- 161,177 ----
int svccmd_send_help_2(struct userNode *user, struct service *service, const char *topic);
/* Check whether a user may invoke a command or not. If they can,
! * return non-zero (if debit is non-zero, also debit the command's
! * weight against the user's command policer). If they cannot (and
! * noisy is non-zero), tell them why not and return 0.
! *
*/
! int svccmd_can_invoke(struct userNode *user, struct userNode *bot, struct svccmd *cmd, struct chanNode *channel, char server_qualified, char debit, char noisy);
/* Execute a command. Returns non-zero on success. */
int svccmd_invoke_argv(struct userNode *user, struct service *service, struct chanNode *channel, unsigned int argc, unsigned char *argv[], unsigned int server_qualified);
+ /* Get notification when a command is being unbound. This lets
+ * services which cache svccmd references remove them.
+ */
+ typedef void (*svccmd_unbind_func_t)(struct svccmd *target);
+ void reg_svccmd_unbind_func(svccmd_unbind_func_t handler);
/* Initialize the module command subsystem. */
Index: nickserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/nickserv.c,v
retrieving revision 1.211
retrieving revision 1.212
diff -C2 -r1.211 -r1.212
*** nickserv.c 21 Oct 2002 02:37:22 -0000 1.211
--- nickserv.c 28 Oct 2002 02:01:47 -0000 1.212
***************
*** 2713,2720 ****
}
! if (subcmd && !svccmd_can_invoke(user, nickserv, subcmd, NULL, 0)) {
! nickserv_notice(user, NSMSG_NO_ACCESS);
! return 0;
! }
discrim = nickserv_discrim_create(user, argc-2, argv+2);
--- 2713,2717 ----
}
! if (subcmd && !svccmd_can_invoke(user, nickserv, subcmd, NULL, 0, 0, 1)) return 0;
discrim = nickserv_discrim_create(user, argc-2, argv+2);
Index: opserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/opserv.c,v
retrieving revision 1.284
retrieving revision 1.285
diff -C2 -r1.284 -r1.285
*** opserv.c 26 Oct 2002 16:17:18 -0000 1.284
--- opserv.c 28 Oct 2002 02:01:47 -0000 1.285
***************
*** 2282,2290 ****
exp.value.table.contents[row] = calloc(exp.value.table.width, sizeof(char*));
exp.value.table.contents[row][0] = iter_key(it);
! level = 0;
! do {
! if (level < cmd->min_opserv_level) level = cmd->min_opserv_level;
! cmd = cmd->template;
! } while (cmd);
if (!level_strings[level]) {
level_strings[level] = malloc(16);
--- 2282,2286 ----
exp.value.table.contents[row] = calloc(exp.value.table.width, sizeof(char*));
exp.value.table.contents[row][0] = iter_key(it);
! level = cmd->min_opserv_level;
if (!level_strings[level]) {
level_strings[level] = malloc(16);
***************
*** 2297,2305 ****
exp.type = HF_STRING;
if (cmd) {
! level = 0;
! do {
! if (level < cmd->min_opserv_level) level = cmd->min_opserv_level;
! cmd = cmd->template;
! } while (cmd);
exp.value.str = malloc(16);
snprintf(exp.value.str, 16, "%3d", level);
--- 2293,2297 ----
exp.type = HF_STRING;
if (cmd) {
! level = cmd->min_opserv_level;
exp.value.str = malloc(16);
snprintf(exp.value.str, 16, "%3d", level);
***************
*** 3243,3247 ****
return 0;
}
! if (!svccmd_can_invoke(user, opserv, subcmd, channel, 0)) return 0;
if (!irccasecmp(argv[1], "print")) action = trace_print_func;
else if (!irccasecmp(argv[1], "count")) action = trace_count_func;
--- 3235,3239 ----
return 0;
}
! if (!svccmd_can_invoke(user, opserv, subcmd, channel, 0, 0, 1)) return 0;
if (!irccasecmp(argv[1], "print")) action = trace_print_func;
else if (!irccasecmp(argv[1], "count")) action = trace_count_func;
***************
*** 3457,3461 ****
sprintf(buf, "%s %s", argv[0], argv[0]);
if ((subcmd = opserv_get_command(buf))
! && !svccmd_can_invoke(user, cmd->parent->bot, subcmd, channel, 0)) {
return 0;
}
--- 3449,3453 ----
sprintf(buf, "%s %s", argv[0], argv[0]);
if ((subcmd = opserv_get_command(buf))
! && !svccmd_can_invoke(user, cmd->parent->bot, subcmd, channel, 0, 0, 1)) {
return 0;
}
***************
*** 3551,3555 ****
sprintf(buf, "%s %s", argv[0], argv[0]);
if ((subcmd = opserv_get_command(buf))
! && !svccmd_can_invoke(user, cmd->parent->bot, subcmd, channel, 0)) {
return 0;
}
--- 3543,3547 ----
sprintf(buf, "%s %s", argv[0], argv[0]);
if ((subcmd = opserv_get_command(buf))
! && !svccmd_can_invoke(user, cmd->parent->bot, subcmd, channel, 0, 0, 1)) {
return 0;
}
***************
*** 3801,3805 ****
return 0;
}
! if (!svccmd_can_invoke(user, opserv, subcmd, channel, 0)) return 0;
if (opserv_add_user_alert(user, name, reaction, unsplit_string(argv + 3, argc - 3, NULL))) {
opserv_notice(user, OSMSG_ADDED_ALERT, name);
--- 3793,3797 ----
return 0;
}
! if (!svccmd_can_invoke(user, opserv, subcmd, channel, 0, 0, 1)) return 0;
if (opserv_add_user_alert(user, name, reaction, unsplit_string(argv + 3, argc - 3, NULL))) {
opserv_notice(user, OSMSG_ADDED_ALERT, name);
|