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

Comparing ircd-hybrid/trunk/src/conf_parser.y (file contents):
Revision 8792 by michael, Thu Jan 17 18:35:32 2019 UTC vs.
Revision 8877 by michael, Sat Feb 16 22:42:59 2019 UTC

# Line 295 | Line 295 | reset_block_state(void)
295   %token  STATS_P_OPER_ONLY
296   %token  STATS_U_OPER_ONLY
297   %token  T_ALL
298 + %token  T_BIND
299   %token  T_BOTS
300   %token  T_CALLERID
301   %token  T_CCONN
# Line 448 | Line 449 | serverinfo_entry: SERVERINFO '{' serveri
449  
450   serverinfo_items:       serverinfo_items serverinfo_item | serverinfo_item ;
451   serverinfo_item:        serverinfo_name |
451                        serverinfo_vhost |
452                          serverinfo_hub |
453                          serverinfo_description |
454                          serverinfo_network_name |
# Line 459 | Line 459 | serverinfo_item:        serverinfo_name
459                          serverinfo_ssl_dh_param_file |
460                          serverinfo_ssl_dh_elliptic_curve |
461                          serverinfo_rsa_private_key_file |
462                        serverinfo_vhost6 |
462                          serverinfo_sid |
463                          serverinfo_ssl_certificate_file |
464                          serverinfo_ssl_cipher_list |
# Line 524 | Line 523 | serverinfo_ssl_dh_elliptic_curve: SSL_DH
523   serverinfo_name: NAME '=' QSTRING ';'
524   {
525    /* This isn't rehashable */
526 <  if (conf_parser_ctx.pass == 2 && !ConfigServerInfo.name)
526 >  if (conf_parser_ctx.pass == 2 && ConfigServerInfo.name == NULL)
527    {
528      if (server_valid_name(yylval.string) == true)
529        ConfigServerInfo.name = xstrdup(yylval.string);
# Line 539 | Line 538 | serverinfo_name: NAME '=' QSTRING ';'
538   serverinfo_sid: IRCD_SID '=' QSTRING ';'
539   {
540    /* This isn't rehashable */
541 <  if (conf_parser_ctx.pass == 2 && !ConfigServerInfo.sid)
541 >  if (conf_parser_ctx.pass == 2 && ConfigServerInfo.sid == NULL)
542    {
543      if (valid_sid(yylval.string))
544        ConfigServerInfo.sid = xstrdup(yylval.string);
# Line 584 | Line 583 | serverinfo_network_desc: NETWORK_DESC '=
583    ConfigServerInfo.network_desc = xstrdup(yylval.string);
584   };
585  
587 serverinfo_vhost: VHOST '=' QSTRING ';'
588 {
589  if (conf_parser_ctx.pass == 2 && *yylval.string != '*')
590  {
591    struct addrinfo hints, *res;
592
593    memset(&hints, 0, sizeof(hints));
594
595    hints.ai_family   = AF_UNSPEC;
596    hints.ai_socktype = SOCK_STREAM;
597    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
598
599    if (getaddrinfo(yylval.string, NULL, &hints, &res))
600      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", yylval.string);
601    else
602    {
603      assert(res);
604
605      memcpy(&ConfigServerInfo.ip, res->ai_addr, res->ai_addrlen);
606      ConfigServerInfo.ip.ss.ss_family = res->ai_family;
607      ConfigServerInfo.ip.ss_len = res->ai_addrlen;
608      freeaddrinfo(res);
609
610      ConfigServerInfo.specific_ipv4_vhost = 1;
611    }
612  }
613 };
614
615 serverinfo_vhost6: VHOST6 '=' QSTRING ';'
616 {
617  if (conf_parser_ctx.pass == 2 && *yylval.string != '*')
618  {
619    struct addrinfo hints, *res;
620
621    memset(&hints, 0, sizeof(hints));
622
623    hints.ai_family   = AF_UNSPEC;
624    hints.ai_socktype = SOCK_STREAM;
625    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
626
627    if (getaddrinfo(yylval.string, NULL, &hints, &res))
628      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost6(%s)", yylval.string);
629    else
630    {
631      assert(res);
632
633      memcpy(&ConfigServerInfo.ip6, res->ai_addr, res->ai_addrlen);
634      ConfigServerInfo.ip6.ss.ss_family = res->ai_family;
635      ConfigServerInfo.ip6.ss_len = res->ai_addrlen;
636      freeaddrinfo(res);
637
638      ConfigServerInfo.specific_ipv6_vhost = 1;
639    }
640  }
641 };
642
586   serverinfo_default_max_clients: DEFAULT_MAX_CLIENTS '=' NUMBER ';'
587   {
588    if (conf_parser_ctx.pass != 2)
# Line 656 | Line 599 | serverinfo_default_max_clients: DEFAULT_
599  
600      snprintf(buf, sizeof(buf), "default_max_clients too high, setting to %d", MAXCLIENTS_MAX);
601      conf_error_report(buf);
602 +
603      ConfigServerInfo.default_max_clients = MAXCLIENTS_MAX;
604    }
605    else
# Line 678 | Line 622 | serverinfo_max_nick_length: MAX_NICK_LEN
622  
623      snprintf(buf, sizeof(buf), "max_nick_length too high, setting to %d", NICKLEN);
624      conf_error_report(buf);
625 +
626      ConfigServerInfo.max_nick_length = NICKLEN;
627    }
628    else
# Line 700 | Line 645 | serverinfo_max_topic_length: MAX_TOPIC_L
645  
646      snprintf(buf, sizeof(buf), "max_topic_length too high, setting to %d", TOPICLEN);
647      conf_error_report(buf);
648 +
649      ConfigServerInfo.max_topic_length = TOPICLEN;
650    }
651    else
# Line 716 | Line 662 | serverinfo_hub: HUB '=' TBOOL ';'
662   /***************************************************************************
663   * admin {} section
664   ***************************************************************************/
665 < admin_entry: ADMIN  '{' admin_items '}' ';' ;
665 > admin_entry: ADMIN '{' admin_items '}' ';' ;
666  
667   admin_items: admin_items admin_item | admin_item;
668   admin_item:  admin_name |
# Line 969 | Line 915 | oper_entry: OPERATOR
915  
916    DLINK_FOREACH(node, block_state.mask.list.head)
917    {
972    struct MaskItem *conf = NULL;
918      struct split_nuh_item nuh;
919      char *s = node->data;
920  
# Line 980 | Line 925 | oper_entry: OPERATOR
925      nuh.nickptr  = NULL;
926      nuh.userptr  = block_state.user.buf;
927      nuh.hostptr  = block_state.host.buf;
928 +
929      nuh.nicksize = 0;
930      nuh.usersize = sizeof(block_state.user.buf);
931      nuh.hostsize = sizeof(block_state.host.buf);
932 +
933      split_nuh(&nuh);
934  
935 <    conf         = conf_make(CONF_OPER);
936 <    conf->name   = xstrdup(block_state.name.buf);
937 <    conf->user   = xstrdup(block_state.user.buf);
938 <    conf->host   = xstrdup(block_state.host.buf);
935 >    struct MaskItem *conf = conf_make(CONF_OPER);
936 >    conf->addr = xcalloc(sizeof(*conf->addr));
937 >    conf->name = xstrdup(block_state.name.buf);
938 >    conf->user = xstrdup(block_state.user.buf);
939 >    conf->host = xstrdup(block_state.host.buf);
940  
941      if (block_state.cert.buf[0])
942        conf->certfp = xstrdup(block_state.cert.buf);
# Line 1002 | Line 950 | oper_entry: OPERATOR
950      conf->flags = block_state.flags.value;
951      conf->modes = block_state.modes.value;
952      conf->port  = block_state.port.value;
953 <    conf->htype = parse_netmask(conf->host, &conf->addr, &conf->bits);
953 >    conf->htype = parse_netmask(conf->host, conf->addr, &conf->bits);
954  
955      conf_add_class_to_conf(conf, block_state.class.buf);
956    }
# Line 1319 | Line 1267 | class_entry: CLASS
1267    block_state.max_recvq.value = DEFAULT_RECVQ;
1268   } '{' class_items '}' ';'
1269   {
1322  struct ClassItem *class = NULL;
1323
1270    if (conf_parser_ctx.pass != 1)
1271      break;
1272  
1273    if (!block_state.class.buf[0])
1274      break;
1275  
1276 <  if (!(class = class_find(block_state.class.buf, false)))
1276 >  struct ClassItem *class = class_find(block_state.class.buf, false);
1277 >  if (class == NULL)
1278      class = class_make();
1279  
1280 <  class->active = 1;
1280 >  class->active = true;
1281    xfree(class->name);
1282    class->name = xstrdup(block_state.class.buf);
1283    class->ping_freq = block_state.ping_freq.value;
# Line 1353 | Line 1300 | class_entry: CLASS
1300    class->min_idle = block_state.min_idle.value;
1301    class->max_idle = block_state.max_idle.value;
1302  
1303 <  int diff = (class->cidr_bitlen_ipv4 != block_state.cidr_bitlen_ipv4.value ||
1304 <              class->cidr_bitlen_ipv6 != block_state.cidr_bitlen_ipv6.value);
1303 >  bool diff = (class->cidr_bitlen_ipv4 != block_state.cidr_bitlen_ipv4.value ||
1304 >               class->cidr_bitlen_ipv6 != block_state.cidr_bitlen_ipv6.value);
1305    class->cidr_bitlen_ipv4 = block_state.cidr_bitlen_ipv4.value;
1306    class->cidr_bitlen_ipv6 = block_state.cidr_bitlen_ipv6.value;
1307    class->number_per_cidr = block_state.number_per_cidr.value;
# Line 1585 | Line 1532 | auth_entry: IRCD_AUTH
1532  
1533    DLINK_FOREACH(node, block_state.mask.list.head)
1534    {
1588    struct MaskItem *conf = NULL;
1535      struct split_nuh_item nuh;
1536      char *s = node->data;
1537  
# Line 1596 | Line 1542 | auth_entry: IRCD_AUTH
1542      nuh.nickptr  = NULL;
1543      nuh.userptr  = block_state.user.buf;
1544      nuh.hostptr  = block_state.host.buf;
1545 +
1546      nuh.nicksize = 0;
1547      nuh.usersize = sizeof(block_state.user.buf);
1548      nuh.hostsize = sizeof(block_state.host.buf);
1549 +
1550      split_nuh(&nuh);
1551  
1552 <    conf        = conf_make(CONF_CLIENT);
1553 <    conf->user  = xstrdup(block_state.user.buf);
1554 <    conf->host  = xstrdup(block_state.host.buf);
1552 >    struct MaskItem *conf = conf_make(CONF_CLIENT);
1553 >    conf->user = xstrdup(block_state.user.buf);
1554 >    conf->host = xstrdup(block_state.host.buf);
1555  
1556      if (block_state.rpass.buf[0])
1557        conf->passwd = xstrdup(block_state.rpass.buf);
# Line 1662 | Line 1610 | auth_flags: IRCD_FLAGS
1610   {
1611    if (conf_parser_ctx.pass == 2)
1612      block_state.flags.value &= (CONF_FLAGS_ENCRYPTED | CONF_FLAGS_SPOOF_IP);
1613 < } '='  auth_flags_items ';';
1613 > } '=' auth_flags_items ';';
1614  
1615   auth_flags_items: auth_flags_items ',' auth_flags_item | auth_flags_item;
1616   auth_flags_item: SPOOF_NOTICE
# Line 2000 | Line 1948 | connect_entry: CONNECT
1948    block_state.port.value = PORTNUM;
1949   } '{' connect_items '}' ';'
1950   {
2003  struct MaskItem *conf = NULL;
1951    struct addrinfo hints, *res;
1952  
1953    if (conf_parser_ctx.pass != 2)
# Line 2014 | Line 1961 | connect_entry: CONNECT
1961        !block_state.spass.buf[0])
1962      break;
1963  
1964 +  if (server_valid_name(block_state.name.buf) == false)
1965 +    break;
1966 +
1967    if (has_wildcards(block_state.name.buf) ||
1968        has_wildcards(block_state.host.buf))
1969      break;
1970  
1971 <  conf = conf_make(CONF_SERVER);
1971 >  struct MaskItem *conf = conf_make(CONF_SERVER);
1972 >  conf->addr = xcalloc(sizeof(*conf->addr));
1973    conf->port = block_state.port.value;
1974    conf->flags = block_state.flags.value;
1975    conf->aftype = block_state.aftype.value;
# Line 2045 | Line 1996 | connect_entry: CONNECT
1996      hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
1997  
1998      if (getaddrinfo(block_state.bind.buf, NULL, &hints, &res))
1999 <      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", block_state.bind.buf);
1999 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server bind(%s)", block_state.bind.buf);
2000      else
2001      {
2002        assert(res);
2003  
2004 <      memcpy(&conf->bind, res->ai_addr, res->ai_addrlen);
2005 <      conf->bind.ss.ss_family = res->ai_family;
2006 <      conf->bind.ss_len = res->ai_addrlen;
2004 >      conf->bind = xcalloc(sizeof(*conf->bind));
2005 >
2006 >      memcpy(conf->bind, res->ai_addr, res->ai_addrlen);
2007 >      conf->bind->ss_len = res->ai_addrlen;
2008        freeaddrinfo(res);
2009      }
2010    }
# Line 2064 | Line 2016 | connect_entry: CONNECT
2016   connect_items:  connect_items connect_item | connect_item;
2017   connect_item:   connect_name |
2018                  connect_host |
2019 <                connect_vhost |
2019 >                connect_bind |
2020                  connect_send_password |
2021                  connect_accept_password |
2022                  connect_ssl_certificate_fingerprint |
# Line 2090 | Line 2042 | connect_host: HOST '=' QSTRING ';'
2042      strlcpy(block_state.host.buf, yylval.string, sizeof(block_state.host.buf));
2043   };
2044  
2045 < connect_vhost: VHOST '=' QSTRING ';'
2045 > connect_bind: T_BIND '=' QSTRING ';'
2046   {
2047    if (conf_parser_ctx.pass == 2)
2048      strlcpy(block_state.bind.buf, yylval.string, sizeof(block_state.bind.buf));
# Line 2101 | Line 2053 | connect_send_password: SEND_PASSWORD '='
2053    if (conf_parser_ctx.pass != 2)
2054      break;
2055  
2056 <  if ($3[0] == ':')
2056 >  if (*yylval.string == ':')
2057      conf_error_report("Server passwords cannot begin with a colon");
2058 <  else if (strchr($3, ' '))
2058 >  else if (strchr(yylval.string, ' '))
2059      conf_error_report("Server passwords cannot contain spaces");
2060    else
2061      strlcpy(block_state.spass.buf, yylval.string, sizeof(block_state.spass.buf));
# Line 2114 | Line 2066 | connect_accept_password: ACCEPT_PASSWORD
2066    if (conf_parser_ctx.pass != 2)
2067      break;
2068  
2069 <  if ($3[0] == ':')
2069 >  if (*yylval.string == ':')
2070      conf_error_report("Server passwords cannot begin with a colon");
2071 <  else if (strchr($3, ' '))
2071 >  else if (strchr(yylval.string, ' '))
2072      conf_error_report("Server passwords cannot contain spaces");
2073    else
2074      strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
# Line 2147 | Line 2099 | connect_aftype: AFTYPE '=' T_IPV4 ';'
2099   connect_flags: IRCD_FLAGS
2100   {
2101    block_state.flags.value &= CONF_FLAGS_ENCRYPTED;
2102 < } '='  connect_flags_items ';';
2102 > } '=' connect_flags_items ';';
2103  
2104   connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;
2105   connect_flags_item: AUTOCONN
# Line 2210 | Line 2162 | kill_entry: KILL
2162      reset_block_state();
2163   } '{' kill_items '}' ';'
2164   {
2213  struct MaskItem *conf = NULL;
2214
2165    if (conf_parser_ctx.pass != 2)
2166      break;
2167  
# Line 2219 | Line 2169 | kill_entry: KILL
2169        !block_state.host.buf[0])
2170      break;
2171  
2172 <  conf = conf_make(CONF_KLINE);
2172 >  struct MaskItem *conf = conf_make(CONF_KLINE);
2173    conf->user = xstrdup(block_state.user.buf);
2174    conf->host = xstrdup(block_state.host.buf);
2175  
# Line 2269 | Line 2219 | deny_entry: DENY
2219      reset_block_state();
2220   } '{' deny_items '}' ';'
2221   {
2272  struct MaskItem *conf = NULL;
2273
2222    if (conf_parser_ctx.pass != 2)
2223      break;
2224  
# Line 2279 | Line 2227 | deny_entry: DENY
2227  
2228    if (parse_netmask(block_state.addr.buf, NULL, NULL) != HM_HOST)
2229    {
2230 <    conf = conf_make(CONF_DLINE);
2230 >    struct MaskItem *conf = conf_make(CONF_DLINE);
2231      conf->host = xstrdup(block_state.addr.buf);
2232  
2233      if (block_state.rpass.buf[0])
# Line 2445 | Line 2393 | general_whowas_history_length: WHOWAS_HI
2393  
2394   general_cycle_on_host_change: CYCLE_ON_HOST_CHANGE '=' TBOOL ';'
2395   {
2396 <  if (conf_parser_ctx.pass == 2)
2449 <    ConfigGeneral.cycle_on_host_change = yylval.number;
2396 >  ConfigGeneral.cycle_on_host_change = yylval.number;
2397   };
2398  
2399   general_dline_min_cidr: DLINE_MIN_CIDR '=' NUMBER ';'
# Line 2516 | Line 2463 | general_ts_warn_delta: TS_WARN_DELTA '='
2463  
2464   general_ts_max_delta: TS_MAX_DELTA '=' timespec ';'
2465   {
2466 <  if (conf_parser_ctx.pass == 2)
2520 <    ConfigGeneral.ts_max_delta = $3;
2466 >  ConfigGeneral.ts_max_delta = $3;
2467   };
2468  
2469   general_invisible_on_connect: INVISIBLE_ON_CONNECT '=' TBOOL ';'
# Line 2634 | Line 2580 | general_throttle_time: THROTTLE_TIME '='
2580   general_oper_umodes: OPER_UMODES
2581   {
2582    ConfigGeneral.oper_umodes = 0;
2583 < } '='  umode_oitems ';' ;
2583 > } '=' umode_oitems ';' ;
2584  
2585   umode_oitems:    umode_oitems ',' umode_oitem | umode_oitem;
2586   umode_oitem:     T_BOTS
# Line 2708 | Line 2654 | umode_oitem:     T_BOTS
2654   general_oper_only_umodes: OPER_ONLY_UMODES
2655   {
2656    ConfigGeneral.oper_only_umodes = 0;
2657 < } '='  umode_items ';' ;
2657 > } '=' umode_items ';' ;
2658  
2659   umode_items:  umode_items ',' umode_item | umode_item;
2660   umode_item:   T_BOTS

Diff Legend

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