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 5039 by michael, Sat Dec 13 16:08:37 2014 UTC vs.
Revision 7766 by michael, Fri Oct 7 16:27:37 2016 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (c) 1997-2014 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;
67 + struct config_serverhide_entry ConfigServerHide;
68 + struct config_general_entry ConfigGeneral;
69 + struct config_log_entry ConfigLog = { .use_logging = 1 };
70 + struct config_serverinfo_entry ConfigServerInfo;
71 + struct config_admin_entry ConfigAdminInfo;
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;
63 < dlink_list cluster_items;
64 < dlink_list oconf_items;
65 < dlink_list uconf_items;
66 < dlink_list xconf_items;
67 < dlink_list nresv_items;
68 < 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 127 | Line 135 | map_to_list(enum maskitem_type type)
135   {
136    switch (type)
137    {
130    case CONF_XLINE:
131      return &xconf_items;
132      break;
133    case CONF_ULINE:
134      return &uconf_items;
135      break;
136    case CONF_NRESV:
137      return &nresv_items;
138      break;
139    case CONF_CRESV:
140      return &cresv_items;
141      break;
138      case CONF_OPER:
139 <      return &oconf_items;
139 >      return &operator_items;
140        break;
141      case CONF_SERVER:
142 <      return &server_items;
147 <      break;
148 <    case CONF_SERVICE:
149 <      return &service_items;
150 <      break;
151 <    case CONF_CLUSTER:
152 <      return &cluster_items;
142 >      return &connect_items;
143        break;
144      default:
145        return NULL;
# Line 159 | 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 180 | 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 191 | 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->user);
189 <  MyFree(conf->host);
190 < #ifdef HAVE_LIBCRYPTO
191 <  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  
203  if (conf->rsa_public_key)
204    RSA_free(conf->rsa_public_key);
205 #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)
221 <  {
222 <    struct exempt *exptr = node->data;
223 <
224 <    dlinkDelete(node, &conf->exempt_list);
225 <    MyFree(exptr->name);
226 <    MyFree(exptr->user);
227 <    MyFree(exptr->host);
228 <    MyFree(exptr);
229 <  }
230 <
231 <  MyFree(conf);
207 >  xfree(conf);
208   }
209  
210   /* attach_iline()
# Line 244 | 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,
254 <                  &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 261 | 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;
268  else if (class->max_ident && ident >= class->max_ident &&
269           client_p->username[0] != '~')
270    a_limit_reached = 1;
243  
244    if (a_limit_reached)
245    {
# Line 291 | Line 263 | static int
263   verify_access(struct Client *client_p)
264   {
265    struct MaskItem *conf = NULL;
294  char non_ident[USERLEN + 1] = "~";
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 302 | Line 273 | verify_access(struct Client *client_p)
273    }
274    else
275    {
276 +    char non_ident[USERLEN + 1] = "~";
277 +
278      strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1);
279      conf = find_address_conf(client_p->host, non_ident,
280                               &client_p->connection->ip,
# Line 309 | Line 282 | verify_access(struct Client *client_p)
282                               client_p->connection->password);
283    }
284  
285 <  if (conf)
286 <  {
314 <    if (IsConfClient(conf))
315 <    {
316 <      if (IsConfRedir(conf))
317 <      {
318 <        sendto_one_numeric(client_p, &me, RPL_REDIR,
319 <                           conf->name ? conf->name : "",
320 <                           conf->port);
321 <        return NOT_AUTHORIZED;
322 <      }
285 >  if (!conf)
286 >    return NOT_AUTHORIZED;
287  
288 <      /* Thanks for spoof idea amm */
325 <      if (IsConfDoSpoofIp(conf))
326 <      {
327 <        if (IsConfSpoofNotice(conf))
328 <          sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, "%s spoofing: %s as %s",
329 <                               client_p->name, client_p->host, conf->name);
288 >  assert(IsConfClient(conf) || IsConfKill(conf));
289  
290 <        strlcpy(client_p->host, conf->name, sizeof(client_p->host));
291 <      }
292 <
293 <      return attach_iline(client_p, conf);
290 >  if (IsConfClient(conf))
291 >  {
292 >    if (IsConfRedir(conf))
293 >    {
294 >      sendto_one_numeric(client_p, &me, RPL_REDIR,
295 >                         conf->name ? conf->name : "",
296 >                         conf->port);
297 >      return NOT_AUTHORIZED;
298      }
299 <    else if (IsConfKill(conf) || (ConfigGeneral.glines && IsConfGline(conf)))
299 >
300 >    if (IsConfDoSpoofIp(conf))
301      {
302 <      if (IsConfGline(conf))
303 <        sendto_one_notice(client_p, &me, ":*** G-lined");
302 >      if (IsConfSpoofNotice(conf))
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 <      sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason);
342 <      return BANNED_CLIENT;
306 >      strlcpy(client_p->host, conf->name, sizeof(client_p->host));
307      }
308 +
309 +    return attach_iline(client_p, conf);
310    }
311  
312 <  return NOT_AUTHORIZED;
312 >  sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason);
313 >  return BANNED_CLIENT;
314   }
315  
316   /* check_client()
# Line 396 | 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),
401                           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 509 | 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);
487 <    return -1;
487 >    return 1;
488    }
489  
490    return 0;
# Line 562 | 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,
566 <                        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;
569  dlink_list *list = map_to_list(type);
570  struct MaskItem *conf = NULL;
535  
536 <  switch (type)
536 >  DLINK_FOREACH(node, connect_items.head)
537    {
538 <  case CONF_SERVICE:
575 <    DLINK_FOREACH(node, list->head)
576 <    {
577 <      conf = node->data;
578 <
579 <      if (EmptyString(conf->name))
580 <        continue;
581 <      if (name && !irccmp(name, conf->name))
582 <        return conf;
583 <    }
584 <    break;
585 <
586 <  case CONF_XLINE:
587 <  case CONF_ULINE:
588 <  case CONF_NRESV:
589 <  case CONF_CRESV:
590 <    DLINK_FOREACH(node, list->head)
591 <    {
592 <      conf = node->data;
593 <
594 <      if (EmptyString(conf->name))
595 <        continue;
596 <      if (name && !match(conf->name, name))
597 <      {
598 <        if ((user == NULL && (host == NULL)))
599 <          return conf;
600 <        if ((conf->flags & flags) != flags)
601 <          continue;
602 <        if (EmptyString(conf->user) || EmptyString(conf->host))
603 <          return conf;
604 <        if (!match(conf->user, user) && !match(conf->host, host))
605 <          return conf;
606 <      }
607 <    }
608 <      break;
609 <
610 <  case CONF_SERVER:
611 <    DLINK_FOREACH(node, list->head)
612 <    {
613 <      conf = node->data;
614 <
615 <      if (name && !match(name, conf->name))
616 <        return conf;
617 <      if (host && !match(host, conf->host))
618 <        return conf;
619 <    }
620 <    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 635 | 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,
639 <                     const char *user, const char *host)
559 > operator_find(const struct Client *who, const char *name)
560   {
561    dlink_node *node = NULL;
642  dlink_list *list = map_to_list(type);
643  struct MaskItem *conf = NULL;
562  
563 <  switch(type)
563 >  DLINK_FOREACH(node, operator_items.head)
564    {
565 <  case CONF_XLINE:
648 <  case CONF_ULINE:
649 <  case CONF_NRESV:
650 <  case CONF_CRESV:
651 <
652 <    DLINK_FOREACH(node, list->head)
653 <    {
654 <      conf = node->data;
655 <
656 <      if (EmptyString(conf->name))
657 <        continue;
658 <
659 <      if (irccmp(conf->name, name) == 0)
660 <      {
661 <        if ((user == NULL && (host == NULL)))
662 <          return conf;
663 <        if (EmptyString(conf->user) || EmptyString(conf->host))
664 <          return conf;
665 <        if (!match(conf->user, user) && !match(conf->host, host))
666 <          return conf;
667 <      }
668 <    }
669 <    break;
565 >    struct MaskItem *conf = node->data;
566  
567 <  case CONF_OPER:
672 <    DLINK_FOREACH(node, list->head)
567 >    if (!irccmp(conf->name, name))
568      {
569 <      conf = node->data;
570 <
676 <      if (EmptyString(conf->name))
677 <        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)
682 <          return conf;
683 <        if (EmptyString(conf->user) || EmptyString(conf->host))
684 <          return NULL;
685 <        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)
702 <                if (match_ipv6(&who->connection->ip, &conf->addr, conf->bits))
703 <                  if (!conf->class->max_total || conf->class->ref_count < conf->class->max_total)
704 <                    return conf;
705 <              break;
706 <            default:
707 <              assert(0);
708 <          }
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      }
712
713    break;
714
715  case CONF_SERVER:
716    DLINK_FOREACH(node, list->head)
717    {
718      conf = node->data;
719
720      if (EmptyString(conf->name))
721        continue;
722
723      if (name == NULL)
724      {
725        if (EmptyString(conf->host))
726          continue;
727        if (irccmp(conf->host, host) == 0)
728          return conf;
729      }
730      else if (irccmp(conf->name, name) == 0)
731        return conf;
732    }
733
734    break;
735
736  default:
737    break;
598    }
599  
600    return NULL;
# Line 757 | Line 617 | set_default_conf(void)
617     */
618    assert(class_default == class_get_list()->tail->data);
619  
760 #ifdef HAVE_LIBCRYPTO
761 #if OPENSSL_VERSION_NUMBER >= 0x009080FFL && !defined(OPENSSL_NO_ECDH)
762  {
763    EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
764
765    if (key)
766    {
767      SSL_CTX_set_tmp_ecdh(ConfigServerInfo.server_ctx, key);
768      EC_KEY_free(key);
769    }
770  }
771
772  SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
773 #endif
774
775  SSL_CTX_set_cipher_list(ConfigServerInfo.server_ctx, "EECDH+HIGH:EDH+HIGH:HIGH:!aNULL");
776  ConfigServerInfo.message_digest_algorithm = EVP_sha256();
777  ConfigServerInfo.rsa_private_key = NULL;
778  ConfigServerInfo.rsa_private_key_file = NULL;
779 #endif
780
781  /* ConfigServerInfo.name is not rehashable */
782  /* ConfigServerInfo.name = ConfigServerInfo.name; */
783  ConfigServerInfo.description = NULL;
620    ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
621    ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
622  
# Line 789 | Line 625 | set_default_conf(void)
625    memset(&ConfigServerInfo.ip6, 0, sizeof(ConfigServerInfo.ip6));
626    ConfigServerInfo.specific_ipv6_vhost = 0;
627  
628 <  ConfigServerInfo.max_clients = MAXCLIENTS_MAX;
628 >  ConfigServerInfo.default_max_clients = MAXCLIENTS_MAX;
629    ConfigServerInfo.max_nick_length = 9;
630    ConfigServerInfo.max_topic_length = 80;
631    ConfigServerInfo.hub = 0;
632 <
797 <  ConfigAdminInfo.name = NULL;
798 <  ConfigAdminInfo.email = NULL;
799 <  ConfigAdminInfo.description = NULL;
632 >  ConfigServerInfo.libgeoip_database_options = 0;
633  
634    log_del_all();
635  
# Line 805 | 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;
645    ConfigChannel.max_channels = 25;
646 +  ConfigChannel.max_invites = 20;
647    ConfigChannel.max_bans = 25;
648 <  ConfigChannel.default_split_user_count = 0;
649 <  ConfigChannel.default_split_server_count = 0;
815 <  ConfigChannel.no_join_on_split = 0;
816 <  ConfigChannel.no_create_on_split = 0;
648 >  ConfigChannel.default_join_flood_count = 18;
649 >  ConfigChannel.default_join_flood_time = 6;
650  
651    ConfigServerHide.flatten_links = 0;
652 <  ConfigServerHide.links_delay = 300;
652 >  ConfigServerHide.flatten_links_delay = 300;
653    ConfigServerHide.hidden = 0;
654    ConfigServerHide.hide_servers = 0;
655    ConfigServerHide.hide_services = 0;
# Line 826 | Line 659 | set_default_conf(void)
659  
660    ConfigGeneral.away_count = 2;
661    ConfigGeneral.away_time = 10;
662 <  ConfigGeneral.max_watch = WATCHSIZE_DEFAULT;
662 >  ConfigGeneral.max_watch = 50;
663 >  ConfigGeneral.whowas_history_length = 15000;
664    ConfigGeneral.cycle_on_host_change = 1;
665 <  ConfigGeneral.glines = 0;
666 <  ConfigGeneral.gline_time = 12 * 3600;
667 <  ConfigGeneral.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
668 <  ConfigGeneral.gline_min_cidr = 16;
835 <  ConfigGeneral.gline_min_cidr6 = 48;
665 >  ConfigGeneral.dline_min_cidr = 16;
666 >  ConfigGeneral.dline_min_cidr6 = 48;
667 >  ConfigGeneral.kline_min_cidr = 16;
668 >  ConfigGeneral.kline_min_cidr6 = 48;
669    ConfigGeneral.invisible_on_connect = 1;
670    ConfigGeneral.tkline_expire_notices = 1;
671    ConfigGeneral.ignore_bogus_ts = 0;
# Line 843 | Line 676 | set_default_conf(void)
676    ConfigGeneral.dots_in_ident = 0;
677    ConfigGeneral.min_nonwildcard = 4;
678    ConfigGeneral.min_nonwildcard_simple = 3;
679 <  ConfigGeneral.max_accept = 20;
679 >  ConfigGeneral.max_accept = 50;
680    ConfigGeneral.anti_nick_flood = 0;
681    ConfigGeneral.max_nick_time = 20;
682    ConfigGeneral.max_nick_changes = 5;
683    ConfigGeneral.anti_spam_exit_message_time = 0;
684 <  ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
685 <  ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
684 >  ConfigGeneral.ts_warn_delta = 30;
685 >  ConfigGeneral.ts_max_delta = 600;
686    ConfigGeneral.warn_no_connect_block = 1;
687    ConfigGeneral.stats_e_disabled = 0;
688    ConfigGeneral.stats_i_oper_only = 1;  /* 1 = masked */
# Line 865 | Line 698 | set_default_conf(void)
698    ConfigGeneral.short_motd = 0;
699    ConfigGeneral.ping_cookie = 0;
700    ConfigGeneral.no_oper_flood = 0;
868  ConfigGeneral.oper_pass_resv = 1;
701    ConfigGeneral.max_targets = MAX_TARGETS_DEFAULT;
702 <  ConfigGeneral.oper_only_umodes = UMODE_DEBUG;
702 >  ConfigGeneral.oper_only_umodes = UMODE_DEBUG | UMODE_LOCOPS | UMODE_HIDDEN | UMODE_FARCONNECT |
703 >                                   UMODE_UNAUTH | UMODE_EXTERNAL | UMODE_BOTS | UMODE_NCHANGE |
704 >                                   UMODE_SPY | UMODE_FULL | UMODE_SKILL | UMODE_REJ | UMODE_CCONN;
705    ConfigGeneral.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP;
706    ConfigGeneral.throttle_count = 1;
707    ConfigGeneral.throttle_time = 1;
# Line 876 | Line 710 | set_default_conf(void)
710   static void
711   validate_conf(void)
712   {
879  if (ConfigGeneral.ts_warn_delta < TS_WARN_DELTA_MIN)
880    ConfigGeneral.ts_warn_delta = TS_WARN_DELTA_DEFAULT;
881
882  if (ConfigGeneral.ts_max_delta < TS_MAX_DELTA_MIN)
883    ConfigGeneral.ts_max_delta = TS_MAX_DELTA_DEFAULT;
884
713    if (EmptyString(ConfigServerInfo.network_name))
714      ConfigServerInfo.network_name = xstrdup(NETWORK_NAME_DEFAULT);
715  
716    if (EmptyString(ConfigServerInfo.network_desc))
717      ConfigServerInfo.network_desc = xstrdup(NETWORK_DESC_DEFAULT);
890
891  ConfigGeneral.max_watch = IRCD_MAX(ConfigGeneral.max_watch, WATCHSIZE_MIN);
718   }
719  
720   /* read_conf()
# Line 900 | Line 726 | validate_conf(void)
726   static void
727   read_conf(FILE *file)
728   {
729 <  lineno = 0;
729 >  lineno = 1;
730  
731    set_default_conf();  /* Set default values prior to conf parsing */
732    conf_parser_ctx.pass = 1;
# Line 912 | Line 738 | read_conf(FILE *file)
738    yyparse();  /* Load the values from the conf */
739    validate_conf();  /* Check to make sure some values are still okay. */
740                      /* Some global values are also loaded here. */
741 +  whowas_trim();  /* Attempt to trim whowas list if necessary */
742    class_delete_marked();  /* Delete unused classes that are marked for deletion */
743   }
744  
# Line 921 | Line 748 | read_conf(FILE *file)
748   * as a result of an operator issuing this command, else assume it has been
749   * called as a result of the server receiving a HUP signal.
750   */
751 < int
751 > void
752   conf_rehash(int sig)
753   {
754    if (sig)
755 <    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
755 >  {
756 >    sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
757                           "Got signal SIGHUP, reloading configuration file(s)");
758 +    ilog(LOG_TYPE_IRCD, "Got signal SIGHUP, reloading configuration file(s)");
759 +  }
760  
761    restart_resolver();
762  
# Line 936 | Line 766 | conf_rehash(int sig)
766  
767    load_conf_modules();
768    check_conf_klines();
939
940  return 0;
769   }
770  
771   /* lookup_confhost()
# Line 988 | Line 816 | int
816   conf_connect_allowed(struct irc_ssaddr *addr, int aftype)
817   {
818    struct ip_entry *ip_found = NULL;
819 <  struct MaskItem *const conf = find_dline_conf(addr, aftype);
992 <
993 <  /* DLINE exempt also gets you out of static limits/pacing... */
994 <  if (conf && (conf->type == CONF_EXEMPT))
995 <    return 0;
819 >  const struct MaskItem *conf = find_dline_conf(addr, aftype);
820  
821    if (conf)
822 +  {
823 +    /* DLINE exempt also gets you out of static limits/pacing... */
824 +    if (conf->type == CONF_EXEMPT)
825 +      return 0;
826      return BANNED_CLIENT;
827 +  }
828  
829    ip_found = ipcache_find_or_add_address(addr);
830  
# Line 1013 | Line 842 | conf_connect_allowed(struct irc_ssaddr *
842    return 0;
843   }
844  
1016 /* expire_tklines()
1017 *
1018 * inputs       - tkline list pointer
1019 * output       - NONE
1020 * side effects - expire tklines
1021 */
1022 static void
1023 expire_tklines(dlink_list *list)
1024 {
1025  dlink_node *node = NULL, *node_next = NULL;
1026
1027  DLINK_FOREACH_SAFE(node, node_next, list->head)
1028  {
1029    struct MaskItem *conf = node->data;
1030
1031    if (!conf->until || conf->until > CurrentTime)
1032      continue;
1033
1034    if (conf->type == CONF_XLINE)
1035    {
1036      if (ConfigGeneral.tkline_expire_notices)
1037        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1038                               "Temporary X-line for [%s] expired", conf->name);
1039      conf_free(conf);
1040    }
1041    else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV)
1042    {
1043      if (ConfigGeneral.tkline_expire_notices)
1044        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1045                               "Temporary RESV for [%s] expired", conf->name);
1046      conf_free(conf);
1047    }
1048  }
1049 }
1050
845   /* cleanup_tklines()
846   *
847   * inputs       - NONE
# Line 1059 | Line 853 | void
853   cleanup_tklines(void *unused)
854   {
855    hostmask_expire_temporary();
856 <  expire_tklines(&xconf_items);
857 <  expire_tklines(&nresv_items);
1064 <  expire_tklines(&cresv_items);
856 >  gecos_expire();
857 >  resv_expire();
858   }
859  
860   /* oper_privs_as_string()
# Line 1070 | Line 863 | cleanup_tklines(void *unused)
863   * output        - pointer to static string showing oper privs
864   * side effects  - return as string, the oper privs as derived from port
865   */
866 < static const struct oper_privs
866 > static const struct oper_flags
867   {
868    const unsigned int flag;
869    const unsigned char c;
870 < } flag_list[] = {
870 > } flag_table[] = {
871    { OPER_FLAG_ADMIN,          'A' },
872 <  { OPER_FLAG_REMOTEBAN,      'B' },
873 <  { OPER_FLAG_DIE,            'D' },
874 <  { OPER_FLAG_GLINE,          'G' },
875 <  { OPER_FLAG_REHASH,         'H' },
872 >  { OPER_FLAG_CLOSE,          'B' },
873 >  { OPER_FLAG_CONNECT,        'C' },
874 >  { OPER_FLAG_CONNECT_REMOTE, 'D' },
875 >  { OPER_FLAG_DIE,            'E' },
876 >  { OPER_FLAG_DLINE,          'F' },
877 >  { OPER_FLAG_GLOBOPS,        'G' },
878 >  { OPER_FLAG_JOIN_RESV,      'H' },
879 >  { OPER_FLAG_KILL,           'I' },
880 >  { OPER_FLAG_KILL_REMOTE,    'J' },
881    { OPER_FLAG_KLINE,          'K' },
882 <  { OPER_FLAG_KILL,           'N' },
883 <  { OPER_FLAG_KILL_REMOTE,    'O' },
884 <  { OPER_FLAG_CONNECT,        'P' },
885 <  { OPER_FLAG_CONNECT_REMOTE, 'Q' },
886 <  { OPER_FLAG_SQUIT,          'R' },
887 <  { OPER_FLAG_SQUIT_REMOTE,   'S' },
888 <  { OPER_FLAG_UNKLINE,        'U' },
889 <  { OPER_FLAG_XLINE,          'X' },
882 >  { OPER_FLAG_LOCOPS,         'L' },
883 >  { OPER_FLAG_MODULE,         'M' },
884 >  { OPER_FLAG_NICK_RESV,      'N' },
885 >  { OPER_FLAG_OPME,           'O' },
886 >  { OPER_FLAG_REHASH,         'P' },
887 >  { OPER_FLAG_REMOTEBAN,      'Q' },
888 >  { OPER_FLAG_RESTART,        'R' },
889 >  { OPER_FLAG_RESV,           'S' },
890 >  { OPER_FLAG_SET,            'T' },
891 >  { OPER_FLAG_SQUIT,          'U' },
892 >  { OPER_FLAG_SQUIT_REMOTE,   'V' },
893 >  { OPER_FLAG_UNDLINE,        'W' },
894 >  { OPER_FLAG_UNKLINE,        'X' },
895 >  { OPER_FLAG_UNRESV,         'Y' },
896 >  { OPER_FLAG_UNXLINE,        'Z' },
897 >  { OPER_FLAG_WALLOPS,        'a' },
898 >  { OPER_FLAG_XLINE,          'b' },
899    { 0, '\0' }
900   };
901  
902 < char *
903 < oper_privs_as_string(const unsigned int port)
902 > const char *
903 > oper_privs_as_string(const unsigned int flags)
904   {
905 <  static char privs_out[IRCD_BUFSIZE];
906 <  char *privs_ptr = privs_out;
905 >  static char buf[sizeof(flag_table) / sizeof(struct oper_flags)];
906 >  char *p = buf;
907  
908 <  for (const struct oper_privs *opriv = flag_list; opriv->flag; ++opriv)
909 <  {
910 <    if (port & opriv->flag)
911 <      *privs_ptr++ = opriv->c;
912 <    else
913 <      *privs_ptr++ = ToLower(opriv->c);
1107 <  }
908 >  for (const struct oper_flags *tab = flag_table; tab->flag; ++tab)
909 >    if (flags & tab->flag)
910 >      *p++ = tab->c;
911 >
912 >  if (p == buf)
913 >    *p++ = '0';
914  
915 <  *privs_ptr = '\0';
915 >  *p = '\0';
916  
917 <  return privs_out;
917 >  return buf;
918   }
919  
920   /*
# Line 1120 | Line 926 | oper_privs_as_string(const unsigned int
926   const char *
927   get_oper_name(const struct Client *client_p)
928   {
929 <  /* +5 for !,@,{,} and null */
1124 <  static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
929 >  static char buffer[IRCD_BUFSIZE];
930  
931    if (IsServer(client_p))
932      return client_p->name;
# Line 1165 | Line 970 | clear_out_old_conf(void)
970   {
971    dlink_node *node = NULL, *node_next = NULL;
972    dlink_list *free_items [] = {
973 <    &server_items,   &oconf_items,
1169 <     &uconf_items,   &xconf_items,
1170 <     &nresv_items, &cluster_items,  &service_items, &cresv_items, NULL
973 >    &connect_items, &operator_items, NULL
974    };
975  
976    dlink_list ** iterator = free_items; /* C is dumb */
# Line 1185 | Line 988 | clear_out_old_conf(void)
988        conf->active = 0;
989        dlinkDelete(&conf->node, *iterator);
990  
991 <      /* XXX This is less than pretty */
1189 <      if (conf->type == CONF_SERVER || conf->type == CONF_OPER)
1190 <      {
1191 <        if (!conf->ref_count)
1192 <          conf_free(conf);
1193 <      }
1194 <      else if (conf->type == CONF_XLINE)
1195 <      {
1196 <        if (!conf->until)
1197 <          conf_free(conf);
1198 <      }
1199 <      else
991 >      if (!conf->ref_count)
992          conf_free(conf);
993      }
994    }
995  
1204  motd_clear();
1205
996    /*
997 <   * don't delete the class table, rather mark all entries
998 <   * for deletion. The table is cleaned up by class_delete_marked. - avalon
997 >   * Don't delete the class table, rather mark all entries for deletion.
998 >   * The table is cleaned up by class_delete_marked. - avalon
999     */
1000    class_mark_for_deletion();
1001  
1002    clear_out_address_conf();
1003  
1004 <  /* clean out module paths */
1005 <  mod_clear_paths();
1004 >  modules_conf_clear();  /* Clear modules {} items */
1005 >
1006 >  motd_clear();  /* Clear motd {} items and re-cache default motd */
1007 >
1008 >  cluster_clear();  /* Clear cluster {} items */
1009 >
1010 >  gecos_clear();  /* Clear gecos {} items */
1011  
1012 <  pseudo_clear();
1012 >  resv_clear();  /* Clear resv {} items */
1013  
1014 <  /* clean out ConfigServerInfo */
1015 <  MyFree(ConfigServerInfo.description);
1014 >  service_clear();  /* Clear service {} items */
1015 >
1016 >  shared_clear();  /* Clear shared {} items */
1017 >
1018 >  pseudo_clear();  /* Clear pseudo {} items */
1019 >
1020 > #ifdef HAVE_LIBGEOIP
1021 >  GeoIP_delete(GeoIPv4_ctx);
1022 >  GeoIPv4_ctx = NULL;
1023 >  GeoIP_delete(GeoIPv6_ctx);
1024 >  GeoIPv6_ctx = NULL;
1025 > #endif
1026 >
1027 >  /* Clean out ConfigServerInfo */
1028 >  xfree(ConfigServerInfo.description);
1029    ConfigServerInfo.description = NULL;
1030 <  MyFree(ConfigServerInfo.network_name);
1030 >  xfree(ConfigServerInfo.network_name);
1031    ConfigServerInfo.network_name = NULL;
1032 <  MyFree(ConfigServerInfo.network_desc);
1032 >  xfree(ConfigServerInfo.network_desc);
1033    ConfigServerInfo.network_desc = NULL;
1034 < #ifdef HAVE_LIBCRYPTO
1035 <  if (ConfigServerInfo.rsa_private_key)
1036 <  {
1037 <    RSA_free(ConfigServerInfo.rsa_private_key);
1038 <    ConfigServerInfo.rsa_private_key = NULL;
1231 <  }
1232 <
1233 <  MyFree(ConfigServerInfo.rsa_private_key_file);
1034 >  xfree(ConfigServerInfo.libgeoip_ipv6_database_file);
1035 >  ConfigServerInfo.libgeoip_ipv6_database_file = NULL;
1036 >  xfree(ConfigServerInfo.libgeoip_ipv4_database_file);
1037 >  ConfigServerInfo.libgeoip_ipv4_database_file = NULL;
1038 >  xfree(ConfigServerInfo.rsa_private_key_file);
1039    ConfigServerInfo.rsa_private_key_file = NULL;
1040 < #endif
1040 >  xfree(ConfigServerInfo.ssl_certificate_file);
1041 >  ConfigServerInfo.ssl_certificate_file = NULL;
1042 >  xfree(ConfigServerInfo.ssl_dh_param_file);
1043 >  ConfigServerInfo.ssl_dh_param_file = NULL;
1044 >  xfree(ConfigServerInfo.ssl_dh_elliptic_curve);
1045 >  ConfigServerInfo.ssl_dh_elliptic_curve = NULL;
1046 >  xfree(ConfigServerInfo.ssl_cipher_list);
1047 >  ConfigServerInfo.ssl_cipher_list = NULL;
1048 >  xfree(ConfigServerInfo.ssl_message_digest_algorithm);
1049 >  ConfigServerInfo.ssl_message_digest_algorithm = NULL;
1050  
1051 <  /* clean out ConfigAdminInfo */
1052 <  MyFree(ConfigAdminInfo.name);
1051 >  /* Clean out ConfigAdminInfo */
1052 >  xfree(ConfigAdminInfo.name);
1053    ConfigAdminInfo.name = NULL;
1054 <  MyFree(ConfigAdminInfo.email);
1054 >  xfree(ConfigAdminInfo.email);
1055    ConfigAdminInfo.email = NULL;
1056 <  MyFree(ConfigAdminInfo.description);
1056 >  xfree(ConfigAdminInfo.description);
1057    ConfigAdminInfo.description = NULL;
1058  
1059 <  /* clean out listeners */
1060 <  close_listeners();
1059 >  xfree(ConfigServerHide.flatten_links_file);
1060 >  ConfigServerHide.flatten_links_file = NULL;
1061 >
1062 >  /* Clean out listeners */
1063 >  listener_close_marked();
1064 > }
1065 >
1066 > static void
1067 > conf_handle_tls(int cold)
1068 > {
1069 >  if (!tls_new_cred())
1070 >  {
1071 >    if (cold)
1072 >    {
1073 >      ilog(LOG_TYPE_IRCD, "Error while initializing TLS");
1074 >      exit(EXIT_FAILURE);
1075 >    }
1076 >    else
1077 >    {
1078 >      /* Failed to load new settings/certs, old ones remain active */
1079 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
1080 >                           "Error reloading TLS settings, check the ircd log"); // report_crypto_errors logs this
1081 >    }
1082 >  }
1083   }
1084  
1085   /* read_conf_files()
# Line 1276 | Line 1112 | read_conf_files(int cold)
1112      {
1113        ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
1114             filename, strerror(errno));
1115 <      exit(-1);
1115 >      exit(EXIT_FAILURE);
1116      }
1117      else
1118      {
1119 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1119 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1120                             "Unable to read configuration file '%s': %s",
1121                             filename, strerror(errno));
1122        return;
# Line 1294 | Line 1130 | read_conf_files(int cold)
1130    fclose(conf_parser_ctx.conf_file);
1131  
1132    log_reopen_all();
1133 +  conf_handle_tls(cold);
1134  
1135 <  add_isupport("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1136 <  add_isupport("NETWORK", ConfigServerInfo.network_name, -1);
1135 >  isupport_add("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1136 >  isupport_add("NETWORK", ConfigServerInfo.network_name, -1);
1137  
1138 <  snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans);
1139 <  add_isupport("MAXLIST", chanmodes, -1);
1140 <  add_isupport("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1141 <  add_isupport("CHANTYPES", "#", -1);
1138 >  snprintf(chanmodes, sizeof(chanmodes), "beI:%u", ConfigChannel.max_bans);
1139 >  isupport_add("MAXLIST", chanmodes, -1);
1140 >  isupport_add("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1141 >  isupport_add("CHANTYPES", "#", -1);
1142  
1143 <  snprintf(chanlimit, sizeof(chanlimit), "#:%d",
1143 >  snprintf(chanlimit, sizeof(chanlimit), "#:%u",
1144             ConfigChannel.max_channels);
1145 <  add_isupport("CHANLIMIT", chanlimit, -1);
1146 <  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstMORS");
1147 <  add_isupport("CHANNELLEN", NULL, CHANNELLEN);
1148 <  add_isupport("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1149 <  add_isupport("CHANMODES", chanmodes, -1);
1313 <
1314 <  /*
1315 <   * message_locale may have changed.  rebuild isupport since it relies
1316 <   * on strlen(form_str(RPL_ISUPPORT))
1317 <   */
1318 <  rebuild_isupport_message_line();
1145 >  isupport_add("CHANLIMIT", chanlimit, -1);
1146 >  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstCMORST");
1147 >  isupport_add("CHANNELLEN", NULL, CHANNELLEN);
1148 >  isupport_add("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1149 >  isupport_add("CHANMODES", chanmodes, -1);
1150   }
1151  
1152   /* conf_add_class_to_conf()
# Line 1325 | Line 1156 | read_conf_files(int cold)
1156   * side effects - Add a class pointer to a conf
1157   */
1158   void
1159 < conf_add_class_to_conf(struct MaskItem *conf, const char *class_name)
1159 > conf_add_class_to_conf(struct MaskItem *conf, const char *name)
1160   {
1161 <  if (class_name == NULL)
1161 >  if (EmptyString(name) || (conf->class = class_find(name, 1)) == NULL)
1162    {
1163      conf->class = class_default;
1164  
1165      if (conf->type == CONF_CLIENT || conf->type == CONF_OPER)
1166 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1336 <                           "Warning *** Defaulting to default class for %s@%s",
1337 <                           conf->user, conf->host);
1338 <    else
1339 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1340 <                           "Warning *** Defaulting to default class for %s",
1341 <                           conf->name);
1342 <  }
1343 <  else
1344 <    conf->class = class_find(class_name, 1);
1345 <
1346 <  if (conf->class == NULL)
1347 <  {
1348 <    if (conf->type == CONF_CLIENT || conf->type == CONF_OPER)
1349 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1166 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1167                             "Warning *** Defaulting to default class for %s@%s",
1168                             conf->user, conf->host);
1169      else
1170 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1170 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1171                             "Warning *** Defaulting to default class for %s",
1172                             conf->name);
1356    conf->class = class_default;
1173    }
1174   }
1175  
# Line 1366 | Line 1182 | conf_add_class_to_conf(struct MaskItem *
1182   void
1183   yyerror(const char *msg)
1184   {
1369  char newlinebuf[IRCD_BUFSIZE];
1370
1185    if (conf_parser_ctx.pass != 1)
1186      return;
1187  
1188 <  strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1189 <  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1188 >  char *p = stripws(linebuf);
1189 >  sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1190                         "\"%s\", line %u: %s: %s",
1191 <                       conffilebuf, lineno + 1, msg, newlinebuf);
1191 >                       conffilebuf, lineno, msg, p);
1192    ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
1193 <       conffilebuf, lineno + 1, msg, newlinebuf);
1193 >       conffilebuf, lineno, msg, p);
1194   }
1195  
1196   void
1197   conf_error_report(const char *msg)
1198   {
1199 <  char newlinebuf[IRCD_BUFSIZE];
1200 <
1387 <  strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1388 <  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1199 >  char *p = stripws(linebuf);
1200 >  sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1201                         "\"%s\", line %u: %s: %s",
1202 <                       conffilebuf, lineno + 1, msg, newlinebuf);
1202 >                       conffilebuf, lineno, msg, linebuf);
1203    ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
1204 <       conffilebuf, lineno + 1, msg, newlinebuf);
1204 >       conffilebuf, lineno, msg, linebuf);
1205   }
1206  
1207   /*
# Line 1402 | Line 1214 | conf_error_report(const char *msg)
1214   * side effects - none
1215   * Originally written by Dianora (Diane, db@db.net)
1216   */
1217 < time_t
1217 > uintmax_t
1218   valid_tkline(const char *data, const int minutes)
1219   {
1220    const unsigned char *p = (const unsigned char *)data;
1221    unsigned char tmpch = '\0';
1222 <  time_t result = 0;
1222 >  uintmax_t result = 0;
1223  
1224    while ((tmpch = *p++))
1225    {
# Line 1420 | Line 1232 | valid_tkline(const char *data, const int
1232  
1233    /*
1234     * In the degenerate case where oper does a /quote kline 0 user@host :reason
1235 <   * i.e. they specifically use 0, I am going to return 1 instead
1236 <   * as a return value of non-zero is used to flag it as a temporary kline
1235 >   * i.e. they specifically use 0, I am going to return 1 instead as a return
1236 >   * value of non-zero is used to flag it as a temporary kline
1237     */
1238    if (result == 0)
1239      result = 1;
# Line 1436 | Line 1248 | valid_tkline(const char *data, const int
1248    if (result > MAX_TDKLINE_TIME)
1249      result = MAX_TDKLINE_TIME;
1250  
1251 <  result = result * 60;  /* turn it into seconds */
1251 >  result = result * 60;  /* Turn it into seconds */
1252  
1253    return result;
1254   }
# Line 1452 | Line 1264 | valid_wild_card_simple(const char *data)
1264   {
1265    const unsigned char *p = (const unsigned char *)data;
1266    unsigned char tmpch = '\0';
1267 <  unsigned int nonwild = 0;
1267 >  unsigned int nonwild = 0, wild = 0;
1268  
1269    while ((tmpch = *p++))
1270    {
# Line 1467 | Line 1279 | valid_wild_card_simple(const char *data)
1279        if (++nonwild >= ConfigGeneral.min_nonwildcard_simple)
1280          return 1;
1281      }
1282 +    else
1283 +      ++wild;
1284    }
1285  
1286 <  return 0;
1286 >  return !wild;
1287   }
1288  
1289   /* valid_wild_card()
# Line 1481 | Line 1295 | valid_wild_card_simple(const char *data)
1295   * side effects - NOTICE is given to source_p if warn is 1
1296   */
1297   int
1298 < valid_wild_card(struct Client *source_p, int warn, int count, ...)
1298 > valid_wild_card(int count, ...)
1299   {
1300    unsigned char tmpch = '\0';
1301    unsigned int nonwild = 0;
# Line 1524 | Line 1338 | valid_wild_card(struct Client *source_p,
1338      }
1339    }
1340  
1527  if (warn)
1528    sendto_one_notice(source_p, &me,
1529                      ":Please include at least %u non-wildcard characters with the mask",
1530                      ConfigGeneral.min_nonwildcard);
1341    va_end(args);
1342    return 0;
1343   }
# Line 1543 | Line 1353 | valid_wild_card(struct Client *source_p,
1353   */
1354   static int
1355   find_user_host(struct Client *source_p, char *user_host_or_nick,
1356 <               char *luser, char *lhost, unsigned int flags)
1356 >               char *luser, char *lhost)
1357   {
1358    struct Client *target_p = NULL;
1359    char *hostp = NULL;
# Line 1588 | Line 1398 | find_user_host(struct Client *source_p,
1398          find_chasing(source_p, user_host_or_nick)) == NULL)
1399        return 0;  /* find_chasing sends ERR_NOSUCHNICK */
1400  
1401 <    if (IsExemptKline(target_p))
1401 >    if (HasFlag(target_p, FLAGS_EXEMPTKLINE))
1402      {
1403        if (IsClient(source_p))
1404          sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name);
# Line 1596 | Line 1406 | find_user_host(struct Client *source_p,
1406      }
1407  
1408      /*
1409 <     * turn the "user" bit into "*user", blow away '~'
1409 >     * Turn the "user" bit into "*user", blow away '~'
1410       * if found in original user name (non-idented)
1411       */
1412      strlcpy(luser, target_p->username, USERLEN*4 + 1);
# Line 1604 | Line 1414 | find_user_host(struct Client *source_p,
1414      if (target_p->username[0] == '~')
1415        luser[0] = '*';
1416  
1417 <    if (!strcmp(target_p->sockhost, "0"))
1608 <      strlcpy(lhost, target_p->host, HOSTLEN*4 + 1);
1609 <    else
1610 <      strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
1417 >    strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
1418      return 1;
1419    }
1420  
# Line 1628 | Line 1435 | find_user_host(struct Client *source_p,
1435   *              - pointer to target_server to parse into if non NULL
1436   *              - pointer to reason to parse into
1437   *
1438 < * output       - 1 if valid, -1 if not valid
1438 > * output       - 1 if valid, 0 if not valid
1439   * side effects - A generalised k/d/x etc. line parser,
1440   *               "ALINE [time] user@host|string [ON] target :reason"
1441   *                will parse returning a parsed user, host if
# Line 1647 | Line 1454 | find_user_host(struct Client *source_p,
1454   int
1455   parse_aline(const char *cmd, struct Client *source_p,
1456              int parc, char **parv,
1457 <            int parse_flags, char **up_p, char **h_p, time_t *tkline_time,
1457 >            char **up_p, char **h_p, uintmax_t *tkline_time,
1458              char **target_server, char **reason)
1459   {
1460 <  int found_tkline_time=0;
1461 <  static char def_reason[] = CONF_NOREASON;
1460 >  uintmax_t found_tkline_time=0;
1461 >  static char default_reason[] = CONF_NOREASON;
1462    static char user[USERLEN*4+1];
1463    static char host[HOSTLEN*4+1];
1464  
# Line 1670 | Line 1477 | parse_aline(const char *cmd, struct Clie
1477      else
1478      {
1479        sendto_one_notice(source_p, &me, ":temp_line not supported by %s", cmd);
1480 <      return -1;
1480 >      return 0;
1481      }
1482    }
1483  
1484    if (parc == 0)
1485    {
1486      sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1487 <    return -1;
1487 >    return 0;
1488    }
1489  
1490    if (h_p == NULL)
1491      *up_p = *parv;
1492    else
1493    {
1494 <    if (find_user_host(source_p, *parv, user, host, parse_flags) == 0)
1495 <      return -1;
1494 >    if (find_user_host(source_p, *parv, user, host) == 0)
1495 >      return 0;
1496  
1497      *up_p = user;
1498      *h_p = host;
# Line 1701 | Line 1508 | parse_aline(const char *cmd, struct Clie
1508        parc--;
1509        parv++;
1510  
1704      if (target_server == NULL)
1705      {
1706        sendto_one_notice(source_p, &me, ":ON server not supported by %s", cmd);
1707        return -1;
1708      }
1709
1511        if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
1512        {
1513          sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "remoteban");
1514 <        return -1;
1514 >        return 0;
1515        }
1516  
1517        if (parc == 0 || EmptyString(*parv))
1518        {
1519          sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1520 <        return -1;
1520 >        return 0;
1521        }
1522  
1523        *target_server = *parv;
# Line 1733 | Line 1534 | parse_aline(const char *cmd, struct Clie
1534      }
1535    }
1536  
1736  if (h_p)
1737  {
1738    if (strchr(user, '!'))
1739    {
1740      sendto_one_notice(source_p, &me, ":Invalid character '!' in kline");
1741      return -1;
1742    }
1743
1744    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p))
1745      return -1;
1746  }
1747  else
1748    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p))
1749      return -1;
1750
1537    if (reason)
1538    {
1539      if (parc && !EmptyString(*parv))
1754    {
1540        *reason = *parv;
1756
1757      if (!valid_comment(source_p, *reason, 1))
1758        return -1;
1759    }
1541      else
1542 <      *reason = def_reason;
1542 >      *reason = default_reason;
1543    }
1544  
1545    return 1;
1546   }
1547  
1767 /* valid_comment()
1768 *
1769 * inputs       - pointer to client
1770 *              - pointer to comment
1771 * output       - 0 if no valid comment,
1772 *              - 1 if valid
1773 * side effects - truncates reason where necessary
1774 */
1775 int
1776 valid_comment(struct Client *source_p, char *comment, int warn)
1777 {
1778  if (strlen(comment) > REASONLEN)
1779    comment[REASONLEN-1] = '\0';
1780
1781  return 1;
1782 }
1783
1548   /* match_conf_password()
1549   *
1550   * inputs       - pointer to given password
# Line 1805 | Line 1569 | match_conf_password(const char *password
1569   }
1570  
1571   /*
1808 * cluster_a_line
1809 *
1810 * inputs       - client sending the cluster
1811 *              - command name "KLINE" "XLINE" etc.
1812 *              - capab -- CAP_KLN etc. from server.h
1813 *              - cluster type -- CLUSTER_KLINE etc. from conf.h
1814 *              - pattern and args to send along
1815 * output       - none
1816 * side effects - Take source_p send the pattern with args given
1817 *                along to all servers that match capab and cluster type
1818 */
1819 void
1820 cluster_a_line(struct Client *source_p, const char *command,
1821               int capab, int cluster_type, const char *pattern, ...)
1822 {
1823  va_list args;
1824  char buffer[IRCD_BUFSIZE] = "";
1825  const dlink_node *node = NULL;
1826
1827  va_start(args, pattern);
1828  vsnprintf(buffer, sizeof(buffer), pattern, args);
1829  va_end(args);
1830
1831  DLINK_FOREACH(node, cluster_items.head)
1832  {
1833    const struct MaskItem *conf = node->data;
1834
1835    if (conf->flags & cluster_type)
1836      sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
1837                         "%s %s %s", command, conf->name, buffer);
1838  }
1839 }
1840
1841 /*
1572   * split_nuh
1573   *
1574   * inputs       - pointer to original mask (modified in place)
# Line 1919 | Line 1649 | split_nuh(struct split_nuh_item *const i
1649      }
1650      else
1651      {
1652 <      /* no @ found */
1652 >      /* No @ found */
1653        if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:"))
1654          strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize);
1655        else

Comparing ircd-hybrid/trunk/src/conf.c (property svn:keywords):
Revision 5039 by michael, Sat Dec 13 16:08:37 2014 UTC vs.
Revision 7766 by michael, Fri Oct 7 16:27:37 2016 UTC

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

Diff Legend

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