Changeset 751 for branches/ithildin-1.1
- Timestamp:
- 06/23/06 01:43:45 (6 years ago)
- Location:
- branches/ithildin-1.1/modules/ircd
- Files:
-
- 8 edited
-
addons/acl.c (modified) (1 diff)
-
addons/hostcrypt.c (modified) (1 diff)
-
addons/quarantine.c (modified) (1 diff)
-
command.c (modified) (1 diff)
-
commands/oper.c (modified) (1 diff)
-
commands/xinfo.c (modified) (3 diffs)
-
support.c (modified) (4 diffs)
-
support.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ithildin-1.1/modules/ircd/addons/acl.c
r732 r751 748 748 LIST_ALLOC(acl.stage3_list); 749 749 750 add_xinfo_handler(xinfo_acl_handler, "ACL", XINFO_HANDLER_OPER, NULL,750 add_xinfo_handler(xinfo_acl_handler, "ACL", XINFO_HANDLER_OPER, 751 751 "Provides information about the server Access Control List"); 752 752 -
branches/ithildin-1.1/modules/ircd/addons/hostcrypt.c
r579 r751 372 372 char addr[IPADDR_SIZE]; 373 373 size_t alen; 374 375 #ifdef INET6 376 if (inet_pton(PF_INET6, cli->ip, addr) == 1) 377 alen = IPADDR_SIZE; 378 else 379 #endif 380 if (inet_pton(PF_INET, cli->ip, addr) == 1) 374 char *s; 375 bool ip = false; 376 int family = PF_INET; 377 #ifdef INET6 378 struct in6_addr i6a; 379 #endif 380 struct in_addr ia; 381 382 /* See if it is an IP address.. */ 383 #ifdef INET6 384 if ((s = strchr(cli->orighost, ':')) != NULL && 385 inet_pton(PF_INET6, cli->orighost, &i6a) == 1) { 386 ip = true; 387 family = PF_INET6; 388 } else 389 #endif 390 if ((s = strrchr(cli->orighost, '.')) != NULL && 391 inet_pton(PF_INET, cli->orighost, &ia) == 1) 392 ip = true; 393 394 if (ip) { 395 inet_pton(family, cli->orighost, addr); 396 #ifdef INET6 397 if (family == PF_INET6) 398 alen = IPADDR_SIZE; 399 else 400 #endif 381 401 alen = 4; 402 403 md5_data(addr, alen, md5buf); 404 memset(addr + (alen / 2), 0, alen / 2); 405 md5_data(addr, alen, md5buf + 32); 406 } else { 407 alen = strlen(cli->orighost); 408 md5_data(cli->orighost, alen, md5buf); 409 410 /* extract only the interesting part of the hostname (domain.tld). 411 * For hostnames which are merely domain.tld to begin with, we 412 * provide the first set of md5 data as additional "seed" for them. */ 413 s = strrchr(cli->orighost, '.'); 414 if (s == NULL) 415 /* singleton string like 'localhost' */ 416 sprintf(buf, "%32s.%s", md5buf, cli->orighost); 382 417 else { 383 inet_pton(PF_INET, "0.0.0.0", addr); 384 alen = 4; 418 while (*s != '.' && s > cli->orighost) 419 s--; /* walk backwards to find the . or beginning of string */ 420 if (s == cli->orighost) 421 /* host is in pure domain.tld form */ 422 sprintf(buf, "%32s.%s", md5buf, cli->orighost); 423 else 424 /* s is the second to last . in the string now */ 425 sprintf(buf, "%s", s + 1); 385 426 } 386 387 md5_data(addr, alen, md5buf);388 memset(addr + (alen / 2), 0, alen /2);389 md5_data(addr, alen, md5buf + 32);427 /* buf now contains the host we wish to md5 on */ 428 alen = strlen(buf); 429 md5_data(buf, alen, md5buf + 32); 430 } 390 431 391 432 /* okay, md5buf is now a 64 byte long base16 encoded string. decode it -
branches/ithildin-1.1/modules/ircd/addons/quarantine.c
r579 r751 237 237 } 238 238 239 add_xinfo_handler(xinfo_quarantine_handler, "QUARANTINE", 0, NULL,239 add_xinfo_handler(xinfo_quarantine_handler, "QUARANTINE", 0, 240 240 "Provides a list of nickname and channel quarantines"); 241 241 -
branches/ithildin-1.1/modules/ircd/command.c
r717 r751 401 401 } 402 402 } 403 /* check operator and command use privileges */ 403 /* check operator and command use privileges. Why do this only for 404 * local clients? Because we need to assume that even if we are not 405 * configured to accept commands from a client, every other server 406 * is. Without a distributed privilege understanding we have to 407 * assume positive intent. */ 404 408 if ((cmd->client.flags & COMMAND_FL_OPERATOR && !OPER(cli)) || 405 409 !BPRIV(cli, cmd->priv)) { -
branches/ithildin-1.1/modules/ircd/commands/oper.c
r579 r751 23 23 MODULE_LOADER(oper) { 24 24 25 add_xinfo_handler(xinfo_oper_func, "OPERATORS", 0, NULL,25 add_xinfo_handler(xinfo_oper_func, "OPERATORS", 0, 26 26 "Provides information about server operators"); 27 27 -
branches/ithildin-1.1/modules/ircd/commands/xinfo.c
r579 r751 30 30 MODULE_LOADER(xinfo) { 31 31 32 add_xinfo_handler(xinfo_class_handler, "CLASS", 0, NULL,32 add_xinfo_handler(xinfo_class_handler, "CLASS", 0, 33 33 "Provides information about server connection classes"); 34 add_xinfo_handler(xinfo_client_handler, "CLIENT", XINFO_HANDLER_OPER, NULL,34 add_xinfo_handler(xinfo_client_handler, "CLIENT", XINFO_HANDLER_OPER, 35 35 "Provices information about clients on this server"); 36 36 add_xinfo_handler(xinfo_connects_handler, "CONNECTS", XINFO_HANDLER_OPER, 37 NULL,"Shows information about server uplinks");38 add_xinfo_handler(xinfo_hash_handler, "HASH", XINFO_HANDLER_OPER, NULL,37 "Shows information about server uplinks"); 38 add_xinfo_handler(xinfo_hash_handler, "HASH", XINFO_HANDLER_OPER, 39 39 "Shows hash table statistics."); 40 add_xinfo_handler(xinfo_me_handler, "ME", XINFO_HANDLER_LOCAL, NULL,40 add_xinfo_handler(xinfo_me_handler, "ME", XINFO_HANDLER_LOCAL, 41 41 "Provides information about your connection statistics"); 42 42 add_xinfo_handler(xinfo_privilege_handler, "PRIVILEGE", 43 XINFO_HANDLER_LOCAL | XINFO_HANDLER_OPER, NULL,43 XINFO_HANDLER_LOCAL | XINFO_HANDLER_OPER, 44 44 "Provides information about available privileges"); 45 add_xinfo_handler(xinfo_server_handler, "SERVER", 0, NULL,45 add_xinfo_handler(xinfo_server_handler, "SERVER", 0, 46 46 "Provides information about this (or other) servers"); 47 add_xinfo_handler(xinfo_xinfo_handler, "XINFO", 0, NULL,47 add_xinfo_handler(xinfo_xinfo_handler, "XINFO", 0, 48 48 "Provides a list of available XINFO query-handlers"); 49 49 … … 136 136 return COMMAND_WEIGHT_LOW; /* silently ignore these */ 137 137 if ((xhp->flags & XINFO_HANDLER_OPER && !OPER(cli)) || 138 (xhp->flags & XINFO_HANDLER_PRIV && !BPRIV(cli, xhp->priv))) {138 !BPRIV(cli, xhp->priv)) { 139 139 sendto_one(cli, RPL_FMT(cli, ERR_NOPRIVILEGES)); 140 140 return COMMAND_WEIGHT_LOW; … … 425 425 continue; /* non-local */ 426 426 if ((xhp->flags & XINFO_HANDLER_OPER && !OPER(cli)) || 427 (xhp->flags & XINFO_HANDLER_PRIV && !BPRIV(cli, xhp->priv)))427 !BPRIV(cli, xhp->priv)) 428 428 continue; /* not privileged */ 429 429 -
branches/ithildin-1.1/modules/ircd/support.c
r579 r751 35 35 ip = malloc(sizeof(struct isupport)); 36 36 memset(ip, 0, sizeof(struct isupport)); 37 ip->name = strdup(name);37 strlcpy(ip->name, name, ISUPPORTNAME_MAXLEN + 1); 38 38 /* now insert into a list. we alphabetically sort our list, just 39 39 * because I like to. :) */ … … 84 84 if (ip != NULL) { 85 85 LIST_REMOVE(ip, lp); 86 free(ip->name);87 86 if (!(ip->flags & ISUPPORT_FL_PRIV) && ip->value.str != NULL) 88 87 free(ip->value.str); … … 144 143 * fifth is a description of the handler (usually short). The function returns 145 144 * non-zero upon successful installation. */ 146 int add_xinfo_handler(xinfo_func func, char *name, int flags, 147 void *udata, char *desc) { 145 int add_xinfo_handler(xinfo_func func, char *name, int flags, char *desc) { 148 146 struct xinfo_handler *xhp = find_xinfo_handler(name); 147 uint64_t i64 = 1; 148 char privname[XINFONAME_MAXLEN + 1 + 6]; /* add 6 for "xinfo-" tag */ 149 149 150 150 if (xhp != NULL) … … 153 153 xhp = malloc(sizeof(struct xinfo_handler)); 154 154 xhp->func = func; 155 xhp->name = strdup(name);155 strlcpy(xhp->name, name, XINFONAME_MAXLEN + 1); 156 156 xhp->flags = flags; 157 if (xhp->flags & XINFO_HANDLER_PRIV) 158 xhp->priv = *(int *)udata; 159 else 160 xhp->priv = -1; 157 158 /* Create a privilege for them. Always bool, this is simply a "yes/no" 159 * flag to whether or not this information is available. Always default 160 * to 1 */ 161 sprintf(privname, "xinfo-%s", xhp->name); 162 xhp->priv = create_privilege(privname, PRIVILEGE_FL_BOOL, &i64, NULL); 163 161 164 xhp->desc = strdup((desc != NULL ? desc : "no description")); 162 165 -
branches/ithildin-1.1/modules/ircd/support.h
r593 r751 11 11 #define IRCD_SUPPORT_H 12 12 13 #define ISUPPORTNAME_MAXLEN 31 /* XXX: what does the spec say, if anything, 14 about this...? */ 15 13 16 /* a feature may have a straightforward string value, or it may have a value 14 17 * which is connect-time dependent. features which are connect-time dependent 15 18 * are assumed to be privileges, but see below. */ 16 19 struct isupport { 17 char *name; /* name of the feature supported. */20 char name[ISUPPORTNAME_MAXLEN + 1]; 18 21 union { 19 22 char *str; /* string value */ … … 47 50 char **argv __UNUSED) 48 51 52 #define XINFONAME_MAXLEN ISUPPORTNAME_MAXLEN 53 49 54 /* The xinfo_handler structure contains a each xinfo handler's necessary 50 55 * details. */ 51 56 struct xinfo_handler { 52 char *name;57 char name[XINFONAME_MAXLEN + 1]; 53 58 char *desc; 54 59 #define XINFO_HANDLER_LOCAL 0x1 55 60 #define XINFO_HANDLER_OPER 0x2 56 #define XINFO_HANDLER_PRIV 0x457 61 int flags; 58 int priv; /* privilege , if any*/62 int priv; /* privilege */ 59 63 xinfo_func func; 60 64 … … 64 68 #define XINFO_LEN 512 65 69 66 int add_xinfo_handler(xinfo_func, char *, int, void *,char *);70 int add_xinfo_handler(xinfo_func, char *, int, char *); 67 71 struct xinfo_handler *find_xinfo_handler(char *); 68 72 void remove_xinfo_handler(xinfo_func);
Note: See TracChangeset
for help on using the changeset viewer.
