ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/src/conf.c
(Generate patch)

Comparing ircd-hybrid/branches/8.2.x/src/conf.c (file contents):
Revision 5954 by michael, Sat May 9 19:34:12 2015 UTC vs.
Revision 7725 by michael, Mon Sep 26 14:59:44 2016 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (c) 1997-2015 ircd-hybrid development team
4 > *  Copyright (c) 1997-2016 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 28 | Line 28
28   #include "list.h"
29   #include "ircd_defs.h"
30   #include "conf.h"
31 + #include "conf_cluster.h"
32 + #include "conf_gecos.h"
33   #include "conf_pseudo.h"
34 + #include "conf_resv.h"
35 + #include "conf_service.h"
36 + #include "conf_shared.h"
37   #include "server.h"
33 #include "resv.h"
38   #include "channel.h"
39   #include "client.h"
40   #include "event.h"
# Line 55 | Line 59
59   #include "conf_class.h"
60   #include "motd.h"
61   #include "ipcache.h"
62 + #include "isupport.h"
63 + #include "whowas.h"
64  
65  
66   struct config_channel_entry ConfigChannel;
# Line 66 | Line 72 | struct config_admin_entry ConfigAdminInf
72   struct conf_parser_context conf_parser_ctx;
73  
74   /* general conf items link list root, other than k lines etc. */
75 < dlink_list service_items;
76 < dlink_list server_items;
71 < dlink_list cluster_items;
72 < dlink_list oconf_items;
73 < dlink_list uconf_items;
74 < dlink_list xconf_items;
75 < dlink_list nresv_items;
76 < dlink_list cresv_items;
75 > dlink_list connect_items;
76 > dlink_list operator_items;
77  
78   extern unsigned int lineno;
79   extern char linebuf[];
# Line 135 | Line 135 | map_to_list(enum maskitem_type type)
135   {
136    switch (type)
137    {
138    case CONF_XLINE:
139      return &xconf_items;
140      break;
141    case CONF_ULINE:
142      return &uconf_items;
143      break;
144    case CONF_NRESV:
145      return &nresv_items;
146      break;
147    case CONF_CRESV:
148      return &cresv_items;
149      break;
138      case CONF_OPER:
139 <      return &oconf_items;
139 >      return &operator_items;
140        break;
141      case CONF_SERVER:
142 <      return &server_items;
155 <      break;
156 <    case CONF_SERVICE:
157 <      return &service_items;
158 <      break;
159 <    case CONF_CLUSTER:
160 <      return &cluster_items;
142 >      return &connect_items;
143        break;
144      default:
145        return NULL;
# Line 167 | Line 149 | map_to_list(enum maskitem_type type)
149   struct MaskItem *
150   conf_make(enum maskitem_type type)
151   {
152 <  struct MaskItem *const conf = MyCalloc(sizeof(*conf));
152 >  struct MaskItem *const conf = xcalloc(sizeof(*conf));
153    dlink_list *list = NULL;
154  
155    conf->type   = type;
# Line 188 | Line 170 | conf_free(struct MaskItem *conf)
170    if ((list = map_to_list(conf->type)))
171      dlinkFindDelete(list, conf);
172  
173 <  MyFree(conf->name);
173 >  xfree(conf->name);
174  
175    if (conf->dns_pending)
176      delete_resolver_queries(conf);
# Line 199 | Line 181 | conf_free(struct MaskItem *conf)
181  
182    conf->class = NULL;
183  
184 <  MyFree(conf->passwd);
185 <  MyFree(conf->spasswd);
186 <  MyFree(conf->reason);
187 <  MyFree(conf->certfp);
188 <  MyFree(conf->whois);
189 <  MyFree(conf->user);
190 <  MyFree(conf->host);
191 < #ifdef HAVE_LIBCRYPTO
210 <  MyFree(conf->cipher_list);
184 >  xfree(conf->passwd);
185 >  xfree(conf->spasswd);
186 >  xfree(conf->reason);
187 >  xfree(conf->certfp);
188 >  xfree(conf->whois);
189 >  xfree(conf->user);
190 >  xfree(conf->host);
191 >  xfree(conf->cipher_list);
192  
212  if (conf->rsa_public_key)
213    RSA_free(conf->rsa_public_key);
214 #endif
193    DLINK_FOREACH_SAFE(node, node_next, conf->hub_list.head)
194    {
195 <    MyFree(node->data);
195 >    xfree(node->data);
196      dlinkDelete(node, &conf->hub_list);
197      free_dlink_node(node);
198    }
199  
200    DLINK_FOREACH_SAFE(node, node_next, conf->leaf_list.head)
201    {
202 <    MyFree(node->data);
202 >    xfree(node->data);
203      dlinkDelete(node, &conf->leaf_list);
204      free_dlink_node(node);
205    }
206  
207 <  DLINK_FOREACH_SAFE(node, node_next, conf->exempt_list.head)
230 <  {
231 <    struct exempt *exptr = node->data;
232 <
233 <    dlinkDelete(node, &conf->exempt_list);
234 <    MyFree(exptr->name);
235 <    MyFree(exptr->user);
236 <    MyFree(exptr->host);
237 <    MyFree(exptr);
238 <  }
239 <
240 <  MyFree(conf);
207 >  xfree(conf);
208   }
209  
210   /* attach_iline()
# Line 253 | Line 220 | attach_iline(struct Client *client_p, st
220    const struct ClassItem *const class = conf->class;
221    struct ip_entry *ip_found;
222    int a_limit_reached = 0;
223 <  unsigned int local = 0, global = 0, ident = 0;
223 >  unsigned int local = 0, global = 0;
224  
225    ip_found = ipcache_find_or_add_address(&client_p->connection->ip);
226    ip_found->count++;
227    AddFlag(client_p, FLAGS_IPHASH);
228  
229 <  count_user_host(client_p->username, client_p->host,
263 <                  &global, &local, &ident);
229 >  userhost_count(client_p->sockhost, &global, &local);
230  
231    /* XXX blah. go down checking the various silly limits
232     * setting a_limit_reached if any limit is reached.
# Line 270 | Line 236 | attach_iline(struct Client *client_p, st
236      a_limit_reached = 1;
237    else if (class->max_perip && ip_found->count > class->max_perip)
238      a_limit_reached = 1;
239 <  else if (class->max_local && local >= class->max_local)
239 >  else if (class->max_local && local >= class->max_local) /* XXX: redundant */
240      a_limit_reached = 1;
241    else if (class->max_global && global >= class->max_global)
242      a_limit_reached = 1;
277  else if (class->max_ident && ident >= class->max_ident &&
278           client_p->username[0] != '~')
279    a_limit_reached = 1;
243  
244    if (a_limit_reached)
245    {
# Line 301 | Line 264 | verify_access(struct Client *client_p)
264   {
265    struct MaskItem *conf = NULL;
266  
267 <  if (IsGotId(client_p))
267 >  if (HasFlag(client_p, FLAGS_GOTID))
268    {
269      conf = find_address_conf(client_p->host, client_p->username,
270                               &client_p->connection->ip,
# Line 337 | Line 300 | verify_access(struct Client *client_p)
300      if (IsConfDoSpoofIp(conf))
301      {
302        if (IsConfSpoofNotice(conf))
303 <        sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, "%s spoofing: %s as %s",
303 >        sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, "%s spoofing: %s as %s",
304                               client_p->name, client_p->host, conf->name);
305  
306        strlcpy(client_p->host, conf->name, sizeof(client_p->host));
# Line 400 | Line 363 | check_client(struct Client *source_p)
363        /* jdc - lists server name & port connections are on */
364        /*       a purely cosmetical change */
365        sendto_realops_flags(UMODE_UNAUTH, L_ALL, SEND_NOTICE,
366 <                           "Unauthorized client connection from %s [%s] on [%s/%u].",
366 >                           "Unauthorized client connection from %s on [%s/%u].",
367                             get_client_name(source_p, SHOW_IP),
405                           source_p->sockhost,
368                             source_p->connection->listener->name,
369                             source_p->connection->listener->port);
370        ilog(LOG_TYPE_IRCD, "Unauthorized client connection from %s on [%s/%u].",
# Line 513 | Line 475 | attach_connect_block(struct Client *clie
475  
476    assert(host);
477  
478 <  DLINK_FOREACH(node, server_items.head)
478 >  DLINK_FOREACH(node, connect_items.head)
479    {
480      struct MaskItem *conf = node->data;
481  
482 <    if (match(conf->name, name) || match(conf->host, host))
482 >    if (irccmp(conf->name, name) ||
483 >        irccmp(conf->host, host))
484        continue;
485  
486      attach_conf(client_p, conf);
# Line 566 | Line 529 | find_conf_name(dlink_list *list, const c
529   * side effects - looks for a match on name field
530   */
531   struct MaskItem *
532 < find_matching_name_conf(enum maskitem_type type, const char *name, const char *user,
570 <                        const char *host, unsigned int flags)
532 > connect_find(const char *name, const char *host, int (*compare)(const char *, const char *))
533   {
534    dlink_node *node = NULL;
573  dlink_list *list = map_to_list(type);
574  struct MaskItem *conf = NULL;
535  
536 <  switch (type)
536 >  DLINK_FOREACH(node, connect_items.head)
537    {
538 <  case CONF_SERVICE:
579 <    DLINK_FOREACH(node, list->head)
580 <    {
581 <      conf = node->data;
582 <
583 <      if (EmptyString(conf->name))
584 <        continue;
585 <      if (name && !irccmp(name, conf->name))
586 <        return conf;
587 <    }
588 <    break;
589 <
590 <  case CONF_XLINE:
591 <  case CONF_ULINE:
592 <  case CONF_NRESV:
593 <  case CONF_CRESV:
594 <    DLINK_FOREACH(node, list->head)
595 <    {
596 <      conf = node->data;
597 <
598 <      if (EmptyString(conf->name))
599 <        continue;
600 <      if (name && !match(conf->name, name))
601 <      {
602 <        if ((user == NULL && (host == NULL)))
603 <          return conf;
604 <        if ((conf->flags & flags) != flags)
605 <          continue;
606 <        if (EmptyString(conf->user) || EmptyString(conf->host))
607 <          return conf;
608 <        if (!match(conf->user, user) && !match(conf->host, host))
609 <          return conf;
610 <      }
611 <    }
612 <      break;
613 <
614 <  case CONF_SERVER:
615 <    DLINK_FOREACH(node, list->head)
616 <    {
617 <      conf = node->data;
618 <
619 <      if (name && !match(name, conf->name))
620 <        return conf;
621 <      if (host && !match(host, conf->host))
622 <        return conf;
623 <    }
624 <    break;
538 >    struct MaskItem *conf = node->data;
539  
540 <  default:
541 <    break;
540 >    if (name && !compare(name, conf->name))
541 >      return conf;
542 >    if (host && !compare(host, conf->host))
543 >      return conf;
544    }
545 +
546    return NULL;
547   }
548  
# Line 639 | Line 556 | find_matching_name_conf(enum maskitem_ty
556   * side effects - looks for an exact match on name field
557   */
558   struct MaskItem *
559 < find_exact_name_conf(enum maskitem_type type, const struct Client *who, const char *name,
643 <                     const char *user, const char *host)
559 > operator_find(const struct Client *who, const char *name)
560   {
561    dlink_node *node = NULL;
646  dlink_list *list = map_to_list(type);
647  struct MaskItem *conf = NULL;
562  
563 <  switch(type)
563 >  DLINK_FOREACH(node, operator_items.head)
564    {
565 <  case CONF_XLINE:
652 <  case CONF_ULINE:
653 <  case CONF_NRESV:
654 <  case CONF_CRESV:
655 <
656 <    DLINK_FOREACH(node, list->head)
657 <    {
658 <      conf = node->data;
659 <
660 <      if (EmptyString(conf->name))
661 <        continue;
662 <
663 <      if (irccmp(conf->name, name) == 0)
664 <      {
665 <        if ((user == NULL && (host == NULL)))
666 <          return conf;
667 <        if (EmptyString(conf->user) || EmptyString(conf->host))
668 <          return conf;
669 <        if (!match(conf->user, user) && !match(conf->host, host))
670 <          return conf;
671 <      }
672 <    }
673 <    break;
565 >    struct MaskItem *conf = node->data;
566  
567 <  case CONF_OPER:
676 <    DLINK_FOREACH(node, list->head)
567 >    if (!irccmp(conf->name, name))
568      {
569 <      conf = node->data;
570 <
680 <      if (EmptyString(conf->name))
681 <        continue;
569 >      if (!who)
570 >        return conf;
571  
572 <      if (!irccmp(conf->name, name))
572 >      if (!match(conf->user, who->username))
573        {
574 <        if (!who)
686 <          return conf;
687 <        if (EmptyString(conf->user) || EmptyString(conf->host))
688 <          return NULL;
689 <        if (!match(conf->user, who->username))
574 >        switch (conf->htype)
575          {
576 <          switch (conf->htype)
577 <          {
578 <            case HM_HOST:
579 <              if (!match(conf->host, who->host) || !match(conf->host, who->sockhost))
576 >          case HM_HOST:
577 >            if (!match(conf->host, who->host) || !match(conf->host, who->sockhost))
578 >              if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
579 >                return conf;
580 >            break;
581 >          case HM_IPV4:
582 >            if (who->connection->aftype == AF_INET)
583 >              if (match_ipv4(&who->connection->ip, &conf->addr, conf->bits))
584                  if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
585                    return conf;
586 <              break;
587 <            case HM_IPV4:
588 <              if (who->connection->aftype == AF_INET)
589 <                if (match_ipv4(&who->connection->ip, &conf->addr, conf->bits))
590 <                  if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
591 <                    return conf;
592 <              break;
593 <            case HM_IPV6:
594 <              if (who->connection->aftype == AF_INET6)
706 <                if (match_ipv6(&who->connection->ip, &conf->addr, conf->bits))
707 <                  if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
708 <                    return conf;
709 <              break;
710 <            default:
711 <              assert(0);
712 <          }
586 >            break;
587 >          case HM_IPV6:
588 >            if (who->connection->aftype == AF_INET6)
589 >              if (match_ipv6(&who->connection->ip, &conf->addr, conf->bits))
590 >                if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
591 >                  return conf;
592 >            break;
593 >          default:
594 >            assert(0);
595          }
596        }
597      }
716
717    break;
718
719  case CONF_SERVER:
720    DLINK_FOREACH(node, list->head)
721    {
722      conf = node->data;
723
724      if (EmptyString(conf->name))
725        continue;
726
727      if (name == NULL)
728      {
729        if (EmptyString(conf->host))
730          continue;
731        if (irccmp(conf->host, host) == 0)
732          return conf;
733      }
734      else if (irccmp(conf->name, name) == 0)
735        return conf;
736    }
737
738    break;
739
740  default:
741    break;
598    }
599  
600    return NULL;
# Line 761 | Line 617 | set_default_conf(void)
617     */
618    assert(class_default == class_get_list()->tail->data);
619  
764 #ifdef HAVE_LIBCRYPTO
765 #if OPENSSL_VERSION_NUMBER >= 0x009080FFL && !defined(OPENSSL_NO_ECDH)
766  {
767    EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
768
769    if (key)
770    {
771      SSL_CTX_set_tmp_ecdh(ConfigServerInfo.server_ctx, key);
772      EC_KEY_free(key);
773    }
774  }
775
776  SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
777 #endif
778
779  SSL_CTX_set_cipher_list(ConfigServerInfo.server_ctx, "EECDH+HIGH:EDH+HIGH:HIGH:!aNULL");
780  ConfigServerInfo.message_digest_algorithm = EVP_sha256();
781  ConfigServerInfo.rsa_private_key = NULL;
782  ConfigServerInfo.rsa_private_key_file = NULL;
783 #endif
784
785  /* ConfigServerInfo.name is not rehashable */
786  /* ConfigServerInfo.name = ConfigServerInfo.name; */
787  ConfigServerInfo.description = NULL;
620    ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
621    ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
622  
# Line 797 | Line 629 | set_default_conf(void)
629    ConfigServerInfo.max_nick_length = 9;
630    ConfigServerInfo.max_topic_length = 80;
631    ConfigServerInfo.hub = 0;
632 <
801 <  ConfigAdminInfo.name = NULL;
802 <  ConfigAdminInfo.email = NULL;
803 <  ConfigAdminInfo.description = NULL;
632 >  ConfigServerInfo.libgeoip_database_options = 0;
633  
634    log_del_all();
635  
# Line 809 | Line 638 | set_default_conf(void)
638    ConfigChannel.disable_fake_channels = 0;
639    ConfigChannel.invite_client_count = 10;
640    ConfigChannel.invite_client_time = 300;
641 +  ConfigChannel.invite_delay_channel = 5;
642    ConfigChannel.knock_client_count = 1;
643    ConfigChannel.knock_client_time = 300;
644    ConfigChannel.knock_delay_channel = 60;
# Line 816 | Line 646 | set_default_conf(void)
646    ConfigChannel.max_bans = 25;
647    ConfigChannel.default_join_flood_count = 18;
648    ConfigChannel.default_join_flood_time = 6;
819  ConfigChannel.default_split_user_count = 0;
820  ConfigChannel.default_split_server_count = 0;
821  ConfigChannel.no_join_on_split = 0;
822  ConfigChannel.no_create_on_split = 0;
649  
650    ConfigServerHide.flatten_links = 0;
651 <  ConfigServerHide.links_delay = 300;
651 >  ConfigServerHide.flatten_links_delay = 300;
652    ConfigServerHide.hidden = 0;
653    ConfigServerHide.hide_servers = 0;
654    ConfigServerHide.hide_services = 0;
# Line 832 | Line 658 | set_default_conf(void)
658  
659    ConfigGeneral.away_count = 2;
660    ConfigGeneral.away_time = 10;
661 <  ConfigGeneral.max_watch = WATCHSIZE_DEFAULT;
661 >  ConfigGeneral.max_watch = 50;
662 >  ConfigGeneral.whowas_history_length = 15000;
663    ConfigGeneral.cycle_on_host_change = 1;
664    ConfigGeneral.dline_min_cidr = 16;
665    ConfigGeneral.dline_min_cidr6 = 48;
# Line 848 | Line 675 | set_default_conf(void)
675    ConfigGeneral.dots_in_ident = 0;
676    ConfigGeneral.min_nonwildcard = 4;
677    ConfigGeneral.min_nonwildcard_simple = 3;
678 <  ConfigGeneral.max_accept = 20;
678 >  ConfigGeneral.max_accept = 50;
679    ConfigGeneral.anti_nick_flood = 0;
680    ConfigGeneral.max_nick_time = 20;
681    ConfigGeneral.max_nick_changes = 5;
682    ConfigGeneral.anti_spam_exit_message_time = 0;
683 <  ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
684 <  ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
683 >  ConfigGeneral.ts_warn_delta = 30;
684 >  ConfigGeneral.ts_max_delta = 600;
685    ConfigGeneral.warn_no_connect_block = 1;
686    ConfigGeneral.stats_e_disabled = 0;
687    ConfigGeneral.stats_i_oper_only = 1;  /* 1 = masked */
# Line 870 | Line 697 | set_default_conf(void)
697    ConfigGeneral.short_motd = 0;
698    ConfigGeneral.ping_cookie = 0;
699    ConfigGeneral.no_oper_flood = 0;
873  ConfigGeneral.oper_pass_resv = 1;
700    ConfigGeneral.max_targets = MAX_TARGETS_DEFAULT;
701    ConfigGeneral.oper_only_umodes = UMODE_DEBUG | UMODE_LOCOPS | UMODE_HIDDEN | UMODE_FARCONNECT |
702                                     UMODE_UNAUTH | UMODE_EXTERNAL | UMODE_BOTS | UMODE_NCHANGE |
# Line 883 | Line 709 | set_default_conf(void)
709   static void
710   validate_conf(void)
711   {
886  if (ConfigGeneral.ts_warn_delta < TS_WARN_DELTA_MIN)
887    ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
888
889  if (ConfigGeneral.ts_max_delta < TS_MAX_DELTA_MIN)
890    ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
891
712    if (EmptyString(ConfigServerInfo.network_name))
713      ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
714  
715    if (EmptyString(ConfigServerInfo.network_desc))
716      ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
897
898  ConfigGeneral.max_watch = IRCD_MAX(ConfigGeneral.max_watch, WATCHSIZE_MIN);
717   }
718  
719   /* read_conf()
# Line 919 | Line 737 | read_conf(FILE *file)
737    yyparse();  /* Load the values from the conf */
738    validate_conf();  /* Check to make sure some values are still okay. */
739                      /* Some global values are also loaded here. */
740 +  whowas_trim();  /* Attempt to trim whowas list if necessary */
741    class_delete_marked();  /* Delete unused classes that are marked for deletion */
742   }
743  
# Line 932 | Line 751 | void
751   conf_rehash(int sig)
752   {
753    if (sig)
754 <    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
754 >  {
755 >    sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
756                           "Got signal SIGHUP, reloading configuration file(s)");
757 +    ilog(LOG_TYPE_IRCD, "Got signal SIGHUP, reloading configuration file(s)");
758 +  }
759  
760    restart_resolver();
761  
# Line 993 | Line 815 | int
815   conf_connect_allowed(struct irc_ssaddr *addr, int aftype)
816   {
817    struct ip_entry *ip_found = NULL;
818 <  struct MaskItem *const conf = find_dline_conf(addr, aftype);
997 <
998 <  /* DLINE exempt also gets you out of static limits/pacing... */
999 <  if (conf && (conf->type == CONF_EXEMPT))
1000 <    return 0;
818 >  const struct MaskItem *conf = find_dline_conf(addr, aftype);
819  
820    if (conf)
821 +  {
822 +    /* DLINE exempt also gets you out of static limits/pacing... */
823 +    if (conf->type == CONF_EXEMPT)
824 +      return 0;
825      return BANNED_CLIENT;
826 +  }
827  
828    ip_found = ipcache_find_or_add_address(addr);
829  
# Line 1018 | Line 841 | conf_connect_allowed(struct irc_ssaddr *
841    return 0;
842   }
843  
1021 /* expire_tklines()
1022 *
1023 * inputs       - tkline list pointer
1024 * output       - NONE
1025 * side effects - expire tklines
1026 */
1027 static void
1028 expire_tklines(dlink_list *list)
1029 {
1030  dlink_node *node = NULL, *node_next = NULL;
1031
1032  DLINK_FOREACH_SAFE(node, node_next, list->head)
1033  {
1034    struct MaskItem *conf = node->data;
1035
1036    if (!conf->until || conf->until > CurrentTime)
1037      continue;
1038
1039    if (ConfigGeneral.tkline_expire_notices)
1040      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "Temporary %s for [%s] expired",
1041                           (conf->type == CONF_XLINE) ? "X-line" : "RESV", conf->name);
1042    conf_free(conf);
1043  }
1044 }
1045
844   /* cleanup_tklines()
845   *
846   * inputs       - NONE
# Line 1054 | Line 852 | void
852   cleanup_tklines(void *unused)
853   {
854    hostmask_expire_temporary();
855 <  expire_tklines(&xconf_items);
856 <  expire_tklines(&nresv_items);
1059 <  expire_tklines(&cresv_items);
855 >  gecos_expire();
856 >  resv_expire();
857   }
858  
859   /* oper_privs_as_string()
# Line 1065 | Line 862 | cleanup_tklines(void *unused)
862   * output        - pointer to static string showing oper privs
863   * side effects  - return as string, the oper privs as derived from port
864   */
865 < static const struct oper_privs
865 > static const struct oper_flags
866   {
867    const unsigned int flag;
868    const unsigned char c;
869 < } flag_list[] = {
869 > } flag_table[] = {
870    { OPER_FLAG_ADMIN,          'A' },
871 <  { OPER_FLAG_REMOTEBAN,      'B' },
872 <  { OPER_FLAG_DIE,            'D' },
873 <  { OPER_FLAG_REHASH,         'H' },
871 >  { OPER_FLAG_CLOSE,          'B' },
872 >  { OPER_FLAG_CONNECT,        'C' },
873 >  { OPER_FLAG_CONNECT_REMOTE, 'D' },
874 >  { OPER_FLAG_DIE,            'E' },
875 >  { OPER_FLAG_DLINE,          'F' },
876 >  { OPER_FLAG_GLOBOPS,        'G' },
877 >  { OPER_FLAG_JOIN_RESV,      'H' },
878 >  { OPER_FLAG_KILL,           'I' },
879 >  { OPER_FLAG_KILL_REMOTE,    'J' },
880    { OPER_FLAG_KLINE,          'K' },
881 <  { OPER_FLAG_KILL,           'N' },
882 <  { OPER_FLAG_KILL_REMOTE,    'O' },
883 <  { OPER_FLAG_CONNECT,        'P' },
884 <  { OPER_FLAG_CONNECT_REMOTE, 'Q' },
885 <  { OPER_FLAG_SQUIT,          'R' },
886 <  { OPER_FLAG_SQUIT_REMOTE,   'S' },
887 <  { OPER_FLAG_UNKLINE,        'U' },
888 <  { OPER_FLAG_XLINE,          'X' },
881 >  { OPER_FLAG_LOCOPS,         'L' },
882 >  { OPER_FLAG_MODULE,         'M' },
883 >  { OPER_FLAG_NICK_RESV,      'N' },
884 >  { OPER_FLAG_OPME,           'O' },
885 >  { OPER_FLAG_REHASH,         'P' },
886 >  { OPER_FLAG_REMOTEBAN,      'Q' },
887 >  { OPER_FLAG_RESTART,        'R' },
888 >  { OPER_FLAG_RESV,           'S' },
889 >  { OPER_FLAG_SET,            'T' },
890 >  { OPER_FLAG_SQUIT,          'U' },
891 >  { OPER_FLAG_SQUIT_REMOTE,   'V' },
892 >  { OPER_FLAG_UNDLINE,        'W' },
893 >  { OPER_FLAG_UNKLINE,        'X' },
894 >  { OPER_FLAG_UNRESV,         'Y' },
895 >  { OPER_FLAG_UNXLINE,        'Z' },
896 >  { OPER_FLAG_WALLOPS,        'a' },
897 >  { OPER_FLAG_XLINE,          'b' },
898    { 0, '\0' }
899   };
900  
901   const char *
902 < oper_privs_as_string(const unsigned int port)
902 > oper_privs_as_string(const unsigned int flags)
903   {
904 <  static char privs_out[IRCD_BUFSIZE];
905 <  char *privs_ptr = privs_out;
904 >  static char buf[sizeof(flag_table) / sizeof(struct oper_flags)];
905 >  char *p = buf;
906  
907 <  for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv)
908 <  {
909 <    if (port & opriv->flag)
1098 <      *privs_ptr++ = opriv->c;
1099 <    else
1100 <      *privs_ptr++ = ToLower(opriv->c);
1101 <  }
907 >  for (const struct oper_flags *tab = flag_table; tab->flag; ++tab)
908 >    if (flags & tab->flag)
909 >      *p++ = tab->c;
910  
911 <  *privs_ptr = '\0';
911 >  if (p == buf)
912 >    *p++ = '0';
913  
914 <  return privs_out;
914 >  *p = '\0';
915 >
916 >  return buf;
917   }
918  
919   /*
# Line 1158 | Line 969 | clear_out_old_conf(void)
969   {
970    dlink_node *node = NULL, *node_next = NULL;
971    dlink_list *free_items [] = {
972 <    &server_items,   &oconf_items,
1162 <     &uconf_items,   &xconf_items,
1163 <     &nresv_items, &cluster_items,  &service_items, &cresv_items, NULL
972 >    &connect_items, &operator_items, NULL
973    };
974  
975    dlink_list ** iterator = free_items; /* C is dumb */
# Line 1176 | Line 985 | clear_out_old_conf(void)
985        struct MaskItem *conf = node->data;
986  
987        conf->active = 0;
988 +      dlinkDelete(&conf->node, *iterator);
989  
990 <      if (!IsConfDatabase(conf))
991 <      {
1182 <        dlinkDelete(&conf->node, *iterator);
1183 <
1184 <        if (!conf->ref_count)
1185 <          conf_free(conf);
1186 <      }
990 >      if (!conf->ref_count)
991 >        conf_free(conf);
992      }
993    }
994  
1190  motd_clear();
1191
995    /*
996     * Don't delete the class table, rather mark all entries for deletion.
997     * The table is cleaned up by class_delete_marked. - avalon
# Line 1197 | Line 1000 | clear_out_old_conf(void)
1000  
1001    clear_out_address_conf();
1002  
1003 <  /* Clean out module paths */
1004 <  mod_clear_paths();
1003 >  modules_conf_clear();  /* Clear modules {} items */
1004 >
1005 >  motd_clear();  /* Clear motd {} items and re-cache default motd */
1006 >
1007 >  cluster_clear();  /* Clear cluster {} items */
1008 >
1009 >  gecos_clear();  /* Clear gecos {} items */
1010 >
1011 >  resv_clear();  /* Clear resv {} items */
1012 >
1013 >  service_clear();  /* Clear service {} items */
1014 >
1015 >  shared_clear();  /* Clear shared {} items */
1016 >
1017 >  pseudo_clear();  /* Clear pseudo {} items */
1018  
1019 <  pseudo_clear();
1019 > #ifdef HAVE_LIBGEOIP
1020 >  GeoIP_delete(GeoIPv4_ctx);
1021 >  GeoIPv4_ctx = NULL;
1022 >  GeoIP_delete(GeoIPv6_ctx);
1023 >  GeoIPv6_ctx = NULL;
1024 > #endif
1025  
1026    /* Clean out ConfigServerInfo */
1027 <  MyFree(ConfigServerInfo.description);
1027 >  xfree(ConfigServerInfo.description);
1028    ConfigServerInfo.description = NULL;
1029 <  MyFree(ConfigServerInfo.network_name);
1029 >  xfree(ConfigServerInfo.network_name);
1030    ConfigServerInfo.network_name = NULL;
1031 <  MyFree(ConfigServerInfo.network_desc);
1031 >  xfree(ConfigServerInfo.network_desc);
1032    ConfigServerInfo.network_desc = NULL;
1033 < #ifdef HAVE_LIBCRYPTO
1034 <  if (ConfigServerInfo.rsa_private_key)
1035 <  {
1036 <    RSA_free(ConfigServerInfo.rsa_private_key);
1037 <    ConfigServerInfo.rsa_private_key = NULL;
1217 <  }
1218 <
1219 <  MyFree(ConfigServerInfo.rsa_private_key_file);
1033 >  xfree(ConfigServerInfo.libgeoip_ipv6_database_file);
1034 >  ConfigServerInfo.libgeoip_ipv6_database_file = NULL;
1035 >  xfree(ConfigServerInfo.libgeoip_ipv4_database_file);
1036 >  ConfigServerInfo.libgeoip_ipv4_database_file = NULL;
1037 >  xfree(ConfigServerInfo.rsa_private_key_file);
1038    ConfigServerInfo.rsa_private_key_file = NULL;
1039 < #endif
1039 >  xfree(ConfigServerInfo.ssl_certificate_file);
1040 >  ConfigServerInfo.ssl_certificate_file = NULL;
1041 >  xfree(ConfigServerInfo.ssl_dh_param_file);
1042 >  ConfigServerInfo.ssl_dh_param_file = NULL;
1043 >  xfree(ConfigServerInfo.ssl_dh_elliptic_curve);
1044 >  ConfigServerInfo.ssl_dh_elliptic_curve = NULL;
1045 >  xfree(ConfigServerInfo.ssl_cipher_list);
1046 >  ConfigServerInfo.ssl_cipher_list = NULL;
1047 >  xfree(ConfigServerInfo.ssl_message_digest_algorithm);
1048 >  ConfigServerInfo.ssl_message_digest_algorithm = NULL;
1049  
1050    /* Clean out ConfigAdminInfo */
1051 <  MyFree(ConfigAdminInfo.name);
1051 >  xfree(ConfigAdminInfo.name);
1052    ConfigAdminInfo.name = NULL;
1053 <  MyFree(ConfigAdminInfo.email);
1053 >  xfree(ConfigAdminInfo.email);
1054    ConfigAdminInfo.email = NULL;
1055 <  MyFree(ConfigAdminInfo.description);
1055 >  xfree(ConfigAdminInfo.description);
1056    ConfigAdminInfo.description = NULL;
1057  
1058 +  xfree(ConfigServerHide.flatten_links_file);
1059 +  ConfigServerHide.flatten_links_file = NULL;
1060 +
1061    /* Clean out listeners */
1062 <  close_listeners();
1062 >  listener_close_marked();
1063 > }
1064 >
1065 > static void
1066 > conf_handle_tls(int cold)
1067 > {
1068 >  if (!tls_new_cred())
1069 >  {
1070 >    if (cold)
1071 >    {
1072 >      ilog(LOG_TYPE_IRCD, "Error while initializing TLS");
1073 >      exit(EXIT_FAILURE);
1074 >    }
1075 >    else
1076 >    {
1077 >      /* Failed to load new settings/certs, old ones remain active */
1078 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
1079 >                           "Error reloading TLS settings, check the ircd log"); // report_crypto_errors logs this
1080 >    }
1081 >  }
1082   }
1083  
1084   /* read_conf_files()
# Line 1262 | Line 1111 | read_conf_files(int cold)
1111      {
1112        ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
1113             filename, strerror(errno));
1114 <      exit(-1);
1114 >      exit(EXIT_FAILURE);
1115      }
1116      else
1117      {
1118 <      sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1118 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1119                             "Unable to read configuration file '%s': %s",
1120                             filename, strerror(errno));
1121        return;
# Line 1280 | Line 1129 | read_conf_files(int cold)
1129    fclose(conf_parser_ctx.conf_file);
1130  
1131    log_reopen_all();
1132 +  conf_handle_tls(cold);
1133  
1134 <  add_isupport("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1135 <  add_isupport("NETWORK", ConfigServerInfo.network_name, -1);
1134 >  isupport_add("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1135 >  isupport_add("NETWORK", ConfigServerInfo.network_name, -1);
1136  
1137 <  snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans);
1138 <  add_isupport("MAXLIST", chanmodes, -1);
1139 <  add_isupport("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1140 <  add_isupport("CHANTYPES", "#", -1);
1137 >  snprintf(chanmodes, sizeof(chanmodes), "beI:%u", ConfigChannel.max_bans);
1138 >  isupport_add("MAXLIST", chanmodes, -1);
1139 >  isupport_add("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1140 >  isupport_add("CHANTYPES", "#", -1);
1141  
1142 <  snprintf(chanlimit, sizeof(chanlimit), "#:%d",
1142 >  snprintf(chanlimit, sizeof(chanlimit), "#:%u",
1143             ConfigChannel.max_channels);
1144 <  add_isupport("CHANLIMIT", chanlimit, -1);
1145 <  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstCMORS");
1146 <  add_isupport("CHANNELLEN", NULL, CHANNELLEN);
1147 <  add_isupport("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1148 <  add_isupport("CHANMODES", chanmodes, -1);
1299 <
1300 <  /*
1301 <   * message_locale may have changed.  rebuild isupport since it relies
1302 <   * on strlen(form_str(RPL_ISUPPORT))
1303 <   */
1304 <  rebuild_isupport_message_line();
1144 >  isupport_add("CHANLIMIT", chanlimit, -1);
1145 >  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstCMORST");
1146 >  isupport_add("CHANNELLEN", NULL, CHANNELLEN);
1147 >  isupport_add("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1148 >  isupport_add("CHANMODES", chanmodes, -1);
1149   }
1150  
1151   /* conf_add_class_to_conf()
# Line 1318 | Line 1162 | conf_add_class_to_conf(struct MaskItem *
1162      conf->class = class_default;
1163  
1164      if (conf->type == CONF_CLIENT || conf->type == CONF_OPER)
1165 <      sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1165 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1166                             "Warning *** Defaulting to default class for %s@%s",
1167                             conf->user, conf->host);
1168      else
1169 <      sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1169 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1170                             "Warning *** Defaulting to default class for %s",
1171                             conf->name);
1172    }
# Line 1337 | Line 1181 | conf_add_class_to_conf(struct MaskItem *
1181   void
1182   yyerror(const char *msg)
1183   {
1340  char newlinebuf[IRCD_BUFSIZE];
1341
1184    if (conf_parser_ctx.pass != 1)
1185      return;
1186  
1187 <  strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1188 <  sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1187 >  char *p = stripws(linebuf);
1188 >  sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1189                         "\"%s\", line %u: %s: %s",
1190 <                       conffilebuf, lineno + 1, msg, newlinebuf);
1190 >                       conffilebuf, lineno + 1, msg, p);
1191    ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
1192 <       conffilebuf, lineno + 1, msg, newlinebuf);
1192 >       conffilebuf, lineno + 1, msg, p);
1193   }
1194  
1195   void
1196   conf_error_report(const char *msg)
1197   {
1198 <  char newlinebuf[IRCD_BUFSIZE];
1199 <
1358 <  strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1359 <  sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE,
1198 >  char *p = stripws(linebuf);
1199 >  sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1200                         "\"%s\", line %u: %s: %s",
1201 <                       conffilebuf, lineno + 1, msg, newlinebuf);
1201 >                       conffilebuf, lineno + 1, msg, linebuf);
1202    ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
1203 <       conffilebuf, lineno + 1, msg, newlinebuf);
1203 >       conffilebuf, lineno + 1, msg, linebuf);
1204   }
1205  
1206   /*
# Line 1373 | Line 1213 | conf_error_report(const char *msg)
1213   * side effects - none
1214   * Originally written by Dianora (Diane, db@db.net)
1215   */
1216 < time_t
1216 > uintmax_t
1217   valid_tkline(const char *data, const int minutes)
1218   {
1219    const unsigned char *p = (const unsigned char *)data;
1220    unsigned char tmpch = '\0';
1221 <  time_t result = 0;
1221 >  uintmax_t result = 0;
1222  
1223    while ((tmpch = *p++))
1224    {
# Line 1423 | Line 1263 | valid_wild_card_simple(const char *data)
1263   {
1264    const unsigned char *p = (const unsigned char *)data;
1265    unsigned char tmpch = '\0';
1266 <  unsigned int nonwild = 0;
1266 >  unsigned int nonwild = 0, wild = 0;
1267  
1268    while ((tmpch = *p++))
1269    {
# Line 1438 | Line 1278 | valid_wild_card_simple(const char *data)
1278        if (++nonwild >= ConfigGeneral.min_nonwildcard_simple)
1279          return 1;
1280      }
1281 +    else
1282 +      ++wild;
1283    }
1284  
1285 <  return 0;
1285 >  return !wild;
1286   }
1287  
1288   /* valid_wild_card()
# Line 1452 | Line 1294 | valid_wild_card_simple(const char *data)
1294   * side effects - NOTICE is given to source_p if warn is 1
1295   */
1296   int
1297 < valid_wild_card(struct Client *source_p, int count, ...)
1297 > valid_wild_card(int count, ...)
1298   {
1299    unsigned char tmpch = '\0';
1300    unsigned int nonwild = 0;
# Line 1495 | Line 1337 | valid_wild_card(struct Client *source_p,
1337      }
1338    }
1339  
1498  if (IsClient(source_p))
1499    sendto_one_notice(source_p, &me,
1500                      ":Please include at least %u non-wildcard characters with the mask",
1501                      ConfigGeneral.min_nonwildcard);
1340    va_end(args);
1341    return 0;
1342   }
# Line 1559 | Line 1397 | find_user_host(struct Client *source_p,
1397          find_chasing(source_p, user_host_or_nick)) == NULL)
1398        return 0;  /* find_chasing sends ERR_NOSUCHNICK */
1399  
1400 <    if (IsExemptKline(target_p))
1400 >    if (HasFlag(target_p, FLAGS_EXEMPTKLINE))
1401      {
1402        if (IsClient(source_p))
1403          sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name);
# Line 1575 | Line 1413 | find_user_host(struct Client *source_p,
1413      if (target_p->username[0] == '~')
1414        luser[0] = '*';
1415  
1416 <    if (!strcmp(target_p->sockhost, "0"))
1579 <      strlcpy(lhost, target_p->host, HOSTLEN*4 + 1);
1580 <    else
1581 <      strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
1416 >    strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
1417      return 1;
1418    }
1419  
# Line 1618 | Line 1453 | find_user_host(struct Client *source_p,
1453   int
1454   parse_aline(const char *cmd, struct Client *source_p,
1455              int parc, char **parv,
1456 <            int parse_flags, char **up_p, char **h_p, time_t *tkline_time,
1456 >            char **up_p, char **h_p, uintmax_t *tkline_time,
1457              char **target_server, char **reason)
1458   {
1459 <  int found_tkline_time=0;
1459 >  uintmax_t found_tkline_time=0;
1460    static char default_reason[] = CONF_NOREASON;
1461    static char user[USERLEN*4+1];
1462    static char host[HOSTLEN*4+1];
# Line 1698 | Line 1533 | parse_aline(const char *cmd, struct Clie
1533      }
1534    }
1535  
1701  if (h_p)
1702  {
1703    if (strchr(user, '!'))
1704    {
1705      sendto_one_notice(source_p, &me, ":Invalid character '!' in kline");
1706      return 0;
1707    }
1708
1709    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 2, *up_p, *h_p))
1710      return 0;
1711  }
1712  else
1713    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, *up_p))
1714      return 0;
1715
1536    if (reason)
1537    {
1538      if (parc && !EmptyString(*parv))
# Line 1748 | Line 1568 | match_conf_password(const char *password
1568   }
1569  
1570   /*
1751 * cluster_a_line
1752 *
1753 * inputs       - client sending the cluster
1754 *              - command name "KLINE" "XLINE" etc.
1755 *              - capab -- CAP_KLN etc. from server.h
1756 *              - cluster type -- CLUSTER_KLINE etc. from conf.h
1757 *              - pattern and args to send along
1758 * output       - none
1759 * side effects - Take source_p send the pattern with args given
1760 *                along to all servers that match capab and cluster type
1761 */
1762 void
1763 cluster_a_line(struct Client *source_p, const char *command, unsigned int capab,
1764               unsigned int cluster_type, const char *pattern, ...)
1765 {
1766  va_list args;
1767  char buffer[IRCD_BUFSIZE] = "";
1768  const dlink_node *node = NULL;
1769
1770  va_start(args, pattern);
1771  vsnprintf(buffer, sizeof(buffer), pattern, args);
1772  va_end(args);
1773
1774  DLINK_FOREACH(node, cluster_items.head)
1775  {
1776    const struct MaskItem *conf = node->data;
1777
1778    if (conf->flags & cluster_type)
1779      sendto_match_servs(source_p, conf->name, CAP_CLUSTER | capab,
1780                         "%s %s %s", command, conf->name, buffer);
1781  }
1782 }
1783
1784 /*
1571   * split_nuh
1572   *
1573   * inputs       - pointer to original mask (modified in place)

Comparing ircd-hybrid/branches/8.2.x/src/conf.c (property svn:keywords):
Revision 5954 by michael, Sat May 9 19:34:12 2015 UTC vs.
Revision 7725 by michael, Mon Sep 26 14:59:44 2016 UTC

# Line 1 | Line 1
1 < Id Revision
1 > Id

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines