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

Comparing ircd-hybrid/trunk/src/conf.c (file contents):
Revision 6597 by michael, Thu Oct 22 17:23:06 2015 UTC vs.
Revision 8314 by michael, Wed Feb 28 17:47:23 2018 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-2018 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
192 <  MyFree(conf->cipher_list);
212 <
213 <  if (conf->rsa_public_key)
214 <    RSA_free(conf->rsa_public_key);
215 < #endif
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 >
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 <  userhost_count(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 378 | Line 340 | check_client(struct Client *source_p)
340      case TOO_MANY:
341        sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
342                             "Too many on IP for %s (%s).",
343 <                           get_client_name(source_p, SHOW_IP),
343 >                           client_get_name(source_p, SHOW_IP),
344                             source_p->sockhost);
345        ilog(LOG_TYPE_IRCD, "Too many connections on IP from %s.",
346 <           get_client_name(source_p, SHOW_IP));
346 >           client_get_name(source_p, SHOW_IP));
347        ++ServerStats.is_ref;
348        exit_client(source_p, "No more connections allowed on that IP");
349        break;
# Line 389 | Line 351 | check_client(struct Client *source_p)
351      case I_LINE_FULL:
352        sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE,
353                             "auth {} block is full for %s (%s).",
354 <                           get_client_name(source_p, SHOW_IP),
354 >                           client_get_name(source_p, SHOW_IP),
355                             source_p->sockhost);
356        ilog(LOG_TYPE_IRCD, "Too many connections from %s.",
357 <           get_client_name(source_p, SHOW_IP));
357 >           client_get_name(source_p, SHOW_IP));
358        ++ServerStats.is_ref;
359        exit_client(source_p, "No more connections allowed in your connection class");
360        break;
# 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].",
367 <                           get_client_name(source_p, SHOW_IP),
406 <                           source_p->sockhost,
366 >                           "Unauthorized client connection from %s on [%s/%u].",
367 >                           client_get_name(source_p, SHOW_IP),
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].",
371 <           get_client_name(source_p, SHOW_IP),
371 >           client_get_name(source_p, SHOW_IP),
372             source_p->connection->listener->name,
373             source_p->connection->listener->port);
374  
# 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 799 | Line 630 | set_default_conf(void)
630    ConfigServerInfo.max_topic_length = 80;
631    ConfigServerInfo.hub = 0;
632  
802  ConfigAdminInfo.name = NULL;
803  ConfigAdminInfo.email = NULL;
804  ConfigAdminInfo.description = NULL;
805
633    log_del_all();
634  
635    ConfigLog.use_logging = 1;
# Line 810 | Line 637 | set_default_conf(void)
637    ConfigChannel.disable_fake_channels = 0;
638    ConfigChannel.invite_client_count = 10;
639    ConfigChannel.invite_client_time = 300;
640 +  ConfigChannel.invite_delay_channel = 5;
641 +  ConfigChannel.invite_expire_time = 1800;
642    ConfigChannel.knock_client_count = 1;
643    ConfigChannel.knock_client_time = 300;
644    ConfigChannel.knock_delay_channel = 60;
645    ConfigChannel.max_channels = 25;
646 <  ConfigChannel.max_bans = 25;
646 >  ConfigChannel.max_invites = 20;
647 >  ConfigChannel.max_bans = 100;
648 >  ConfigChannel.max_bans_large = 500;
649    ConfigChannel.default_join_flood_count = 18;
650    ConfigChannel.default_join_flood_time = 6;
651  
# Line 829 | Line 660 | set_default_conf(void)
660  
661    ConfigGeneral.away_count = 2;
662    ConfigGeneral.away_time = 10;
663 <  ConfigGeneral.max_watch = WATCHSIZE_DEFAULT;
663 >  ConfigGeneral.max_watch = 50;
664 >  ConfigGeneral.whowas_history_length = 15000;
665    ConfigGeneral.cycle_on_host_change = 1;
666    ConfigGeneral.dline_min_cidr = 16;
667    ConfigGeneral.dline_min_cidr6 = 48;
# Line 841 | Line 673 | set_default_conf(void)
673    ConfigGeneral.disable_auth = 0;
674    ConfigGeneral.kill_chase_time_limit = 90;
675    ConfigGeneral.default_floodcount = 8;
676 +  ConfigGeneral.default_floodtime = 1;
677    ConfigGeneral.failed_oper_notice = 1;
678    ConfigGeneral.dots_in_ident = 0;
679    ConfigGeneral.min_nonwildcard = 4;
680    ConfigGeneral.min_nonwildcard_simple = 3;
681 <  ConfigGeneral.max_accept = 20;
681 >  ConfigGeneral.max_accept = 50;
682    ConfigGeneral.anti_nick_flood = 0;
683    ConfigGeneral.max_nick_time = 20;
684    ConfigGeneral.max_nick_changes = 5;
685    ConfigGeneral.anti_spam_exit_message_time = 0;
686 <  ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
687 <  ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
686 >  ConfigGeneral.ts_warn_delta = 30;
687 >  ConfigGeneral.ts_max_delta = 600;
688    ConfigGeneral.warn_no_connect_block = 1;
689    ConfigGeneral.stats_e_disabled = 0;
690    ConfigGeneral.stats_i_oper_only = 1;  /* 1 = masked */
# Line 861 | Line 694 | set_default_conf(void)
694    ConfigGeneral.stats_P_oper_only = 0;
695    ConfigGeneral.stats_u_oper_only = 0;
696    ConfigGeneral.caller_id_wait = 60;
697 <  ConfigGeneral.opers_bypass_callerid = 0;
697 >  ConfigGeneral.opers_bypass_callerid = 1;
698    ConfigGeneral.pace_wait = 10;
699    ConfigGeneral.pace_wait_simple = 1;
700    ConfigGeneral.short_motd = 0;
# Line 879 | Line 712 | set_default_conf(void)
712   static void
713   validate_conf(void)
714   {
882  if (ConfigGeneral.ts_warn_delta < TS_WARN_DELTA_MIN)
883    ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
884
885  if (ConfigGeneral.ts_max_delta < TS_MAX_DELTA_MIN)
886    ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
887
715    if (EmptyString(ConfigServerInfo.network_name))
716      ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
717  
718    if (EmptyString(ConfigServerInfo.network_desc))
719      ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
893
894  ConfigGeneral.max_watch = IRCD_MAX(ConfigGeneral.max_watch, WATCHSIZE_MIN);
720   }
721  
722   /* read_conf()
# Line 903 | Line 728 | validate_conf(void)
728   static void
729   read_conf(FILE *file)
730   {
731 <  lineno = 0;
731 >  lineno = 1;
732  
733    set_default_conf();  /* Set default values prior to conf parsing */
734    conf_parser_ctx.pass = 1;
# Line 915 | Line 740 | read_conf(FILE *file)
740    yyparse();  /* Load the values from the conf */
741    validate_conf();  /* Check to make sure some values are still okay. */
742                      /* Some global values are also loaded here. */
743 +  whowas_trim();  /* Attempt to trim whowas list if necessary */
744    class_delete_marked();  /* Delete unused classes that are marked for deletion */
745   }
746  
# Line 928 | Line 754 | void
754   conf_rehash(int sig)
755   {
756    if (sig)
757 +  {
758      sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
759                           "Got signal SIGHUP, reloading configuration file(s)");
760 +    ilog(LOG_TYPE_IRCD, "Got signal SIGHUP, reloading configuration file(s)");
761 +  }
762  
763    restart_resolver();
764  
# Line 1015 | Line 844 | conf_connect_allowed(struct irc_ssaddr *
844    return 0;
845   }
846  
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
847   /* cleanup_tklines()
848   *
849   * inputs       - NONE
# Line 1051 | Line 855 | void
855   cleanup_tklines(void *unused)
856   {
857    hostmask_expire_temporary();
858 <  expire_tklines(&xconf_items);
859 <  expire_tklines(&nresv_items);
1056 <  expire_tklines(&cresv_items);
858 >  gecos_expire();
859 >  resv_expire();
860   }
861  
862   /* oper_privs_as_string()
# Line 1062 | Line 865 | cleanup_tklines(void *unused)
865   * output        - pointer to static string showing oper privs
866   * side effects  - return as string, the oper privs as derived from port
867   */
868 < static const struct oper_privs
868 > static const struct oper_flags
869   {
870    const unsigned int flag;
871    const unsigned char c;
872 < } flag_list[] = {
872 > } flag_table[] = {
873    { OPER_FLAG_ADMIN,          'A' },
874 <  { OPER_FLAG_REMOTEBAN,      'B' },
875 <  { OPER_FLAG_DIE,            'D' },
876 <  { OPER_FLAG_REHASH,         'H' },
874 >  { OPER_FLAG_CLOSE,          'B' },
875 >  { OPER_FLAG_CONNECT,        'C' },
876 >  { OPER_FLAG_CONNECT_REMOTE, 'D' },
877 >  { OPER_FLAG_DIE,            'E' },
878 >  { OPER_FLAG_DLINE,          'F' },
879 >  { OPER_FLAG_GLOBOPS,        'G' },
880 >  { OPER_FLAG_JOIN_RESV,      'H' },
881 >  { OPER_FLAG_KILL,           'I' },
882 >  { OPER_FLAG_KILL_REMOTE,    'J' },
883    { OPER_FLAG_KLINE,          'K' },
884 <  { OPER_FLAG_KILL,           'N' },
885 <  { OPER_FLAG_KILL_REMOTE,    'O' },
886 <  { OPER_FLAG_CONNECT,        'P' },
887 <  { OPER_FLAG_CONNECT_REMOTE, 'Q' },
888 <  { OPER_FLAG_SQUIT,          'R' },
889 <  { OPER_FLAG_SQUIT_REMOTE,   'S' },
890 <  { OPER_FLAG_UNKLINE,        'U' },
891 <  { OPER_FLAG_XLINE,          'X' },
884 >  { OPER_FLAG_LOCOPS,         'L' },
885 >  { OPER_FLAG_MODULE,         'M' },
886 >  { OPER_FLAG_NICK_RESV,      'N' },
887 >  { OPER_FLAG_OPME,           'O' },
888 >  { OPER_FLAG_REHASH,         'P' },
889 >  { OPER_FLAG_REMOTEBAN,      'Q' },
890 >  { OPER_FLAG_RESTART,        'R' },
891 >  { OPER_FLAG_RESV,           'S' },
892 >  { OPER_FLAG_SET,            'T' },
893 >  { OPER_FLAG_SQUIT,          'U' },
894 >  { OPER_FLAG_SQUIT_REMOTE,   'V' },
895 >  { OPER_FLAG_UNDLINE,        'W' },
896 >  { OPER_FLAG_UNKLINE,        'X' },
897 >  { OPER_FLAG_UNRESV,         'Y' },
898 >  { OPER_FLAG_UNXLINE,        'Z' },
899 >  { OPER_FLAG_WALLOPS,        'a' },
900 >  { OPER_FLAG_XLINE,          'b' },
901    { 0, '\0' }
902   };
903  
904   const char *
905 < oper_privs_as_string(const unsigned int port)
905 > oper_privs_as_string(const unsigned int flags)
906   {
907 <  static char privs_out[IRCD_BUFSIZE];
908 <  char *privs_ptr = privs_out;
907 >  static char buf[sizeof(flag_table) / sizeof(flag_table[0])];
908 >  char *p = buf;
909  
910 <  for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv)
911 <  {
912 <    if (port & opriv->flag)
913 <      *privs_ptr++ = opriv->c;
914 <    else
915 <      *privs_ptr++ = ToLower(opriv->c);
1098 <  }
910 >  for (const struct oper_flags *tab = flag_table; tab->flag; ++tab)
911 >    if (flags & tab->flag)
912 >      *p++ = tab->c;
913 >
914 >  if (p == buf)
915 >    *p++ = '0';
916  
917 <  *privs_ptr = '\0';
917 >  *p = '\0';
918  
919 <  return privs_out;
919 >  return buf;
920   }
921  
922   /*
# Line 1155 | Line 972 | clear_out_old_conf(void)
972   {
973    dlink_node *node = NULL, *node_next = NULL;
974    dlink_list *free_items [] = {
975 <    &server_items,   &oconf_items,
1159 <     &uconf_items,   &xconf_items,
1160 <     &nresv_items, &cluster_items,  &service_items, &cresv_items, NULL
975 >    &connect_items, &operator_items, NULL
976    };
977  
978    dlink_list ** iterator = free_items; /* C is dumb */
# Line 1173 | Line 988 | clear_out_old_conf(void)
988        struct MaskItem *conf = node->data;
989  
990        conf->active = 0;
991 +      dlinkDelete(&conf->node, *iterator);
992  
993 <      if (!IsConfDatabase(conf))
994 <      {
1179 <        dlinkDelete(&conf->node, *iterator);
1180 <
1181 <        if (!conf->ref_count)
1182 <          conf_free(conf);
1183 <      }
993 >      if (!conf->ref_count)
994 >        conf_free(conf);
995      }
996    }
997  
1187  motd_clear();
1188
998    /*
999     * Don't delete the class table, rather mark all entries for deletion.
1000     * The table is cleaned up by class_delete_marked. - avalon
# Line 1194 | Line 1003 | clear_out_old_conf(void)
1003  
1004    clear_out_address_conf();
1005  
1006 <  /* Clean out module paths */
1007 <  mod_clear_paths();
1006 >  modules_conf_clear();  /* Clear modules {} items */
1007 >
1008 >  motd_clear();  /* Clear motd {} items and re-cache default motd */
1009 >
1010 >  cluster_clear();  /* Clear cluster {} items */
1011 >
1012 >  gecos_clear();  /* Clear gecos {} items */
1013 >
1014 >  resv_clear();  /* Clear resv {} items */
1015 >
1016 >  service_clear();  /* Clear service {} items */
1017 >
1018 >  shared_clear();  /* Clear shared {} items */
1019  
1020 <  pseudo_clear();
1020 >  pseudo_clear();  /* Clear pseudo {} items */
1021  
1022    /* Clean out ConfigServerInfo */
1023 <  MyFree(ConfigServerInfo.description);
1023 >  xfree(ConfigServerInfo.description);
1024    ConfigServerInfo.description = NULL;
1025 <  MyFree(ConfigServerInfo.network_name);
1025 >  xfree(ConfigServerInfo.network_name);
1026    ConfigServerInfo.network_name = NULL;
1027 <  MyFree(ConfigServerInfo.network_desc);
1027 >  xfree(ConfigServerInfo.network_desc);
1028    ConfigServerInfo.network_desc = NULL;
1029 < #ifdef HAVE_LIBCRYPTO
1210 <  if (ConfigServerInfo.rsa_private_key)
1211 <  {
1212 <    RSA_free(ConfigServerInfo.rsa_private_key);
1213 <    ConfigServerInfo.rsa_private_key = NULL;
1214 <  }
1215 <
1216 <  MyFree(ConfigServerInfo.rsa_private_key_file);
1029 >  xfree(ConfigServerInfo.rsa_private_key_file);
1030    ConfigServerInfo.rsa_private_key_file = NULL;
1031 < #endif
1031 >  xfree(ConfigServerInfo.ssl_certificate_file);
1032 >  ConfigServerInfo.ssl_certificate_file = NULL;
1033 >  xfree(ConfigServerInfo.ssl_dh_param_file);
1034 >  ConfigServerInfo.ssl_dh_param_file = NULL;
1035 >  xfree(ConfigServerInfo.ssl_dh_elliptic_curve);
1036 >  ConfigServerInfo.ssl_dh_elliptic_curve = NULL;
1037 >  xfree(ConfigServerInfo.ssl_cipher_list);
1038 >  ConfigServerInfo.ssl_cipher_list = NULL;
1039 >  xfree(ConfigServerInfo.ssl_message_digest_algorithm);
1040 >  ConfigServerInfo.ssl_message_digest_algorithm = NULL;
1041  
1042    /* Clean out ConfigAdminInfo */
1043 <  MyFree(ConfigAdminInfo.name);
1043 >  xfree(ConfigAdminInfo.name);
1044    ConfigAdminInfo.name = NULL;
1045 <  MyFree(ConfigAdminInfo.email);
1045 >  xfree(ConfigAdminInfo.email);
1046    ConfigAdminInfo.email = NULL;
1047 <  MyFree(ConfigAdminInfo.description);
1047 >  xfree(ConfigAdminInfo.description);
1048    ConfigAdminInfo.description = NULL;
1049  
1050 +  xfree(ConfigServerHide.flatten_links_file);
1051 +  ConfigServerHide.flatten_links_file = NULL;
1052 +
1053    /* Clean out listeners */
1054    listener_close_marked();
1055   }
1056  
1057 + static void
1058 + conf_handle_tls(int cold)
1059 + {
1060 +  if (!tls_new_cred())
1061 +  {
1062 +    if (cold)
1063 +    {
1064 +      ilog(LOG_TYPE_IRCD, "Error while initializing TLS");
1065 +      exit(EXIT_FAILURE);
1066 +    }
1067 +    else
1068 +    {
1069 +      /* Failed to load new settings/certs, old ones remain active */
1070 +      sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
1071 +                           "Error reloading TLS settings, check the ircd log"); // report_crypto_errors logs this
1072 +    }
1073 +  }
1074 + }
1075 +
1076   /* read_conf_files()
1077   *
1078   * inputs       - cold start YES or NO
# Line 1259 | Line 1103 | read_conf_files(int cold)
1103      {
1104        ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
1105             filename, strerror(errno));
1106 <      exit(-1);
1106 >      exit(EXIT_FAILURE);
1107      }
1108      else
1109      {
# Line 1277 | Line 1121 | read_conf_files(int cold)
1121    fclose(conf_parser_ctx.conf_file);
1122  
1123    log_reopen_all();
1124 +  conf_handle_tls(cold);
1125  
1126    isupport_add("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1127    isupport_add("NETWORK", ConfigServerInfo.network_name, -1);
1128  
1129 <  snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans);
1129 >  snprintf(chanmodes, sizeof(chanmodes), "beI:%u", ConfigChannel.max_bans);
1130    isupport_add("MAXLIST", chanmodes, -1);
1131    isupport_add("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1132    isupport_add("CHANTYPES", "#", -1);
1133  
1134 <  snprintf(chanlimit, sizeof(chanlimit), "#:%d",
1134 >  snprintf(chanlimit, sizeof(chanlimit), "#:%u",
1135             ConfigChannel.max_channels);
1136    isupport_add("CHANLIMIT", chanlimit, -1);
1137 <  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstCMORS");
1137 >  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstuCLMORST");
1138    isupport_add("CHANNELLEN", NULL, CHANNELLEN);
1139    isupport_add("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1140    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();
1141   }
1142  
1143   /* conf_add_class_to_conf()
# Line 1334 | Line 1173 | conf_add_class_to_conf(struct MaskItem *
1173   void
1174   yyerror(const char *msg)
1175   {
1337  char newlinebuf[IRCD_BUFSIZE];
1338
1176    if (conf_parser_ctx.pass != 1)
1177      return;
1178  
1179 <  strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1179 >  const char *p = stripws(linebuf);
1180    sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1181                         "\"%s\", line %u: %s: %s",
1182 <                       conffilebuf, lineno + 1, msg, newlinebuf);
1182 >                       conffilebuf, lineno, msg, p);
1183    ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
1184 <       conffilebuf, lineno + 1, msg, newlinebuf);
1184 >       conffilebuf, lineno, msg, p);
1185   }
1186  
1187   void
1188   conf_error_report(const char *msg)
1189   {
1190 <  char newlinebuf[IRCD_BUFSIZE];
1354 <
1355 <  strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1190 >  const char *p = stripws(linebuf);
1191    sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1192                         "\"%s\", line %u: %s: %s",
1193 <                       conffilebuf, lineno + 1, msg, newlinebuf);
1193 >                       conffilebuf, lineno, msg, p);
1194    ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
1195 <       conffilebuf, lineno + 1, msg, newlinebuf);
1195 >       conffilebuf, lineno, msg, p);
1196   }
1197  
1198   /*
# Line 1370 | Line 1205 | conf_error_report(const char *msg)
1205   * side effects - none
1206   * Originally written by Dianora (Diane, db@db.net)
1207   */
1208 < time_t
1208 > uintmax_t
1209   valid_tkline(const char *data, const int minutes)
1210   {
1211    const unsigned char *p = (const unsigned char *)data;
1212    unsigned char tmpch = '\0';
1213 <  time_t result = 0;
1213 >  uintmax_t result = 0;
1214  
1215    while ((tmpch = *p++))
1216    {
# Line 1451 | Line 1286 | valid_wild_card_simple(const char *data)
1286   * side effects - NOTICE is given to source_p if warn is 1
1287   */
1288   int
1289 < valid_wild_card(struct Client *source_p, int count, ...)
1289 > valid_wild_card(int count, ...)
1290   {
1291    unsigned char tmpch = '\0';
1292    unsigned int nonwild = 0;
# Line 1494 | Line 1329 | valid_wild_card(struct Client *source_p,
1329      }
1330    }
1331  
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);
1332    va_end(args);
1333    return 0;
1334   }
# Line 1574 | Line 1405 | find_user_host(struct Client *source_p,
1405      if (target_p->username[0] == '~')
1406        luser[0] = '*';
1407  
1408 <    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);
1408 >    strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
1409      return 1;
1410    }
1411  
# Line 1617 | Line 1445 | find_user_host(struct Client *source_p,
1445   int
1446   parse_aline(const char *cmd, struct Client *source_p,
1447              int parc, char **parv,
1448 <            int parse_flags, char **up_p, char **h_p, time_t *tkline_time,
1448 >            char **up_p, char **h_p, uintmax_t *tkline_time,
1449              char **target_server, char **reason)
1450   {
1451 <  int found_tkline_time=0;
1451 >  uintmax_t found_tkline_time=0;
1452    static char default_reason[] = CONF_NOREASON;
1453    static char user[USERLEN*4+1];
1454    static char host[HOSTLEN*4+1];
# Line 1697 | Line 1525 | parse_aline(const char *cmd, struct Clie
1525      }
1526    }
1527  
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
1528    if (reason)
1529    {
1530      if (parc && !EmptyString(*parv))
# Line 1747 | Line 1560 | match_conf_password(const char *password
1560   }
1561  
1562   /*
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 /*
1563   * split_nuh
1564   *
1565   * inputs       - pointer to original mask (modified in place)

Comparing ircd-hybrid/trunk/src/conf.c (property svn:keywords):
Revision 6597 by michael, Thu Oct 22 17:23:06 2015 UTC vs.
Revision 8314 by michael, Wed Feb 28 17:47:23 2018 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)