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 1736 by michael, Sun Jan 13 09:31:46 2013 UTC vs.
Revision 1851 by michael, Wed Apr 24 18:31:06 2013 UTC

# Line 38 | Line 38
38   #include "log.h"
39   #include "client.h"     /* for UMODE_ALL only */
40   #include "irc_string.h"
41 #include "sprintf_irc.h"
41   #include "memory.h"
42   #include "modules.h"
43   #include "s_serv.h"
# Line 56 | Line 55
55   #include <openssl/dh.h>
56   #endif
57  
58 + #include "rsa.h"
59 +
60   int yylex(void);
61  
62   static struct
# Line 90 | Line 91 | static struct
91      ping_freq,
92      max_perip,
93      con_freq,
94 +    min_idle,
95 +    max_idle,
96      max_total,
97      max_global,
98      max_local,
# Line 187 | Line 190 | reset_block_state(void)
190   %token  HIDDEN_NAME
191   %token  HIDE_SERVER_IPS
192   %token  HIDE_SERVERS
193 + %token  HIDE_SERVICES
194   %token  HIDE_SPOOF_IPS
195   %token  HOST
196   %token  HUB
# Line 212 | Line 216 | reset_block_state(void)
216   %token  MAX_IDENT
217   %token  MAX_LOCAL
218   %token  MAX_NICK_CHANGES
219 + %token  MAX_NICK_LENGTH
220   %token  MAX_NICK_TIME
221   %token  MAX_NUMBER
222   %token  MAX_TARGETS
223 + %token  MAX_TOPIC_LENGTH
224   %token  MAX_WATCH
219 %token  MESSAGE_LOCALE
225   %token  MIN_NONWILDCARD
226   %token  MIN_NONWILDCARD_SIMPLE
227 + %token  MIN_IDLE
228 + %token  MAX_IDLE
229 + %token  RANDOM_IDLE
230 + %token  HIDE_IDLE_FROM_OPERS
231   %token  MODULE
232   %token  MODULES
233   %token  NAME
# Line 269 | Line 278 | reset_block_state(void)
278   %token  T_TLSV1
279   %token  RESV
280   %token  RESV_EXEMPT
281 < %token  SECONDS MINUTES HOURS DAYS WEEKS
281 > %token  SECONDS MINUTES HOURS DAYS WEEKS MONTHS YEARS
282   %token  SENDQ
283   %token  SEND_PASSWORD
284   %token  SERVERHIDE
# Line 406 | Line 415 | timespec:      NUMBER timespec_
415                  {
416                          $$ = $1 * 60 * 60 * 24 * 7 + $3;
417                  }
418 +                | NUMBER MONTHS timespec_
419 +                {
420 +                        $$ = $1 * 60 * 60 * 24 * 7 * 4 + $3;
421 +                }
422 +                | NUMBER YEARS timespec_
423 +                {
424 +                        $$ = $1 * 60 * 60 * 24 * 365 + $3;
425 +                }
426                  ;
427  
428   sizespec_:      { $$ = 0; } | sizespec;
# Line 444 | Line 461 | serverinfo_items:       serverinfo_items
461   serverinfo_item:        serverinfo_name | serverinfo_vhost |
462                          serverinfo_hub | serverinfo_description |
463                          serverinfo_network_name | serverinfo_network_desc |
464 <                        serverinfo_max_clients | serverinfo_ssl_dh_param_file |
464 >                        serverinfo_max_clients | serverinfo_max_nick_length |
465 >                        serverinfo_max_topic_length | serverinfo_ssl_dh_param_file |
466                          serverinfo_rsa_private_key_file | serverinfo_vhost6 |
467                          serverinfo_sid | serverinfo_ssl_certificate_file |
468                          serverinfo_ssl_client_method | serverinfo_ssl_server_method |
# Line 492 | Line 510 | serverinfo_ssl_certificate_file: SSL_CER
510    {
511      if (!ServerInfo.rsa_private_key_file)
512      {
513 <      yyerror("No rsa_private_key_file specified, SSL disabled");
513 >      conf_error_report("No rsa_private_key_file specified, SSL disabled");
514        break;
515      }
516  
# Line 501 | Line 519 | serverinfo_ssl_certificate_file: SSL_CER
519          SSL_CTX_use_certificate_file(ServerInfo.client_ctx, yylval.string,
520                                       SSL_FILETYPE_PEM) <= 0)
521      {
522 <      yyerror(ERR_lib_error_string(ERR_get_error()));
522 >      report_crypto_errors();
523 >      conf_error_report("Could not open/read certificate file");
524        break;
525      }
526  
# Line 510 | Line 529 | serverinfo_ssl_certificate_file: SSL_CER
529          SSL_CTX_use_PrivateKey_file(ServerInfo.client_ctx, ServerInfo.rsa_private_key_file,
530                                      SSL_FILETYPE_PEM) <= 0)
531      {
532 <      yyerror(ERR_lib_error_string(ERR_get_error()));
532 >      report_crypto_errors();
533 >      conf_error_report("Could not read RSA private key");
534        break;
535      }
536  
537      if (!SSL_CTX_check_private_key(ServerInfo.server_ctx) ||
538          !SSL_CTX_check_private_key(ServerInfo.client_ctx))
539      {
540 <      yyerror(ERR_lib_error_string(ERR_get_error()));
540 >      report_crypto_errors();
541 >      conf_error_report("Could not read RSA private key");
542        break;
543      }
544    }
# Line 547 | Line 568 | serverinfo_rsa_private_key_file: RSA_PRI
568  
569      if ((file = BIO_new_file(yylval.string, "r")) == NULL)
570      {
571 <      yyerror("File open failed, ignoring");
571 >      conf_error_report("File open failed, ignoring");
572        break;
573      }
574  
# Line 558 | Line 579 | serverinfo_rsa_private_key_file: RSA_PRI
579  
580      if (ServerInfo.rsa_private_key == NULL)
581      {
582 <      yyerror("Couldn't extract key, ignoring");
582 >      conf_error_report("Couldn't extract key, ignoring");
583        break;
584      }
585  
# Line 567 | Line 588 | serverinfo_rsa_private_key_file: RSA_PRI
588        RSA_free(ServerInfo.rsa_private_key);
589        ServerInfo.rsa_private_key = NULL;
590  
591 <      yyerror("Invalid key, ignoring");
591 >      conf_error_report("Invalid key, ignoring");
592        break;
593      }
594  
# Line 577 | Line 598 | serverinfo_rsa_private_key_file: RSA_PRI
598        RSA_free(ServerInfo.rsa_private_key);
599        ServerInfo.rsa_private_key = NULL;
600  
601 <      yyerror("Not a 2048 bit key, ignoring");
601 >      conf_error_report("Not a 2048 bit key, ignoring");
602      }
603    }
604   #endif
# Line 600 | Line 621 | serverinfo_ssl_dh_param_file: SSL_DH_PAR
621        if (dh)
622        {
623          if (DH_size(dh) < 128)
624 <          ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::ssl_dh_param_file -- need at least a 1024 bit DH prime size");
624 >          conf_error_report("Ignoring serverinfo::ssl_dh_param_file -- need at least a 1024 bit DH prime size");
625          else
626            SSL_CTX_set_tmp_dh(ServerInfo.server_ctx, dh);
627  
# Line 628 | Line 649 | serverinfo_name: NAME '=' QSTRING ';'
649        ServerInfo.name = xstrdup(yylval.string);
650      else
651      {
652 <      ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::name -- invalid name. Aborting.");
652 >      conf_error_report("Ignoring serverinfo::name -- invalid name. Aborting.");
653        exit(0);
654      }
655    }
# Line 643 | Line 664 | serverinfo_sid: IRCD_SID '=' QSTRING ';'
664        ServerInfo.sid = xstrdup(yylval.string);
665      else
666      {
667 <      ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::sid -- invalid SID. Aborting.");
667 >      conf_error_report("Ignoring serverinfo::sid -- invalid SID. Aborting.");
668        exit(0);
669      }
670    }
# Line 749 | Line 770 | serverinfo_max_clients: T_MAX_CLIENTS '=
770      char buf[IRCD_BUFSIZE];
771  
772      snprintf(buf, sizeof(buf), "MAXCLIENTS too low, setting to %d", MAXCLIENTS_MIN);
773 <    yyerror(buf);
773 >    conf_error_report(buf);
774      ServerInfo.max_clients = MAXCLIENTS_MIN;
775    }
776    else if ($3 > MAXCLIENTS_MAX)
# Line 757 | Line 778 | serverinfo_max_clients: T_MAX_CLIENTS '=
778      char buf[IRCD_BUFSIZE];
779  
780      snprintf(buf, sizeof(buf), "MAXCLIENTS too high, setting to %d", MAXCLIENTS_MAX);
781 <    yyerror(buf);
781 >    conf_error_report(buf);
782      ServerInfo.max_clients = MAXCLIENTS_MAX;
783    }
784    else
785      ServerInfo.max_clients = $3;
786   };
787  
788 + serverinfo_max_nick_length: MAX_NICK_LENGTH '=' NUMBER ';'
789 + {
790 +  if (conf_parser_ctx.pass != 2)
791 +    break;
792 +
793 +  if ($3 < 9)
794 +  {
795 +    conf_error_report("max_nick_length too low, setting to 9");
796 +    ServerInfo.max_nick_length = 9;
797 +  }
798 +  else if ($3 > NICKLEN)
799 +  {
800 +    char buf[IRCD_BUFSIZE];
801 +
802 +    snprintf(buf, sizeof(buf), "max_nick_length too high, setting to %d", NICKLEN);
803 +    conf_error_report(buf);
804 +    ServerInfo.max_nick_length = NICKLEN;
805 +  }
806 +  else
807 +    ServerInfo.max_nick_length = $3;
808 + };
809 +
810 + serverinfo_max_topic_length: MAX_TOPIC_LENGTH '=' NUMBER ';'
811 + {
812 +  if (conf_parser_ctx.pass != 2)
813 +    break;
814 +
815 +  if ($3 < 80)
816 +  {
817 +    conf_error_report("max_topic_length too low, setting to 80");
818 +    ServerInfo.max_topic_length = 80;
819 +  }
820 +  else if ($3 > TOPICLEN)
821 +  {
822 +    char buf[IRCD_BUFSIZE];
823 +
824 +    snprintf(buf, sizeof(buf), "max_topic_length too high, setting to %d", TOPICLEN);
825 +    conf_error_report(buf);
826 +    ServerInfo.max_topic_length = TOPICLEN;
827 +  }
828 +  else
829 +    ServerInfo.max_topic_length = $3;
830 + };
831 +
832   serverinfo_hub: HUB '=' TBOOL ';'
833   {
834    if (conf_parser_ctx.pass == 2)
# Line 831 | Line 896 | logging_file_entry:
896      break;
897  
898    if (block_state.type.value && block_state.file.buf[0])
899 <    log_add_file(block_state.type.value, block_state.size.value,
899 >    log_set_file(block_state.type.value, block_state.size.value,
900                   block_state.file.buf);
901   };
902  
# Line 960 | Line 1025 | oper_entry: OPERATOR
1025  
1026        if ((file = BIO_new_file(block_state.file.buf, "r")) == NULL)
1027        {
1028 <        yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
1028 >        conf_error_report("Ignoring rsa_public_key_file -- file doesn't exist");
1029          break;
1030        }
1031  
1032        if ((pkey = PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL)) == NULL)
1033 <      {
969 <        yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
970 <        break;
971 <      }
1033 >        conf_error_report("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
1034  
1035        conf->rsa_public_key = pkey;
1036        BIO_set_close(file, BIO_CLOSE);
# Line 1214 | Line 1276 | class_entry: CLASS
1276    block_state.max_total.value = MAXIMUM_LINKS_DEFAULT;
1277    block_state.max_sendq.value = DEFAULT_SENDQ;
1278    block_state.max_recvq.value = DEFAULT_RECVQ;
1217
1279   } '{' class_items '}' ';'
1280   {
1281    struct ClassItem *class = NULL;
# Line 1241 | Line 1302 | class_entry: CLASS
1302    class->max_sendq = block_state.max_sendq.value;
1303    class->max_recvq = block_state.max_recvq.value;
1304  
1305 +  if (block_state.min_idle.value > block_state.max_idle.value)
1306 +  {
1307 +    block_state.min_idle.value = 0;
1308 +    block_state.max_idle.value = 0;
1309 +    block_state.flags.value &= ~CLASS_FLAGS_FAKE_IDLE;
1310 +  }
1311 +
1312 +  class->flags = block_state.flags.value;
1313 +  class->min_idle = block_state.min_idle.value;
1314 +  class->max_idle = block_state.max_idle.value;
1315 +
1316    if (class->number_per_cidr && block_state.number_per_cidr.value)
1317      if ((class->cidr_bitlen_ipv4 && block_state.cidr_bitlen_ipv4.value) ||
1318          (class->cidr_bitlen_ipv6 && block_state.cidr_bitlen_ipv6.value))
# Line 1265 | Line 1337 | class_item:     class_name |
1337                  class_max_local |
1338                  class_max_ident |
1339                  class_sendq | class_recvq |
1340 +                class_min_idle |
1341 +                class_max_idle |
1342 +                class_flags |
1343                  error ';' ;
1344  
1345   class_name: NAME '=' QSTRING ';'
# Line 1346 | Line 1421 | class_number_per_cidr: NUMBER_PER_CIDR '
1421      block_state.number_per_cidr.value = $3;
1422   };
1423  
1424 + class_min_idle: MIN_IDLE '=' timespec ';'
1425 + {
1426 +  if (conf_parser_ctx.pass != 1)
1427 +    break;
1428 +
1429 +  block_state.min_idle.value = $3;
1430 +  block_state.flags.value |= CLASS_FLAGS_FAKE_IDLE;
1431 + };
1432 +
1433 + class_max_idle: MAX_IDLE '=' timespec ';'
1434 + {
1435 +  if (conf_parser_ctx.pass != 1)
1436 +    break;
1437 +
1438 +  block_state.max_idle.value = $3;
1439 +  block_state.flags.value |= CLASS_FLAGS_FAKE_IDLE;
1440 + };
1441 +
1442 + class_flags: IRCD_FLAGS
1443 + {
1444 +  if (conf_parser_ctx.pass == 1)
1445 +    block_state.flags.value &= CLASS_FLAGS_FAKE_IDLE;
1446 + } '='  class_flags_items ';';
1447 +
1448 + class_flags_items: class_flags_items ',' class_flags_item | class_flags_item;
1449 + class_flags_item: RANDOM_IDLE
1450 + {
1451 +  if (conf_parser_ctx.pass == 1)
1452 +    block_state.flags.value |= CLASS_FLAGS_RANDOM_IDLE;
1453 + } | HIDE_IDLE_FROM_OPERS
1454 + {
1455 +  if (conf_parser_ctx.pass == 1)
1456 +    block_state.flags.value |= CLASS_FLAGS_HIDE_IDLE_FROM_OPERS;
1457 + };
1458 +
1459 +
1460   /***************************************************************************
1461   *  section listen
1462   ***************************************************************************/
# Line 1391 | Line 1502 | port_item: NUMBER
1502        if (!ServerInfo.server_ctx)
1503   #endif
1504        {
1505 <        yyerror("SSL not available - port closed");
1505 >        conf_error_report("SSL not available - port closed");
1506          break;
1507        }
1508      add_listener($1, block_state.addr.buf, block_state.flags.value);
# Line 1407 | Line 1518 | port_item: NUMBER
1518        if (!ServerInfo.server_ctx)
1519   #endif
1520        {
1521 <        yyerror("SSL not available - port closed");
1521 >        conf_error_report("SSL not available - port closed");
1522          break;
1523        }
1524  
# Line 1599 | Line 1710 | resv_entry: RESV
1710  
1711    reset_block_state();
1712    strlcpy(block_state.rpass.buf, CONF_NOREASON, sizeof(block_state.rpass.buf));
1713 < } '{' resv_items '}' ';';
1713 > } '{' resv_items '}' ';'
1714 > {
1715 >  if (IsChanPrefix(block_state.name.buf[0]))
1716 >    create_channel_resv(block_state.name.buf, block_state.rpass.buf);
1717 >  else if (block_state.name.buf[0])
1718 >    create_nick_resv(block_state.name.buf, block_state.rpass.buf);
1719 > };
1720  
1721   resv_items:     resv_items resv_item | resv_item;
1722 < resv_item:      resv_creason | resv_channel | resv_nick | error ';' ;
1722 > resv_item:      resv_reason | resv_channel | resv_nick | error ';' ;
1723  
1724 < resv_creason: REASON '=' QSTRING ';'
1724 > resv_reason: REASON '=' QSTRING ';'
1725   {
1726    if (conf_parser_ctx.pass == 2)
1727      strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
# Line 1612 | Line 1729 | resv_creason: REASON '=' QSTRING ';'
1729  
1730   resv_channel: CHANNEL '=' QSTRING ';'
1731   {
1732 <  if (conf_parser_ctx.pass != 2)
1733 <    break;
1617 <
1618 <  if (IsChanPrefix(*yylval.string))
1619 <    create_channel_resv(yylval.string, block_state.rpass.buf, 1);
1732 >  if (conf_parser_ctx.pass == 2)
1733 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1734   };
1735  
1736   resv_nick: NICK '=' QSTRING ';'
1737   {
1738    if (conf_parser_ctx.pass == 2)
1739 <    create_nick_resv(yylval.string, block_state.rpass.buf, 1);
1739 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1740   };
1741  
1742   /***************************************************************************
# Line 1933 | Line 2047 | connect_send_password: SEND_PASSWORD '='
2047      break;
2048  
2049    if ($3[0] == ':')
2050 <    yyerror("Server passwords cannot begin with a colon");
2050 >    conf_error_report("Server passwords cannot begin with a colon");
2051    else if (strchr($3, ' ') != NULL)
2052 <    yyerror("Server passwords cannot contain spaces");
2052 >    conf_error_report("Server passwords cannot contain spaces");
2053    else
2054      strlcpy(block_state.spass.buf, yylval.string, sizeof(block_state.spass.buf));
2055   };
# Line 1946 | Line 2060 | connect_accept_password: ACCEPT_PASSWORD
2060      break;
2061  
2062    if ($3[0] == ':')
2063 <    yyerror("Server passwords cannot begin with a colon");
2063 >    conf_error_report("Server passwords cannot begin with a colon");
2064    else if (strchr($3, ' ') != NULL)
2065 <    yyerror("Server passwords cannot contain spaces");
2065 >    conf_error_report("Server passwords cannot contain spaces");
2066    else
2067      strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2068   };
# Line 2023 | Line 2137 | connect_ssl_cipher_list: T_SSL_CIPHER_LI
2137      strlcpy(block_state.ciph.buf, yylval.string, sizeof(block_state.ciph.buf));
2138   #else
2139    if (conf_parser_ctx.pass == 2)
2140 <    yyerror("Ignoring connect::ciphers -- no OpenSSL support");
2140 >    conf_error_report("Ignoring connect::ciphers -- no OpenSSL support");
2141   #endif
2142   };
2143  
# Line 2235 | Line 2349 | gecos_entry: GECOS
2349      conf = conf_make(CONF_RXLINE);
2350      conf->regexuser = exp_p;
2351   #else
2352 <    ilog(LOG_TYPE_IRCD, "Failed to add regular expression based X-Line: no PCRE support");
2352 >    conf_error_report("Failed to add regular expression based X-Line: no PCRE support");
2353      break;
2354   #endif
2355    }
# Line 2298 | Line 2412 | general_item:       general_hide_spoof_i
2412                      general_pace_wait_simple | general_stats_P_oper_only |
2413                      general_short_motd | general_no_oper_flood |
2414                      general_true_no_oper_flood | general_oper_pass_resv |
2301                    general_message_locale |
2415                      general_oper_only_umodes | general_max_targets |
2416                      general_use_egd | general_egdpool_path |
2417                      general_oper_umodes | general_caller_id_wait |
# Line 2508 | Line 2621 | general_oper_pass_resv: OPER_PASS_RESV '
2621    ConfigFileEntry.oper_pass_resv = yylval.number;
2622   };
2623  
2511 general_message_locale: MESSAGE_LOCALE '=' QSTRING ';'
2512 {
2513  if (conf_parser_ctx.pass == 2)
2514  {
2515    if (strlen(yylval.string) > LOCALE_LENGTH-2)
2516      yylval.string[LOCALE_LENGTH-1] = '\0';
2517
2518    set_locale(yylval.string);
2519  }
2520 };
2521
2624   general_dots_in_ident: DOTS_IN_IDENT '=' NUMBER ';'
2625   {
2626    ConfigFileEntry.dots_in_ident = $3;
# Line 2814 | Line 2916 | serverhide_entry: SERVERHIDE
2916  
2917   serverhide_items:   serverhide_items serverhide_item | serverhide_item;
2918   serverhide_item:    serverhide_flatten_links | serverhide_hide_servers |
2919 +                    serverhide_hide_services |
2920                      serverhide_links_delay |
2921                      serverhide_hidden | serverhide_hidden_name |
2922                      serverhide_hide_server_ips |
# Line 2831 | Line 2934 | serverhide_hide_servers: HIDE_SERVERS '=
2934      ConfigServerHide.hide_servers = yylval.number;
2935   };
2936  
2937 + serverhide_hide_services: HIDE_SERVICES '=' TBOOL ';'
2938 + {
2939 +  if (conf_parser_ctx.pass == 2)
2940 +    ConfigServerHide.hide_services = yylval.number;
2941 + };
2942 +
2943   serverhide_hidden_name: HIDDEN_NAME '=' QSTRING ';'
2944   {
2945    if (conf_parser_ctx.pass == 2)

Diff Legend

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