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 5506 by michael, Mon Feb 9 19:11:43 2015 UTC vs.
Revision 7726 by michael, Mon Sep 26 15:00:20 2016 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (c) 1997-2015 ircd-hybrid development team
4 > *  Copyright (c) 1997-2016 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 28 | Line 28
28   #include "list.h"
29   #include "ircd_defs.h"
30   #include "conf.h"
31 + #include "conf_cluster.h"
32 + #include "conf_gecos.h"
33   #include "conf_pseudo.h"
34 + #include "conf_resv.h"
35 + #include "conf_service.h"
36 + #include "conf_shared.h"
37   #include "server.h"
33 #include "resv.h"
38   #include "channel.h"
39   #include "client.h"
40   #include "event.h"
# Line 55 | Line 59
59   #include "conf_class.h"
60   #include "motd.h"
61   #include "ipcache.h"
62 + #include "isupport.h"
63 + #include "whowas.h"
64  
65  
66 + struct config_channel_entry ConfigChannel;
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 793 | Line 629 | set_default_conf(void)
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;
# Line 812 | Line 646 | set_default_conf(void)
646    ConfigChannel.max_bans = 25;
647    ConfigChannel.default_join_flood_count = 18;
648    ConfigChannel.default_join_flood_time = 6;
815  ConfigChannel.default_split_user_count = 0;
816  ConfigChannel.default_split_server_count = 0;
817  ConfigChannel.no_join_on_split = 0;
818  ConfigChannel.no_create_on_split = 0;
649  
650    ConfigServerHide.flatten_links = 0;
651 <  ConfigServerHide.links_delay = 300;
651 >  ConfigServerHide.flatten_links_delay = 300;
652    ConfigServerHide.hidden = 0;
653    ConfigServerHide.hide_servers = 0;
654    ConfigServerHide.hide_services = 0;
# Line 828 | 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.glines = 0;
665 <  ConfigGeneral.gline_time = 12 * 3600;
666 <  ConfigGeneral.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT;
667 <  ConfigGeneral.gline_min_cidr = 16;
837 <  ConfigGeneral.gline_min_cidr6 = 48;
664 >  ConfigGeneral.dline_min_cidr = 16;
665 >  ConfigGeneral.dline_min_cidr6 = 48;
666 >  ConfigGeneral.kline_min_cidr = 16;
667 >  ConfigGeneral.kline_min_cidr6 = 48;
668    ConfigGeneral.invisible_on_connect = 1;
669    ConfigGeneral.tkline_expire_notices = 1;
670    ConfigGeneral.ignore_bogus_ts = 0;
# 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 925 | Line 747 | read_conf(FILE *file)
747   * as a result of an operator issuing this command, else assume it has been
748   * called as a result of the server receiving a HUP signal.
749   */
750 < int
750 > void
751   conf_rehash(int sig)
752   {
753    if (sig)
754 <    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
754 >  {
755 >    sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
756                           "Got signal SIGHUP, reloading configuration file(s)");
757 +    ilog(LOG_TYPE_IRCD, "Got signal SIGHUP, reloading configuration file(s)");
758 +  }
759  
760    restart_resolver();
761  
# Line 940 | Line 765 | conf_rehash(int sig)
765  
766    load_conf_modules();
767    check_conf_klines();
943
944  return 0;
768   }
769  
770   /* lookup_confhost()
# Line 992 | 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);
996 <
997 <  /* DLINE exempt also gets you out of static limits/pacing... */
998 <  if (conf && (conf->type == CONF_EXEMPT))
999 <    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 1017 | Line 841 | conf_connect_allowed(struct irc_ssaddr *
841    return 0;
842   }
843  
1020 /* expire_tklines()
1021 *
1022 * inputs       - tkline list pointer
1023 * output       - NONE
1024 * side effects - expire tklines
1025 */
1026 static void
1027 expire_tklines(dlink_list *list)
1028 {
1029  dlink_node *node = NULL, *node_next = NULL;
1030
1031  DLINK_FOREACH_SAFE(node, node_next, list->head)
1032  {
1033    struct MaskItem *conf = node->data;
1034
1035    if (!conf->until || conf->until > CurrentTime)
1036      continue;
1037
1038    if (conf->type == CONF_XLINE)
1039    {
1040      if (ConfigGeneral.tkline_expire_notices)
1041        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1042                               "Temporary X-line for [%s] expired", conf->name);
1043      conf_free(conf);
1044    }
1045    else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV)
1046    {
1047      if (ConfigGeneral.tkline_expire_notices)
1048        sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1049                               "Temporary RESV for [%s] expired", conf->name);
1050      conf_free(conf);
1051    }
1052  }
1053 }
1054
844   /* cleanup_tklines()
845   *
846   * inputs       - NONE
# Line 1063 | Line 852 | void
852   cleanup_tklines(void *unused)
853   {
854    hostmask_expire_temporary();
855 <  expire_tklines(&xconf_items);
856 <  expire_tklines(&nresv_items);
1068 <  expire_tklines(&cresv_items);
855 >  gecos_expire();
856 >  resv_expire();
857   }
858  
859   /* oper_privs_as_string()
# Line 1074 | 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_GLINE,          'G' },
874 <  { 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 < char *
902 < oper_privs_as_string(const unsigned int port)
901 > const char *
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)
910 <      *privs_ptr++ = opriv->c;
911 <    else
912 <      *privs_ptr++ = ToLower(opriv->c);
1111 <  }
907 >  for (const struct oper_flags *tab = flag_table; tab->flag; ++tab)
908 >    if (flags & tab->flag)
909 >      *p++ = tab->c;
910 >
911 >  if (p == buf)
912 >    *p++ = '0';
913  
914 <  *privs_ptr = '\0';
914 >  *p = '\0';
915  
916 <  return privs_out;
916 >  return buf;
917   }
918  
919   /*
# Line 1124 | Line 925 | oper_privs_as_string(const unsigned int
925   const char *
926   get_oper_name(const struct Client *client_p)
927   {
928 <  /* +5 for !,@,{,} and null */
1128 <  static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5];
928 >  static char buffer[IRCD_BUFSIZE];
929  
930    if (IsServer(client_p))
931      return client_p->name;
# Line 1169 | 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,
1173 <     &uconf_items,   &xconf_items,
1174 <     &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 1189 | Line 987 | clear_out_old_conf(void)
987        conf->active = 0;
988        dlinkDelete(&conf->node, *iterator);
989  
990 <      /* XXX This is less than pretty */
1193 <      if (conf->type == CONF_SERVER || conf->type == CONF_OPER)
1194 <      {
1195 <        if (!conf->ref_count)
1196 <          conf_free(conf);
1197 <      }
1198 <      else if (conf->type == CONF_XLINE)
1199 <      {
1200 <        if (!conf->until)
1201 <          conf_free(conf);
1202 <      }
1203 <      else
990 >      if (!conf->ref_count)
991          conf_free(conf);
992      }
993    }
994  
1208  motd_clear();
1209
995    /*
996 <   * don't delete the class table, rather mark all entries
997 <   * for deletion. The table is cleaned up by class_delete_marked. - avalon
996 >   * Don't delete the class table, rather mark all entries for deletion.
997 >   * The table is cleaned up by class_delete_marked. - avalon
998     */
999    class_mark_for_deletion();
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 <  pseudo_clear();
1011 >  resv_clear();  /* Clear resv {} items */
1012  
1013 <  /* clean out ConfigServerInfo */
1014 <  MyFree(ConfigServerInfo.description);
1013 >  service_clear();  /* Clear service {} items */
1014 >
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 >  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;
1235 <  }
1236 <
1237 <  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);
1050 >  /* Clean out ConfigAdminInfo */
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 <  /* clean out listeners */
1059 <  close_listeners();
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()
# Line 1280 | Line 1111 | read_conf_files(int cold)
1111      {
1112        ilog(LOG_TYPE_IRCD, "Unable to read configuration file '%s': %s",
1113             filename, strerror(errno));
1114 <      exit(-1);
1114 >      exit(EXIT_FAILURE);
1115      }
1116      else
1117      {
1118 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1118 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1119                             "Unable to read configuration file '%s': %s",
1120                             filename, strerror(errno));
1121        return;
# Line 1298 | Line 1129 | read_conf_files(int cold)
1129    fclose(conf_parser_ctx.conf_file);
1130  
1131    log_reopen_all();
1132 +  conf_handle_tls(cold);
1133  
1134 <  add_isupport("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1135 <  add_isupport("NETWORK", ConfigServerInfo.network_name, -1);
1134 >  isupport_add("NICKLEN", NULL, ConfigServerInfo.max_nick_length);
1135 >  isupport_add("NETWORK", ConfigServerInfo.network_name, -1);
1136  
1137 <  snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans);
1138 <  add_isupport("MAXLIST", chanmodes, -1);
1139 <  add_isupport("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1140 <  add_isupport("CHANTYPES", "#", -1);
1137 >  snprintf(chanmodes, sizeof(chanmodes), "beI:%u", ConfigChannel.max_bans);
1138 >  isupport_add("MAXLIST", chanmodes, -1);
1139 >  isupport_add("MAXTARGETS", NULL, ConfigGeneral.max_targets);
1140 >  isupport_add("CHANTYPES", "#", -1);
1141  
1142 <  snprintf(chanlimit, sizeof(chanlimit), "#:%d",
1142 >  snprintf(chanlimit, sizeof(chanlimit), "#:%u",
1143             ConfigChannel.max_channels);
1144 <  add_isupport("CHANLIMIT", chanlimit, -1);
1145 <  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstMORS");
1146 <  add_isupport("CHANNELLEN", NULL, CHANNELLEN);
1147 <  add_isupport("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1148 <  add_isupport("CHANMODES", chanmodes, -1);
1317 <
1318 <  /*
1319 <   * message_locale may have changed.  rebuild isupport since it relies
1320 <   * on strlen(form_str(RPL_ISUPPORT))
1321 <   */
1322 <  rebuild_isupport_message_line();
1144 >  isupport_add("CHANLIMIT", chanlimit, -1);
1145 >  snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstCMORST");
1146 >  isupport_add("CHANNELLEN", NULL, CHANNELLEN);
1147 >  isupport_add("TOPICLEN", NULL, ConfigServerInfo.max_topic_length);
1148 >  isupport_add("CHANMODES", chanmodes, -1);
1149   }
1150  
1151   /* conf_add_class_to_conf()
# Line 1329 | Line 1155 | read_conf_files(int cold)
1155   * side effects - Add a class pointer to a conf
1156   */
1157   void
1158 < conf_add_class_to_conf(struct MaskItem *conf, const char *class_name)
1158 > conf_add_class_to_conf(struct MaskItem *conf, const char *name)
1159   {
1160 <  if (class_name == NULL)
1160 >  if (EmptyString(name) || (conf->class = class_find(name, 1)) == NULL)
1161    {
1162      conf->class = class_default;
1163  
1164      if (conf->type == CONF_CLIENT || conf->type == CONF_OPER)
1165 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1340 <                           "Warning *** Defaulting to default class for %s@%s",
1341 <                           conf->user, conf->host);
1342 <    else
1343 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1344 <                           "Warning *** Defaulting to default class for %s",
1345 <                           conf->name);
1346 <  }
1347 <  else
1348 <    conf->class = class_find(class_name, 1);
1349 <
1350 <  if (conf->class == NULL)
1351 <  {
1352 <    if (conf->type == CONF_CLIENT || conf->type == CONF_OPER)
1353 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1165 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1166                             "Warning *** Defaulting to default class for %s@%s",
1167                             conf->user, conf->host);
1168      else
1169 <      sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1169 >      sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1170                             "Warning *** Defaulting to default class for %s",
1171                             conf->name);
1360    conf->class = class_default;
1172    }
1173   }
1174  
# Line 1370 | Line 1181 | conf_add_class_to_conf(struct MaskItem *
1181   void
1182   yyerror(const char *msg)
1183   {
1373  char newlinebuf[IRCD_BUFSIZE];
1374
1184    if (conf_parser_ctx.pass != 1)
1185      return;
1186  
1187 <  strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1188 <  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1187 >  char *p = stripws(linebuf);
1188 >  sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1189                         "\"%s\", line %u: %s: %s",
1190 <                       conffilebuf, lineno + 1, msg, newlinebuf);
1190 >                       conffilebuf, lineno + 1, msg, p);
1191    ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
1192 <       conffilebuf, lineno + 1, msg, newlinebuf);
1192 >       conffilebuf, lineno + 1, msg, p);
1193   }
1194  
1195   void
1196   conf_error_report(const char *msg)
1197   {
1198 <  char newlinebuf[IRCD_BUFSIZE];
1199 <
1391 <  strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf));
1392 <  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
1198 >  char *p = stripws(linebuf);
1199 >  sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE,
1200                         "\"%s\", line %u: %s: %s",
1201 <                       conffilebuf, lineno + 1, msg, newlinebuf);
1201 >                       conffilebuf, lineno + 1, msg, linebuf);
1202    ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s",
1203 <       conffilebuf, lineno + 1, msg, newlinebuf);
1203 >       conffilebuf, lineno + 1, msg, linebuf);
1204   }
1205  
1206   /*
# Line 1406 | 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 1424 | Line 1231 | valid_tkline(const char *data, const int
1231  
1232    /*
1233     * In the degenerate case where oper does a /quote kline 0 user@host :reason
1234 <   * i.e. they specifically use 0, I am going to return 1 instead
1235 <   * as a return value of non-zero is used to flag it as a temporary kline
1234 >   * i.e. they specifically use 0, I am going to return 1 instead as a return
1235 >   * value of non-zero is used to flag it as a temporary kline
1236     */
1237    if (result == 0)
1238      result = 1;
# Line 1440 | Line 1247 | valid_tkline(const char *data, const int
1247    if (result > MAX_TDKLINE_TIME)
1248      result = MAX_TDKLINE_TIME;
1249  
1250 <  result = result * 60;  /* turn it into seconds */
1250 >  result = result * 60;  /* Turn it into seconds */
1251  
1252    return result;
1253   }
# Line 1456 | Line 1263 | valid_wild_card_simple(const char *data)
1263   {
1264    const unsigned char *p = (const unsigned char *)data;
1265    unsigned char tmpch = '\0';
1266 <  unsigned int nonwild = 0;
1266 >  unsigned int nonwild = 0, wild = 0;
1267  
1268    while ((tmpch = *p++))
1269    {
# Line 1471 | Line 1278 | valid_wild_card_simple(const char *data)
1278        if (++nonwild >= ConfigGeneral.min_nonwildcard_simple)
1279          return 1;
1280      }
1281 +    else
1282 +      ++wild;
1283    }
1284  
1285 <  return 0;
1285 >  return !wild;
1286   }
1287  
1288   /* valid_wild_card()
# Line 1485 | 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 warn, int count, ...)
1297 > valid_wild_card(int count, ...)
1298   {
1299    unsigned char tmpch = '\0';
1300    unsigned int nonwild = 0;
# Line 1528 | Line 1337 | valid_wild_card(struct Client *source_p,
1337      }
1338    }
1339  
1531  if (warn)
1532    sendto_one_notice(source_p, &me,
1533                      ":Please include at least %u non-wildcard characters with the mask",
1534                      ConfigGeneral.min_nonwildcard);
1340    va_end(args);
1341    return 0;
1342   }
# Line 1547 | Line 1352 | valid_wild_card(struct Client *source_p,
1352   */
1353   static int
1354   find_user_host(struct Client *source_p, char *user_host_or_nick,
1355 <               char *luser, char *lhost, unsigned int flags)
1355 >               char *luser, char *lhost)
1356   {
1357    struct Client *target_p = NULL;
1358    char *hostp = NULL;
# Line 1592 | Line 1397 | find_user_host(struct Client *source_p,
1397          find_chasing(source_p, user_host_or_nick)) == NULL)
1398        return 0;  /* find_chasing sends ERR_NOSUCHNICK */
1399  
1400 <    if (IsExemptKline(target_p))
1400 >    if (HasFlag(target_p, FLAGS_EXEMPTKLINE))
1401      {
1402        if (IsClient(source_p))
1403          sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name);
# Line 1600 | Line 1405 | find_user_host(struct Client *source_p,
1405      }
1406  
1407      /*
1408 <     * turn the "user" bit into "*user", blow away '~'
1408 >     * Turn the "user" bit into "*user", blow away '~'
1409       * if found in original user name (non-idented)
1410       */
1411      strlcpy(luser, target_p->username, USERLEN*4 + 1);
# Line 1608 | 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"))
1612 <      strlcpy(lhost, target_p->host, HOSTLEN*4 + 1);
1613 <    else
1614 <      strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
1416 >    strlcpy(lhost, target_p->sockhost, HOSTLEN*4 + 1);
1417      return 1;
1418    }
1419  
# Line 1632 | Line 1434 | find_user_host(struct Client *source_p,
1434   *              - pointer to target_server to parse into if non NULL
1435   *              - pointer to reason to parse into
1436   *
1437 < * output       - 1 if valid, -1 if not valid
1437 > * output       - 1 if valid, 0 if not valid
1438   * side effects - A generalised k/d/x etc. line parser,
1439   *               "ALINE [time] user@host|string [ON] target :reason"
1440   *                will parse returning a parsed user, host if
# Line 1651 | 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;
1460 <  static char def_reason[] = CONF_NOREASON;
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];
1463  
# Line 1674 | Line 1476 | parse_aline(const char *cmd, struct Clie
1476      else
1477      {
1478        sendto_one_notice(source_p, &me, ":temp_line not supported by %s", cmd);
1479 <      return -1;
1479 >      return 0;
1480      }
1481    }
1482  
1483    if (parc == 0)
1484    {
1485      sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1486 <    return -1;
1486 >    return 0;
1487    }
1488  
1489    if (h_p == NULL)
1490      *up_p = *parv;
1491    else
1492    {
1493 <    if (find_user_host(source_p, *parv, user, host, parse_flags) == 0)
1494 <      return -1;
1493 >    if (find_user_host(source_p, *parv, user, host) == 0)
1494 >      return 0;
1495  
1496      *up_p = user;
1497      *h_p = host;
# Line 1705 | Line 1507 | parse_aline(const char *cmd, struct Clie
1507        parc--;
1508        parv++;
1509  
1708      if (target_server == NULL)
1709      {
1710        sendto_one_notice(source_p, &me, ":ON server not supported by %s", cmd);
1711        return -1;
1712      }
1713
1510        if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN))
1511        {
1512          sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "remoteban");
1513 <        return -1;
1513 >        return 0;
1514        }
1515  
1516        if (parc == 0 || EmptyString(*parv))
1517        {
1518          sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd);
1519 <        return -1;
1519 >        return 0;
1520        }
1521  
1522        *target_server = *parv;
# Line 1737 | Line 1533 | parse_aline(const char *cmd, struct Clie
1533      }
1534    }
1535  
1740  if (h_p)
1741  {
1742    if (strchr(user, '!'))
1743    {
1744      sendto_one_notice(source_p, &me, ":Invalid character '!' in kline");
1745      return -1;
1746    }
1747
1748    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p))
1749      return -1;
1750  }
1751  else
1752    if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p))
1753      return -1;
1754
1536    if (reason)
1537    {
1538      if (parc && !EmptyString(*parv))
1758    {
1539        *reason = *parv;
1760
1761      if (!valid_comment(source_p, *reason, 1))
1762        return -1;
1763    }
1540      else
1541 <      *reason = def_reason;
1541 >      *reason = default_reason;
1542    }
1543  
1544    return 1;
1545   }
1546  
1771 /* valid_comment()
1772 *
1773 * inputs       - pointer to client
1774 *              - pointer to comment
1775 * output       - 0 if no valid comment,
1776 *              - 1 if valid
1777 * side effects - truncates reason where necessary
1778 */
1779 int
1780 valid_comment(struct Client *source_p, char *comment, int warn)
1781 {
1782  if (strlen(comment) > REASONLEN)
1783    comment[REASONLEN-1] = '\0';
1784
1785  return 1;
1786 }
1787
1547   /* match_conf_password()
1548   *
1549   * inputs       - pointer to given password
# Line 1809 | Line 1568 | match_conf_password(const char *password
1568   }
1569  
1570   /*
1812 * cluster_a_line
1813 *
1814 * inputs       - client sending the cluster
1815 *              - command name "KLINE" "XLINE" etc.
1816 *              - capab -- CAP_KLN etc. from server.h
1817 *              - cluster type -- CLUSTER_KLINE etc. from conf.h
1818 *              - pattern and args to send along
1819 * output       - none
1820 * side effects - Take source_p send the pattern with args given
1821 *                along to all servers that match capab and cluster type
1822 */
1823 void
1824 cluster_a_line(struct Client *source_p, const char *command,
1825               int capab, int cluster_type, const char *pattern, ...)
1826 {
1827  va_list args;
1828  char buffer[IRCD_BUFSIZE] = "";
1829  const dlink_node *node = NULL;
1830
1831  va_start(args, pattern);
1832  vsnprintf(buffer, sizeof(buffer), pattern, args);
1833  va_end(args);
1834
1835  DLINK_FOREACH(node, cluster_items.head)
1836  {
1837    const struct MaskItem *conf = node->data;
1838
1839    if (conf->flags & cluster_type)
1840      sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab,
1841                         "%s %s %s", command, conf->name, buffer);
1842  }
1843 }
1844
1845 /*
1571   * split_nuh
1572   *
1573   * inputs       - pointer to original mask (modified in place)
# Line 1923 | Line 1648 | split_nuh(struct split_nuh_item *const i
1648      }
1649      else
1650      {
1651 <      /* no @ found */
1651 >      /* No @ found */
1652        if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:"))
1653          strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize);
1654        else

Comparing ircd-hybrid/trunk/src/conf.c (property svn:keywords):
Revision 5506 by michael, Mon Feb 9 19:11:43 2015 UTC vs.
Revision 7726 by michael, Mon Sep 26 15:00:20 2016 UTC

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

Diff Legend

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