- Timestamp:
- 05/12/06 03:35:50 (6 years ago)
- Location:
- branches/ithildin-1.1/modules/ircd
- Files:
-
- 1 deleted
- 5 edited
-
addons/acl.c (modified) (10 diffs)
-
addons/acl.h (modified) (2 diffs)
-
addons/drone_fizzer.c (deleted)
-
addons/throttle.c (modified) (1 diff)
-
commands/acl.c (modified) (2 diffs)
-
commands/akill.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ithildin-1.1/modules/ircd/addons/acl.c
r730 r731 26 26 * CIDR mask, or something else) */ 27 27 #define ACL_DEFAULT_HASH 0 28 /* the default rule at which inserts happen */29 #define ACL_DEFAULT_RULE 100030 #define ACL_DEFAULT_CONF_RULE 200031 28 32 29 /* function prototypes */ … … 36 33 XINFO_FUNC(xinfo_acl_handler); 37 34 38 /* create an acl structure with the given definition (or find one if it exists 39 * already) and add it in to the system. ACLs are equivalent for our purposes 40 * if they are in the same stage and have the same host-pattern. It doesn't 41 * make sense to have an accept for a host and a deny for host (with the 42 * exception that hosts which have a password are considered different enough 43 * to be left alone. */ 44 acl_t *create_acl(int stage, int acc, char *host, const char *type) { 35 /* Create an ACL with the given data. We will override ACLs that are 36 * similar enough to ourself (same stage/host/access/rule#) unless they have 37 * special parameter data (such as passwords or 'info line' bans) */ 38 acl_t *create_acl(int stage, int acc, char *host, const char *type, int rule) { 45 39 acl_t *ap, *ap2; 46 40 char *at, hostcopy[USERLEN + HOSTLEN + 2]; 47 41 struct acl_list *list; 48 42 49 if ((ap = find_acl(stage, host, type, NULL, NULL)) != NULL) { 50 if ((ap->pass != NULL && (ap->access != acc)) || ap->info != NULL) 51 ap = NULL; /* if it has a password, don't trample it unless we are 52 adding another rule with a password and the same 53 access. if it has an info field, don't trample it at 54 all. */ 43 /* look for an ACL in this stage from the same hostname and with the 44 * same access and rule number. If we find one we will delete it unless 45 * it has an info-line, in which case we will leave it alone. (This is 46 * sort of a broken concession to not having a create command which 47 * takes that information...) */ 48 if ((ap = find_acl(stage, acc, host, type, rule, NULL, NULL)) != NULL) { 49 if (ap->info != NULL) 50 ap = NULL; 55 51 } 56 52 … … 78 74 79 75 /* add them into the big list... */ 80 ap->rule = acl.default_rule; 76 if (rule == ACL_DEFAULT_RULE) 77 ap->rule = acl.default_rule; 78 else 79 ap->rule = (short)rule; 81 80 ap->hash = get_acl_hash(ap->host); 82 81 … … 154 153 /* this function finds an ACL based on stage/host/type, and possibly based on 155 154 * the pass/info parameters. */ 156 acl_t *find_acl(int stage, char *hostmask, const char *type, char *pass,157 char *info) {155 acl_t *find_acl(int stage, int acc, char *hostmask, const char *type, 156 int rule, char *pass, char *info) { 158 157 struct acl_list *list; 159 158 char *at, hostcopy[USERLEN + HOSTLEN + 2], user[USERLEN + 1]; … … 182 181 /* now try and find them in the bucket. */ 183 182 LIST_FOREACH(ap, list, intlp) { 183 if (acc != ACL_ACCESS_ANY && ap->access != acc) 184 continue; 185 if (rule != ACL_ANY_RULE && ap->rule != rule) 186 continue; 187 184 188 if (!strcasecmp(ap->user, user) && !strcasecmp(ap->host, host) && 185 189 !strcasecmp(ap->type, type) && … … 457 461 } 458 462 463 /* These two are the defaults for runtime and configured rule numbers, 464 * respectively. */ 465 #define ACLCONF_DEFAULT_RULE 1000 466 #define ACLCONF_DEFAULT_CONF_RULE 2000 459 467 HOOK_FUNCTION(acl_conf_hook) { 460 468 conf_entry_t *cep; … … 465 473 char redirect[SERVLEN + 1]; 466 474 class_t *cls; 467 int odr, rn, dcr; /* Old Default Rule, Rule Number, Default Conf Rule */ 475 int rule; 476 int default_rule; /* default rule for config entries */ 468 477 469 478 /* remove anything that points to a conf. usually this will only be … … 480 489 /* see about setting the default rule number.. */ 481 490 if ((s = conf_find_entry("default-acl-rule", *ircd.confhead, 1)) != NULL) 482 acl.default_rule = str_conv_int(s, ACL _DEFAULT_RULE);491 acl.default_rule = str_conv_int(s, ACLCONF_DEFAULT_RULE); 483 492 else 484 acl.default_rule = ACL _DEFAULT_RULE;493 acl.default_rule = ACLCONF_DEFAULT_RULE; 485 494 if ((s = conf_find_entry("default-acl-conf-rule", *ircd.confhead, 1)) != 486 495 NULL) 487 d cr = str_conv_int(s, ACL_DEFAULT_CONF_RULE);496 default_rule = str_conv_int(s, ACLCONF_DEFAULT_CONF_RULE); 488 497 else 489 d cr = ACL_DEFAULT_CONF_RULE;498 default_rule = ACLCONF_DEFAULT_CONF_RULE; 490 499 491 500 /* now read through the conf looking for ACLs, as we find them parse and … … 496 505 while ((cep = conf_find_next("acl", NULL, CONF_TYPE_LIST, cep, 497 506 *ircd.confhead, 1)) != NULL) { 498 r n = dcr;507 rule = default_rule; 499 508 if (cep->string != NULL) 500 r n= str_conv_int(cep->string, -1);501 if (r n < 0 || rn> USHRT_MAX) {502 log_warn("got acl with bogus rule number (%d)", r n);503 r n = dcr;509 rule = str_conv_int(cep->string, -1); 510 if (rule < 0 || rule > USHRT_MAX) { 511 log_warn("got acl with bogus rule number (%d)", rule); 512 rule = default_rule; 504 513 } 505 514 … … 566 575 * add the acl. yikes! Use this macro to make life a bit easier. */ 567 576 #define ACL_PARSE_ADD(_host) do { \ 568 odr = acl.default_rule; \ 569 acl.default_rule = rn; \ 570 ap = create_acl(stg, acc, _host, "acl"); \ 571 acl.default_rule = odr; \ 577 ap = create_acl(stg, acc, _host, "acl", rule); \ 572 578 ap->conf = clp; \ 573 579 ap->cls = cls; \ -
branches/ithildin-1.1/modules/ircd/addons/acl.h
r729 r731 16 16 #define ACL_STAGE_REGISTER 3 17 17 int stage; /* one of 1, 2, or 3 */ 18 #define ACL_ACCESS_ANY -1 18 19 #define ACL_DENY 0 19 20 #define ACL_ALLOW 1 … … 63 64 } acl; 64 65 65 acl_t *create_acl(int, int, char *, const char *); 66 acl_t *find_acl(int, char *, const char *, char *, char *); 66 #define ACL_ANY_RULE -1 67 #define ACL_DEFAULT_RULE -2 68 acl_t *create_acl(int, int, char *, const char *, int); 69 acl_t *find_acl(int, int, char *, const char *, int, char *, char *); 67 70 void destroy_acl(acl_t *); 68 71 void acl_add_timer(acl_t *, time_t); -
branches/ithildin-1.1/modules/ircd/addons/throttle.c
r664 r731 164 164 165 165 if (tp->banned + len >= me.now) { 166 if ((ap = find_acl(ACL_STAGE_CONNECT, cp->host, throttle_acl_type,167 NULL, NULL)) == NULL) {166 if ((ap = find_acl(ACL_STAGE_CONNECT, ACL_DENY, cp->host, 167 throttle_acl_type, NULL, NULL)) == NULL) { 168 168 ap = create_acl(ACL_STAGE_CONNECT, ACL_DENY, cp->host, 169 throttle_acl_type );169 throttle_acl_type, ACL_DEFAULT_RULE); 170 170 ap->reason = strdup(THROTTLE_ERRMSG); 171 171 } -
branches/ithildin-1.1/modules/ircd/commands/acl.c
r586 r731 228 228 229 229 /* see if it exists */ 230 ap = find_acl(stage, mask, type, NULL, NULL);230 ap = find_acl(stage, acc, mask, type, ACL_DEFAULT_RULE, NULL, NULL); 231 231 232 232 /* are we adding..? */ … … 238 238 } 239 239 240 ap = create_acl(stage, acc, mask, type );240 ap = create_acl(stage, acc, mask, type, ACL_DEFAULT_RULE); 241 241 ap->reason = strdup(reason); 242 242 /* if the expire time is non-zero, set a conf to 0x1 so it will get -
branches/ithildin-1.1/modules/ircd/commands/akill.c
r706 r731 187 187 188 188 if (op == ACL_ADD) { 189 ap = create_acl(stage, ACL_DENY, mask, type );189 ap = create_acl(stage, ACL_DENY, mask, type, ACL_DEFAULT_RULE); 190 190 ap->conf = ACL_CONF_TEMP; 191 191 if (expire) … … 198 198 acl_force_check(ap->stage, ap, srv->name, false); 199 199 } else if (op == ACL_DEL) { 200 if ((ap = find_acl(stage, mask, type, NULL, info)))200 if ((ap = find_acl(stage, ACL_DENY, mask, type, ACL_DEFAULT_RULE, NULL, info))) 201 201 destroy_acl(ap); 202 202 }
Note: See TracChangeset
for help on using the changeset viewer.
