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 6376 by michael, Fri Aug 21 10:36:52 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 56 | Line 60
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 67 | 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;
72 < dlink_list cluster_items;
73 < dlink_list oconf_items;
74 < dlink_list uconf_items;
75 < dlink_list xconf_items;
76 < dlink_list nresv_items;
77 < 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 136 | Line 135 | map_to_list(enum maskitem_type type)
135   {
136    switch (type)
137    {
139    case CONF_XLINE:
140      return &xconf_items;
141      break;
142    case CONF_ULINE:
143      return &uconf_items;
144      break;
145    case CONF_NRESV:
146      return &nresv_items;
147      break;
148    case CONF_CRESV:
149      return &cresv_items;
150      break;
138      case CONF_OPER:
139 <      return &oconf_items;
139 >      return &operator_items;
140        break;
141      case CONF_SERVER:
142 <      return &server_items;
156 <      break;
157 <    case CONF_SERVICE:
158 <      return &service_items;
159 <      break;
160 <    case CONF_CLUSTER:
161 <      return &cluster_items;
142 >      return &connect_items;
143        break;
144      default:
145        return NULL;
# Line 168 | 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 189 | 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 200 | 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
211 <  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  
213  if (conf->rsa_public_key)
214    RSA_free(conf->rsa_public_key);
215 #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)
231 <  {
232 <    struct exempt *exptr = node->data;
233 <
234 <    dlinkDelete(node, &conf->exempt_list);
235 <    MyFree(exptr->name);
236 <    MyFree(exptr->user);
237 <    MyFree(exptr->host);
238 <    MyFree(exptr);
239 <  }
240 <
241 <  MyFree(conf);
207 >  xfree(conf);
208   }
209  
210   /* attach_iline()
# Line 254 | 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,
264 <                  &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 271 | 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;
278  else if (class->max_ident && ident >= class->max_ident &&
279           client_p->username[0] != '~')
280    a_limit_reached = 1;
243  
244    if (a_limit_reached)
245    {
# Line 401 | 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),
406                           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 514 | 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 567 | 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,
571 <                        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;
574  dlink_list *list = map_to_list(type);
575  struct MaskItem *conf = NULL;
535  
536 <  switch (type)
536 >  DLINK_FOREACH(node, connect_items.head)
537    {
538 <  case CONF_SERVICE:
580 <    DLINK_FOREACH(node, list->head)
581 <    {
582 <      conf = node->data;
583 <
584 <      if (EmptyString(conf->name))
585 <        continue;
586 <      if (name && !irccmp(name, conf->name))
587 <        return conf;
588 <    }
589 <    break;
590 <
591 <  case CONF_XLINE:
592 <  case CONF_ULINE:
593 <  case CONF_NRESV:
594 <  case CONF_CRESV:
595 <    DLINK_FOREACH(node, list->head)
596 <    {
597 <      conf = node->data;
598 <
599 <      if (EmptyString(conf->name))
600 <        continue;
601 <      if (name && !match(conf->name, name))
602 <      {
603 <        if ((user == NULL && (host == NULL)))
604 <          return conf;
605 <        if ((conf->flags & flags) != flags)
606 <          continue;
607 <        if (EmptyString(conf->user) || EmptyString(conf->host))
608 <          return conf;
609 <        if (!match(conf->user, user) && !match(conf->host, host))
610 <          return conf;
611 <      }
612 <    }
613 <      break;
614 <
615 <  case CONF_SERVER:
616 <    DLINK_FOREACH(node, list->head)
617 <    {
618 <      conf = node->data;
619 <
620 <      if (name && !match(name, conf->name))
621 <        return conf;
622 <      if (host && !match(host, conf->host))
623 <        return conf;
624 <    }
625 <    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 640 | 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,
644 <                     const char *user, const char *host)
559 > operator_find(const struct Client *who, const char *name)
560   {
561    dlink_node *node = NULL;
647  dlink_list *list = map_to_list(type);
648  struct MaskItem *conf = NULL;
562  
563 <  switch(type)
563 >  DLINK_FOREACH(node, operator_items.head)
564    {
565 <  case CONF_XLINE:
653 <  case CONF_ULINE:
654 <  case CONF_NRESV:
655 <  case CONF_CRESV:
656 <
657 <    DLINK_FOREACH(node, list->head)
658 <    {
659 <      conf = node->data;
660 <
661 <      if (EmptyString(conf->name))
662 <        continue;
663 <
664 <      if (irccmp(conf->name, name) == 0)
665 <      {
666 <        if ((user == NULL && (host == NULL)))
667 <          return conf;
668 <        if (EmptyString(conf->user) || EmptyString(conf->host))
669 <          return conf;
670 <        if (!match(conf->user, user) && !match(conf->host, host))
671 <          return conf;
672 <      }
673 <    }
674 <    break;
565 >    struct MaskItem *conf = node->data;
566  
567 <  case CONF_OPER:
677 <    DLINK_FOREACH(node, list->head)
567 >    if (!irccmp(conf->name, name))
568      {
569 <      conf = node->data;
570 <
681 <      if (EmptyString(conf->name))
682 <        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)
687 <          return conf;
688 <        if (EmptyString(conf->user) || EmptyString(conf->host))
689 <          return NULL;
690 <        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_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 <            case HM_IPV4:
594 <              if (who->connection->aftype == AF_INET)
701 <                if (match_ipv4(&who->connection->ip, &conf->addr, conf->bits))
702 <                  if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
703 <                    return conf;
704 <              break;
705 <            case HM_IPV6:
706 <              if (who->connection->aftype == AF_INET6)
707 <                if (match_ipv6(&who->connection->ip, &conf->addr, conf->bits))
708 <                  if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
709 <                    return conf;
710 <              break;
711 <            default:
712 <              assert(0);
713 <          }
592 >            break;
593 >          default:
594 >            assert(0);
595          }
596        }
597      }
717
718    break;
719
720  case CONF_SERVER:
721    DLINK_FOREACH(node, list->head)
722    {
723      conf = node->data;
724
725      if (EmptyString(conf->name))
726        continue;
727
728      if (name == NULL)
729      {
730        if (EmptyString(conf->host))
731          continue;
732        if (irccmp(conf->host, host) == 0)
733          return conf;
734      }
735      else if (irccmp(conf->name, name) == 0)
736        return conf;
737    }
738
739    break;
740
741  default:
742    break;
598    }
599  
600    return NULL;
# Line 762 | Line 617 | set_default_conf(void)
617     */
618    assert(class_default == class_get_list()->tail->data);
619  
765 #ifdef HAVE_LIBCRYPTO
766 #if OPENSSL_VERSION_NUMBER >= 0x009080FFL && !defined(OPENSSL_NO_ECDH)
767  {
768    EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
769
770    if (key)
771    {
772      SSL_CTX_set_tmp_ecdh(ConfigServerInfo.server_ctx, key);
773      EC_KEY_free(key);
774    }
775  }
776
777  SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
778 #endif
779
780  SSL_CTX_set_cipher_list(ConfigServerInfo.server_ctx, "EECDH+HIGH:EDH+HIGH:HIGH:!aNULL");
781  ConfigServerInfo.message_digest_algorithm = EVP_sha256();
782  ConfigServerInfo.rsa_private_key = NULL;
783  ConfigServerInfo.rsa_private_key_file = NULL;
784 #endif
785
786  /* ConfigServerInfo.name is not rehashable */
787  /* ConfigServerInfo.name = ConfigServerInfo.name; */
788  ConfigServerInfo.description = NULL;
620    ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
621    ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
622  
# Line 798 | Line 629 | set_default_conf(void)
629    ConfigServerInfo.max_nick_length = 9;
630    ConfigServerInfo.max_topic_length = 80;
631    ConfigServerInfo.hub = 0;
632 <
802 <  ConfigAdminInfo.name = NULL;
803 <  ConfigAdminInfo.email = NULL;
804 <  ConfigAdminInfo.description = NULL;
632 >  ConfigServerInfo.libgeoip_database_options = 0;
633  
634    log_del_all();
635  
# Line 810 | 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 819 | Line 648 | set_default_conf(void)
648    ConfigChannel.default_join_flood_time = 6;
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 829 | 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 845 | 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 867 | Line 697 | set_default_conf(void)
697    ConfigGeneral.short_motd = 0;
698    ConfigGeneral.ping_cookie = 0;
699    ConfigGeneral.no_oper_flood = 0;
870  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 880 | Line 709 | set_default_conf(void)
709   static void
710   validate_conf(void)
711   {
883  if (ConfigGeneral.ts_warn_delta < TS_WARN_DELTA_MIN)
884    ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
885
886  if (ConfigGeneral.ts_max_delta < TS_MAX_DELTA_MIN)
887    ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
888
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);
894
895  ConfigGeneral.max_watch = IRCD_MAX(ConfigGeneral.max_watch, WATCHSIZE_MIN);
717   }
718  
719   /* read_conf()
# Line 916 | 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 929 | Line 751 | void
751   conf_rehash(int sig)
752   {
753    if (sig)
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 990 | 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);
994 <
995 <  /* DLINE exempt also gets you out of static limits/pacing... */
996 <  if (conf && (conf->type == CONF_EXEMPT))
997 <    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 1015 | Line 841 | conf_connect_allowed(struct irc_ssaddr *
841    return 0;
842   }
843  
1018 /* expire_tklines()
1019 *
1020 * inputs       - tkline list pointer
1021 * output       - NONE
1022 * side effects - expire tklines
1023 */
1024 static void
1025 expire_tklines(dlink_list *list)
1026 {
1027  dlink_node *node = NULL, *node_next = NULL;
1028
1029  DLINK_FOREACH_SAFE(node, node_next, list->head)
1030  {
1031    struct MaskItem *conf = node->data;
1032
1033    if (!conf->until || conf->until > CurrentTime)
1034      continue;
1035
1036    if (ConfigGeneral.tkline_expire_notices)
1037      sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "Temporary %s for [%s] expired",
1038                           (conf->type == CONF_XLINE) ? "X-line" : "RESV", conf->name);
1039    conf_free(conf);
1040  }
1041 }
1042
844   /* cleanup_tklines()
845   *
846   * inputs       - NONE
# Line 1051 | Line 852 | void
852   cleanup_tklines(void *unused)
853   {
854    hostmask_expire_temporary();
855 <  expire_tklines(&xconf_items);
856 <  expire_tklines(&nresv_items);
1056 <  expire_tklines(&cresv_items);
855 >  gecos_expire();
856 >  resv_expire();
857   }
858  
859   /* oper_privs_as_string()
# Line 1062 | 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)
1095 <      *privs_ptr++ = opriv->c;
1096 <    else
1097 <      *privs_ptr++ = ToLower(opriv->c);
1098 <  }
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 1155 | 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,
1159 <     &uconf_items,   &xconf_items,
1160 <     &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 1173 | 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 <      {
1179 <        dlinkDelete(&conf->node, *iterator);
1180 <
1181 <        if (!conf->ref_count)
1182 <          conf_free(conf);
1183 <      }
990 >      if (!conf->ref_count)
991 >        conf_free(conf);
992      }
993    }
994  
1187  motd_clear();
1188
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 1194 | 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 <  pseudo_clear();
1015 >  shared_clear();  /* Clear shared {} items */
1016 >
1017 >  pseudo_clear();  /* Clear pseudo {} items */
1018 >
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;
1214 <  }
1215 <
1216 <  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    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()
1085   *
1086   * inputs       - cold start YES or NO
# Line 1259 | 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      {
# Line 1277 | 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    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);
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    isupport_add("CHANLIMIT", chanlimit, -1);
1145 <  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstCMORS");
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);
1296
1297  /*
1298   * message_locale may have changed.  rebuild isupport since it relies
1299   * on strlen(form_str(RPL_ISUPPORT))
1300   */
1301  isupport_rebuild();
1149   }
1150  
1151   /* conf_add_class_to_conf()
# Line 1334 | Line 1181 | conf_add_class_to_conf(struct MaskItem *
1181   void
1182   yyerror(const char *msg)
1183   {
1337  char newlinebuf[IRCD_BUFSIZE];
1338
1184    if (conf_parser_ctx.pass != 1)
1185      return;
1186  
1187 <  strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
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];
1354 <
1355 <  strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
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 1370 | 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 1451 | 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 1494 | Line 1337 | valid_wild_card(struct Client *source_p,
1337      }
1338    }
1339  
1497  if (IsClient(source_p))
1498    sendto_one_notice(source_p, &me,
1499                      ":Please include at least %u non-wildcard characters with the mask",
1500                      ConfigGeneral.min_nonwildcard);
1340    va_end(args);
1341    return 0;
1342   }
# Line 1574 | 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"))
1578 <      strlcpy(lhost, target_p->host, HOSTLEN*4 + 1);
1579 <    else
1580 <      strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
1416 >    strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
1417      return 1;
1418    }
1419  
# Line 1617 | 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 1697 | Line 1533 | parse_aline(const char *cmd, struct Clie
1533      }
1534    }
1535  
1700  if (h_p)
1701  {
1702    if (strchr(user, '!'))
1703    {
1704      sendto_one_notice(source_p, &me, ":Invalid character '!' in kline");
1705      return 0;
1706    }
1707
1708    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 2, *up_p, *h_p))
1709      return 0;
1710  }
1711  else
1712    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, *up_p))
1713      return 0;
1714
1536    if (reason)
1537    {
1538      if (parc && !EmptyString(*parv))
# Line 1747 | Line 1568 | match_conf_password(const char *password
1568   }
1569  
1570   /*
1750 * cluster_a_line
1751 *
1752 * inputs       - client sending the cluster
1753 *              - command name "KLINE" "XLINE" etc.
1754 *              - capab -- CAPAB_KLN etc. from server.h
1755 *              - cluster type -- CLUSTER_KLINE etc. from conf.h
1756 *              - pattern and args to send along
1757 * output       - none
1758 * side effects - Take source_p send the pattern with args given
1759 *                along to all servers that match capab and cluster type
1760 */
1761 void
1762 cluster_a_line(struct Client *source_p, const char *command, unsigned int capab,
1763               unsigned int cluster_type, const char *pattern, ...)
1764 {
1765  va_list args;
1766  char buffer[IRCD_BUFSIZE] = "";
1767  const dlink_node *node = NULL;
1768
1769  va_start(args, pattern);
1770  vsnprintf(buffer, sizeof(buffer), pattern, args);
1771  va_end(args);
1772
1773  DLINK_FOREACH(node, cluster_items.head)
1774  {
1775    const struct MaskItem *conf = node->data;
1776
1777    if (conf->flags & cluster_type)
1778      sendto_match_servs(source_p, conf->name, CAPAB_CLUSTER | capab,
1779                         "%s %s %s", command, conf->name, buffer);
1780  }
1781 }
1782
1783 /*
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 6376 by michael, Fri Aug 21 10:36:52 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