[srvx-commits] CVS: services/src proto-p10.c,1.83,1.84 nickserv.h,1.50,1.51 modcmd.h,1.22,1.23 modcm
Brought to you by:
entrope
From: Entrope <en...@us...> - 2003-12-17 04:21:55
|
Update of /cvsroot/srvx/services/src In directory sc8-pr-cvs1:/tmp/cvs-serv21773/src Modified Files: proto-p10.c nickserv.h modcmd.h modcmd.c helpserv.c hash.h chanserv.c Log Message: define and use IsStaff() macro define and use "never_csuspend" flag for commands that may never be used on suspended channels remove command rate limiting, since it did not seem to be worth the pain it incurred Index: proto-p10.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto-p10.c,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -r1.83 -r1.84 *** proto-p10.c 9 Dec 2003 16:09:43 -0000 1.83 --- proto-p10.c 17 Dec 2003 04:21:52 -0000 1.84 *************** *** 1844,1849 **** uNode->uplink->max_clients = uNode->uplink->clients; } - uNode->command_policer.last_req = now; - uNode->command_policer.params = IsOper(uNode) ? oper_policer_params : luser_policer_params; uNode->num_local = base64toint(numeric+strlen(uNode->uplink->numeric), 3) & uNode->uplink->num_mask; uNode->uplink->users[uNode->num_local] = uNode; --- 1844,1847 ---- *************** *** 1913,1917 **** void mod_usermode(struct userNode *user, const char *mode_change) { - extern struct policer_params *oper_policer_params, *luser_policer_params; static void call_oper_funcs(struct userNode *user); int add = 1; --- 1911,1914 ---- *************** *** 1932,1940 **** if (add) { userList_append(&curr_opers, user); - user->command_policer.params = oper_policer_params; call_oper_funcs(user); } else { userList_remove(&curr_opers, user); - user->command_policer.params = luser_policer_params; } break; --- 1929,1935 ---- Index: nickserv.h =================================================================== RCS file: /cvsroot/srvx/services/src/nickserv.h,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -r1.50 -r1.51 *** nickserv.h 15 Dec 2003 04:01:15 -0000 1.50 --- nickserv.h 17 Dec 2003 04:21:52 -0000 1.51 *************** *** 57,60 **** --- 57,61 ---- #define IsHelper(user) (IsSupportHelper(user) || IsNetworkHelper(user)) #define IsHelping(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, HELPING)) + #define IsStaff(user) (IsOper(user) || IsSupportHelper(user) || IsNetworkHelper(user)) enum cookie_type { Index: modcmd.h =================================================================== RCS file: /cvsroot/srvx/services/src/modcmd.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** modcmd.h 18 Oct 2003 15:52:21 -0000 1.22 --- modcmd.h 17 Dec 2003 04:21:52 -0000 1.23 *************** *** 53,56 **** --- 53,57 ---- #define MODCMD_LOG_HOSTMASK 0x040 #define MODCMD_IGNORE_CSUSPEND 0x080 + #define MODCMD_NEVER_CSUSPEND 0x100 /* Requirement (access control) flags */ #define MODCMD_REQUIRE_AUTHED 0x001000 *************** *** 109,113 **** struct string_list alias; /* if it's a complicated binding, what is the expansion? */ unsigned int uses; /* how many times was this command used? */ - float weight; /* how much should it count against the command policer? */ unsigned int flags; unsigned long req_account_flags; --- 110,113 ---- *************** *** 164,171 **** 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, int flags); --- 164,169 ---- 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 (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, int flags); Index: modcmd.c =================================================================== RCS file: /cvsroot/srvx/services/src/modcmd.c,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -r1.74 -r1.75 *** modcmd.c 9 Dec 2003 02:46:56 -0000 1.74 --- modcmd.c 17 Dec 2003 04:21:52 -0000 1.75 *************** *** 31,35 **** #define MCMSG_LEVEL_TOO_HIGH "You cannot set the access requirements to %s (that is too high)." #define MCMSG_UNKNOWN_COMMAND "Unknown command name %s (as template for %s in service %s)." - #define MCMSG_BAD_WEIGHT "Invalid command weight %s." #define MCMSG_BAD_OPTION "Unknown option %s." #define MCMSG_MUST_QUALIFY "You $bMUST$b \"/msg %s@$s %s\" (not just /msg %s)." --- 31,34 ---- *************** *** 92,95 **** --- 91,95 ---- #define MCMSG_HELPFILE_SEQUENCE "Help priority %d: %s" #define MCMSG_HELPFILE_SEQUENCE_SET "Set helpfile priority sequence for %s." + #define MCMSG_BAD_SERVICE_NICK "$b%s$b is an invalid nickname." #define MCMSG_ALREADY_SERVICE "$b%s$b is already a service." #define MCMSG_NEW_SERVICE "Added new service bot $b%s$b." *************** *** 139,142 **** --- 139,143 ---- { "nolog", MODCMD_NO_LOG }, { "networkhelper", MODCMD_REQUIRE_NETWORK_HELPER }, + { "never_csuspend", MODCMD_NEVER_CSUSPEND }, { "oper", MODCMD_REQUIRE_OPER }, { "qualified", MODCMD_REQUIRE_QUALIFIED }, *************** *** 278,284 **** dest->req_account_flags |= src->req_account_flags; dest->deny_account_flags |= src->deny_account_flags; - if (src->weight > dest->weight) { - dest->weight = src->weight; - } if (src->min_opserv_level > dest->min_opserv_level) { dest->min_opserv_level = src->min_opserv_level; --- 279,282 ---- *************** *** 368,385 **** } else if (!irccasecmp(param, "account_flags")) { return nickserv_modify_handle_flags(user, bot, value, &cmd->req_account_flags, &cmd->deny_account_flags); - } else if (!irccasecmp(param, "weight")) { - double new_weight; - char *end; - new_weight = strtod(value, &end); - if ((end == value) || (new_weight < 0)) { - if (user) { - send_message(user, bot, MCMSG_BAD_WEIGHT, value); - } else { - log_module(MAIN_LOG, LOG_ERROR, "Invalid command weight %s (for command %s).", value, cmd->name); - } - return 0; - } - cmd->weight = new_weight; - return 1; } else { if (user) { --- 366,369 ---- *************** *** 406,410 **** newcmd->defaults = calloc(1, sizeof(*newcmd->defaults)); newcmd->defaults->name = strdup(newcmd->name); - newcmd->defaults->weight = 1.0; newcmd->defaults->command = newcmd; dict_insert(module->commands, newcmd->name, newcmd); --- 390,393 ---- *************** *** 480,484 **** } 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 (!user->handle_info || !HANDLE_FLAGGED(user->handle_info, HELPING)) { if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_CHAN_SUSPENDED, channel->name, channel->channel_info->suspended->reason); --- 463,469 ---- } 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 (!user->handle_info ! || !HANDLE_FLAGGED(user->handle_info, HELPING) ! || (flags & MODCMD_NEVER_CSUSPEND)) { if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_CHAN_SUSPENDED, channel->name, channel->channel_info->suspended->reason); *************** *** 566,574 **** } } - if ((options & SVCCMD_DEBIT) && !policer_conforms(&user->command_policer, now, cmd->weight)) { - if (options & SVCCMD_NOISY) - send_message(user, bot, MSG_COMMAND_FLOOD); - return 0; - } /* If it's an override, return a special value. */ --- 551,554 ---- *************** *** 741,746 **** channel = NULL; } - perms = svccmd_can_invoke(user, service->bot, cmd, channel, options); - if (!perms) return 0; if (argc < cmd->command->min_argc) { send_message(user, service->bot, MSG_MISSING_PARAMS, cmd->name); --- 721,724 ---- *************** *** 751,765 **** return 0; } cmd->uses++; ! if (perms & ACTION_NOCHANNEL) channel = NULL; ! if (channel) safestrncpy(channel_name, channel->name, sizeof(channel_name)); ! else channel_name[0] = 0; ! if (!cmd->command->func(user, channel, argc, argv, cmd)) return 0; if (!(flags & MODCMD_NO_LOG)) { enum log_severity slvl; ! if (perms & ACTION_STAFF) slvl = LOG_STAFF; ! else if (perms & ACTION_OVERRIDE) slvl = LOG_OVERRIDE; ! else slvl = LOG_COMMAND; /* Unsplit argv after running the function to get the benefit * of any mangling/hiding done by the commands. */ --- 729,753 ---- return 0; } + perms = svccmd_can_invoke(user, service->bot, cmd, channel, options); + if (!perms) + return 0; cmd->uses++; ! if (perms & ACTION_NOCHANNEL) ! channel = NULL; ! if (channel) ! safestrncpy(channel_name, channel->name, sizeof(channel_name)); ! else ! channel_name[0] = 0; ! if (!cmd->command->func(user, channel, argc, argv, cmd)) ! return 0; if (!(flags & MODCMD_NO_LOG)) { enum log_severity slvl; ! if (perms & ACTION_STAFF) ! slvl = LOG_STAFF; ! else if (perms & ACTION_OVERRIDE) ! slvl = LOG_OVERRIDE; ! else ! slvl = LOG_COMMAND; /* Unsplit argv after running the function to get the benefit * of any mangling/hiding done by the commands. */ *************** *** 1349,1353 **** static MODCMD_FUNC(cmd_god) { - extern struct policer_params *luser_policer_params, *god_policer_params; int helping; --- 1337,1340 ---- *************** *** 1376,1384 **** HANDLE_SET_FLAG(user->handle_info, HELPING); send_message(user, cmd->parent->bot, MSMSG_NOW_HELPING); - if (!IsOper(user)) user->command_policer.params = god_policer_params; } else { HANDLE_CLEAR_FLAG(user->handle_info, HELPING); send_message(user, cmd->parent->bot, MSMSG_NOW_NOT_HELPING); - if (!IsOper(user)) user->command_policer.params = luser_policer_params; } --- 1363,1369 ---- *************** *** 1640,1643 **** --- 1625,1632 ---- nick = argv[1]; + if (!is_valid_nick(nick)) { + reply(MCMSG_BAD_SERVICE_NICK, nick); + return 0; + } desc = unsplit_string(argv+2, argc-2, NULL); bot = GetUserH(nick); Index: helpserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/helpserv.c,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -r1.87 -r1.88 *** helpserv.c 10 Dec 2003 17:37:23 -0000 1.87 --- helpserv.c 17 Dec 2003 04:21:52 -0000 1.88 *************** *** 969,977 **** hs = dict_find(helpserv_bots_dict, target->nick, NULL); - if (!policer_conforms(&user->command_policer, now, 1)) { - helpserv_notice(user, MSG_COMMAND_FLOOD); - return; - } - /* See if we should listen to their message as a command (helper) * or a help request (user) */ --- 969,972 ---- Index: hash.h =================================================================== RCS file: /cvsroot/srvx/services/src/hash.h,v retrieving revision 1.107 retrieving revision 1.108 diff -C2 -r1.107 -r1.108 *** hash.h 5 Aug 2003 02:22:29 -0000 1.107 --- hash.h 17 Dec 2003 04:21:52 -0000 1.108 *************** *** 115,120 **** struct userNode *next_authed; struct policer auth_policer; - /* from modcmd */ - struct policer command_policer; }; --- 115,118 ---- Index: chanserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/chanserv.c,v retrieving revision 1.400 retrieving revision 1.401 diff -C2 -r1.400 -r1.401 *** chanserv.c 15 Dec 2003 18:38:58 -0000 1.400 --- chanserv.c 17 Dec 2003 04:21:52 -0000 1.401 *************** *** 4107,4111 **** chanserv_notice(user, CSMSG_CHANNEL_REGISTERED, buffer); ! privileged = IsOper(user) || IsHelper(user); if((uData && uData->access >= ulCoowner) || privileged) { --- 4107,4111 ---- chanserv_notice(user, CSMSG_CHANNEL_REGISTERED, buffer); ! privileged = IsStaff(user); if((uData && uData->access >= ulCoowner) || privileged) { *************** *** 7255,7259 **** DEFINE_COMMAND(unbanme, 1, MODCMD_REQUIRE_CHANUSER, "template", "op", NULL); DEFINE_COMMAND(open, 1, MODCMD_REQUIRE_CHANUSER, "template", "op", NULL); ! DEFINE_COMMAND(topic, 1, MODCMD_REQUIRE_REGCHAN, "template", "op", NULL); DEFINE_COMMAND(mode, 1, MODCMD_REQUIRE_REGCHAN, "template", "op", NULL); DEFINE_COMMAND(inviteme, 1, MODCMD_REQUIRE_CHANNEL, "access", "peon", NULL); --- 7255,7259 ---- DEFINE_COMMAND(unbanme, 1, MODCMD_REQUIRE_CHANUSER, "template", "op", NULL); DEFINE_COMMAND(open, 1, MODCMD_REQUIRE_CHANUSER, "template", "op", NULL); ! DEFINE_COMMAND(topic, 1, MODCMD_REQUIRE_REGCHAN, "template", "op", "flags", "+never_csuspend", NULL); DEFINE_COMMAND(mode, 1, MODCMD_REQUIRE_REGCHAN, "template", "op", NULL); DEFINE_COMMAND(inviteme, 1, MODCMD_REQUIRE_CHANNEL, "access", "peon", NULL); |