srvx-commits Mailing List for srvx IRC Services (Page 78)
Brought to you by:
entrope
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(80) |
Sep
(51) |
Oct
(94) |
Nov
(132) |
Dec
(85) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(163) |
Feb
(96) |
Mar
(70) |
Apr
(182) |
May
(173) |
Jun
(73) |
Jul
(101) |
Aug
(101) |
Sep
(71) |
Oct
(76) |
Nov
(58) |
Dec
(60) |
2003 |
Jan
(61) |
Feb
(14) |
Mar
(3) |
Apr
|
May
(7) |
Jun
(22) |
Jul
(81) |
Aug
(41) |
Sep
(34) |
Oct
(41) |
Nov
(16) |
Dec
(28) |
2004 |
Jan
(7) |
Feb
|
Mar
(3) |
Apr
(15) |
May
(11) |
Jun
(1) |
Jul
(4) |
Aug
(1) |
Sep
(4) |
Oct
(1) |
Nov
(1) |
Dec
(1) |
2005 |
Jan
(13) |
Feb
(6) |
Mar
(1) |
Apr
|
May
(2) |
Jun
(1) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2009 |
Jan
|
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
2010 |
Jan
(2) |
Feb
(3) |
Mar
(4) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
2012 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(4) |
Jun
|
Jul
(1) |
Aug
|
Sep
(3) |
Oct
(2) |
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2023 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2025 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Entrope <en...@us...> - 2001-10-25 18:32:43
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv15119/src Modified Files: Tag: rel-1_0 nickserv.c Log Message: set lastseen to now for !oregister'ed handles Index: nickserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/nickserv.c,v retrieving revision 1.138.2.48 retrieving revision 1.138.2.49 diff -C2 -r1.138.2.48 -r1.138.2.49 *** nickserv.c 2001/10/20 17:34:11 1.138.2.48 --- nickserv.c 2001/10/25 18:32:41 1.138.2.49 *************** *** 614,617 **** --- 614,618 ---- hi->users = NULL; hi->registered = now; + hi->lastseen = now; hi->flags = HI_DEFAULT_FLAGS; if (settee) set_user_handle_info(settee, hi); |
From: Entrope <en...@us...> - 2001-10-25 18:31:38
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv14852/src Modified Files: Tag: rel-1_0 parse.c Log Message: map a few more messages to cmd_dummy Index: parse.c =================================================================== RCS file: /cvsroot/srvx/services/src/Attic/parse.c,v retrieving revision 1.113.2.19 retrieving revision 1.113.2.20 diff -C2 -r1.113.2.19 -r1.113.2.20 *** parse.c 2001/09/20 21:26:01 1.113.2.19 --- parse.c 2001/10/25 18:31:35 1.113.2.20 *************** *** 807,810 **** --- 807,813 ---- dict_insert(irc_func_dict, CMD_DESTRUCT, cmd_dummy); dict_insert(irc_func_dict, TOK_DESTRUCT, cmd_dummy); + /* Ignore invites */ + dict_insert(irc_func_dict, CMD_INVITE, cmd_dummy); + dict_insert(irc_func_dict, TOK_INVITE, cmd_dummy); /* DESYNCH is just informational, so ignore it */ dict_insert(irc_func_dict, CMD_DESYNCH, cmd_dummy); *************** *** 826,829 **** --- 829,833 ---- dict_insert(irc_func_dict, "441", cmd_dummy); /* target isn't on that channel */ dict_insert(irc_func_dict, "442", cmd_dummy); /* you aren't on that channel */ + dict_insert(irc_func_dict, "443", cmd_dummy); /* is already on channel (after invite?) */ num_privmsg_funcs = 16; |
From: Entrope <en...@us...> - 2001-10-25 17:34:09
|
Update of /cvsroot/srvx/services In directory usw-pr-cvs1:/tmp/cvs-serv301 Modified Files: srvx.conf.example Log Message: show example of new services invocation Index: srvx.conf.example =================================================================== RCS file: /cvsroot/srvx/services/srvx.conf.example,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** srvx.conf.example 2001/10/15 14:39:55 1.6 --- srvx.conf.example 2001/10/25 17:34:05 1.7 *************** *** 26,123 **** "services" { ! "nickserv" { ! "nick" "NickServ"; ! // Normally, nickserv requires at least one hostmask per handle ! // (and adds one when the user registers). If there are any ! // hostmasks for a handle, then at least one must match for ! // the user to auth. ! "allow_no_hostmasks" "1"; ! "default_no_hostmasks" "0"; ! // one handle may only have this many nicks ! "nicks_per_handle" "4"; ! // this is the default ! "disable_nicks" "0"; ! // minimum number of various types of characters for a password ! "password_min_length" "4"; ! "password_min_digits" "1"; ! "password_min_upper" "1"; ! "password_min_lower" "1"; ! // other than A-Z, a-z, 0-9, what else should be valid? ! "valid_handle_chars" "[]{}\\-_^|`"; ! "valid_nick_chars" "[]{}\\-_^|`"; ! // What OpServ levels are necessary to change flags? ! "flag_levels" { ! "g" "800"; ! "h" "800"; ! "S" "999"; }; ! // How often should handles be expired? ! "handle_expire_freq" "1d"; ! // how long until a handle with access to a channel expires? ! "handle_expire_delay" "35d"; ! // how long until a handle with no access to any channels expires? ! "nochan_handle_expire_delay" "14d"; ! }; ! ! "opserv" { ! "nick" "OpServ"; ! // how often should it save state? ! "db_backup_freq" "2h"; ! // what channel should opserv send debug output to? ! "debug_channel" "#opserv"; ! // where to send general alerts (e.g. flood alerts)? ! "alert_channel" "#ircops"; ! // how many clones to allow from an untrusted host? ! "untrusted_max" "4"; ! // how long to keep an illegal channel locked down (seconds)? ! "purge_lock_delay" "60"; ! // channel join flood policer params? ! "join_policer" { ! "size" "20"; ! "drain-rate" "1"; ! }; ! // new user flood policer params ! "new_user_policer" { ! "size" "200"; ! "drain-rate" "3"; ! }; ! // character to make OpServ pay attention to you ! "trigger" "?"; ! }; ! ! "chanserv" { ! "nick" "ChanServ"; ! "debug_channel" "#chanserv"; ! "db_backup_freq" "2h"; ! // how long should a person be unseen before resending infoline? ! "info_delay" "3m"; ! // maximum greeting length ! "max_greetlen" "120"; ! "adjust_threshold" "15"; ! "joinflood_threshold" "5"; ! // How long before dynamically adjusting +l limit? ! "adjust_delay" "30"; ! // How often to expire old channels? ! "chan_expire_freq" "3d"; ! // Unvisited channels at least this age get expired. ! "chan_expire_delay" "30d"; ! // Allowed users per channel ! "max_chan_users" "512"; ! // Allowed bans per channel ! "max_chan_bans" "512"; ! // character to make ChanServ pay attention to you ! "trigger" "!"; ! // transition support ! "old_chanserv_name" "X2"; ! "max_switch_load" "15"; // only transition 15 channels at a time ! "switch_timeout" "60s"; // time out transitions after this long ! "access_regex" "([^[:space:]]+) is (an? [^[:space:]]+) on (#[^ ,]+)"; ! "auth_regex" "([^[:space:]]+) is (NOT )?authenticated on channel (#[^ ,]+)"; ! }; ! ! "global" { ! "nick" "GlobalServ"; ! "db_backup_freq" "2h"; ! }; }; --- 26,37 ---- "services" { ! "AuthServ" { ! // "hostname" "I.Am.AuthServ"; ! "userinfo" "Authentication Services"; ! "commands" { ! "auth" "authserv/auth"; ! "register" "authserv/register"; }; ! }; }; |
From: Entrope <en...@us...> - 2001-10-25 17:29:43
|
Update of /cvsroot/srvx/services/src/srvx In directory usw-pr-cvs1:/tmp/cvs-serv31396/src/srvx Modified Files: messages.h service.c service.h Log Message: fix some AuthServ module bugs register commands for services Index: messages.h =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/messages.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** messages.h 2001/10/20 18:47:05 1.1 --- messages.h 2001/10/25 17:29:40 1.2 *************** *** 52,58 **** #define MSG_INVALID_DURATION N_("Invalid time span '%s'.") - #define MSG_INVALID_CHANNEL N_("You must provide the name of a channel that exists.") - #define MSG_CHANNEL_ABSENT N_("You aren't currently in $b%s$b.") - #define MSG_MISSING_PARAMS N_("$b%s$b requires more parameters.") --- 52,55 ---- *************** *** 69,72 **** --- 66,75 ---- #define IDENT_FORMAT "%s [%s@%s/%ld.%ld.%ld.%ld]" #define IDENT_DATA(user) user->nick, user->username, user->hostname, (user->ip >> 24) & 255, (user->ip >> 16) & 255, (user->ip >> 8) & 255, user->ip & 255 + + #define MIN_PARMS(N) do { \ + if (argc < N) { \ + send_message(bot, source, MSG_MISSING_PARAMS, argv[0]); \ + return; } \ + } while (0) #endif /* ifdef _MESSAGES_H_ */ Index: service.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/service.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** service.c 2001/10/23 21:07:07 1.4 --- service.c 2001/10/25 17:29:40 1.5 *************** *** 33,36 **** --- 33,37 ---- struct service_command { + const char *name; struct module_command *base; struct expression *rule; *************** *** 50,60 **** } - void - service_init(void) - { - service_module = module_register("service", MAKE_VERSION(SERVICE_MAJOR, SERVICE_MINOR, SERVICE_REVISION), NULL, NULL); - reg_del_user_func(service_free_user); - } - static struct service_command * service_find_command(struct service *sinst, const char *name) --- 51,54 ---- *************** *** 88,92 **** service_find_conf(struct service *sinst, const char *path, enum recdb_type type) { ! return service_find_conf_by_name(sinst->user->nick, path, type); } --- 82,86 ---- service_find_conf(struct service *sinst, const char *path, enum recdb_type type) { ! return service_find_conf_by_name(sinst->name, path, type); } *************** *** 100,103 **** --- 94,98 ---- struct service_command *cmd; struct expression_context rule_ctx; + struct expression *expr; shift = 0; *************** *** 110,114 **** chan_name = argv[0]; } else { ! send_message(bot, source, MSG_INVALID_CHANNEL); return; } --- 105,109 ---- chan_name = argv[0]; } else { ! send_message(bot, source, N_("You must provide the name of a channel that exists.")); return; } *************** *** 127,130 **** --- 122,130 ---- cmd = service_find_command(sinst, argv[0]); } + /* Make sure command exists */ + if (!cmd) { + send_message(bot, source, N_("$b%s$b is an unknown command."), argv[shift]); + return; + } /* Check flags */ if ((cmd->base->flags & (1 << REQUIRE_AUTHED)) && !source->handle_info) { *************** *** 136,150 **** } if ((cmd->base->flags & (1 << REQUIRE_CHANNEL)) && !channel) { ! send_message(bot, source, MSG_INVALID_CHANNEL); return; } ! /* Fill in rule context and evaluate it */ ! rule_ctx.source = source; ! rule_ctx.channel = channel; ! rule_ctx.argc = argc-shift; ! rule_ctx.argv = argv+shift; ! if (!expression_evaluate(cmd->rule ? cmd->rule : cmd->base->default_rule, &rule_ctx)) { ! send_message(bot, source, N_("Access to $b%s$b denied."), argv[shift]); ! return; } cmd->base->function(bot, source, channel, argc-shift, argv+shift); --- 136,154 ---- } if ((cmd->base->flags & (1 << REQUIRE_CHANNEL)) && !channel) { ! send_message(bot, source, N_("You must provide the name of a channel that exists.")); return; } ! /* Figure out expression to use */ ! expr = cmd->rule ? cmd->rule : cmd->base->default_rule; ! if (expr) { ! /* Fill in rule context and evaluate it */ ! rule_ctx.source = source; ! rule_ctx.channel = channel; ! rule_ctx.argc = argc-shift; ! rule_ctx.argv = argv+shift; ! if (!expression_evaluate(expr, &rule_ctx)) { ! send_message(bot, source, N_("Access to $b%s$b denied."), argv[shift]); ! return; ! } } cmd->base->function(bot, source, channel, argc-shift, argv+shift); *************** *** 158,161 **** --- 162,229 ---- } + static int + service_install_command(const char *key, void *data, void *extra) + { + struct record_data *rd = data; + struct service *service = extra; + struct service_command *cmd; + struct module *module; + const char *rule_text; + char *base_cmd_name, *sep; + + switch (rd->type) { + case RECDB_QSTRING: + base_cmd_name = rd->d.qstring; + rule_text = NULL; + break; + case RECDB_OBJECT: + base_cmd_name = database_get_data(rd->d.object, "command", RECDB_QSTRING); + rule_text = database_get_data(rd->d.object, "rule", RECDB_QSTRING); + break; + default: + log(MAIN_LOG, LOG_ERROR, N_("Invalid entry type for service %s command %s\n"), service->name, key); + return 0; + } + assert(base_cmd_name != NULL); + base_cmd_name = strdup(base_cmd_name); + if (!(sep = strchr(base_cmd_name, '/'))) { + log(MAIN_LOG, LOG_ERROR, N_("Invalid base command name for service %s command %s: %s missing a /\n"), service->name, key, base_cmd_name); + free(base_cmd_name); + return 0; + } + cmd = calloc(1, sizeof(*cmd)); + /* Set command name */ + cmd->name = strdup(key); + /* Look up base command (both module and command name) */ + *sep++ = '\0'; + if (!(module = module_try_load(base_cmd_name))) { + log(MAIN_LOG, LOG_ERROR, N_("Module %s (for service %s command %s) not found.\n"), base_cmd_name, service->name, cmd->name); + free(base_cmd_name); + return 0; + } + if (!(cmd->base = module_find_command(module, sep))) { + log(MAIN_LOG, LOG_ERROR, N_("Module %s command %s (for service %s command %s) not defined.\n"), base_cmd_name, sep, service->name, cmd->name); + free(base_cmd_name); + return 0; + } + /* If any rule text was given, parse it. */ + if (rule_text) cmd->rule = expression_parse(rule_text); + free(base_cmd_name); + dict_insert(service->commands, cmd->name, cmd); + return 0; + } + + static void + service_install_commands(struct service *service) + { + dict_t cmds; + + service->commands = dict_new(); + /* First look for explicitly named commands */ + cmds = service_find_conf(service, "commands", RECDB_OBJECT); + if (cmds) dict_foreach(cmds, service_install_command, service); + /* TODO: Anything else? (Look for entire services to import?) */ + } + struct service * service_create(const char *name) *************** *** 164,180 **** struct service *sinst; /* Check if we've already created it */ if ((sinst = dict_find(services, name, NULL))) return sinst; /* Get the various parameters from the params dict */ hostname = service_find_conf_by_name(name, "hostname", RECDB_QSTRING); ! if (!hostname) { ! log(MAIN_LOG, LOG_ERROR, "No 'hostname' entry defined for service '%s'\n", name); ! return NULL; ! } userinfo = service_find_conf_by_name(name, "userinfo", RECDB_QSTRING); ! if (!userinfo) { ! log(MAIN_LOG, LOG_ERROR, "No 'userinfo' entry defined for service '%s'\n", name); ! return NULL; ! } trigger = service_find_conf_by_name(name, "trigger", RECDB_QSTRING); /* Create the user and annotate it */ --- 232,243 ---- struct service *sinst; + if (!name) return NULL; /* Check if we've already created it */ if ((sinst = dict_find(services, name, NULL))) return sinst; /* Get the various parameters from the params dict */ hostname = service_find_conf_by_name(name, "hostname", RECDB_QSTRING); ! if (!hostname) hostname = self->name; userinfo = service_find_conf_by_name(name, "userinfo", RECDB_QSTRING); ! if (!userinfo) userinfo = "srvx Service bot"; trigger = service_find_conf_by_name(name, "trigger", RECDB_QSTRING); /* Create the user and annotate it */ *************** *** 191,198 **** reg_privmsg_func(user, service_privmsg); } ! sinst->commands = dict_new(); /* Put into services dict */ dict_insert(services, sinst->name, sinst); - /* TODO: finish service_create(): load commands, ?call callbacks? */ return sinst; } --- 254,287 ---- reg_privmsg_func(user, service_privmsg); } ! /* Link commands */ ! service_install_commands(sinst); ! /* TODO: finish service_create(): ?call callbacks? */ /* Put into services dict */ dict_insert(services, sinst->name, sinst); return sinst; + } + + static int + instantiate_service(const char *key, void *data, void *extra) + { + (void)data; (void)extra; + service_create(key); + return 0; + } + + void + service_init(void) + { + struct record_data *rd; + + service_module = module_register("service", MAKE_VERSION(SERVICE_MAJOR, SERVICE_MINOR, SERVICE_REVISION), NULL, NULL); + reg_del_user_func(service_free_user); + services = dict_new(); + rd = conf_get_node("services"); + if (rd && (rd->type == RECDB_OBJECT)) { + dict_foreach(rd->d.object, instantiate_service, NULL); + } else { + log(MAIN_LOG, LOG_ERROR, N_("Missing or invalid config DB key \"services\".\n")); + return; + } } Index: service.h =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/service.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** service.h 2001/10/20 18:47:05 1.1 --- service.h 2001/10/25 17:29:40 1.2 *************** *** 41,45 **** void service_init(); struct service *service_create(const char *name); ! void * service_find_conf(struct service *sinst, const char *path, enum recdb_type type); void service_chanmsg(struct user *bot, struct user *source, struct channel *chan, char *real_text); --- 41,45 ---- void service_init(); struct service *service_create(const char *name); ! void *service_find_conf(struct service *sinst, const char *path, enum recdb_type type); void service_chanmsg(struct user *bot, struct user *source, struct channel *chan, char *real_text); |
From: Entrope <en...@us...> - 2001-10-25 17:29:43
|
Update of /cvsroot/srvx/services/src/modules In directory usw-pr-cvs1:/tmp/cvs-serv31396/src/modules Modified Files: authserv.c authserv.h Log Message: fix some AuthServ module bugs register commands for services Index: authserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/modules/authserv.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** authserv.c 2001/10/24 14:35:45 1.4 --- authserv.c 2001/10/25 17:29:40 1.5 *************** *** 42,45 **** --- 42,51 ---- #define MODMSG_BAD_HANDLE N_("Handle $b%s$b not registered because it is in use by a network services, or contains invalid characters.") + /**********************/ + /* EXPORTED VARIABLES */ + /**********************/ + + struct userList curr_helpers; + /********************/ /* STATIC VARIABLES */ *************** *** 70,83 **** } cfg; - #define NEED_CHANNEL() do { if (!channel) { \ - send_message(bot, source, MSG_INVALID_CHANNEL); \ - return; } } while (0) - #define MIN_PARMS(N, NEEDCHAN) do { \ - if (argc < N) { \ - send_message(bot, source, MSG_MISSING_PARAMS, argv[0]); \ - return; } \ - if (NEEDCHAN) NEED_CHANNEL(); } \ - while (0) - /********************/ /* INTERNAL HELPERS */ --- 76,79 ---- *************** *** 540,544 **** struct handle_info *hi; ! MIN_PARMS(3, 0); if (!(target = GetUser(argv[1]))) { send_message(bot, source, MSG_NICK_UNKNOWN, argv[1]); --- 536,540 ---- struct handle_info *hi; ! MIN_PARMS(3); (void)channel; if (!(target = GetUser(argv[1]))) { send_message(bot, source, MSG_NICK_UNKNOWN, argv[1]); *************** *** 571,575 **** MODULE_COMMAND(cmd_delmask) { ! MIN_PARMS(2, 0); authserv_delmask(bot, source, source->handle_info, argv[1]); } --- 567,571 ---- MODULE_COMMAND(cmd_delmask) { ! MIN_PARMS(2); (void)channel; authserv_delmask(bot, source, source->handle_info, argv[1]); } *************** *** 672,676 **** const char *old_pass, *new_pass, *reason; ! MIN_PARMS(3, 0); hi = source->handle_info; old_pass = argv[1]; --- 668,672 ---- const char *old_pass, *new_pass, *reason; ! MIN_PARMS(3); (void)channel; hi = source->handle_info; old_pass = argv[1]; *************** *** 705,709 **** } ! MIN_PARMS(3, 0); if (!is_valid_handle(argv[1])) { --- 701,705 ---- } ! MIN_PARMS(3); (void)channel; if (!is_valid_handle(argv[1])) { *************** *** 736,740 **** struct handle_info *hi; ! MIN_PARMS(3, 0); if (!(hi = get_oper_victim(bot, source, argv[1]))) return; if (!is_valid_handle(argv[2])) { --- 732,736 ---- struct handle_info *hi; ! MIN_PARMS(3); (void)channel; if (!(hi = get_oper_victim(bot, source, argv[1]))) return; if (!is_valid_handle(argv[2])) { *************** *** 762,766 **** struct handle_info *hi; ! MIN_PARMS(2, 0); hi = source->handle_info; if (checkpass(argv[1], hi->passwd)) { --- 758,762 ---- struct handle_info *hi; ! MIN_PARMS(2); (void)channel; hi = source->handle_info; if (checkpass(argv[1], hi->passwd)) { *************** *** 776,780 **** struct user *target; ! MIN_PARMS(2, 0); if (!(target = GetUser(argv[1]))) { send_message(bot, source, MSG_NICK_UNKNOWN, argv[1]); --- 772,776 ---- struct user *target; ! MIN_PARMS(2); (void)channel; if (!(target = GetUser(argv[1]))) { send_message(bot, source, MSG_NICK_UNKNOWN, argv[1]); *************** *** 831,837 **** int add, pos; ! if ((argc < 2) || (argv[1]->type != PEXPR_QSTRING)) return 1; expr->argc = 1; ! for (add=1, on=0, off=0, flags=argv[1]->u.qstring; *flags; flags++) { switch (*flags) { case '+': add = 1; break; --- 827,833 ---- int add, pos; ! if ((argc < 2) || (argv[1]->type != PEXPR_TOKEN)) return 1; expr->argc = 1; ! for (add=1, on=0, off=0, flags=argv[1]->u.token; *flags; flags++) { switch (*flags) { case '+': add = 1; break; *************** *** 998,1001 **** --- 994,1003 ---- /* TODO: remove when okay */ (void)authserv_apply_flags; /* TODO: remove when okay */ (void)authserv_set_flag_level; + allow_auth_dict = dict_new(); + assert(allow_auth_dict != NULL); + cfg.weak_password_dict = dict_new(); + assert(cfg.weak_password_dict != NULL); + dict_insert(cfg.weak_password_dict, "password", "password"); + dict_insert(cfg.weak_password_dict, "<password>", "<password>"); /* TODO: finish authserv's mod_init */ return 0; Index: authserv.h =================================================================== RCS file: /cvsroot/srvx/services/src/modules/authserv.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** authserv.h 2001/10/24 14:35:45 1.4 --- authserv.h 2001/10/25 17:29:40 1.5 *************** *** 71,74 **** --- 71,76 ---- }; + extern struct userList curr_helpers; + struct handle_info *get_handle_info(const char *handle); struct handle_info *smart_get_handle_info(struct user *bot, struct user *source, const unsigned char *name); |
From: Entrope <en...@us...> - 2001-10-25 17:28:47
|
Update of /cvsroot/srvx/services/src/srvx In directory usw-pr-cvs1:/tmp/cvs-serv31015/src/srvx Modified Files: modules.c Log Message: when loading modules, use retval of module_load_library rather than searching by name Index: modules.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/modules.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** modules.c 2001/10/25 16:38:23 1.2 --- modules.c 2001/10/25 17:28:44 1.3 *************** *** 73,76 **** --- 73,77 ---- if (!(lib->handle = dlopen(so_name, RTLD_GLOBAL|RTLD_LAZY))) { + log(MAIN_LOG, LOG_WARNING, N_("Unable to load module %s: %s\n"), so_name, dlerror()); free(lib); return NULL; *************** *** 139,143 **** switch (rd->type) { case RECDB_QSTRING: ! return module_try_load(rd->d.qstring); default: log(MAIN_LOG, LOG_ERROR, N_("Unknown/invalid record type for config DB key \"modules\"/\"%s\"."), name); --- 140,145 ---- switch (rd->type) { case RECDB_QSTRING: ! module_try_load(rd->d.qstring); ! return dict_find(loaded_modules, name, NULL); default: log(MAIN_LOG, LOG_ERROR, N_("Unknown/invalid record type for config DB key \"modules\"/\"%s\"."), name); *************** *** 155,170 **** return NULL; } ! module_load_library(rd->d.qstring); ! if ((mod = dict_find(loaded_modules, name, NULL))) return mod; } /* second: use package library directory */ snprintf(path, sizeof(path), PKGLIBDIR"/"SHLIB_PREFIX"%s"SHLIB_SUFFIX, name); ! module_load_library(path); ! if ((mod = dict_find(loaded_modules, name, NULL))) return mod; /* third: use OS's default path */ snprintf(path, sizeof(path), SHLIB_PREFIX"%s"SHLIB_SUFFIX, name); ! module_load_library(path); ! if ((mod = dict_find(loaded_modules, name, NULL))) return mod; ! return mod; } --- 157,170 ---- return NULL; } ! if (!module_load_library(rd->d.qstring)) return dict_find(loaded_modules, name, NULL); } /* second: use package library directory */ snprintf(path, sizeof(path), PKGLIBDIR"/"SHLIB_PREFIX"%s"SHLIB_SUFFIX, name); ! if (!module_load_library(path)) return dict_find(loaded_modules, name, NULL); /* third: use OS's default path */ snprintf(path, sizeof(path), SHLIB_PREFIX"%s"SHLIB_SUFFIX, name); ! if (!module_load_library(path)) return dict_find(loaded_modules, name, NULL); ! log(MAIN_LOG, LOG_ERROR, N_("Unable to find module \"%s\" in any of known locations.\n"), name); ! return NULL; } |
From: Entrope <en...@us...> - 2001-10-25 17:28:16
|
Update of /cvsroot/srvx/services/src/srvx In directory usw-pr-cvs1:/tmp/cvs-serv30813/src/srvx Modified Files: modules.h Log Message: fix ordering of arguments in MODULE_COMMAND macro Index: modules.h =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/modules.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** modules.h 2001/10/25 16:38:23 1.2 --- modules.h 2001/10/25 17:28:13 1.3 *************** *** 63,67 **** }; ! #define MODULE_COMMAND(NAME) void NAME(struct user *source, struct user *bot, struct channel *channel, unsigned int argc, unsigned char *argv[]) /* Represents a command loaded from a module. */ --- 63,67 ---- }; ! #define MODULE_COMMAND(NAME) void NAME(struct user *bot, struct user *source, struct channel *channel, unsigned int argc, unsigned char *argv[]) /* Represents a command loaded from a module. */ |
From: Entrope <en...@us...> - 2001-10-25 17:27:41
|
Update of /cvsroot/srvx/services/src/srvx In directory usw-pr-cvs1:/tmp/cvs-serv30593/src/srvx Modified Files: main.c Log Message: reorder init functions some Index: main.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/main.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** main.c 2001/10/24 14:31:54 1.2 --- main.c 2001/10/25 17:27:38 1.3 *************** *** 460,471 **** modules_init(); timeq_init(); gline_init(); sockcheck_init(); /* could be modularized */ ! hash_init(); ! rules_init(); ! service_init(); conf_rlimits(); - module_try_load("proto"); if (replay_file) log(MAIN_LOG, LOG_INFO, "Beginning replay...\n"); --- 460,471 ---- modules_init(); + rules_init(); /* must be after modules_init()! */ timeq_init(); gline_init(); sockcheck_init(); /* could be modularized */ ! hash_init(); /* must be after rules_init()! */ ! module_try_load("proto"); /* must be after hash_init()! */ ! service_init(); /* must be after loading proto module! */ conf_rlimits(); if (replay_file) log(MAIN_LOG, LOG_INFO, "Beginning replay...\n"); |
From: Entrope <en...@us...> - 2001-10-25 17:27:22
|
Update of /cvsroot/srvx/services/src/srvx In directory usw-pr-cvs1:/tmp/cvs-serv30451/src/srvx Modified Files: hash.c Log Message: implement "umode" operator for rules Index: hash.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/hash.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** hash.c 2001/10/20 18:47:05 1.1 --- hash.c 2001/10/25 17:27:20 1.2 *************** *** 31,36 **** --- 31,41 ---- #include "log.h" #include "proto.h" + #include "rules.h" #include "tools.h" + /**********************/ + /* EXPORTED VARIABLES */ + /**********************/ + struct server *self; struct userList curr_opers; *************** *** 38,68 **** dict_t clients; dict_t servers; - - static struct module *hash_module; ! static void hash_cleanup(void); ! static void channel_free(void *channel); ! static void client_free(void *client); ! void ! hash_init(void) ! { ! /* Initialize data structures */ ! channels = dict_new(); ! assert(channels != NULL); ! dict_set_free_data(channels, channel_free); ! clients = dict_new(); ! assert(clients != NULL); ! dict_set_free_data(clients, client_free); ! servers = dict_new(); ! assert(servers != NULL); ! dict_set_free_data(servers, free); ! userList_init(&curr_opers); ! /* Register modules, callbacks, etc. */ ! hash_module = module_register("hash", HASH_VERSION, NULL, NULL); ! assert(hash_module != NULL); ! reg_exit_func(hash_cleanup); ! } ! static server_link_func_t *ns_list; static size_t ns_size, ns_used; --- 43,52 ---- dict_t clients; dict_t servers; ! /********************/ ! /* STATIC VARIABLES */ ! /********************/ ! static struct module *hash_module; static server_link_func_t *ns_list; static size_t ns_size, ns_used; *************** *** 945,952 **** } static void hash_cleanup(void) { ! DelServer(self, 0, ""); userList_clean(&curr_opers); --- 929,993 ---- } + /* This is used as the first argument for umode matching. */ + struct umode_match { + unsigned long on, mask; + }; + + EXPR_COMPILE_FUNCTION(expr_umode_compile) + { + struct umode_match *um; + const unsigned char *modes; + unsigned long on, off; + int add, pos; + + if ((argc < 2) || (argv[1]->type != PEXPR_TOKEN)) return 1; + expr->argc = 1; + for (add=1, on=0, off=0, modes=argv[1]->u.token; *modes; modes++) { + switch (*modes) { + case '+': add = 1; break; + case '-': add = 0; break; + default: + if ((pos = user_inverse_modes[*modes])) { + pos--; + if (add) { + on |= 1 << pos; + } else { + off |= 1 << pos; + } + } else { + return 1; + } + break; + } + } + if (on & off) { + return 1; + } + um = calloc(1, sizeof(*um)); + if (!um) return 1; + um->on = on; + um->mask = on | off; + expr->argc = 1; + expr->argv = calloc(expr->argc, sizeof(expr->argv[0])); + expr->argv[0] = um; + return 0; + } + + EXPR_EVAL_FUNCTION(expr_umode_eval) + { + struct umode_match *um = expr->argv[0]; + return ((context->source->modes & um->mask) == um->on); + } + + EXPR_FREE_FUNCTION(expr_umode_free) + { + free(expr->argv[0]); + free(expr->argv); + } + static void hash_cleanup(void) { ! DelServer(self, 0, "Cleaning hash"); userList_clean(&curr_opers); *************** *** 963,966 **** --- 1004,1035 ---- if (kf_list) free(kf_list); if (dcf_list) free(dcf_list); + } + + void + hash_init(void) + { + struct expression_operator *op; + + /* Initialize data structures */ + channels = dict_new(); + assert(channels != NULL); + dict_set_free_data(channels, channel_free); + clients = dict_new(); + assert(clients != NULL); + dict_set_free_data(clients, client_free); + servers = dict_new(); + assert(servers != NULL); + dict_set_free_data(servers, free); + userList_init(&curr_opers); + /* Register modules, callbacks, etc. */ + hash_module = module_register("hash", HASH_VERSION, NULL, NULL); + assert(hash_module != NULL); + reg_exit_func(hash_cleanup); + op = calloc(1, sizeof(*op)); + op->name = "umode"; + op->compile = expr_umode_compile; + op->eval = expr_umode_eval; + op->free_ = expr_umode_free; + expression_register_operator(op); } |
From: Entrope <en...@us...> - 2001-10-25 17:26:48
|
Update of /cvsroot/srvx/services/src/srvx In directory usw-pr-cvs1:/tmp/cvs-serv30192/src/srvx Modified Files: dict-splay.c Log Message: avoid tripping an assertion in dict_splay() Index: dict-splay.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/dict-splay.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** dict-splay.c 2001/10/20 18:47:05 1.1 --- dict-splay.c 2001/10/25 17:26:43 1.2 *************** *** 230,233 **** --- 230,234 ---- dict_remove2(dict_t dict, const char *key, int no_dispose) { + if (!dict->root) return 0; dict->root = dict_splay(dict->root, key); if (dict->root && !strcasecmp(key, dict->root->key)) { |
From: Entrope <en...@us...> - 2001-10-25 16:38:26
|
Update of /cvsroot/srvx/services/src/srvx In directory usw-pr-cvs1:/tmp/cvs-serv17173/src/srvx Modified Files: modules.c modules.h Log Message: support aliases for modules (e.g. "proto" "proto_ircu_p10";) allow looking up module commands Index: modules.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/modules.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** modules.c 2001/10/20 18:47:05 1.1 --- modules.c 2001/10/25 16:38:23 1.2 *************** *** 73,77 **** if (!(lib->handle = dlopen(so_name, RTLD_GLOBAL|RTLD_LAZY))) { - log(MAIN_LOG, LOG_ERROR, "Unable to load shared library %s: %s\n", so_name, dlerror()); free(lib); return NULL; --- 73,76 ---- *************** *** 125,136 **** { struct module *mod; ! char path[256], *libname; if ((mod = dict_find(loaded_modules, name, NULL))) return mod; ! /* try to find a shared library that contains the module */ ! /* first: what's specified in the configuration file */ ! snprintf(path, sizeof(path), "modules/%s/path", name); ! if ((libname = database_get_data(conf_db, path, RECDB_QSTRING))) { ! module_load_library(libname); if ((mod = dict_find(loaded_modules, name, NULL))) return mod; } --- 124,159 ---- { struct module *mod; ! struct record_data *rd; ! char path[256]; if ((mod = dict_find(loaded_modules, name, NULL))) return mod; ! /* look to see if we should resolve an alias or anything */ ! rd = dict_find(conf_db, "modules", NULL); ! if (rd) { ! if (rd->type != RECDB_OBJECT) { ! log(MAIN_LOG, LOG_ERROR, N_("\"modules\" key in config DB isn't an object.\n")); ! return NULL; ! } ! rd = dict_find(rd->d.object, name, NULL); ! if (rd) { ! switch (rd->type) { ! case RECDB_QSTRING: ! return module_try_load(rd->d.qstring); ! default: ! log(MAIN_LOG, LOG_ERROR, N_("Unknown/invalid record type for config DB key \"modules\"/\"%s\"."), name); ! return NULL; ! case RECDB_OBJECT: ! /* unaliased name; try to find the shared library */ ! break; ! } ! } ! } ! /* first: what's specified in the configuration file (if anything) */ ! if (rd && (rd = dict_find(rd->d.object, "path", NULL))) { ! if (rd->type != RECDB_QSTRING) { ! log(MAIN_LOG, LOG_ERROR, N_("Config DB key \"modules\"/\"%s\"/\"path\" should be a string, but isn't.\n"), name); ! return NULL; ! } ! module_load_library(rd->d.qstring); if ((mod = dict_find(loaded_modules, name, NULL))) return mod; } *************** *** 198,202 **** { if (dict_find(mod->commands, cmd->name, NULL)) { ! log(MAIN_LOG, LOG_ERROR, "Module %s attempted to insert duplicate command %s\n", mod->name, cmd->name); return; } --- 221,225 ---- { if (dict_find(mod->commands, cmd->name, NULL)) { ! log(MAIN_LOG, LOG_ERROR, N_("Module %s attempted to insert duplicate command %s\n"), mod->name, cmd->name); return; } *************** *** 204,208 **** cmd->default_rule = expression_parse(cmd->default_rule_text); if (!cmd->default_rule) { ! log(MAIN_LOG, LOG_ERROR, "Parse error for default rule for module %s command %s: %s\n", mod->name, cmd->name, cmd->default_rule_text); } } --- 227,231 ---- cmd->default_rule = expression_parse(cmd->default_rule_text); if (!cmd->default_rule) { ! log(MAIN_LOG, LOG_ERROR, N_("Parse error for default rule for module %s command %s: %s\n"), mod->name, cmd->name, cmd->default_rule_text); } } *************** *** 214,217 **** --- 237,246 ---- { return module_resolve_symbol(module->lib, symname); + } + + struct module_command * + module_find_command(struct module *mod, const char *cmd_name) + { + return dict_find(mod->commands, cmd_name, NULL); } Index: modules.h =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/modules.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** modules.h 2001/10/20 18:47:05 1.1 --- modules.h 2001/10/25 16:38:23 1.2 *************** *** 83,86 **** --- 83,87 ---- struct module *module_find_loaded(const char *name); void module_define_command(struct module *mod, struct module_command *cmd); + struct module_command *module_find_command(struct module *mod, const char *cmd_name); void *get_module_symbol(struct module *module, const char *symname); |
From: Entrope <en...@us...> - 2001-10-25 16:32:43
|
Update of /cvsroot/srvx/services/src/srvx In directory usw-pr-cvs1:/tmp/cvs-serv15559/src/srvx Modified Files: common.h Log Message: fix #include's for Boehm GC Index: common.h =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/common.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** common.h 2001/10/24 14:31:54 1.2 --- common.h 2001/10/25 16:32:37 1.3 *************** *** 82,85 **** --- 82,88 ---- #define GC_DEBUG DEBUG #endif + #include <stdlib.h> + #include <string.h> + #include <gc/gc.h> #define malloc(n) GC_MALLOC(n) #define calloc(m,n) GC_MALLOC(m*n) *************** *** 87,91 **** #define free(p) GC_FREE(p) #undef HAVE_STRDUP ! #include <gc/gc.h> #endif --- 90,95 ---- #define free(p) GC_FREE(p) #undef HAVE_STRDUP ! #undef strdup ! #include "compat.h" #endif |
From: Entrope <en...@us...> - 2001-10-25 16:32:18
|
Update of /cvsroot/srvx/services/src/modules In directory usw-pr-cvs1:/tmp/cvs-serv15412/src/modules Modified Files: proto_ircu_p10.c Log Message: fix libirc_notice() like libirc_privmsg() is fixed Index: proto_ircu_p10.c =================================================================== RCS file: /cvsroot/srvx/services/src/modules/proto_ircu_p10.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** proto_ircu_p10.c 2001/10/20 18:47:05 1.1 --- proto_ircu_p10.c 2001/10/25 16:32:15 1.2 *************** *** 355,359 **** libirc_notice(struct user *from, const char *to, const char *message) { ! putsock("%s %s %s :%s", UPROTO(from)->numeric, CMD_NOTICE, to, message); } --- 355,364 ---- libirc_notice(struct user *from, const char *to, const char *message) { ! if (IsChannelName(to)) { ! putsock("%s %s %s :%s", UPROTO(from)->numeric, CMD_NOTICE, to, message); ! } else { ! struct user *user = GetUser(to); ! if (user) putsock("%s %s %s :%s", UPROTO(from)->numeric, CMD_NOTICE, UPROTO(user)->numeric, message); ! } } |
From: Entrope <en...@us...> - 2001-10-24 21:32:38
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv31272/src Modified Files: Tag: rel-1_0 proto.c Log Message: emit a log message when sending an SQUIT Index: proto.c =================================================================== RCS file: /cvsroot/srvx/services/src/Attic/proto.c,v retrieving revision 1.68.2.11 retrieving revision 1.68.2.12 diff -C2 -r1.68.2.11 -r1.68.2.12 *** proto.c 2001/08/23 01:49:17 1.68.2.11 --- proto.c 2001/10/24 21:32:33 1.68.2.12 *************** *** 406,409 **** --- 406,410 ---- /* Force a reconnect to the currently selected server. */ cManager.uplink->tries = 0; + log(MAIN_LOG, LOG_INFO, "Squitting from uplink: %s\n", message); close_socket(); } |
From: Entrope <en...@us...> - 2001-10-24 21:31:37
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv31053/src Modified Files: Tag: rel-1_0 chanserv.h Log Message: change default level for EnfModes and EnfTopic to op Index: chanserv.h =================================================================== RCS file: /cvsroot/srvx/services/src/chanserv.h,v retrieving revision 1.25.2.2 retrieving revision 1.25.2.3 diff -C2 -r1.25.2.2 -r1.25.2.3 *** chanserv.h 2001/08/03 22:46:38 1.25.2.2 --- chanserv.h 2001/10/24 21:31:34 1.25.2.3 *************** *** 74,78 **** #define CHANNEL_DEFAULT_FLAGS (CHANNEL_INFO_LINES) ! #define CHANNEL_DEFAULT_OPTIONS "lmoaaanp" #define IsProtected(x) ((x)->flags & CHANNEL_NODELETE) --- 74,78 ---- #define CHANNEL_DEFAULT_FLAGS (CHANNEL_INFO_LINES) ! #define CHANNEL_DEFAULT_OPTIONS "lmoooanp" #define IsProtected(x) ((x)->flags & CHANNEL_NODELETE) |
From: Entrope <en...@us...> - 2001-10-24 14:35:51
|
Update of /cvsroot/srvx/services/src/modules In directory usw-pr-cvs1:/tmp/cvs-serv10499/src/modules Modified Files: authserv.c authserv.h Log Message: implement most of authserv, except for DB interactions, configuration, and option settings Index: authserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/modules/authserv.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** authserv.c 2001/10/22 13:51:11 1.3 --- authserv.c 2001/10/24 14:35:45 1.4 *************** *** 21,24 **** --- 21,28 ---- #include <ctype.h> #include <stdlib.h> + #ifdef HAVE_SYS_TYPES_H + #include <sys/types.h> + #endif + #include "regex.h" #include "dict.h" *************** *** 33,37 **** #include "authserv.h" ! #define MODMSG_PASSWORD_INVALID "Incorrect password; please try again." /********************/ --- 37,44 ---- #include "authserv.h" ! #define MODMSG_PASSWORD_INVALID N_("Incorrect password; please try again.") ! #define MODMSG_WEAK_PASSWORD N_("Invalid \"weak\" password: %s. Please try again with a harder password.") ! #define MODMSG_WEAK_PASSWORD_CURR N_("WARNING: You are using a password that is considered weak (easy to guess): %s. It is STRONGLY recommended you change it using the $bPASS$b command.") ! #define MODMSG_BAD_HANDLE N_("Handle $b%s$b not registered because it is in use by a network services, or contains invalid characters.") /********************/ *************** *** 58,61 **** --- 65,71 ---- dict_t weak_password_dict; unsigned int password_min_length, password_min_lower, password_min_upper, password_min_other; + const char *default_hostmask; + unsigned int valid_handle_regex_set : 1; + regex_t valid_handle_regex; } cfg; *************** *** 207,210 **** --- 217,322 ---- } + static int + is_valid_handle(const char *handle) + { + struct user *user; + /* cant register a juped nick/service nick as handle, to prevent confusion */ + user = GetUser(handle); + if (user && (user->uplink == self)) return 0; + /* test either regex or containing all valid chars */ + if (cfg.valid_handle_regex_set) { + int err = regexec(&cfg.valid_handle_regex, handle, 0, 0, 0); + if (err) { + char buff[256]; + regerror(err, &cfg.valid_handle_regex, buff, sizeof(buff)); + log(NS_LOG, LOG_INFO, "regexec error: %s (%d)\n", buff, err); + } + return !err; + } else { + return !handle[strspn(handle, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_")]; + } + } + + static struct handle_info * + register_handle(const char *handle, const char *passwd) + { + struct handle_info *hi; + hi = malloc(sizeof(*hi)); + memset(hi, 0, sizeof(*hi)); + hi->userlist_style = HI_DEFAULT_STYLE; + hi->screen_width = MAX_LINE_SIZE; + safestrncpy(hi->handle, handle, sizeof(hi->handle)); + safestrncpy(hi->passwd, passwd, sizeof(hi->passwd)); + hi->info[0] = 0; + dict_insert(handle_dict, hi->handle, hi); + return hi; + } + + static struct handle_info * + authserv_register(struct user *bot, struct user *source, struct user *user, const char *handle, const char *passwd) + { + struct handle_info *hi; + const char *reason; + char crypted[MD5_CRYPT_LENGTH]; + + if ((hi = dict_find(handle_dict, handle, NULL))) { + send_message(bot, source, N_("Handle $b%s$b already registered."), handle); + return NULL; + } + + if (strlen(handle) > (sizeof(hi->handle)-1)) { + send_message(bot, source, N_("Handle too long.")); + return NULL; + } + + if ((reason = is_insecure_password(handle, passwd))) { + send_message(bot, source, MODMSG_WEAK_PASSWORD, reason); + return NULL; + } + + cryptpass(passwd, crypted); + hi = register_handle(handle, crypted); + hi->masks = alloc_string_list(1); + hi->users = NULL; + hi->registered = now; + hi->flags = HI_DEFAULT_FLAGS; + if (user) set_user_handle_info(user, hi); + return hi; + } + + static void + unregister_handle(struct user *bot, struct user *source, struct handle_info *hi) + { + struct user *usr, *next; + unsigned int n; + + send_message(bot, source, N_("Handle $b%s$b has been unregistered."), hi->handle); + log(NS_LOG, LOG_INFO, "Handle '%s' unregistered by %s(%s).\n", hi->handle, source->nick, source->handle_info->handle); + for (n=0; n<unreg_func_used; n++) unreg_func_list[n](bot, source, hi); + for (usr=hi->users; usr; usr=next) { + next = usr->next_authed; + usr->handle_info = NULL; + usr->next_authed = NULL; + } + dict_remove(handle_dict, hi->handle); + } + + static int + oper_outranked(struct user *user, struct handle_info *hi) + { + int outranked = 1; + if (hi->opserv_level < user->handle_info->opserv_level) outranked = 0; + if (hi->opserv_level == user->handle_info->opserv_level) { + if ((user->handle_info->opserv_level == 1000) + || (user->handle_info == hi) + || ((hi->opserv_level == 0) + && !HANDLE_FLAGGED(hi, HELPER) + && IsHelping(user))) { + outranked = 0; + } + } + return outranked; + } + /**********************/ /* EXPORTED FUNCTIONS */ *************** *** 257,261 **** case '*': if (!(hi = get_handle_info(++name))) { ! send_message(bot, source, MSG_HANDLE_UNKNOWN, name); return 0; } --- 369,373 ---- case '*': if (!(hi = get_handle_info(++name))) { ! if (bot) send_message(bot, source, MSG_HANDLE_UNKNOWN, name); return 0; } *************** *** 263,271 **** default: if (!(target = GetUser(name))) { ! send_message(bot, source, MSG_NICK_UNKNOWN, name); return 0; } if (!(hi = target->handle_info)) { ! send_message(bot, source, MSG_USER_AUTHENTICATE, target->nick); return 0; } --- 375,383 ---- default: if (!(target = GetUser(name))) { ! if (bot) send_message(bot, source, MSG_NICK_UNKNOWN, name); return 0; } if (!(hi = target->handle_info)) { ! if (bot) send_message(bot, source, MSG_USER_AUTHENTICATE, target->nick); return 0; } *************** *** 321,346 **** { struct handle_info *hi; - int outranked; if (!(hi = smart_get_handle_info(bot, source, target))) return NULL; if (HANDLE_FLAGGED(source->handle_info, OPER_SUSPENDED)) { send_message(bot, source, MSG_OPER_SUSPENDED); return NULL; - } - outranked = 1; - if (hi->opserv_level < source->handle_info->opserv_level) outranked = 0; - if (hi->opserv_level == source->handle_info->opserv_level) { - if ((source->handle_info->opserv_level == 1000) - || (source->handle_info == hi) - || ((hi->opserv_level == 0) - && !HANDLE_FLAGGED(hi, HELPER) - && IsHelping(source))) { - outranked = 0; - } } ! if (outranked) { send_message(bot, source, MSG_USER_OUTRANKED, hi->handle); return NULL; } return hi; } --- 433,449 ---- { struct handle_info *hi; if (!(hi = smart_get_handle_info(bot, source, target))) return NULL; + if (HANDLE_FLAGGED(source->handle_info, OPER_SUSPENDED)) { send_message(bot, source, MSG_OPER_SUSPENDED); return NULL; } ! ! if (oper_outranked(source, hi)) { send_message(bot, source, MSG_USER_OUTRANKED, hi->handle); return NULL; } + return hi; } *************** *** 407,414 **** } if ((reason = is_insecure_password(hi->handle, passwd))) { ! send_message(bot, source, N_("WARNING: You are using a password that is considered weak (easy to guess): %s. It is STRONGLY recommended you change it using the $bPASS$b command."), reason); } dict_remove(allow_auth_dict, source->nick); ! HANDLE_CLEAR_FLAG(hi, FROZEN); set_user_handle_info(source, hi); send_message(bot, source, N_("I recognize you.")); --- 510,517 ---- } if ((reason = is_insecure_password(hi->handle, passwd))) { ! send_message(bot, source, MODMSG_WEAK_PASSWORD_CURR, reason); } dict_remove(allow_auth_dict, source->nick); ! HANDLE_CLEAR_FLAG(hi, VACATION); set_user_handle_info(source, hi); send_message(bot, source, N_("I recognize you.")); *************** *** 437,441 **** struct handle_info *hi; - (void)channel; MIN_PARMS(3, 0); if (!(target = GetUser(argv[1]))) { --- 540,543 ---- *************** *** 469,473 **** MODULE_COMMAND(cmd_delmask) { - (void)channel; MIN_PARMS(2, 0); authserv_delmask(bot, source, source->handle_info, argv[1]); --- 571,574 ---- *************** *** 503,507 **** if (hi->info[0]) send_message(bot, source, N_(" Infoline: %s"), hi->info); ! if (HANDLE_FLAGGED(hi, FROZEN)) send_message(bot, source, N_(" On vacation.")); /* Don't allow non-privileged users to look at somebody else's handle details. */ --- 604,608 ---- if (hi->info[0]) send_message(bot, source, N_(" Infoline: %s"), hi->info); ! if (HANDLE_FLAGGED(hi, VACATION)) send_message(bot, source, N_(" On vacation.")); /* Don't allow non-privileged users to look at somebody else's handle details. */ *************** *** 562,583 **** } } } MODULE_COMMAND(cmd_password) { ! (void)source; (void)bot; (void)channel; (void)argc; (void)argv; ! /* TODO: implement cmd_password */ } MODULE_COMMAND(cmd_register) { ! (void)source; (void)bot; (void)channel; (void)argc; (void)argv; ! /* TODO: implement cmd_register */ } MODULE_COMMAND(cmd_rename) { ! (void)source; (void)bot; (void)channel; (void)argc; (void)argv; ! /* TODO: implement cmd_rename */ } --- 663,753 ---- } } + + /* TODO: add hook list so modules can print further information (regged nicks, channels, etc) */ } MODULE_COMMAND(cmd_password) { ! struct handle_info *hi; ! const char *old_pass, *new_pass, *reason; ! ! MIN_PARMS(3, 0); ! hi = source->handle_info; ! old_pass = argv[1]; ! new_pass = argv[2]; ! if ((reason = is_insecure_password(hi->handle, new_pass))) { ! send_message(bot, source, MODMSG_WEAK_PASSWORD, reason); ! return; ! } ! if (!checkpass(old_pass, hi->passwd)) { ! send_message(bot, source, MODMSG_PASSWORD_INVALID); ! return; ! } ! cryptpass(new_pass, hi->passwd); ! send_message(bot, source, N_("Password changed")); ! log(NS_LOG, LOG_OTHER, N_("Handle '%s' successfully changed passwords.\n"), hi->handle); ! return; } MODULE_COMMAND(cmd_register) { ! struct handle_info *hi; ! ! if (!IsOper(source) && !dict_size(handle_dict)) { ! /* Require the first handle registered to belong to someone +o. */ ! send_message(bot, source, N_("You must be an $bIRC operator$b to register the first handle.")); ! return; ! } ! ! if (source->handle_info) { ! send_message(bot, source, N_("You are already authenticated to handle $b%s$b -- contact the support staff to rename your handle."), source->handle_info->handle); ! return; ! } ! ! MIN_PARMS(3, 0); ! ! if (!is_valid_handle(argv[1])) { ! send_message(bot, source, MODMSG_BAD_HANDLE, argv[1]); ! return; ! } ! ! if ((hi = authserv_register(bot, source, source, argv[1], argv[2]))) { ! log(NS_LOG, LOG_INFO, "Registered handle '%s' to "IDENT_FORMAT".\n", argv[1], IDENT_DATA(source)); ! /* Add any masks they should get. */ ! if (cfg.default_hostmask) { ! string_list_append(hi->masks, strdup(cfg.default_hostmask)); ! } else { ! string_list_append(hi->masks, generate_hostmask(source, GENMASK_OMITNICK)); ! if (source->ip != 0) { ! string_list_append(hi->masks, generate_hostmask(source, GENMASK_OMITNICK|GENMASK_BYIP)); ! } ! } ! ! /* If they're the first to register, give them level 1000. */ ! if (dict_size(handle_dict) == 1) { ! hi->opserv_level = 1000; ! send_message(bot, source, N_("Handle %s has been granted $bsuperuser privileges$b."), hi->handle); ! } ! } } MODULE_COMMAND(cmd_rename) { ! struct handle_info *hi; ! ! MIN_PARMS(3, 0); ! if (!(hi = get_oper_victim(bot, source, argv[1]))) return; ! if (!is_valid_handle(argv[2])) { ! send_message(bot, source, N_("Handle $b%s$b is in use by a network service or contains invalid characters."), argv[1], argv[2]); ! return; ! } ! if (get_handle_info(argv[2])) { ! send_message(bot, source, N_("Handle $b%s$b already registered."), argv[2]); ! return; ! } ! dict_remove2(handle_dict, hi->handle, 1); ! safestrncpy(hi->handle, argv[2], sizeof(hi->handle)); ! dict_insert(handle_dict, hi->handle, hi); ! send_message(bot, source, N_("$b%s$b's handle has been changed to $b%s$b."), argv[1]+((argv[1][0]=='*')?1:0), argv[2]); } *************** *** 588,613 **** } - MODULE_COMMAND(cmd_status) - { - (void)source; (void)bot; (void)channel; (void)argc; (void)argv; - /* TODO: implement cmd_status */ - } - MODULE_COMMAND(cmd_unregister) { ! (void)source; (void)bot; (void)channel; (void)argc; (void)argv; ! /* TODO: implement cmd_unregister */ } MODULE_COMMAND(cmd_userinfo) { ! (void)source; (void)bot; (void)channel; (void)argc; (void)argv; ! /* TODO: implement cmd_userinfo */ } MODULE_COMMAND(cmd_vacation) { ! (void)source; (void)bot; (void)channel; (void)argc; (void)argv; ! /* TODO: implement cmd_vacation */ } --- 758,797 ---- } MODULE_COMMAND(cmd_unregister) { ! struct handle_info *hi; ! ! MIN_PARMS(2, 0); ! hi = source->handle_info; ! if (checkpass(argv[1], hi->passwd)) { ! log(NS_LOG, LOG_INFO, N_("%s unregistered their handle %s.\n"), source->nick, hi->handle); ! unregister_handle(bot, source, hi); ! } else { ! send_message(bot, source, MODMSG_PASSWORD_INVALID); ! } } MODULE_COMMAND(cmd_userinfo) { ! struct user *target; ! ! MIN_PARMS(2, 0); ! if (!(target = GetUser(argv[1]))) { ! send_message(bot, source, MSG_NICK_UNKNOWN, argv[1]); ! return; ! } ! if (target->handle_info) { ! send_message(bot, source, N_("$b%s$b is authenticated to handle $b%s$b."), target->nick, target->handle_info->handle); ! } else { ! send_message(bot, source, N_("$b%s$b is not authenticated to any handle."), target->nick); ! } ! return; } MODULE_COMMAND(cmd_vacation) { ! (void)channel; (void)argc; (void)argv; ! HANDLE_SET_FLAG(source->handle_info, VACATION); ! send_message(bot, source, N_("You are now on vacation. Have a nice one!")); } *************** *** 618,623 **** EXPR_COMPILE_FUNCTION(rule_authed_comp) { ! (void)expr; (void)argc; (void)pexpr; ! /* TODO: implement rule_authed_comp */ return 0; } --- 802,808 ---- EXPR_COMPILE_FUNCTION(rule_authed_comp) { ! (void)argc; (void)argv; ! expr->argc = 0; ! expr->argv = NULL; return 0; } *************** *** 625,631 **** EXPR_EVAL_FUNCTION(rule_authed_eval) { ! (void)expr; (void)context; ! /* TODO: implement rule_authed_eval */ ! return 0; } --- 810,815 ---- EXPR_EVAL_FUNCTION(rule_authed_eval) { ! (void)expr; ! return context->source->handle_info != NULL; } *************** *** 633,643 **** { (void)expr; - /* TODO: implement rule_authed_free */ } EXPR_COMPILE_FUNCTION(rule_flags_comp) { ! (void)expr; (void)argc; (void)pexpr; ! /* TODO: implement rule_flags_comp */ return 0; } --- 817,864 ---- { (void)expr; } + /* This is used as the first argument for flag matching. */ + struct flags_match { + unsigned long on, mask; + }; + EXPR_COMPILE_FUNCTION(rule_flags_comp) { ! struct flags_match *fm; ! const unsigned char *flags; ! unsigned long on, off; ! int add, pos; ! ! if ((argc < 2) || (argv[1]->type != PEXPR_QSTRING)) return 1; ! expr->argc = 1; ! for (add=1, on=0, off=0, flags=argv[1]->u.qstring; *flags; flags++) { ! switch (*flags) { ! case '+': add = 1; break; ! case '-': add = 0; break; ! default: ! if ((pos = handle_inverse_flags[*flags])) { ! pos--; ! if (add) { ! on |= 1 << pos; ! } else { ! off |= 1 << pos; ! } ! } else { ! return 1; ! } ! break; ! } ! } ! if (on & off) { ! return 1; ! } ! fm = calloc(1, sizeof(*fm)); ! if (!fm) return 1; ! fm->on = on; ! fm->mask = on | off; ! expr->argc = 1; ! expr->argv = calloc(expr->argc, sizeof(expr->argv[0])); ! expr->argv[0] = fm; return 0; } *************** *** 645,663 **** EXPR_EVAL_FUNCTION(rule_flags_eval) { ! (void)expr; (void)context; ! /* TODO: implement rule_flags_eval */ ! return 0; } EXPR_FREE_FUNCTION(rule_flags_free) { ! (void)expr; ! /* TODO: implement rule_flags_free */ } EXPR_COMPILE_FUNCTION(rule_outranks_comp) { ! (void)expr; (void)argc; (void)pexpr; ! /* TODO: implement rule_outranks_comp */ return 0; } --- 866,897 ---- EXPR_EVAL_FUNCTION(rule_flags_eval) { ! struct flags_match *fm; ! struct handle_info *hi; ! ! fm = expr->argv[0]; ! hi = context->source->handle_info; ! return ((hi != NULL) && ((hi->flags & fm->mask) == fm->on)); } EXPR_FREE_FUNCTION(rule_flags_free) { ! free(expr->argv[0]); ! free(expr->argv); } EXPR_COMPILE_FUNCTION(rule_outranks_comp) { ! unsigned int *pint; ! ! if ((argc < 2) ! || (argv[1]->type != PEXPR_TOKEN) ! || (argv[1]->u.token[0] != '$')) { ! return 1; ! } ! pint = malloc(sizeof(*pint)); ! *pint = strtoul(argv[1]->u.token+1, NULL, 0); ! expr->argc = 1; ! expr->argv = calloc(expr->argc, sizeof(expr->argv[0])); ! expr->argv[0] = pint; return 0; } *************** *** 665,683 **** EXPR_EVAL_FUNCTION(rule_outranks_eval) { ! (void)expr; (void)context; ! /* TODO: implement rule_outranks_eval */ ! return 0; } EXPR_FREE_FUNCTION(rule_outranks_free) { ! (void)expr; ! /* TODO: implement rule_outranks_free */ } EXPR_COMPILE_FUNCTION(rule_oslvl_comp) { ! (void)expr; (void)argc; (void)pexpr; ! /* TODO: implement rule_oslvl_comp */ return 0; } --- 899,929 ---- EXPR_EVAL_FUNCTION(rule_outranks_eval) { ! unsigned int *pint; ! struct handle_info *hi; ! ! pint = expr->argv[0]; ! hi = smart_get_handle_info(NULL, context->source, context->argv[*pint]); ! return hi && !oper_outranked(context->source, hi); } EXPR_FREE_FUNCTION(rule_outranks_free) { ! free(expr->argv[0]); ! free(expr->argv); } EXPR_COMPILE_FUNCTION(rule_oslvl_comp) { ! unsigned int *pint; ! ! if ((argc < 2) ! || (argv[1]->type != PEXPR_TOKEN)) { ! return 1; ! } ! pint = malloc(sizeof(*pint)); ! *pint = strtoul(argv[1]->u.token, NULL, 0); ! expr->argc = 1; ! expr->argv = calloc(expr->argc, sizeof(expr->argv[0])); ! expr->argv[0] = pint; return 0; } *************** *** 685,697 **** EXPR_EVAL_FUNCTION(rule_oslvl_eval) { ! (void)expr; (void)context; ! /* TODO: implement rule_oslvl_eval */ ! return 0; } EXPR_FREE_FUNCTION(rule_oslvl_free) { ! (void)expr; ! /* TODO: implement rule_oslvl_free */ } --- 931,946 ---- EXPR_EVAL_FUNCTION(rule_oslvl_eval) { ! unsigned int *pint; ! struct handle_info *hi; ! ! pint = expr->argv[0]; ! hi = context->source->handle_info; ! return hi && (hi->opserv_level >= *pint); } EXPR_FREE_FUNCTION(rule_oslvl_free) { ! free(expr->argv[0]); ! free(expr->argv); } *************** *** 706,710 **** { "rename", 0, NULL, cmd_userinfo, "(umode +o)" }, { "set", REQUIRE_AUTHED, NULL, cmd_set, NULL }, - { "status", 0, NULL, cmd_status, NULL }, { "unregister", REQUIRE_AUTHED, NULL, cmd_unregister, NULL }, { "userinfo", 0, NULL, cmd_userinfo, NULL }, --- 955,958 ---- Index: authserv.h =================================================================== RCS file: /cvsroot/srvx/services/src/modules/authserv.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** authserv.h 2001/10/22 13:51:11 1.3 --- authserv.h 2001/10/24 14:35:45 1.4 *************** *** 35,39 **** #define HI_FLAG_SUSPENDED 0x00000010 #define HI_FLAG_MIRC_COLOR 0x00000020 ! #define HI_FLAG_FROZEN 0x00000040 #define HI_FLAG_NODELETE 0x00000080 /* Flag characters for the above. First char is LSB, etc. */ --- 35,39 ---- #define HI_FLAG_SUSPENDED 0x00000010 #define HI_FLAG_MIRC_COLOR 0x00000020 ! #define HI_FLAG_VACATION 0x00000040 #define HI_FLAG_NODELETE 0x00000080 /* Flag characters for the above. First char is LSB, etc. */ *************** *** 87,93 **** /* unreg_funcs are called right before a handle is unregistered. ! * `user' is the person who caused the handle to be unregistered (either a ! * client authed to the handle, or an oper). */ ! typedef void (*unreg_func_t)(struct user *user, struct handle_info *handle); void reg_unreg_func(unreg_func_t func); --- 87,93 ---- /* unreg_funcs are called right before a handle is unregistered. ! * `user' is the person who caused the handle to be unregistered ! * (either a client authed to the handle, or an oper). */ ! typedef void (*unreg_func_t)(struct user *bot, struct user *user, struct handle_info *handle); void reg_unreg_func(unreg_func_t func); |
From: Entrope <en...@us...> - 2001-10-24 14:31:57
|
Update of /cvsroot/srvx/services/src/srvx In directory usw-pr-cvs1:/tmp/cvs-serv9295/src/srvx Modified Files: common.h compat.c compat.h main.c saxdb.h Log Message: support multiple malloc debugging libraries (adding mpatrol and boehm-gc to list) Index: common.h =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/common.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** common.h 2001/10/20 18:47:05 1.1 --- common.h 2001/10/24 14:31:54 1.2 *************** *** 71,78 **** #define safestrncpy(dest, src, len) do { unsigned char *d = (dest); size_t l = (len); strncpy(d, (src), l); d[l-1] = '\0'; } while (0) ! #if WITH_DMALLOC #define DMALLOC_FUNC_CHECK 1 #include <string.h> #include <dmalloc.h> #endif --- 71,91 ---- #define safestrncpy(dest, src, len) do { unsigned char *d = (dest); size_t l = (len); strncpy(d, (src), l); d[l-1] = '\0'; } while (0) ! #if defined(WITH_MALLOC_DMALLOC) #define DMALLOC_FUNC_CHECK 1 #include <string.h> #include <dmalloc.h> + #elif defined(WITH_MALLOC_MPATROL) + #include <string.h> + #include <mpatrol.h> + #elif defined(WITH_MALLOC_BOEHM_GC) + #if defined(DEBUG) + #define GC_DEBUG DEBUG + #endif + #define malloc(n) GC_MALLOC(n) + #define calloc(m,n) GC_MALLOC(m*n) + #define realloc(p,n) GC_REALLOC(p,n) + #define free(p) GC_FREE(p) + #undef HAVE_STRDUP + #include <gc/gc.h> #endif Index: compat.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/compat.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** compat.c 2001/10/20 22:27:36 1.2 --- compat.c 2001/10/24 14:31:54 1.3 *************** *** 124,127 **** --- 124,128 ---- #ifndef HAVE_STRDUP + #undef strdup extern char * strdup(char const * str) { Index: compat.h =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/compat.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** compat.h 2001/10/20 18:47:05 1.1 --- compat.h 2001/10/24 14:31:54 1.2 *************** *** 39,42 **** --- 39,44 ---- #ifndef HAVE_STRDUP + /* Just in case it's a macro and we're using Boehm GC */ + #undef strdup extern char * strdup(char const * str); #endif Index: main.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/main.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** main.c 2001/10/20 18:47:05 1.1 --- main.c 2001/10/24 14:31:54 1.2 *************** *** 335,338 **** --- 335,341 ---- daemon = 1; silent = 1; + #if defined(WITH_MALLOC_BOEHM_GC) + GC_find_leak = 1; + #endif /* set up some signal handlers */ Index: saxdb.h =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/saxdb.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** saxdb.h 2001/10/20 18:47:05 1.1 --- saxdb.h 2001/10/24 14:31:54 1.2 *************** *** 20,23 **** --- 20,25 ---- #define SAXDB_H + #include <stddef.h> /* for offsetof() */ + #include "config.h" #include "dict.h" |
From: Entrope <en...@us...> - 2001-10-24 14:31:57
|
Update of /cvsroot/srvx/services In directory usw-pr-cvs1:/tmp/cvs-serv9295 Modified Files: configure.ac Log Message: support multiple malloc debugging libraries (adding mpatrol and boehm-gc to list) Index: configure.ac =================================================================== RCS file: /cvsroot/srvx/services/configure.ac,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** configure.ac 2001/10/20 22:27:36 1.17 --- configure.ac 2001/10/24 14:31:53 1.18 *************** *** 204,217 **** ]) ! AC_ARG_WITH(dmalloc, ! [ --with-dmalloc Enables use of the dmalloc library, as in ! http://dmalloc.com/], ! [AC_CHECK_HEADERS(dmalloc.h,,AC_MSG_ERROR([dmalloc header file missing. dmalloc build will fail.])) AC_CHECK_LIB(dmallocth, malloc,, AC_CHECK_LIB(dmalloc, malloc, AC_MSG_ERROR([dmalloc library is missing thread support. dmalloc build will fail.]), AC_MSG_ERROR([dmalloc library is missing completely. dmalloc build will fail.]))) ! AC_DEFINE(WITH_DMALLOC, 1, [Define if using the dmalloc debugging malloc package]) ! LDFLAGS="$LDFLAGS -g"]) AC_ARG_WITH(getopt, [ --without-getopt Disables building of the GNU getopt library], --- 204,237 ---- ]) ! AC_ARG_WITH(malloc, ! [ --with-malloc=type Enables use of a special malloc library; one of: ! system (the default), dmalloc, mpatrol, boehm-gc], ! [], ! [withval="system"]) ! if test "x$withval" = "xsystem" ; then ! : ! # Do nothing; this is the default ! elif test "x$withval" = "xdmalloc" ; then ! AC_CHECK_HEADERS(dmalloc.h,,AC_MSG_ERROR([dmalloc header file missing. dmalloc build will fail.])) AC_CHECK_LIB(dmallocth, malloc,, AC_CHECK_LIB(dmalloc, malloc, AC_MSG_ERROR([dmalloc library is missing thread support. dmalloc build will fail.]), AC_MSG_ERROR([dmalloc library is missing completely. dmalloc build will fail.]))) ! AC_DEFINE(WITH_MALLOC_DMALLOC, 1, [Define if using the dmalloc malloc debugging package]) ! elif test "x$withval" = "xmpatrol" ; then ! AC_CHECK_HEADERS(mpatrol.h,,AC_MSG_ERROR([mpatrol header file missing. mpatrol build will fail.])) ! AC_CHECK_LIB(mpatrolmt, malloc,, ! AC_CHECK_LIB(mpatrol, malloc, ! AC_MSG_ERROR([mpatrol library is missing thread support. mpatrol build will fail.]), ! AC_MSG_ERROR([mpatrol library is missing. mpatrol build will fail.]))) ! AC_DEFINE(WITH_MALLOC_MPATROL, 1, [Define if using the mpatrol malloc debugging package]) ! elif test "x$withval" = "xboehm-gc" ; then ! AC_CHECK_HEADERS(gc/gc.h,,AC_MSG_ERROR([Boehm GC header file missing. boehm-gc build will fail.])) ! AC_CHECK_LIB(gc, GC_gcollect, , AC_MSG_ERROR([Boehm GC library is missing. boehm-gc build will fail.])) ! AC_DEFINE(WITH_MALLOC_BOEHM_GC, 1, [Define if using the Boehm GC to garbage collect and check memory leaks]) ! else ! AC_MSG_ERROR([Unknown malloc type $withval]) ! fi ! AC_ARG_WITH(getopt, [ --without-getopt Disables building of the GNU getopt library], |
From: Entrope <en...@us...> - 2001-10-23 21:07:09
|
Update of /cvsroot/srvx/services/src/srvx In directory usw-pr-cvs1:/tmp/cvs-serv18087/src/srvx Modified Files: rules.c rules.h service.c Log Message: rename some struct members so they're consistent with other instances of the same ideas Index: rules.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/rules.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** rules.c 2001/10/23 12:32:12 1.2 --- rules.c 2001/10/23 21:07:07 1.3 *************** *** 25,28 **** --- 25,31 ---- #include "rules.h" + /* We allow tokens to be alphanumeric, or one of "+-_$" */ + #define istokchar(CH) (isalnum(CH) || ((CH) == '+') || ((CH) == '-') || ((CH) == '_') || ((CH) == '$')) + static dict_t expr_opers; *************** *** 61,69 **** unsigned int maxlen; ! for (pos=*string; *pos && isalnum(*pos); pos++) ; if (!*pos) return NULL; maxlen = pos - *string; dp = dest = malloc(maxlen); ! for (pos=*string; *pos && isalnum(*pos); pos++) *dp++ = *pos; *dp = 0; *string = pos; --- 64,72 ---- unsigned int maxlen; ! for (pos=*string; *pos && istokchar(*pos); pos++) ; if (!*pos) return NULL; maxlen = pos - *string; dp = dest = malloc(maxlen); ! for (pos=*string; *pos && istokchar(*pos); pos++) *dp++ = *pos; *dp = 0; *string = pos; *************** *** 100,104 **** arg->u.qstring = expr_parse_string(&string); if (!arg->u.qstring) while (*string) (string)++; ! } else if (isalnum(*string)) { arg->type = PEXPR_TOKEN; arg->u.token = expr_parse_token(&string); --- 103,107 ---- arg->u.qstring = expr_parse_string(&string); if (!arg->u.qstring) while (*string) (string)++; ! } else if (istokchar(*string)) { arg->type = PEXPR_TOKEN; arg->u.token = expr_parse_token(&string); *************** *** 189,200 **** unsigned int nn; expr->argc = argc - 1; ! expr->args = malloc(expr->argc * sizeof(expr->args[0])); for (nn=1; nn<argc; nn++) { ! if (pexpr[nn]->type != PEXPR_EXPR) break; ! expr->args[nn-1] = pexpr[nn]->u.expr; ! pexpr[nn]->u.expr = NULL; /* "steal" it */ } if (nn < expr->argc) { ! free(expr->args); return 1; } --- 192,203 ---- unsigned int nn; expr->argc = argc - 1; ! expr->argv = malloc(expr->argc * sizeof(expr->argv[0])); for (nn=1; nn<argc; nn++) { ! if (argv[nn]->type != PEXPR_EXPR) break; ! expr->argv[nn-1] = argv[nn]->u.expr; ! argv[nn]->u.expr = NULL; /* "steal" it */ } if (nn < expr->argc) { ! free(expr->argv); return 1; } *************** *** 204,208 **** static EXPR_COMPILE_FUNCTION(oper_not_compile) { ! return (argc != 2) ? 1 : oper_subexpr_compile(expr, argc, pexpr); } --- 207,211 ---- static EXPR_COMPILE_FUNCTION(oper_not_compile) { ! return (argc != 2) ? 1 : oper_subexpr_compile(expr, argc, argv); } *************** *** 213,217 **** for (nn=0; nn<expr->argc; nn++) { ! if ((res = expression_evaluate(expr->args[nn], context))) return res; } return 0; --- 216,220 ---- for (nn=0; nn<expr->argc; nn++) { ! if ((res = expression_evaluate(expr->argv[nn], context))) return res; } return 0; *************** *** 223,227 **** for (nn=0; nn<expr->argc; nn++) { ! if (!expression_evaluate(expr->args[nn], context)) return 0; } return 1; --- 226,230 ---- for (nn=0; nn<expr->argc; nn++) { ! if (!expression_evaluate(expr->argv[nn], context)) return 0; } return 1; *************** *** 230,234 **** static EXPR_EVAL_FUNCTION(oper_not_eval) { ! return !expression_evaluate(expr->args[0], context); } --- 233,237 ---- static EXPR_EVAL_FUNCTION(oper_not_eval) { ! return !expression_evaluate(expr->argv[0], context); } *************** *** 239,243 **** unsigned int nn; for (nn=0; nn<expr->argc; nn++) { ! expression_free(expr->args[nn]); } } --- 242,246 ---- unsigned int nn; for (nn=0; nn<expr->argc; nn++) { ! expression_free(expr->argv[nn]); } } *************** *** 246,252 **** static EXPR_COMPILE_FUNCTION(oper_constant_compile) { ! (void)argc; (void)pexpr; expr->argc = 0; ! expr->args = NULL; return 0; } --- 249,255 ---- static EXPR_COMPILE_FUNCTION(oper_constant_compile) { ! (void)argc; (void)argv; expr->argc = 0; ! expr->argv = NULL; return 0; } Index: rules.h =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/rules.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** rules.h 2001/10/23 12:32:51 1.2 --- rules.h 2001/10/23 21:07:07 1.3 *************** *** 23,27 **** struct expression_context { ! struct user *user; struct channel *channel; unsigned int argc; --- 23,27 ---- struct expression_context { ! struct user *source; struct channel *channel; unsigned int argc; *************** *** 29,33 **** }; ! #define EXPR_COMPILE_FUNCTION(FUNC) int FUNC(struct expression *expr, unsigned int argc, struct parse_expression **pexpr) #define EXPR_EVAL_FUNCTION(FUNC) int FUNC(struct expression *expr, struct expression_context *context) #define EXPR_FREE_FUNCTION(FUNC) void FUNC(struct expression *expr) --- 29,33 ---- }; ! #define EXPR_COMPILE_FUNCTION(FUNC) int FUNC(struct expression *expr, unsigned int argc, struct parse_expression **argv) #define EXPR_EVAL_FUNCTION(FUNC) int FUNC(struct expression *expr, struct expression_context *context) #define EXPR_FREE_FUNCTION(FUNC) void FUNC(struct expression *expr) *************** *** 36,40 **** struct expression_operator *oper; unsigned int argc; ! void **args; }; --- 36,40 ---- struct expression_operator *oper; unsigned int argc; ! void **argv; }; Index: service.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/service.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** service.c 2001/10/23 12:32:51 1.3 --- service.c 2001/10/23 21:07:07 1.4 *************** *** 92,96 **** void ! service_chanmsg(struct user *bot, struct user *source, struct channel *chan, char *real_text) { unsigned char *text = real_text; --- 92,96 ---- void ! service_chanmsg(struct user *bot, struct user *source, struct channel *channel, char *real_text) { unsigned char *text = real_text; *************** *** 101,105 **** struct expression_context rule_ctx; - (void)source; (void)chan; shift = 0; argc = split_line(text, 0, ArrayLength(argv), argv); --- 101,104 ---- *************** *** 134,146 **** } if ((cmd->base->flags & (1 << TAKES_CHANNEL)) && shift) { ! chan = GetChannel(argv[shift-1]); } ! if ((cmd->base->flags & (1 << REQUIRE_CHANNEL)) && !chan) { send_message(bot, source, MSG_INVALID_CHANNEL); return; } /* Fill in rule context and evaluate it */ ! rule_ctx.user = source; ! rule_ctx.channel = chan; rule_ctx.argc = argc-shift; rule_ctx.argv = argv+shift; --- 133,145 ---- } if ((cmd->base->flags & (1 << TAKES_CHANNEL)) && shift) { ! channel = GetChannel(argv[shift-1]); } ! if ((cmd->base->flags & (1 << REQUIRE_CHANNEL)) && !channel) { send_message(bot, source, MSG_INVALID_CHANNEL); return; } /* Fill in rule context and evaluate it */ ! rule_ctx.source = source; ! rule_ctx.channel = channel; rule_ctx.argc = argc-shift; rule_ctx.argv = argv+shift; *************** *** 149,153 **** return; } ! cmd->base->function(bot, source, chan, argc-shift, argv+shift); } --- 148,152 ---- return; } ! cmd->base->function(bot, source, channel, argc-shift, argv+shift); } |
From: Zoot <zo...@us...> - 2001-10-23 20:08:47
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv24996/src Modified Files: Tag: rel-1_0 chanserv.c Log Message: Fix a dumb bug that caused ChanServ to essentially protect users when the channel options were set otherwise. Index: chanserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/chanserv.c,v retrieving revision 1.161.2.86 retrieving revision 1.161.2.87 diff -C2 -r1.161.2.86 -r1.161.2.87 *** chanserv.c 2001/10/17 01:48:47 1.161.2.86 --- chanserv.c 2001/10/23 20:08:44 1.161.2.87 *************** *** 1490,1495 **** --- 1490,1497 ---- case 'l': if(cs_victim->access > cs_aggressor->access) return 1; + break; case 'e': if(cs_victim->access >= cs_aggressor->access) return 1; + break; } |
From: Entrope <en...@us...> - 2001-10-23 12:32:53
|
Update of /cvsroot/srvx/services/src/srvx In directory usw-pr-cvs1:/tmp/cvs-serv12512/src/srvx Modified Files: rules.h service.c Log Message: add argc, argv to expression_context (needed for things like "(outranks $1)") Index: rules.h =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/rules.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** rules.h 2001/10/20 18:47:05 1.1 --- rules.h 2001/10/23 12:32:51 1.2 *************** *** 25,28 **** --- 25,30 ---- struct user *user; struct channel *channel; + unsigned int argc; + unsigned char **argv; }; Index: service.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/service.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** service.c 2001/10/22 13:50:45 1.2 --- service.c 2001/10/23 12:32:51 1.3 *************** *** 128,131 **** --- 128,132 ---- cmd = service_find_command(sinst, argv[0]); } + /* Check flags */ if ((cmd->base->flags & (1 << REQUIRE_AUTHED)) && !source->handle_info) { send_message(bot, source, N_("You must authenticate yourself first.")); *************** *** 142,145 **** --- 143,148 ---- rule_ctx.user = source; rule_ctx.channel = chan; + rule_ctx.argc = argc-shift; + rule_ctx.argv = argv+shift; if (!expression_evaluate(cmd->rule ? cmd->rule : cmd->base->default_rule, &rule_ctx)) { send_message(bot, source, N_("Access to $b%s$b denied."), argv[shift]); |
From: Entrope <en...@us...> - 2001-10-23 12:32:16
|
Update of /cvsroot/srvx/services/src/srvx In directory usw-pr-cvs1:/tmp/cvs-serv12232/src/srvx Modified Files: rules.c Log Message: add error messages to expr_parse_int Index: rules.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/rules.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** rules.c 2001/10/20 18:47:05 1.1 --- rules.c 2001/10/23 12:32:12 1.2 *************** *** 77,85 **** unsigned int nn, argno, num_args; struct parse_expression **args, *arg; ! const unsigned char *string; string = *input; if (*string++ != '(') return NULL; expr = NULL; argno = 0; num_args = 4; --- 77,86 ---- unsigned int nn, argno, num_args; struct parse_expression **args, *arg; ! const unsigned char *string, *errmsg; string = *input; if (*string++ != '(') return NULL; expr = NULL; + errmsg = "Unknown error"; argno = 0; num_args = 4; *************** *** 107,119 **** while (*string) (string)++; } ! if (!*string) goto out; ! if (expr_skip_whitespace(&string)) goto out; } ! if (!*string) goto out; /* make sure first argument (start of list) is a token */ ! if (args[0]->type != PEXPR_TOKEN) goto out; expr = calloc(1, sizeof(*expr)); /* look up expression operator and "compile" expression */ if (!(expr->oper = dict_find(expr_opers, args[0]->u.token, NULL))) { free(expr); expr = NULL; --- 108,126 ---- while (*string) (string)++; } ! if (*string) expr_skip_whitespace(&string); } ! if (!*string) { ! errmsg = "Expected more input"; ! goto out; ! } /* make sure first argument (start of list) is a token */ ! if (args[0]->type != PEXPR_TOKEN) { ! errmsg = "First list element isn't a token"; ! goto out; ! } expr = calloc(1, sizeof(*expr)); /* look up expression operator and "compile" expression */ if (!(expr->oper = dict_find(expr_opers, args[0]->u.token, NULL))) { + errmsg = "Unknown operator"; free(expr); expr = NULL; *************** *** 121,124 **** --- 128,132 ---- } if (expr->oper->compile(expr, argno, args)) { + errmsg = "Compile failure"; free(expr); expr = NULL; *************** *** 126,129 **** --- 134,138 ---- } out: + if (!expr) log(MAIN_LOG, LOG_ERROR, "Expression parse error: %s\n", errmsg); for (nn=0; nn<argno; nn++) { switch ((arg = args[nn])->type) { |
From: Entrope <en...@us...> - 2001-10-22 13:51:14
|
Update of /cvsroot/srvx/services/src/modules In directory usw-pr-cvs1:/tmp/cvs-serv6220 Modified Files: authserv.c authserv.h Log Message: implement more of AuthServ module consistently put service bot before user in argument lists Index: authserv.c =================================================================== RCS file: /cvsroot/srvx/services/src/modules/authserv.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** authserv.c 2001/10/20 19:23:12 1.2 --- authserv.c 2001/10/22 13:51:11 1.3 *************** *** 61,69 **** #define NEED_CHANNEL() do { if (!channel) { \ ! send_message(source, bot, MSG_INVALID_CHANNEL); \ return; } } while (0) #define MIN_PARMS(N, NEEDCHAN) do { \ if (argc < N) { \ ! send_message(source, bot, MSG_MISSING_PARAMS, argv[0]); \ return; } \ if (NEEDCHAN) NEED_CHANNEL(); } \ --- 61,69 ---- #define NEED_CHANNEL() do { if (!channel) { \ ! send_message(bot, source, MSG_INVALID_CHANNEL); \ return; } } while (0) #define MIN_PARMS(N, NEEDCHAN) do { \ if (argc < N) { \ ! send_message(bot, source, MSG_MISSING_PARAMS, argv[0]); \ return; } \ if (NEEDCHAN) NEED_CHANNEL(); } \ *************** *** 96,105 **** default: if (!(pos = handle_inverse_flags[flags[n]])) { ! send_message(source, bot, N_("$b%c$b is not a valid handle flag."), flags[n]); return 0; } if (source->handle_info->opserv_level < flag_access_levels[pos-1]) { /* cheesy avoidance of looking up the flag name.. */ ! send_message(source, bot, MSG_SETTING_PRIVILEGED, "That flag"); return 0; } --- 96,105 ---- default: if (!(pos = handle_inverse_flags[flags[n]])) { ! send_message(bot, source, N_("$b%c$b is not a valid handle flag."), flags[n]); return 0; } if (source->handle_info->opserv_level < flag_access_levels[pos-1]) { /* cheesy avoidance of looking up the flag name.. */ ! send_message(bot, source, MSG_SETTING_PRIVILEGED, "That flag"); return 0; } *************** *** 257,261 **** case '*': if (!(hi = get_handle_info(++name))) { ! send_message(source, bot, MSG_HANDLE_UNKNOWN, name); return 0; } --- 257,261 ---- case '*': if (!(hi = get_handle_info(++name))) { ! send_message(bot, source, MSG_HANDLE_UNKNOWN, name); return 0; } *************** *** 263,271 **** default: if (!(target = GetUser(name))) { ! send_message(source, bot, MSG_NICK_UNKNOWN, name); return 0; } if (!(hi = target->handle_info)) { ! send_message(source, bot, MSG_USER_AUTHENTICATE, target->nick); return 0; } --- 263,271 ---- default: if (!(target = GetUser(name))) { ! send_message(bot, source, MSG_NICK_UNKNOWN, name); return 0; } if (!(hi = target->handle_info)) { ! send_message(bot, source, MSG_USER_AUTHENTICATE, target->nick); return 0; } *************** *** 275,279 **** int ! authserv_addmask(struct user *source, struct user *bot, struct handle_info *hi, const char *mask) { unsigned int i; --- 275,279 ---- int ! authserv_addmask(struct user *bot, struct user *source, struct handle_info *hi, const char *mask) { unsigned int i; *************** *** 283,287 **** for (i=0; i<hi->masks->used; i++) { if (!strcasecmp(new_mask, hi->masks->list[i])) { ! send_message(source, bot, N_("$b%s$b is already a hostmask in your handle."), new_mask); free(new_mask); return 0; --- 283,287 ---- for (i=0; i<hi->masks->used; i++) { if (!strcasecmp(new_mask, hi->masks->list[i])) { ! send_message(bot, source, N_("$b%s$b is already a hostmask in your handle."), new_mask); free(new_mask); return 0; *************** *** 289,293 **** } string_list_append(hi->masks, new_mask); ! send_message(source, bot, N_("Hostmask $b%s$b added."), new_mask); log(NS_LOG, LOG_OTHER, "'%s' added new mask '%s' to handle '%s'.\n", source->nick, new_mask, hi->handle); return 1; --- 289,293 ---- } string_list_append(hi->masks, new_mask); ! send_message(bot, source, N_("Hostmask $b%s$b added."), new_mask); log(NS_LOG, LOG_OTHER, "'%s' added new mask '%s' to handle '%s'.\n", source->nick, new_mask, hi->handle); return 1; *************** *** 295,299 **** int ! authserv_delmask(struct user *source, struct user *bot, struct handle_info *hi, const char *del_mask) { unsigned int i; --- 295,299 ---- int ! authserv_delmask(struct user *bot, struct user *source, struct handle_info *hi, const char *del_mask) { unsigned int i; *************** *** 303,311 **** char *old_mask = hi->masks->list[i]; if (hi->masks->used == 1) { ! send_message(source, bot, N_("You may not delete your last hostmask.")); return 0; } hi->masks->list[i] = hi->masks->list[--hi->masks->used]; ! send_message(source, bot, N_("Hostmask %s deleted."), old_mask); log(NS_LOG, LOG_OTHER, N_("'%s' deleted mask '%s' from handle '%s'.\n"), source->nick, old_mask, hi->handle); free(old_mask); --- 303,311 ---- char *old_mask = hi->masks->list[i]; if (hi->masks->used == 1) { ! send_message(bot, source, N_("You may not delete your last hostmask.")); return 0; } hi->masks->list[i] = hi->masks->list[--hi->masks->used]; ! send_message(bot, source, N_("Hostmask %s deleted."), old_mask); log(NS_LOG, LOG_OTHER, N_("'%s' deleted mask '%s' from handle '%s'.\n"), source->nick, old_mask, hi->handle); free(old_mask); *************** *** 313,320 **** } } ! send_message(source, bot, N_("Unable to find mask to be deleted.")); return 0; } /*******************/ /* MODULE COMMANDS */ --- 313,370 ---- } } ! send_message(bot, source, N_("Unable to find mask to be deleted.")); return 0; } + struct handle_info * + get_oper_victim(struct user *bot, struct user *source, const char *target) + { + struct handle_info *hi; + int outranked; + + if (!(hi = smart_get_handle_info(bot, source, target))) return NULL; + if (HANDLE_FLAGGED(source->handle_info, OPER_SUSPENDED)) { + send_message(bot, source, MSG_OPER_SUSPENDED); + return NULL; + } + outranked = 1; + if (hi->opserv_level < source->handle_info->opserv_level) outranked = 0; + if (hi->opserv_level == source->handle_info->opserv_level) { + if ((source->handle_info->opserv_level == 1000) + || (source->handle_info == hi) + || ((hi->opserv_level == 0) + && !HANDLE_FLAGGED(hi, HELPER) + && IsHelping(source))) { + outranked = 0; + } + } + if (outranked) { + send_message(bot, source, MSG_USER_OUTRANKED, hi->handle); + return NULL; + } + return hi; + } + + int + is_valid_oper(struct user *bot, struct user *source, unsigned int min_level) + { + if (!IsPrivileged(source) || (min_level && !IsOper(source))) { + send_message(bot, source, N_("Access denied!")); + return 0; + } + + if (HANDLE_FLAGGED(source->handle_info, OPER_SUSPENDED)) { + send_message(bot, source, MSG_OPER_SUSPENDED); + return 0; + } + + if (source->handle_info->opserv_level < min_level) { + send_message(bot, source, N_("Access denied!")); + return 0; + } + + return 1; + } + /*******************/ /* MODULE COMMANDS */ *************** *** 334,366 **** passwd = argv[1]; } else { ! send_message(source, bot, MSG_MISSING_PARAMS, argv[0]); return; } if (!hi) { ! send_message(source, bot, N_("Handle not found -- did you register yet?")); return; } if (!valid_user_for(source, hi)) { ! send_message(source, bot, N_("Your hostmask is not valid.")); log(NS_LOG, LOG_OTHER, N_(IDENT_FORMAT" did not have a matching host for handle '%s'.\n"), IDENT_DATA(source), hi->handle); return; } if (!checkpass(passwd, hi->passwd)) { ! send_message(source, bot, MODMSG_PASSWORD_INVALID); log(NS_LOG, LOG_OTHER, N_(IDENT_FORMAT" had the wrong password for handle '%s'.\n"), IDENT_DATA(source), hi->handle); return; } if (HANDLE_FLAGGED(hi, SUSPENDED)) { ! send_message(source, bot, N_("Your handle has been suspended, and cannot be used.")); log(NS_LOG, LOG_OTHER, N_(IDENT_FORMAT" tried to auth to suspended handle '%s'.\n"), IDENT_DATA(source), hi->handle); return; } if ((reason = is_insecure_password(hi->handle, passwd))) { ! send_message(source, bot, N_("WARNING: You are using a password that is considered weak (easy to guess): %s. It is STRONGLY recommended you change it using the $bPASS$b command."), reason); } dict_remove(allow_auth_dict, source->nick); HANDLE_CLEAR_FLAG(hi, FROZEN); set_user_handle_info(source, hi); ! send_message(source, bot, N_("I recognize you.")); log(NS_LOG, LOG_INFO, N_(IDENT_FORMAT" was authenticated to handle '%s'.\n"), IDENT_DATA(source), hi->handle); } --- 384,416 ---- passwd = argv[1]; } else { ! send_message(bot, source, MSG_MISSING_PARAMS, argv[0]); return; } if (!hi) { ! send_message(bot, source, N_("Handle not found -- did you register yet?")); return; } if (!valid_user_for(source, hi)) { ! send_message(bot, source, N_("Your hostmask is not valid.")); log(NS_LOG, LOG_OTHER, N_(IDENT_FORMAT" did not have a matching host for handle '%s'.\n"), IDENT_DATA(source), hi->handle); return; } if (!checkpass(passwd, hi->passwd)) { ! send_message(bot, source, MODMSG_PASSWORD_INVALID); log(NS_LOG, LOG_OTHER, N_(IDENT_FORMAT" had the wrong password for handle '%s'.\n"), IDENT_DATA(source), hi->handle); return; } if (HANDLE_FLAGGED(hi, SUSPENDED)) { ! send_message(bot, source, N_("Your handle has been suspended, and cannot be used.")); log(NS_LOG, LOG_OTHER, N_(IDENT_FORMAT" tried to auth to suspended handle '%s'.\n"), IDENT_DATA(source), hi->handle); return; } if ((reason = is_insecure_password(hi->handle, passwd))) { ! send_message(bot, source, N_("WARNING: You are using a password that is considered weak (easy to guess): %s. It is STRONGLY recommended you change it using the $bPASS$b command."), reason); } dict_remove(allow_auth_dict, source->nick); HANDLE_CLEAR_FLAG(hi, FROZEN); set_user_handle_info(source, hi); ! send_message(bot, source, N_("I recognize you.")); log(NS_LOG, LOG_INFO, N_(IDENT_FORMAT" was authenticated to handle '%s'.\n"), IDENT_DATA(source), hi->handle); } *************** *** 371,381 **** if (argc < 2) { char *mask = generate_hostmask(source, GENMASK_OMITNICK); ! authserv_addmask(source, bot, source->handle_info, mask); free(mask); } else { if (is_gline(argv[1])) { ! authserv_addmask(source, bot, source->handle_info, argv[1]); } else { ! send_message(source, bot, N_("$b%s$b is an invalid hostmask."), argv[1]); } } --- 421,431 ---- if (argc < 2) { char *mask = generate_hostmask(source, GENMASK_OMITNICK); ! authserv_addmask(bot, source, source->handle_info, mask); free(mask); } else { if (is_gline(argv[1])) { ! authserv_addmask(bot, source, source->handle_info, argv[1]); } else { ! send_message(bot, source, N_("$b%s$b is an invalid hostmask."), argv[1]); } } *************** *** 390,416 **** MIN_PARMS(3, 0); if (!(target = GetUser(argv[1]))) { ! send_message(source, bot, MSG_NICK_UNKNOWN, argv[1]); return; } if (!strcasecmp(argv[2], "none")) hi = NULL; else if (!(hi = get_handle_info(argv[2]))) { ! send_message(source, bot, MSG_HANDLE_UNKNOWN, argv[2]); return; } if (hi) { if (hi->opserv_level > source->handle_info->opserv_level) { ! send_message(source, bot, MSG_USER_OUTRANKED, hi->handle); return; } dict_insert(allow_auth_dict, target->nick, hi); ! send_message(source, bot, N_("User $b%s$b may now authenticate to handle $b%s$b."), target->nick, hi->handle); send_message(target, bot, N_("You may now authenticate to handle $b%s$b by typing $b/msg $n auth %s password$b (using your password)."), hi->handle, hi->handle); log(NS_LOG, LOG_INFO, "%s allowed "IDENT_FORMAT" to authenticate to handle '%s'.\n", source->handle_info->handle, IDENT_DATA(target), hi->handle); } else { if (dict_remove(allow_auth_dict, target->nick)) { ! send_message(source, bot, N_("User $b%s$b may now only authenticate to handles with matching hostmasks."), target->nick); log(NS_LOG, LOG_INFO, "%s removed "IDENT_FORMAT"'s authorization to auth without hostmask.", source->handle_info->handle, IDENT_DATA(target)); } else { ! send_message(source, bot, N_("User $b%s$b did not have any special auth allowance."), target->nick); } } --- 440,466 ---- MIN_PARMS(3, 0); if (!(target = GetUser(argv[1]))) { ! send_message(bot, source, MSG_NICK_UNKNOWN, argv[1]); return; } if (!strcasecmp(argv[2], "none")) hi = NULL; else if (!(hi = get_handle_info(argv[2]))) { ! send_message(bot, source, MSG_HANDLE_UNKNOWN, argv[2]); return; } if (hi) { if (hi->opserv_level > source->handle_info->opserv_level) { ! send_message(bot, source, MSG_USER_OUTRANKED, hi->handle); return; } dict_insert(allow_auth_dict, target->nick, hi); ! send_message(bot, source, N_("User $b%s$b may now authenticate to handle $b%s$b."), target->nick, hi->handle); send_message(target, bot, N_("You may now authenticate to handle $b%s$b by typing $b/msg $n auth %s password$b (using your password)."), hi->handle, hi->handle); log(NS_LOG, LOG_INFO, "%s allowed "IDENT_FORMAT" to authenticate to handle '%s'.\n", source->handle_info->handle, IDENT_DATA(target), hi->handle); } else { if (dict_remove(allow_auth_dict, target->nick)) { ! send_message(bot, source, N_("User $b%s$b may now only authenticate to handles with matching hostmasks."), target->nick); log(NS_LOG, LOG_INFO, "%s removed "IDENT_FORMAT"'s authorization to auth without hostmask.", source->handle_info->handle, IDENT_DATA(target)); } else { ! send_message(bot, source, N_("User $b%s$b did not have any special auth allowance."), target->nick); } } *************** *** 421,431 **** (void)channel; MIN_PARMS(2, 0); ! authserv_delmask(source, bot, source->handle_info, argv[1]); } MODULE_COMMAND(cmd_handleinfo) { ! (void)source; (void)bot; (void)channel; (void)argc; (void)argv; ! /* TODO: implement cmd_handleinfo */ } --- 471,565 ---- (void)channel; MIN_PARMS(2, 0); ! authserv_delmask(bot, source, source->handle_info, argv[1]); } MODULE_COMMAND(cmd_handleinfo) { ! char buff[400]; ! unsigned int i, pos=0, herelen; ! struct user *target, *next_user; ! struct handle_info *hi; ! ! (void)channel; ! ! if (argc < 2) { ! if (!(hi = source->handle_info)) { ! send_message(bot, source, N_("You must authenticate first.")); ! return; ! } ! } else if (!(hi = smart_get_handle_info(bot, source, argv[1]))) { ! return; ! } ! ! send_message(bot, source, N_("Handle information for $b%s$b:"), hi->handle); ! send_message(bot, source, N_(" Registered on: %s"), ctime(&hi->registered)); ! ! if (!hi->users) { ! intervalString(buff, now - hi->lastseen); ! send_message(bot, source, N_(" Last seen: %s"), buff); ! } else { ! send_message(bot, source, N_(" Last seen: Right now!")); ! } ! ! if (hi->info[0]) send_message(bot, source, N_(" Infoline: %s"), hi->info); ! if (HANDLE_FLAGGED(hi, FROZEN)) send_message(bot, source, N_(" On vacation.")); ! ! /* Don't allow non-privileged users to look at somebody else's handle details. */ ! if (hi != source->handle_info ! && (!source->handle_info ! || !IsPrivileged(source) ! || !is_valid_oper(bot, source, 0))) { ! return; ! } ! ! if (hi->flags) { ! unsigned long flen = 1; ! char *flags = alloca(strlen(handle_flags) + 2); ! flags[0] = '+'; ! for (i=0, flen=1; handle_flags[i]; i++) { ! if (hi->flags & 1 << i) flags[flen++] = handle_flags[i]; ! } ! flags[flen] = 0; ! send_message(bot, source, N_("Flags: %s"), flags); ! } else { ! send_message(bot, source, N_("Flags: (none)")); ! } ! ! if (hi->masks->used) { ! for (i=0; i < hi->masks->used; i++) { ! herelen = strlen(hi->masks->list[i]); ! if (pos + herelen + 1 > ArrayLength(buff)) { ! i--; goto print_mask_buff; ! } ! memcpy(buff+pos, hi->masks->list[i], herelen); ! pos += herelen; buff[pos++] = ' '; ! if (i+1 == hi->masks->used) { ! print_mask_buff: ! buff[pos-1] = 0; ! send_message(bot, source, N_(" Hostmask(s): %s"), buff); ! pos = 0; ! } ! } ! } else { ! send_message(bot, source, N_(" Hostmask(s): (none)")); ! } ! ! for (target = hi->users; target; target = next_user) { ! herelen = strlen(target->nick); ! if (pos + herelen + 1 > ArrayLength(buff)) { ! next_user = target; ! goto print_cnick_buff; ! } else { ! next_user = target->next_authed; ! } ! memcpy(buff+pos, target->nick, herelen); ! pos += herelen; buff[pos++] = ' '; ! if (!next_user) { ! print_cnick_buff: ! buff[pos-1] = 0; ! send_message(bot, source, N_(" Current nickname(s): %s"), buff); ! pos = 0; ! } ! } } Index: authserv.h =================================================================== RCS file: /cvsroot/srvx/services/src/modules/authserv.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** authserv.h 2001/10/20 19:23:12 1.2 --- authserv.h 2001/10/22 13:51:11 1.3 *************** *** 52,56 **** --- 52,58 ---- #define HANDLE_CLEAR_FLAG(hi, tok) ((hi)->flags &= ~HI_FLAG_##tok) + #define IsHelper(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, HELPER)) #define IsHelping(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, HELPING)) + #define IsPrivileged(user) (IsOper(user) || IsHelping(user)) struct handle_info { *************** *** 71,76 **** struct handle_info *get_handle_info(const char *handle); struct handle_info *smart_get_handle_info(struct user *bot, struct user *source, const unsigned char *name); ! int authserv_addmask(struct user *user, struct user *bot, struct handle_info *hi, const char *mask); ! int authserv_delmask(struct user *source, struct user *bot, struct handle_info *hi, const char *del_mask); /* auth_funcs are called when a user gets a new handle_info. They are --- 73,80 ---- struct handle_info *get_handle_info(const char *handle); struct handle_info *smart_get_handle_info(struct user *bot, struct user *source, const unsigned char *name); ! struct handle_info *get_oper_victim(struct user *bot, struct user *source, const char *target); ! int authserv_addmask(struct user *bot, struct user *source, struct handle_info *hi, const char *mask); ! int authserv_delmask(struct user *bot, struct user *source, struct handle_info *hi, const char *del_mask); ! int is_valid_oper(struct user *bot, struct user *source, unsigned int min_level); /* auth_funcs are called when a user gets a new handle_info. They are |
From: Entrope <en...@us...> - 2001-10-22 13:50:49
|
Update of /cvsroot/srvx/services/src/srvx In directory usw-pr-cvs1:/tmp/cvs-serv6098 Modified Files: gline.c gline.h log.c proto.c service.c Log Message: consistently put service bot before user in argument lists Index: gline.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/gline.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** gline.c 2001/10/20 18:47:05 1.1 --- gline.c 2001/10/22 13:50:45 1.2 *************** *** 272,276 **** struct gline_discrim * ! gline_discrim_create(struct user *user, struct user *src, unsigned int argc, unsigned char *argv[]) { unsigned int i; --- 272,276 ---- struct gline_discrim * ! gline_discrim_create(struct user *bot, struct user *source, unsigned int argc, unsigned char *argv[]) { unsigned int i; *************** *** 278,282 **** if (argc % 2) { ! send_message(user, src, MSG_MISSING_PARAMS, argv[argc-1]); return NULL; } --- 278,282 ---- if (argc % 2) { ! send_message(bot, source, MSG_MISSING_PARAMS, argv[argc-1]); return NULL; } *************** *** 289,293 **** if (!strcasecmp(argv[i], "mask")) { if (!is_gline(argv[++i])) { ! send_message(user, src, MSG_INVALID_GLINE, argv[i]); goto fail; } --- 289,293 ---- if (!strcasecmp(argv[i], "mask")) { if (!is_gline(argv[++i])) { ! send_message(bot, source, MSG_INVALID_GLINE, argv[i]); goto fail; } *************** *** 302,306 **** discrim->min_expire = now + ParseInterval(argv[++i]); } else { ! send_message(user, src, MSG_INVALID_CRITERIA, argv[i]); goto fail; } --- 302,306 ---- discrim->min_expire = now + ParseInterval(argv[++i]); } else { ! send_message(bot, source, MSG_INVALID_CRITERIA, argv[i]); goto fail; } Index: gline.h =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/gline.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** gline.h 2001/10/20 18:47:05 1.1 --- gline.h 2001/10/22 13:50:45 1.2 *************** *** 45,49 **** typedef void (*gline_search_func)(struct gline *gline, void *extra); ! struct gline_discrim *gline_discrim_create(struct user *user, struct user *src, unsigned int argc, unsigned char *argv[]); unsigned int gline_discrim_search(struct gline_discrim *discrim, gline_search_func gsf, void *data); --- 45,49 ---- typedef void (*gline_search_func)(struct gline *gline, void *extra); ! struct gline_discrim *gline_discrim_create(struct user *bot, struct user *source, unsigned int argc, unsigned char *argv[]); unsigned int gline_discrim_search(struct gline_discrim *discrim, gline_search_func gsf, void *data); Index: log.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/log.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** log.c 2001/10/20 18:47:05 1.1 --- log.c 2001/10/22 13:50:45 1.2 *************** *** 198,202 **** if((argc - 1) % 2) { ! send_message(user, service, MSG_MISSING_PARAMS, argv[0]); return NULL; } --- 198,202 ---- if((argc - 1) % 2) { ! send_message(service, user, MSG_MISSING_PARAMS, argv[0]); return NULL; } *************** *** 210,214 **** discrim->severity = find_severity(argv[i], strlen(argv[i])); if (discrim->severity == LOG_NUM_SEVERITIES) { ! send_message(user, service, MSG_INVALID_SEVERITY, argv[i]); goto fail; } --- 210,214 ---- discrim->severity = find_severity(argv[i], strlen(argv[i])); if (discrim->severity == LOG_NUM_SEVERITIES) { ! send_message(service, user, MSG_INVALID_SEVERITY, argv[i]); goto fail; } *************** *** 216,220 **** discrim->type = find_log_type(argv[++i]); if (discrim->type == NUM_LOGS) { ! send_message(user, service, MSG_INVALID_TYPE, argv[i]); goto fail; } --- 216,220 ---- discrim->type = find_log_type(argv[++i]); if (discrim->type == NUM_LOGS) { ! send_message(service, user, MSG_INVALID_TYPE, argv[i]); goto fail; } *************** *** 224,228 **** discrim->limit = strtoul(argv[++i], NULL, 10); } else { ! send_message(user, service, MSG_INVALID_CRITERIA, argv[i]); goto fail; } --- 224,228 ---- discrim->limit = strtoul(argv[++i], NULL, 10); } else { ! send_message(service, user, MSG_INVALID_CRITERIA, argv[i]); goto fail; } Index: proto.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/proto.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** proto.c 2001/10/20 18:47:05 1.1 --- proto.c 2001/10/22 13:50:45 1.2 *************** *** 350,354 **** static void ! vsend_message(const char *dest, struct user *src, int use_privmsg, expand_func_t expand, const char *format, va_list al) { void (*irc_send)(struct user *from, const char *to, const char *msg); --- 350,354 ---- static void ! vsend_message(struct user *src, const char *dest, int use_privmsg, expand_func_t expand, const char *format, va_list al) { void (*irc_send)(struct user *from, const char *to, const char *msg); *************** *** 523,532 **** void ! send_message(struct user *dest, struct user *src, const char *format, ...) { va_list ap; va_start(ap, format); ! vsend_message(dest->nick, src, 0, NULL, format, ap); va_end(ap); } --- 523,532 ---- void ! send_message(struct user *src, struct user *dest, const char *format, ...) { va_list ap; va_start(ap, format); ! vsend_message(src, dest->nick, 0, NULL, format, ap); va_end(ap); } Index: service.c =================================================================== RCS file: /cvsroot/srvx/services/src/srvx/service.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** service.c 2001/10/20 18:47:05 1.1 --- service.c 2001/10/22 13:50:45 1.2 *************** *** 111,115 **** chan_name = argv[0]; } else { ! send_message(source, bot, MSG_INVALID_CHANNEL); return; } --- 111,115 ---- chan_name = argv[0]; } else { ! send_message(bot, source, MSG_INVALID_CHANNEL); return; } *************** *** 129,133 **** } if ((cmd->base->flags & (1 << REQUIRE_AUTHED)) && !source->handle_info) { ! send_message(source, bot, N_("You must authenticate yourself first.")); return; } --- 129,133 ---- } if ((cmd->base->flags & (1 << REQUIRE_AUTHED)) && !source->handle_info) { ! send_message(bot, source, N_("You must authenticate yourself first.")); return; } *************** *** 136,140 **** } if ((cmd->base->flags & (1 << REQUIRE_CHANNEL)) && !chan) { ! send_message(source, bot, MSG_INVALID_CHANNEL); return; } --- 136,140 ---- } if ((cmd->base->flags & (1 << REQUIRE_CHANNEL)) && !chan) { ! send_message(bot, source, MSG_INVALID_CHANNEL); return; } *************** *** 143,150 **** rule_ctx.channel = chan; if (!expression_evaluate(cmd->rule ? cmd->rule : cmd->base->default_rule, &rule_ctx)) { ! send_message(source, bot, N_("Access to $b%s$b denied."), argv[shift]); return; } ! cmd->base->function(source, bot, chan, argc-shift, argv+shift); } --- 143,150 ---- rule_ctx.channel = chan; if (!expression_evaluate(cmd->rule ? cmd->rule : cmd->base->default_rule, &rule_ctx)) { ! send_message(bot, source, N_("Access to $b%s$b denied."), argv[shift]); return; } ! cmd->base->function(bot, source, chan, argc-shift, argv+shift); } |
From: Entrope <en...@us...> - 2001-10-20 22:27:39
|
Update of /cvsroot/srvx/services In directory usw-pr-cvs1:/tmp/cvs-serv4390 Modified Files: configure.ac Log Message: fix ANSI header file checks in compat.c Index: configure.ac =================================================================== RCS file: /cvsroot/srvx/services/configure.ac,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** configure.ac 2001/10/20 20:57:26 1.16 --- configure.ac 2001/10/20 22:27:36 1.17 *************** *** 86,90 **** dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi ! AC_CHECK_HEADERS(arpa/inet.h fcntl.h malloc.h netdb.h netinet/in.h pthread.h sys/resource.h sys/timeb.h sys/times.h sys/select.h sys/param.h sys/poll.h sys/socket.h sys/time.h sys/types.h unistd.h getopt.h memory.h regex.h alloca.h dlfcn.h libintl.h ctype.h,,) dnl portability stuff, hurray! -Jedi --- 86,90 ---- dnl Would rather not bail on headers, BSD has alot of the functions elsewhere. -Jedi ! AC_CHECK_HEADERS(arpa/inet.h fcntl.h malloc.h netdb.h netinet/in.h pthread.h sys/resource.h sys/timeb.h sys/times.h sys/select.h sys/param.h sys/poll.h sys/socket.h sys/time.h sys/types.h unistd.h getopt.h memory.h regex.h alloca.h dlfcn.h libintl.h,,) dnl portability stuff, hurray! -Jedi |