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/src/ircd_parser.y (file contents), Revision 33 by knight, Sun Oct 2 20:50:00 2005 UTC vs.
ircd-hybrid-8/src/conf_parser.y (file contents), Revision 1352 by michael, Fri Apr 13 09:57:08 2012 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  ircd_parser.y: Parses the ircd configuration file.
3 > *  conf_parser.y: Parses the ircd configuration file.
4   *
5   *  Copyright (C) 2005 by the past and present ircd coders, and others.
6   *
# Line 26 | Line 26
26  
27   #define YY_NO_UNPUT
28   #include <sys/types.h>
29 + #include <string.h>
30  
31 + #include "config.h"
32   #include "stdinc.h"
31 #include "dalloca.h"
33   #include "ircd.h"
33 #include "tools.h"
34   #include "list.h"
35 < #include "s_conf.h"
35 > #include "conf.h"
36   #include "event.h"
37 < #include "s_log.h"
37 > #include "log.h"
38   #include "client.h"     /* for UMODE_ALL only */
39 #include "pcre.h"
39   #include "irc_string.h"
41 #include "irc_getaddrinfo.h"
40   #include "sprintf_irc.h"
41   #include "memory.h"
42   #include "modules.h"
43 < #include "s_serv.h" /* for CAP_LL / IsCapable */
43 > #include "s_serv.h"
44   #include "hostmask.h"
45   #include "send.h"
46   #include "listener.h"
# Line 54 | Line 52
52   #include <openssl/rsa.h>
53   #include <openssl/bio.h>
54   #include <openssl/pem.h>
55 + #include <openssl/dh.h>
56   #endif
57  
58 + int yylex(void);
59 +
60   static char *class_name = NULL;
61   static struct ConfItem *yy_conf = NULL;
62   static struct AccessItem *yy_aconf = NULL;
# Line 72 | Line 73 | static char userbuf[IRCD_BUFSIZE];
73   static char hostbuf[IRCD_BUFSIZE];
74   static char reasonbuf[REASONLEN + 1];
75   static char gecos_name[REALLEN * 4];
76 <
77 < extern dlink_list gdeny_items; /* XXX */
78 <
76 > static char lfile[IRCD_BUFSIZE];
77 > static unsigned int ltype = 0;
78 > static unsigned int lsize = 0;
79   static char *resv_reason = NULL;
80   static char *listener_address = NULL;
80 static int not_atom = 0;
81  
82 < struct CollectItem {
82 > struct CollectItem
83 > {
84    dlink_node node;
85    char *name;
86    char *user;
# Line 150 | Line 151 | unhook_hub_leaf_confs(void)
151   %token  BYTES KBYTES MBYTES GBYTES TBYTES
152   %token  CALLER_ID_WAIT
153   %token  CAN_FLOOD
153 %token  CAN_IDLE
154   %token  CHANNEL
155   %token  CIDR_BITLEN_IPV4
156   %token  CIDR_BITLEN_IPV6
157 %token  CIPHER_PREFERENCE
157   %token  CLASS
159 %token  COMPRESSED
160 %token  COMPRESSION_LEVEL
158   %token  CONNECT
159   %token  CONNECTFREQ
163 %token  CRYPTLINK
164 %token  DEFAULT_CIPHER_PREFERENCE
160   %token  DEFAULT_FLOODCOUNT
161   %token  DEFAULT_SPLIT_SERVER_COUNT
162   %token  DEFAULT_SPLIT_USER_COUNT
# Line 169 | Line 164 | unhook_hub_leaf_confs(void)
164   %token  DESCRIPTION
165   %token  DIE
166   %token  DISABLE_AUTH
167 + %token  DISABLE_FAKE_CHANNELS
168   %token  DISABLE_HIDDEN
169   %token  DISABLE_LOCAL_CHANNELS
170   %token  DISABLE_REMOTE_COMMANDS
175 %token  DOT_IN_IP6_ADDR
171   %token  DOTS_IN_IDENT
172   %token  DURATION
173   %token  EGDPOOL_PATH
# Line 182 | Line 177 | unhook_hub_leaf_confs(void)
177   %token  EXCEED_LIMIT
178   %token  EXEMPT
179   %token  FAILED_OPER_NOTICE
185 %token  FAKENAME
180   %token  IRCD_FLAGS
181   %token  FLATTEN_LINKS
188 %token  FFAILED_OPERLOG
189 %token  FKILLLOG
190 %token  FKLINELOG
191 %token  FGLINELOG
192 %token  FIOERRLOG
193 %token  FOPERLOG
194 %token  FOPERSPYLOG
195 %token  FUSERLOG
182   %token  GECOS
183   %token  GENERAL
184   %token  GLINE
185   %token  GLINES
186   %token  GLINE_EXEMPT
201 %token  GLINE_LOG
187   %token  GLINE_TIME
188   %token  GLINE_MIN_CIDR
189   %token  GLINE_MIN_CIDR6
# Line 207 | Line 192 | unhook_hub_leaf_confs(void)
192   %token  NEED_IDENT
193   %token  HAVENT_READ_CONF
194   %token  HIDDEN
210 %token  HIDDEN_ADMIN
195   %token  HIDDEN_NAME
212 %token  HIDDEN_OPER
196   %token  HIDE_SERVER_IPS
197   %token  HIDE_SERVERS
198   %token  HIDE_SPOOF_IPS
199   %token  HOST
200   %token  HUB
201   %token  HUB_MASK
219 %token  IDLETIME
202   %token  IGNORE_BOGUS_TS
203   %token  INVISIBLE_ON_CONNECT
204   %token  IP
# Line 228 | Line 210 | unhook_hub_leaf_confs(void)
210   %token  KLINE_WITH_REASON
211   %token  KNOCK_DELAY
212   %token  KNOCK_DELAY_CHANNEL
231 %token  LAZYLINK
213   %token  LEAF_MASK
214   %token  LINKS_DELAY
215   %token  LISTEN
216   %token  T_LOG
236 %token  LOGGING
237 %token  LOG_LEVEL
217   %token  MAX_ACCEPT
218   %token  MAX_BANS
219   %token  MAX_CHANS_PER_USER
# Line 245 | Line 224 | unhook_hub_leaf_confs(void)
224   %token  MAX_NICK_TIME
225   %token  MAX_NUMBER
226   %token  MAX_TARGETS
227 + %token  MAX_WATCH
228   %token  MESSAGE_LOCALE
229   %token  MIN_NONWILDCARD
230   %token  MIN_NONWILDCARD_SIMPLE
# Line 260 | Line 240 | unhook_hub_leaf_confs(void)
240   %token  NO_JOIN_ON_SPLIT
241   %token  NO_OPER_FLOOD
242   %token  NO_TILDE
263 %token  NOT
243   %token  NUMBER
244   %token  NUMBER_PER_IDENT
245   %token  NUMBER_PER_CIDR
# Line 268 | Line 247 | unhook_hub_leaf_confs(void)
247   %token  NUMBER_PER_IP_GLOBAL
248   %token  OPERATOR
249   %token  OPERS_BYPASS_CALLERID
271 %token  OPER_LOG
250   %token  OPER_ONLY_UMODES
251   %token  OPER_PASS_RESV
252   %token  OPER_SPY_T
253   %token  OPER_UMODES
276 %token  INVITE_OPS_ONLY
254   %token  JOIN_FLOOD_COUNT
255   %token  JOIN_FLOOD_TIME
256   %token  PACE_WAIT
# Line 299 | Line 276 | unhook_hub_leaf_confs(void)
276   %token  RSA_PRIVATE_KEY_FILE
277   %token  RSA_PUBLIC_KEY_FILE
278   %token  SSL_CERTIFICATE_FILE
279 + %token  SSL_DH_PARAM_FILE
280 + %token  T_SSL_CLIENT_METHOD
281 + %token  T_SSL_SERVER_METHOD
282 + %token  T_SSLV3
283 + %token  T_TLSV1
284   %token  RESV
285   %token  RESV_EXEMPT
286   %token  SECONDS MINUTES HOURS DAYS WEEKS
# Line 306 | Line 288 | unhook_hub_leaf_confs(void)
288   %token  SEND_PASSWORD
289   %token  SERVERHIDE
290   %token  SERVERINFO
309 %token  SERVLINK_PATH
291   %token  IRCD_SID
292   %token  TKLINE_EXPIRE_NOTICES
293   %token  T_SHARED
# Line 316 | Line 297 | unhook_hub_leaf_confs(void)
297   %token  SILENT
298   %token  SPOOF
299   %token  SPOOF_NOTICE
300 + %token  STATS_E_DISABLED
301   %token  STATS_I_OPER_ONLY
302   %token  STATS_K_OPER_ONLY
303   %token  STATS_O_OPER_ONLY
# Line 331 | Line 313 | unhook_hub_leaf_confs(void)
313   %token  T_SOFTCALLERID
314   %token  T_CALLERID
315   %token  T_CCONN
316 + %token  T_CCONN_FULL
317 + %token  T_SSL_CIPHER_LIST
318   %token  T_CLIENT_FLOOD
319   %token  T_DEAF
320   %token  T_DEBUG
321 + %token  T_DLINE
322   %token  T_DRONE
323   %token  T_EXTERNAL
324   %token  T_FULL
# Line 341 | Line 326 | unhook_hub_leaf_confs(void)
326   %token  T_IPV4
327   %token  T_IPV6
328   %token  T_LOCOPS
344 %token  T_LOGPATH
345 %token  T_L_CRIT
346 %token  T_L_DEBUG
347 %token  T_L_ERROR
348 %token  T_L_INFO
349 %token  T_L_NOTICE
350 %token  T_L_TRACE
351 %token  T_L_WARN
329   %token  T_MAX_CLIENTS
330   %token  T_NCHANGE
331   %token  T_OPERWALL
332   %token  T_REJ
333 + %token  T_SERVER
334   %token  T_SERVNOTICE
335   %token  T_SKILL
336   %token  T_SPY
337   %token  T_SSL
338 + %token  T_UMODES
339   %token  T_UNAUTH
340 + %token  T_UNDLINE
341 + %token  T_UNLIMITED
342   %token  T_UNRESV
343   %token  T_UNXLINE
344 + %token  T_GLOBOPS
345   %token  T_WALLOP
346 + %token  T_RESTART
347 + %token  T_SERVICE
348 + %token  T_SERVICES_NAME
349   %token  THROTTLE_TIME
350   %token  TOPICBURST
351   %token  TRUE_NO_OPER_FLOOD
# Line 380 | Line 365 | unhook_hub_leaf_confs(void)
365   %token  XLINE
366   %token  WARN
367   %token  WARN_NO_NLINE
368 + %token  T_SIZE
369 + %token  T_FILE
370  
371   %type <string> QSTRING
372   %type <number> NUMBER
# Line 403 | Line 390 | conf_item:        admin_entry
390                  | serverinfo_entry
391                  | serverhide_entry
392                  | resv_entry
393 +                | service_entry
394                  | shared_entry
395                  | cluster_entry
396                  | connect_entry
# Line 464 | Line 452 | modules_item:   modules_module | modules
452  
453   modules_module: MODULE '=' QSTRING ';'
454   {
455 < #ifndef STATIC_MODULES /* NOOP in the static case */
456 <  if (ypass == 2)
469 <  {
470 <    char *m_bn;
471 <
472 <    m_bn = basename(yylval.string);
473 <
474 <    /* I suppose we should just ignore it if it is already loaded(since
475 <     * otherwise we would flood the opers on rehash) -A1kmm.
476 <     */
477 <    add_conf_module(yylval.string);
478 <  }
479 < #endif
455 >  if (conf_parser_ctx.pass == 2)
456 >    add_conf_module(libio_basename(yylval.string));
457   };
458  
459   modules_path: PATH '=' QSTRING ';'
460   {
461 < #ifndef STATIC_MODULES
485 <  if (ypass == 2)
461 >  if (conf_parser_ctx.pass == 2)
462      mod_add_path(yylval.string);
487 #endif
463   };
464  
490 /***************************************************************************
491 *  section serverinfo
492 ***************************************************************************/
493 serverinfo_entry: SERVERINFO
494  '{' serverinfo_items '}' ';';
465  
466 < serverinfo_items:       serverinfo_items serverinfo_item |
467 <                        serverinfo_item ;
466 > serverinfo_entry: SERVERINFO '{' serverinfo_items '}' ';';
467 >
468 > serverinfo_items:       serverinfo_items serverinfo_item | serverinfo_item ;
469   serverinfo_item:        serverinfo_name | serverinfo_vhost |
470                          serverinfo_hub | serverinfo_description |
471                          serverinfo_network_name | serverinfo_network_desc |
472 <                        serverinfo_max_clients |
472 >                        serverinfo_max_clients | serverinfo_ssl_dh_param_file |
473                          serverinfo_rsa_private_key_file | serverinfo_vhost6 |
474                          serverinfo_sid | serverinfo_ssl_certificate_file |
475 +                        serverinfo_ssl_client_method | serverinfo_ssl_server_method |
476 +                        serverinfo_ssl_cipher_list |
477                          error ';' ;
478  
479 +
480 + serverinfo_ssl_client_method: T_SSL_CLIENT_METHOD '=' client_method_types ';' ;
481 + serverinfo_ssl_server_method: T_SSL_SERVER_METHOD '=' server_method_types ';' ;
482 +
483 + client_method_types: client_method_types ',' client_method_type_item | client_method_type_item;
484 + client_method_type_item: T_SSLV3
485 + {
486 + #ifdef HAVE_LIBCRYPTO
487 +  if (conf_parser_ctx.pass == 2 && ServerInfo.client_ctx)
488 +    SSL_CTX_clear_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv3);
489 + #endif
490 + } | T_TLSV1
491 + {
492 + #ifdef HAVE_LIBCRYPTO
493 +  if (conf_parser_ctx.pass == 2 && ServerInfo.client_ctx)
494 +    SSL_CTX_clear_options(ServerInfo.client_ctx, SSL_OP_NO_TLSv1);
495 + #endif
496 + };
497 +
498 + server_method_types: server_method_types ',' server_method_type_item | server_method_type_item;
499 + server_method_type_item: T_SSLV3
500 + {
501 + #ifdef HAVE_LIBCRYPTO
502 +  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
503 +    SSL_CTX_clear_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv3);
504 + #endif
505 + } | T_TLSV1
506 + {
507 + #ifdef HAVE_LIBCRYPTO
508 +  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
509 +    SSL_CTX_clear_options(ServerInfo.server_ctx, SSL_OP_NO_TLSv1);
510 + #endif
511 + };
512 +
513   serverinfo_ssl_certificate_file: SSL_CERTIFICATE_FILE '=' QSTRING ';'
514   {
515   #ifdef HAVE_LIBCRYPTO
516 <  if (ypass == 2 && ServerInfo.ctx)
516 >  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
517    {
518      if (!ServerInfo.rsa_private_key_file)
519      {
# Line 514 | Line 521 | serverinfo_ssl_certificate_file: SSL_CER
521        break;
522      }
523  
524 <    if (SSL_CTX_use_certificate_file(ServerInfo.ctx,
525 <      yylval.string, SSL_FILETYPE_PEM) <= 0)
524 >    if (SSL_CTX_use_certificate_file(ServerInfo.server_ctx, yylval.string,
525 >                                     SSL_FILETYPE_PEM) <= 0 ||
526 >        SSL_CTX_use_certificate_file(ServerInfo.client_ctx, yylval.string,
527 >                                     SSL_FILETYPE_PEM) <= 0)
528      {
529        yyerror(ERR_lib_error_string(ERR_get_error()));
530        break;
531      }
532  
533 <    if (SSL_CTX_use_PrivateKey_file(ServerInfo.ctx,
534 <      ServerInfo.rsa_private_key_file, SSL_FILETYPE_PEM) <= 0)
533 >    if (SSL_CTX_use_PrivateKey_file(ServerInfo.server_ctx, ServerInfo.rsa_private_key_file,
534 >                                    SSL_FILETYPE_PEM) <= 0 ||
535 >        SSL_CTX_use_PrivateKey_file(ServerInfo.client_ctx, ServerInfo.rsa_private_key_file,
536 >                                    SSL_FILETYPE_PEM) <= 0)
537      {
538        yyerror(ERR_lib_error_string(ERR_get_error()));
539        break;
540      }
541  
542 <    if (!SSL_CTX_check_private_key(ServerInfo.ctx))
542 >    if (!SSL_CTX_check_private_key(ServerInfo.server_ctx) ||
543 >        !SSL_CTX_check_private_key(ServerInfo.client_ctx))
544      {
545 <      yyerror("RSA private key does not match the SSL certificate public key!");
545 >      yyerror(ERR_lib_error_string(ERR_get_error()));
546        break;
547      }
548    }
# Line 540 | Line 552 | serverinfo_ssl_certificate_file: SSL_CER
552   serverinfo_rsa_private_key_file: RSA_PRIVATE_KEY_FILE '=' QSTRING ';'
553   {
554   #ifdef HAVE_LIBCRYPTO
555 <  if (ypass == 1)
555 >  if (conf_parser_ctx.pass == 1)
556    {
557      BIO *file;
558  
# Line 564 | Line 576 | serverinfo_rsa_private_key_file: RSA_PRI
576        break;
577      }
578  
579 <    ServerInfo.rsa_private_key = (RSA *)PEM_read_bio_RSAPrivateKey(file, NULL,
568 <      0, NULL);
579 >    ServerInfo.rsa_private_key = PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL);
580  
581      BIO_set_close(file, BIO_CLOSE);
582      BIO_free(file);
# Line 597 | Line 608 | serverinfo_rsa_private_key_file: RSA_PRI
608   #endif
609   };
610  
611 + serverinfo_ssl_dh_param_file: SSL_DH_PARAM_FILE '=' QSTRING ';'
612 + {
613 + /* TBD - XXX: error reporting */
614 + #ifdef HAVE_LIBCRYPTO
615 +  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
616 +  {
617 +    BIO *file = BIO_new_file(yylval.string, "r");
618 +
619 +    if (file)
620 +    {
621 +      DH *dh = PEM_read_bio_DHparams(file, NULL, NULL, NULL);
622 +
623 +      BIO_free(file);
624 +
625 +      if (dh)
626 +      {
627 +        if (DH_size(dh) < 128)
628 +          ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::ssl_dh_param_file -- need at least a 1024 bit DH prime size");
629 +        else
630 +          SSL_CTX_set_tmp_dh(ServerInfo.server_ctx, dh);
631 +
632 +        DH_free(dh);
633 +      }
634 +    }
635 +  }
636 + #endif
637 + };
638 +
639 + serverinfo_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
640 + {
641 + #ifdef HAVE_LIBCRYPTO
642 +  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
643 +    SSL_CTX_set_cipher_list(ServerInfo.server_ctx, yylval.string);
644 + #endif
645 + };
646 +
647   serverinfo_name: NAME '=' QSTRING ';'
648   {
649    /* this isn't rehashable */
650 <  if (ypass == 2)
650 >  if (conf_parser_ctx.pass == 2 && !ServerInfo.name)
651    {
652 <    if (ServerInfo.name == NULL)
652 >    if (valid_servname(yylval.string))
653 >      DupString(ServerInfo.name, yylval.string);
654 >    else
655      {
656 <      /* the ircd will exit() in main() if we dont set one */
657 <      if (strlen(yylval.string) <= HOSTLEN)
609 <        DupString(ServerInfo.name, yylval.string);
656 >      ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::name -- invalid name. Aborting.");
657 >      exit(0);
658      }
659    }
660   };
# Line 614 | Line 662 | serverinfo_name: NAME '=' QSTRING ';'
662   serverinfo_sid: IRCD_SID '=' QSTRING ';'
663   {
664    /* this isn't rehashable */
665 <  if (ypass == 2 && !ServerInfo.sid)
665 >  if (conf_parser_ctx.pass == 2 && !ServerInfo.sid)
666    {
667 <    if ((strlen(yylval.string) == IRC_MAXSID) && IsDigit(yylval.string[0])
620 <        && IsAlNum(yylval.string[1]) && IsAlNum(yylval.string[2]))
621 <    {
667 >    if (valid_sid(yylval.string))
668        DupString(ServerInfo.sid, yylval.string);
623    }
669      else
670      {
671 <      ilog(L_ERROR, "Ignoring config file entry SID -- invalid SID. Aborting.");
671 >      ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::sid -- invalid SID. Aborting.");
672        exit(0);
673      }
674    }
# Line 631 | Line 676 | serverinfo_sid: IRCD_SID '=' QSTRING ';'
676  
677   serverinfo_description: DESCRIPTION '=' QSTRING ';'
678   {
679 <  if (ypass == 2)
679 >  if (conf_parser_ctx.pass == 2)
680    {
681      MyFree(ServerInfo.description);
682      DupString(ServerInfo.description,yylval.string);
# Line 640 | Line 685 | serverinfo_description: DESCRIPTION '='
685  
686   serverinfo_network_name: NETWORK_NAME '=' QSTRING ';'
687   {
688 <  if (ypass == 2)
688 >  if (conf_parser_ctx.pass == 2)
689    {
690      char *p;
691  
# Line 654 | Line 699 | serverinfo_network_name: NETWORK_NAME '=
699  
700   serverinfo_network_desc: NETWORK_DESC '=' QSTRING ';'
701   {
702 <  if (ypass == 2)
702 >  if (conf_parser_ctx.pass == 2)
703    {
704      MyFree(ServerInfo.network_desc);
705      DupString(ServerInfo.network_desc, yylval.string);
# Line 663 | Line 708 | serverinfo_network_desc: NETWORK_DESC '=
708  
709   serverinfo_vhost: VHOST '=' QSTRING ';'
710   {
711 <  if (ypass == 2 && *yylval.string != '*')
711 >  if (conf_parser_ctx.pass == 2 && *yylval.string != '*')
712    {
713      struct addrinfo hints, *res;
714  
# Line 673 | Line 718 | serverinfo_vhost: VHOST '=' QSTRING ';'
718      hints.ai_socktype = SOCK_STREAM;
719      hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
720  
721 <    if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
722 <      ilog(L_ERROR, "Invalid netmask for server vhost(%s)", yylval.string);
721 >    if (getaddrinfo(yylval.string, NULL, &hints, &res))
722 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", yylval.string);
723      else
724      {
725        assert(res != NULL);
# Line 682 | Line 727 | serverinfo_vhost: VHOST '=' QSTRING ';'
727        memcpy(&ServerInfo.ip, res->ai_addr, res->ai_addrlen);
728        ServerInfo.ip.ss.ss_family = res->ai_family;
729        ServerInfo.ip.ss_len = res->ai_addrlen;
730 <      irc_freeaddrinfo(res);
730 >      freeaddrinfo(res);
731  
732        ServerInfo.specific_ipv4_vhost = 1;
733      }
# Line 692 | Line 737 | serverinfo_vhost: VHOST '=' QSTRING ';'
737   serverinfo_vhost6: VHOST6 '=' QSTRING ';'
738   {
739   #ifdef IPV6
740 <  if (ypass == 2 && *yylval.string != '*')
740 >  if (conf_parser_ctx.pass == 2 && *yylval.string != '*')
741    {
742      struct addrinfo hints, *res;
743  
# Line 702 | Line 747 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
747      hints.ai_socktype = SOCK_STREAM;
748      hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
749  
750 <    if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
751 <      ilog(L_ERROR, "Invalid netmask for server vhost6(%s)", yylval.string);
750 >    if (getaddrinfo(yylval.string, NULL, &hints, &res))
751 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost6(%s)", yylval.string);
752      else
753      {
754        assert(res != NULL);
# Line 711 | Line 756 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
756        memcpy(&ServerInfo.ip6, res->ai_addr, res->ai_addrlen);
757        ServerInfo.ip6.ss.ss_family = res->ai_family;
758        ServerInfo.ip6.ss_len = res->ai_addrlen;
759 <      irc_freeaddrinfo(res);
759 >      freeaddrinfo(res);
760  
761        ServerInfo.specific_ipv6_vhost = 1;
762      }
# Line 721 | Line 766 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
766  
767   serverinfo_max_clients: T_MAX_CLIENTS '=' NUMBER ';'
768   {
769 <  if (ypass == 2)
769 >  if (conf_parser_ctx.pass == 2)
770    {
771      recalc_fdlimit(NULL);
772  
# Line 744 | Line 789 | serverinfo_max_clients: T_MAX_CLIENTS '=
789  
790   serverinfo_hub: HUB '=' TBOOL ';'
791   {
792 <  if (ypass == 2)
793 <  {
749 <    if (yylval.number)
750 <    {
751 <      /* Don't become a hub if we have a lazylink active. */
752 <      if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
753 <      {
754 <        sendto_realops_flags(UMODE_ALL, L_ALL,
755 <                             "Ignoring config file line hub=yes; "
756 <                             "due to active LazyLink (%s)", uplink->name);
757 <      }
758 <      else
759 <      {
760 <        ServerInfo.hub = 1;
761 <        uplink = NULL;
762 <        delete_capability("HUB");
763 <        add_capability("HUB", CAP_HUB, 1);
764 <      }
765 <    }
766 <    else if (ServerInfo.hub)
767 <    {
768 <      dlink_node *ptr = NULL;
769 <
770 <      ServerInfo.hub = 0;
771 <      delete_capability("HUB");
772 <
773 <      /* Don't become a leaf if we have a lazylink active. */
774 <      DLINK_FOREACH(ptr, serv_list.head)
775 <      {
776 <        const struct Client *acptr = ptr->data;
777 <        if (MyConnect(acptr) && IsCapable(acptr, CAP_LL))
778 <        {
779 <          sendto_realops_flags(UMODE_ALL, L_ALL,
780 <                               "Ignoring config file line hub=no; "
781 <                               "due to active LazyLink (%s)",
782 <                               acptr->name);
783 <          add_capability("HUB", CAP_HUB, 1);
784 <          ServerInfo.hub = 1;
785 <          break;
786 <        }
787 <      }
788 <    }
789 <  }
792 >  if (conf_parser_ctx.pass == 2)
793 >    ServerInfo.hub = yylval.number;
794   };
795  
796   /***************************************************************************
# Line 800 | Line 804 | admin_item:  admin_name | admin_descript
804  
805   admin_name: NAME '=' QSTRING ';'
806   {
807 <  if (ypass == 2)
807 >  if (conf_parser_ctx.pass == 2)
808    {
809      MyFree(AdminInfo.name);
810      DupString(AdminInfo.name, yylval.string);
# Line 809 | Line 813 | admin_name: NAME '=' QSTRING ';'
813  
814   admin_email: EMAIL '=' QSTRING ';'
815   {
816 <  if (ypass == 2)
816 >  if (conf_parser_ctx.pass == 2)
817    {
818      MyFree(AdminInfo.email);
819      DupString(AdminInfo.email, yylval.string);
# Line 818 | Line 822 | admin_email: EMAIL '=' QSTRING ';'
822  
823   admin_description: DESCRIPTION '=' QSTRING ';'
824   {
825 <  if (ypass == 2)
825 >  if (conf_parser_ctx.pass == 2)
826    {
827      MyFree(AdminInfo.description);
828      DupString(AdminInfo.description, yylval.string);
# Line 828 | Line 832 | admin_description: DESCRIPTION '=' QSTRI
832   /***************************************************************************
833   *  section logging
834   ***************************************************************************/
835 < /* XXX */
836 < logging_entry:          LOGGING  '{' logging_items '}' ';' ;
833 <
834 < logging_items:          logging_items logging_item |
835 <                        logging_item ;
835 > logging_entry:          T_LOG  '{' logging_items '}' ';' ;
836 > logging_items:          logging_items logging_item | logging_item ;
837  
838 < logging_item:           logging_path | logging_oper_log |
838 <                        logging_log_level |
839 <                        logging_use_logging | logging_fuserlog |
840 <                        logging_foperlog | logging_fglinelog |
841 <                        logging_fklinelog | logging_killlog |
842 <                        logging_foperspylog | logging_ioerrlog |
843 <                        logging_ffailed_operlog |
838 > logging_item:           logging_use_logging | logging_file_entry |
839                          error ';' ;
840  
841 < logging_path:           T_LOGPATH '=' QSTRING ';'
847 <                        {
848 <                        };
849 <
850 < logging_oper_log:       OPER_LOG '=' QSTRING ';'
851 <                        {
852 <                        };
853 <
854 < logging_fuserlog: FUSERLOG '=' QSTRING ';'
841 > logging_use_logging: USE_LOGGING '=' TBOOL ';'
842   {
843 <  if (ypass == 2)
844 <    strlcpy(ConfigLoggingEntry.userlog, yylval.string,
858 <            sizeof(ConfigLoggingEntry.userlog));
843 >  if (conf_parser_ctx.pass == 2)
844 >    ConfigLoggingEntry.use_logging = yylval.number;
845   };
846  
847 < logging_ffailed_operlog: FFAILED_OPERLOG '=' QSTRING ';'
847 > logging_file_entry:
848   {
849 <  if (ypass == 2)
850 <    strlcpy(ConfigLoggingEntry.failed_operlog, yylval.string,
851 <            sizeof(ConfigLoggingEntry.failed_operlog));
852 < };
867 <
868 < logging_foperlog: FOPERLOG '=' QSTRING ';'
849 >  lfile[0] = '\0';
850 >  ltype = 0;
851 >  lsize = 0;
852 > } T_FILE  '{' logging_file_items '}' ';'
853   {
854 <  if (ypass == 2)
855 <    strlcpy(ConfigLoggingEntry.operlog, yylval.string,
872 <            sizeof(ConfigLoggingEntry.operlog));
854 >  if (conf_parser_ctx.pass == 2 && ltype > 0)
855 >    log_add_file(ltype, lsize, lfile);
856   };
857  
858 < logging_foperspylog: FOPERSPYLOG '=' QSTRING ';'
859 < {
877 <  if (ypass == 2)
878 <    strlcpy(ConfigLoggingEntry.operspylog, yylval.string,
879 <            sizeof(ConfigLoggingEntry.operspylog));
880 < };
858 > logging_file_items: logging_file_items logging_file_item |
859 >                    logging_file_item ;
860  
861 < logging_fglinelog: FGLINELOG '=' QSTRING ';'
862 < {
884 <  if (ypass == 2)
885 <    strlcpy(ConfigLoggingEntry.glinelog, yylval.string,
886 <            sizeof(ConfigLoggingEntry.glinelog));
887 < };
861 > logging_file_item:  logging_file_name | logging_file_type |
862 >                    logging_file_size | error ';' ;
863  
864 < logging_fklinelog: FKLINELOG '=' QSTRING ';'
864 > logging_file_name: NAME '=' QSTRING ';'
865   {
866 <  if (ypass == 2)
867 <    strlcpy(ConfigLoggingEntry.klinelog, yylval.string,
893 <            sizeof(ConfigLoggingEntry.klinelog));
894 < };
866 >  strlcpy(lfile, yylval.string, sizeof(lfile));
867 > }
868  
869 < logging_ioerrlog: FIOERRLOG '=' QSTRING ';'
869 > logging_file_size: T_SIZE '=' sizespec ';'
870   {
871 <  if (ypass == 2)
872 <    strlcpy(ConfigLoggingEntry.ioerrlog, yylval.string,
900 <            sizeof(ConfigLoggingEntry.ioerrlog));
901 < };
902 <
903 < logging_killlog: FKILLLOG '=' QSTRING ';'
871 >  lsize = $3;
872 > } | T_SIZE '=' T_UNLIMITED ';'
873   {
874 <  if (ypass == 2)
906 <    strlcpy(ConfigLoggingEntry.killlog, yylval.string,
907 <            sizeof(ConfigLoggingEntry.killlog));
874 >  lsize = 0;
875   };
876  
877 < logging_log_level: LOG_LEVEL '=' T_L_CRIT ';'
911 < {
912 <  if (ypass == 2)
913 <    set_log_level(L_CRIT);
914 < } | LOG_LEVEL '=' T_L_ERROR ';'
915 < {
916 <  if (ypass == 2)
917 <    set_log_level(L_ERROR);
918 < } | LOG_LEVEL '=' T_L_WARN ';'
919 < {
920 <  if (ypass == 2)
921 <    set_log_level(L_WARN);
922 < } | LOG_LEVEL '=' T_L_NOTICE ';'
923 < {
924 <  if (ypass == 2)
925 <    set_log_level(L_NOTICE);
926 < } | LOG_LEVEL '=' T_L_TRACE ';'
927 < {
928 <  if (ypass == 2)
929 <    set_log_level(L_TRACE);
930 < } | LOG_LEVEL '=' T_L_INFO ';'
931 < {
932 <  if (ypass == 2)
933 <    set_log_level(L_INFO);
934 < } | LOG_LEVEL '=' T_L_DEBUG ';'
877 > logging_file_type: TYPE
878   {
879 <  if (ypass == 2)
880 <    set_log_level(L_DEBUG);
881 < };
879 >  if (conf_parser_ctx.pass == 2)
880 >    ltype = 0;
881 > } '='  logging_file_type_items ';' ;
882  
883 < logging_use_logging: USE_LOGGING '=' TBOOL ';'
883 > logging_file_type_items: logging_file_type_items ',' logging_file_type_item | logging_file_type_item;
884 > logging_file_type_item:  USER
885   {
886 <  if (ypass == 2)
887 <    ConfigLoggingEntry.use_logging = yylval.number;
886 >  if (conf_parser_ctx.pass == 2)
887 >    ltype = LOG_TYPE_USER;
888 > } | OPERATOR
889 > {
890 >  if (conf_parser_ctx.pass == 2)
891 >    ltype = LOG_TYPE_OPER;
892 > } | GLINE
893 > {
894 >  if (conf_parser_ctx.pass == 2)
895 >    ltype = LOG_TYPE_GLINE;
896 > } | T_DLINE
897 > {
898 >  if (conf_parser_ctx.pass == 2)
899 >    ltype = LOG_TYPE_DLINE;
900 > } | KLINE
901 > {
902 >  if (conf_parser_ctx.pass == 2)
903 >    ltype = LOG_TYPE_KLINE;
904 > } | KILL
905 > {
906 >  if (conf_parser_ctx.pass == 2)
907 >    ltype = LOG_TYPE_KILL;
908 > } | T_DEBUG
909 > {
910 >  if (conf_parser_ctx.pass == 2)
911 >    ltype = LOG_TYPE_DEBUG;
912   };
913  
914 +
915   /***************************************************************************
916   * section oper
917   ***************************************************************************/
918   oper_entry: OPERATOR
919   {
920 <  if (ypass == 2)
920 >  if (conf_parser_ctx.pass == 2)
921    {
922      yy_conf = make_conf_item(OPER_TYPE);
923      yy_aconf = map_to_conf(yy_conf);
# Line 959 | Line 928 | oper_entry: OPERATOR
928      MyFree(class_name);
929      class_name = NULL;
930    }
931 < } oper_name_b '{' oper_items '}' ';'
931 > } '{' oper_items '}' ';'
932   {
933 <  if (ypass == 2)
933 >  if (conf_parser_ctx.pass == 2)
934    {
935      struct CollectItem *yy_tmp;
936      dlink_node *ptr;
# Line 994 | Line 963 | oper_entry: OPERATOR
963          DupString(new_aconf->host, yy_tmp->host);
964        else
965          DupString(new_aconf->host, "*");
966 +
967 +      new_aconf->type = parse_netmask(new_aconf->host, &new_aconf->ipnum,
968 +                                     &new_aconf->bits);
969 +
970        conf_add_class_to_conf(new_conf, class_name);
971        if (yy_aconf->passwd != NULL)
972          DupString(new_aconf->passwd, yy_aconf->passwd);
# Line 1040 | Line 1013 | oper_entry: OPERATOR
1013    }
1014   };
1015  
1043 oper_name_b: | oper_name_t;
1016   oper_items:     oper_items oper_item | oper_item;
1017 < oper_item:      oper_name | oper_user | oper_password | oper_hidden_admin |
1018 <                oper_hidden_oper |
1019 <                oper_class | oper_global_kill | oper_remote |
1048 <                oper_kline | oper_xline | oper_unkline |
1049 <                oper_gline | oper_nick_changes | oper_remoteban |
1050 <                oper_die | oper_rehash | oper_admin | oper_operwall |
1051 <                oper_encrypted | oper_rsa_public_key_file |
1052 <                oper_flags | error ';' ;
1017 > oper_item:      oper_name | oper_user | oper_password |
1018 >                oper_umodes | oper_class | oper_encrypted |
1019 >                oper_rsa_public_key_file | oper_flags | error ';' ;
1020  
1021   oper_name: NAME '=' QSTRING ';'
1022   {
1023 <  if (ypass == 2)
1023 >  if (conf_parser_ctx.pass == 2)
1024    {
1025      if (strlen(yylval.string) > OPERNICKLEN)
1026        yylval.string[OPERNICKLEN] = '\0';
# Line 1063 | Line 1030 | oper_name: NAME '=' QSTRING ';'
1030    }
1031   };
1032  
1033 < oper_name_t: QSTRING
1033 > oper_user: USER '=' QSTRING ';'
1034   {
1035 <  if (ypass == 2)
1035 >  if (conf_parser_ctx.pass == 2)
1036    {
1037 <    if (strlen(yylval.string) > OPERNICKLEN)
1071 <      yylval.string[OPERNICKLEN] = '\0';
1037 >    struct split_nuh_item nuh;
1038  
1039 <    MyFree(yy_conf->name);
1040 <    DupString(yy_conf->name, yylval.string);
1041 <  }
1042 < };
1039 >    nuh.nuhmask  = yylval.string;
1040 >    nuh.nickptr  = NULL;
1041 >    nuh.userptr  = userbuf;
1042 >    nuh.hostptr  = hostbuf;
1043  
1044 < oper_user: USER '=' QSTRING ';'
1045 < {
1046 <  if (ypass == 2)
1047 <  {
1048 <    struct CollectItem *yy_tmp;
1044 >    nuh.nicksize = 0;
1045 >    nuh.usersize = sizeof(userbuf);
1046 >    nuh.hostsize = sizeof(hostbuf);
1047 >
1048 >    split_nuh(&nuh);
1049  
1050      if (yy_aconf->user == NULL)
1051      {
1052 <      split_nuh(yylval.string, NULL, &yy_aconf->user, &yy_aconf->host);
1052 >      DupString(yy_aconf->user, userbuf);
1053 >      DupString(yy_aconf->host, hostbuf);
1054 >
1055 >      yy_aconf->type = parse_netmask(yy_aconf->host, &yy_aconf->ipnum,
1056 >                                    &yy_aconf->bits);
1057      }
1058      else
1059      {
1060 <      yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
1061 <      split_nuh(yylval.string, NULL, &yy_tmp->user, &yy_tmp->host);
1060 >      struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
1061 >
1062 >      DupString(yy_tmp->user, userbuf);
1063 >      DupString(yy_tmp->host, hostbuf);
1064 >
1065        dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1066      }
1067    }
# Line 1096 | Line 1069 | oper_user: USER '=' QSTRING ';'
1069  
1070   oper_password: PASSWORD '=' QSTRING ';'
1071   {
1072 <  if (ypass == 2)
1072 >  if (conf_parser_ctx.pass == 2)
1073    {
1074      if (yy_aconf->passwd != NULL)
1075        memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
# Line 1108 | Line 1081 | oper_password: PASSWORD '=' QSTRING ';'
1081  
1082   oper_encrypted: ENCRYPTED '=' TBOOL ';'
1083   {
1084 <  if (ypass == 2)
1084 >  if (conf_parser_ctx.pass == 2)
1085    {
1086      if (yylval.number)
1087        SetConfEncrypted(yy_aconf);
# Line 1120 | Line 1093 | oper_encrypted: ENCRYPTED '=' TBOOL ';'
1093   oper_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
1094   {
1095   #ifdef HAVE_LIBCRYPTO
1096 <  if (ypass == 2)
1096 >  if (conf_parser_ctx.pass == 2)
1097    {
1098      BIO *file;
1099  
# Line 1161 | Line 1134 | oper_rsa_public_key_file: RSA_PUBLIC_KEY
1134  
1135   oper_class: CLASS '=' QSTRING ';'
1136   {
1137 <  if (ypass == 2)
1137 >  if (conf_parser_ctx.pass == 2)
1138    {
1139      MyFree(class_name);
1140      DupString(class_name, yylval.string);
1141    }
1142   };
1143  
1144 < oper_global_kill: GLOBAL_KILL '=' TBOOL ';'
1144 > oper_umodes: T_UMODES
1145   {
1146 <  if (ypass == 2)
1147 <  {
1148 <    if (yylval.number)
1176 <      yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1177 <    else
1178 <      yy_aconf->port &= ~OPER_FLAG_GLOBAL_KILL;
1179 <  }
1180 < };
1146 >  if (conf_parser_ctx.pass == 2)
1147 >    yy_aconf->modes = 0;
1148 > } '='  oper_umodes_items ';' ;
1149  
1150 < oper_remote: REMOTE '=' TBOOL ';'
1150 > oper_umodes_items: oper_umodes_items ',' oper_umodes_item | oper_umodes_item;
1151 > oper_umodes_item:  T_BOTS
1152   {
1153 <  if (ypass == 2)
1154 <  {
1155 <    if (yylval.number)
1187 <      yy_aconf->port |= OPER_FLAG_REMOTE;
1188 <    else
1189 <      yy_aconf->port &= ~OPER_FLAG_REMOTE;
1190 <  }
1191 < };
1192 <
1193 < oper_remoteban: REMOTEBAN '=' TBOOL ';'
1153 >  if (conf_parser_ctx.pass == 2)
1154 >    yy_aconf->modes |= UMODE_BOTS;
1155 > } | T_CCONN
1156   {
1157 <  if (ypass == 2)
1158 <  {
1159 <    if (yylval.number)
1198 <      yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1199 <    else
1200 <      yy_aconf->port &= ~OPER_FLAG_REMOTEBAN;
1201 <  }
1202 < };
1203 <
1204 < oper_kline: KLINE '=' TBOOL ';'
1157 >  if (conf_parser_ctx.pass == 2)
1158 >    yy_aconf->modes |= UMODE_CCONN;
1159 > } | T_CCONN_FULL
1160   {
1161 <  if (ypass == 2)
1162 <  {
1163 <    if (yylval.number)
1209 <      yy_aconf->port |= OPER_FLAG_K;
1210 <    else
1211 <      yy_aconf->port &= ~OPER_FLAG_K;
1212 <  }
1213 < };
1214 <
1215 < oper_xline: XLINE '=' TBOOL ';'
1161 >  if (conf_parser_ctx.pass == 2)
1162 >    yy_aconf->modes |= UMODE_CCONN_FULL;
1163 > } | T_DEAF
1164   {
1165 <  if (ypass == 2)
1166 <  {
1167 <    if (yylval.number)
1220 <      yy_aconf->port |= OPER_FLAG_X;
1221 <    else
1222 <      yy_aconf->port &= ~OPER_FLAG_X;
1223 <  }
1224 < };
1225 <
1226 < oper_unkline: UNKLINE '=' TBOOL ';'
1165 >  if (conf_parser_ctx.pass == 2)
1166 >    yy_aconf->modes |= UMODE_DEAF;
1167 > } | T_DEBUG
1168   {
1169 <  if (ypass == 2)
1170 <  {
1171 <    if (yylval.number)
1231 <      yy_aconf->port |= OPER_FLAG_UNKLINE;
1232 <    else
1233 <      yy_aconf->port &= ~OPER_FLAG_UNKLINE;
1234 <  }
1235 < };
1236 <
1237 < oper_gline: GLINE '=' TBOOL ';'
1169 >  if (conf_parser_ctx.pass == 2)
1170 >    yy_aconf->modes |= UMODE_DEBUG;
1171 > } | T_FULL
1172   {
1173 <  if (ypass == 2)
1174 <  {
1175 <    if (yylval.number)
1242 <      yy_aconf->port |= OPER_FLAG_GLINE;
1243 <    else
1244 <      yy_aconf->port &= ~OPER_FLAG_GLINE;
1245 <  }
1246 < };
1247 <
1248 < oper_nick_changes: NICK_CHANGES '=' TBOOL ';'
1173 >  if (conf_parser_ctx.pass == 2)
1174 >    yy_aconf->modes |= UMODE_FULL;
1175 > } | HIDDEN
1176   {
1177 <  if (ypass == 2)
1178 <  {
1179 <    if (yylval.number)
1253 <      yy_aconf->port |= OPER_FLAG_N;
1254 <    else
1255 <      yy_aconf->port &= ~OPER_FLAG_N;
1256 <  }
1257 < };
1258 <
1259 < oper_die: DIE '=' TBOOL ';'
1177 >  if (conf_parser_ctx.pass == 2)
1178 >    yy_aconf->modes |= UMODE_HIDDEN;
1179 > } | T_SKILL
1180   {
1181 <  if (ypass == 2)
1182 <  {
1183 <    if (yylval.number)
1264 <      yy_aconf->port |= OPER_FLAG_DIE;
1265 <    else
1266 <      yy_aconf->port &= ~OPER_FLAG_DIE;
1267 <  }
1268 < };
1269 <
1270 < oper_rehash: REHASH '=' TBOOL ';'
1181 >  if (conf_parser_ctx.pass == 2)
1182 >    yy_aconf->modes |= UMODE_SKILL;
1183 > } | T_NCHANGE
1184   {
1185 <  if (ypass == 2)
1186 <  {
1187 <    if (yylval.number)
1275 <      yy_aconf->port |= OPER_FLAG_REHASH;
1276 <    else
1277 <      yy_aconf->port &= ~OPER_FLAG_REHASH;
1278 <  }
1279 < };
1280 <
1281 < oper_admin: ADMIN '=' TBOOL ';'
1185 >  if (conf_parser_ctx.pass == 2)
1186 >    yy_aconf->modes |= UMODE_NCHANGE;
1187 > } | T_REJ
1188   {
1189 <  if (ypass == 2)
1190 <  {
1191 <    if (yylval.number)
1286 <      yy_aconf->port |= OPER_FLAG_ADMIN;
1287 <    else
1288 <      yy_aconf->port &= ~OPER_FLAG_ADMIN;
1289 <  }
1290 < };
1291 <
1292 < oper_hidden_admin: HIDDEN_ADMIN '=' TBOOL ';'
1189 >  if (conf_parser_ctx.pass == 2)
1190 >    yy_aconf->modes |= UMODE_REJ;
1191 > } | T_UNAUTH
1192   {
1193 <  if (ypass == 2)
1194 <  {
1195 <    if (yylval.number)
1297 <      yy_aconf->port |= OPER_FLAG_HIDDEN_ADMIN;
1298 <    else
1299 <      yy_aconf->port &= ~OPER_FLAG_HIDDEN_ADMIN;
1300 <  }
1301 < };
1302 <
1303 < oper_hidden_oper: HIDDEN_OPER '=' TBOOL ';'
1193 >  if (conf_parser_ctx.pass == 2)
1194 >    yy_aconf->modes |= UMODE_UNAUTH;
1195 > } | T_SPY
1196   {
1197 <  if (ypass == 2)
1198 <  {
1199 <    if (yylval.number)
1308 <      yy_aconf->port |= OPER_FLAG_HIDDEN_OPER;
1309 <    else
1310 <      yy_aconf->port &= ~OPER_FLAG_HIDDEN_OPER;
1311 <  }
1312 < };
1313 <
1314 < oper_operwall: T_OPERWALL '=' TBOOL ';'
1197 >  if (conf_parser_ctx.pass == 2)
1198 >    yy_aconf->modes |= UMODE_SPY;
1199 > } | T_EXTERNAL
1200   {
1201 <  if (ypass == 2)
1202 <  {
1203 <    if (yylval.number)
1204 <      yy_aconf->port |= OPER_FLAG_OPERWALL;
1205 <    else
1206 <      yy_aconf->port &= ~OPER_FLAG_OPERWALL;
1207 <  }
1201 >  if (conf_parser_ctx.pass == 2)
1202 >    yy_aconf->modes |= UMODE_EXTERNAL;
1203 > } | T_OPERWALL
1204 > {
1205 >  if (conf_parser_ctx.pass == 2)
1206 >    yy_aconf->modes |= UMODE_OPERWALL;
1207 > } | T_SERVNOTICE
1208 > {
1209 >  if (conf_parser_ctx.pass == 2)
1210 >    yy_aconf->modes |= UMODE_SERVNOTICE;
1211 > } | T_INVISIBLE
1212 > {
1213 >  if (conf_parser_ctx.pass == 2)
1214 >    yy_aconf->modes |= UMODE_INVISIBLE;
1215 > } | T_WALLOP
1216 > {
1217 >  if (conf_parser_ctx.pass == 2)
1218 >    yy_aconf->modes |= UMODE_WALLOP;
1219 > } | T_SOFTCALLERID
1220 > {
1221 >  if (conf_parser_ctx.pass == 2)
1222 >    yy_aconf->modes |= UMODE_SOFTCALLERID;
1223 > } | T_CALLERID
1224 > {
1225 >  if (conf_parser_ctx.pass == 2)
1226 >    yy_aconf->modes |= UMODE_CALLERID;
1227 > } | T_LOCOPS
1228 > {
1229 >  if (conf_parser_ctx.pass == 2)
1230 >    yy_aconf->modes |= UMODE_LOCOPS;
1231   };
1232  
1233   oper_flags: IRCD_FLAGS
1234   {
1235 +  if (conf_parser_ctx.pass == 2)
1236 +    yy_aconf->port = 0;
1237   } '='  oper_flags_items ';';
1238  
1239   oper_flags_items: oper_flags_items ',' oper_flags_item | oper_flags_item;
1240 < oper_flags_item: NOT oper_flags_item_atom { not_atom = 1; }
1331 <                | oper_flags_item_atom { not_atom = 0; };
1332 <
1333 < oper_flags_item_atom: GLOBAL_KILL
1240 > oper_flags_item: GLOBAL_KILL
1241   {
1242 <  if (ypass == 2)
1243 <  {
1337 <    if (not_atom)yy_aconf->port &= ~OPER_FLAG_GLOBAL_KILL;
1338 <    else yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1339 <  }
1242 >  if (conf_parser_ctx.pass == 2)
1243 >    yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1244   } | REMOTE
1245   {
1246 <  if (ypass == 2)
1247 <  {
1344 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_REMOTE;
1345 <    else yy_aconf->port |= OPER_FLAG_REMOTE;
1346 <  }
1246 >  if (conf_parser_ctx.pass == 2)
1247 >    yy_aconf->port |= OPER_FLAG_REMOTE;
1248   } | KLINE
1249   {
1250 <  if (ypass == 2)
1251 <  {
1351 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_K;
1352 <    else yy_aconf->port |= OPER_FLAG_K;
1353 <  }
1250 >  if (conf_parser_ctx.pass == 2)
1251 >    yy_aconf->port |= OPER_FLAG_K;
1252   } | UNKLINE
1253   {
1254 <  if (ypass == 2)
1255 <  {
1256 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_UNKLINE;
1257 <    else yy_aconf->port |= OPER_FLAG_UNKLINE;
1258 <  }
1254 >  if (conf_parser_ctx.pass == 2)
1255 >    yy_aconf->port |= OPER_FLAG_UNKLINE;
1256 > } | T_DLINE
1257 > {
1258 >  if (conf_parser_ctx.pass == 2)
1259 >    yy_aconf->port |= OPER_FLAG_DLINE;
1260 > } | T_UNDLINE
1261 > {
1262 >  if (conf_parser_ctx.pass == 2)
1263 >    yy_aconf->port |= OPER_FLAG_UNDLINE;
1264   } | XLINE
1265   {
1266 <  if (ypass == 2)
1267 <  {
1365 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_X;
1366 <    else yy_aconf->port |= OPER_FLAG_X;
1367 <  }
1266 >  if (conf_parser_ctx.pass == 2)
1267 >    yy_aconf->port |= OPER_FLAG_X;
1268   } | GLINE
1269   {
1270 <  if (ypass == 2)
1271 <  {
1372 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_GLINE;
1373 <    else yy_aconf->port |= OPER_FLAG_GLINE;
1374 <  }
1270 >  if (conf_parser_ctx.pass == 2)
1271 >    yy_aconf->port |= OPER_FLAG_GLINE;
1272   } | DIE
1273   {
1274 <  if (ypass == 2)
1275 <  {
1276 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_DIE;
1277 <    else yy_aconf->port |= OPER_FLAG_DIE;
1278 <  }
1274 >  if (conf_parser_ctx.pass == 2)
1275 >    yy_aconf->port |= OPER_FLAG_DIE;
1276 > } | T_RESTART
1277 > {
1278 >  if (conf_parser_ctx.pass == 2)
1279 >    yy_aconf->port |= OPER_FLAG_RESTART;
1280   } | REHASH
1281   {
1282 <  if (ypass == 2)
1283 <  {
1386 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_REHASH;
1387 <    else yy_aconf->port |= OPER_FLAG_REHASH;
1388 <  }
1282 >  if (conf_parser_ctx.pass == 2)
1283 >    yy_aconf->port |= OPER_FLAG_REHASH;
1284   } | ADMIN
1285   {
1286 <  if (ypass == 2)
1287 <  {
1393 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_ADMIN;
1394 <    else yy_aconf->port |= OPER_FLAG_ADMIN;
1395 <  }
1396 < } | HIDDEN_ADMIN
1397 < {
1398 <  if (ypass == 2)
1399 <  {
1400 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_HIDDEN_ADMIN;
1401 <    else yy_aconf->port |= OPER_FLAG_HIDDEN_ADMIN;
1402 <  }
1286 >  if (conf_parser_ctx.pass == 2)
1287 >    yy_aconf->port |= OPER_FLAG_ADMIN;
1288   } | NICK_CHANGES
1289   {
1290 <  if (ypass == 2)
1291 <  {
1407 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_N;
1408 <    else yy_aconf->port |= OPER_FLAG_N;
1409 <  }
1290 >  if (conf_parser_ctx.pass == 2)
1291 >    yy_aconf->port |= OPER_FLAG_N;
1292   } | T_OPERWALL
1293   {
1294 <  if (ypass == 2)
1295 <  {
1296 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_OPERWALL;
1415 <    else yy_aconf->port |= OPER_FLAG_OPERWALL;
1416 <  }
1417 < } | OPER_SPY_T
1294 >  if (conf_parser_ctx.pass == 2)
1295 >    yy_aconf->port |= OPER_FLAG_OPERWALL;
1296 > } | T_GLOBOPS
1297   {
1298 <  if (ypass == 2)
1299 <  {
1300 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_OPER_SPY;
1422 <    else yy_aconf->port |= OPER_FLAG_OPER_SPY;
1423 <  }
1424 < } | HIDDEN_OPER
1298 >  if (conf_parser_ctx.pass == 2)
1299 >    yy_aconf->port |= OPER_FLAG_GLOBOPS;
1300 > } | OPER_SPY_T
1301   {
1302 <  if (ypass == 2)
1303 <  {
1428 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_HIDDEN_OPER;
1429 <    else yy_aconf->port |= OPER_FLAG_HIDDEN_OPER;
1430 <  }
1302 >  if (conf_parser_ctx.pass == 2)
1303 >    yy_aconf->port |= OPER_FLAG_OPER_SPY;
1304   } | REMOTEBAN
1305   {
1306 <  if (ypass == 2)
1307 <  {
1308 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_REMOTEBAN;
1436 <    else yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1437 <  }
1438 < } | ENCRYPTED
1306 >  if (conf_parser_ctx.pass == 2)
1307 >    yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1308 > } | MODULE
1309   {
1310 <  if (ypass == 2)
1311 <  {
1442 <    if (not_atom) ClearConfEncrypted(yy_aconf);
1443 <    else SetConfEncrypted(yy_aconf);
1444 <  }
1310 >  if (conf_parser_ctx.pass == 2)
1311 >    yy_aconf->port |= OPER_FLAG_MODULE;
1312   };
1313  
1314  
# Line 1450 | Line 1317 | oper_flags_item_atom: GLOBAL_KILL
1317   ***************************************************************************/
1318   class_entry: CLASS
1319   {
1320 <  if (ypass == 1)
1320 >  if (conf_parser_ctx.pass == 1)
1321    {
1322      yy_conf = make_conf_item(CLASS_TYPE);
1323 <    yy_class = (struct ClassItem *)map_to_conf(yy_conf);
1323 >    yy_class = map_to_conf(yy_conf);
1324    }
1325 < } class_name_b '{' class_items '}' ';'
1325 > } '{' class_items '}' ';'
1326   {
1327 <  if (ypass == 1)
1327 >  if (conf_parser_ctx.pass == 1)
1328    {
1329 <    struct ConfItem *cconf;
1329 >    struct ConfItem *cconf = NULL;
1330      struct ClassItem *class = NULL;
1331  
1332      if (yy_class_name == NULL)
1466    {
1333        delete_conf_item(yy_conf);
1468    }
1334      else
1335      {
1336 <      cconf = find_exact_name_conf(CLASS_TYPE, yy_class_name, NULL, NULL);
1336 >      cconf = find_exact_name_conf(CLASS_TYPE, NULL, yy_class_name, NULL, NULL);
1337  
1338        if (cconf != NULL)                /* The class existed already */
1339        {
1340 +        int user_count = 0;
1341 +
1342          rebuild_cidr_class(cconf, yy_class);
1343 <        class = (struct ClassItem *) map_to_conf(cconf);
1344 <        *class = *yy_class;
1343 >
1344 >        class = map_to_conf(cconf);
1345 >
1346 >        user_count = class->curr_user_count;
1347 >        memcpy(class, yy_class, sizeof(*class));
1348 >        class->curr_user_count = user_count;
1349 >        class->active = 1;
1350 >
1351          delete_conf_item(yy_conf);
1352  
1353          MyFree(cconf->name);            /* Allows case change of class name */
# Line 1484 | Line 1357 | class_entry: CLASS
1357        {
1358          MyFree(yy_conf->name);          /* just in case it was allocated */
1359          yy_conf->name = yy_class_name;
1360 +        yy_class->active = 1;
1361        }
1362      }
1363 +
1364      yy_class_name = NULL;
1365    }
1366   };
1367  
1493 class_name_b: | class_name_t;
1494
1368   class_items:    class_items class_item | class_item;
1369   class_item:     class_name |
1370                  class_cidr_bitlen_ipv4 | class_cidr_bitlen_ipv6 |
# Line 1509 | Line 1382 | class_item:     class_name |
1382  
1383   class_name: NAME '=' QSTRING ';'
1384   {
1385 <  if (ypass == 1)
1513 <  {
1514 <    MyFree(yy_class_name);
1515 <    DupString(yy_class_name, yylval.string);
1516 <  }
1517 < };
1518 <
1519 < class_name_t: QSTRING
1520 < {
1521 <  if (ypass == 1)
1385 >  if (conf_parser_ctx.pass == 1)
1386    {
1387      MyFree(yy_class_name);
1388      DupString(yy_class_name, yylval.string);
# Line 1527 | Line 1391 | class_name_t: QSTRING
1391  
1392   class_ping_time: PING_TIME '=' timespec ';'
1393   {
1394 <  if (ypass == 1)
1394 >  if (conf_parser_ctx.pass == 1)
1395      PingFreq(yy_class) = $3;
1396   };
1397  
1398   class_ping_warning: PING_WARNING '=' timespec ';'
1399   {
1400 <  if (ypass == 1)
1400 >  if (conf_parser_ctx.pass == 1)
1401      PingWarning(yy_class) = $3;
1402   };
1403  
1404   class_number_per_ip: NUMBER_PER_IP '=' NUMBER ';'
1405   {
1406 <  if (ypass == 1)
1406 >  if (conf_parser_ctx.pass == 1)
1407      MaxPerIp(yy_class) = $3;
1408   };
1409  
1410   class_connectfreq: CONNECTFREQ '=' timespec ';'
1411   {
1412 <  if (ypass == 1)
1412 >  if (conf_parser_ctx.pass == 1)
1413      ConFreq(yy_class) = $3;
1414   };
1415  
1416   class_max_number: MAX_NUMBER '=' NUMBER ';'
1417   {
1418 <  if (ypass == 1)
1418 >  if (conf_parser_ctx.pass == 1)
1419      MaxTotal(yy_class) = $3;
1420   };
1421  
1422   class_max_global: MAX_GLOBAL '=' NUMBER ';'
1423   {
1424 <  if (ypass == 1)
1424 >  if (conf_parser_ctx.pass == 1)
1425      MaxGlobal(yy_class) = $3;
1426   };
1427  
1428   class_max_local: MAX_LOCAL '=' NUMBER ';'
1429   {
1430 <  if (ypass == 1)
1430 >  if (conf_parser_ctx.pass == 1)
1431      MaxLocal(yy_class) = $3;
1432   };
1433  
1434   class_max_ident: MAX_IDENT '=' NUMBER ';'
1435   {
1436 <  if (ypass == 1)
1436 >  if (conf_parser_ctx.pass == 1)
1437      MaxIdent(yy_class) = $3;
1438   };
1439  
1440   class_sendq: SENDQ '=' sizespec ';'
1441   {
1442 <  if (ypass == 1)
1442 >  if (conf_parser_ctx.pass == 1)
1443      MaxSendq(yy_class) = $3;
1444   };
1445  
1446   class_cidr_bitlen_ipv4: CIDR_BITLEN_IPV4 '=' NUMBER ';'
1447   {
1448 <  if (ypass == 1)
1448 >  if (conf_parser_ctx.pass == 1)
1449      CidrBitlenIPV4(yy_class) = $3;
1450   };
1451  
1452   class_cidr_bitlen_ipv6: CIDR_BITLEN_IPV6 '=' NUMBER ';'
1453   {
1454 <  if (ypass == 1)
1454 >  if (conf_parser_ctx.pass == 1)
1455      CidrBitlenIPV6(yy_class) = $3;
1456   };
1457  
1458   class_number_per_cidr: NUMBER_PER_CIDR '=' NUMBER ';'
1459   {
1460 <  if (ypass == 1)
1460 >  if (conf_parser_ctx.pass == 1)
1461      NumberPerCidr(yy_class) = $3;
1462   };
1463  
# Line 1602 | Line 1466 | class_number_per_cidr: NUMBER_PER_CIDR '
1466   ***************************************************************************/
1467   listen_entry: LISTEN
1468   {
1469 <  if (ypass == 2)
1469 >  if (conf_parser_ctx.pass == 2)
1470    {
1471      listener_address = NULL;
1472      listener_flags = 0;
1473    }
1474   } '{' listen_items '}' ';'
1475   {
1476 <  if (ypass == 2)
1476 >  if (conf_parser_ctx.pass == 2)
1477    {
1478      MyFree(listener_address);
1479      listener_address = NULL;
# Line 1618 | Line 1482 | listen_entry: LISTEN
1482  
1483   listen_flags: IRCD_FLAGS
1484   {
1485 +  listener_flags = 0;
1486   } '='  listen_flags_items ';';
1487  
1488   listen_flags_items: listen_flags_items ',' listen_flags_item | listen_flags_item;
1489   listen_flags_item: T_SSL
1490   {
1491 <  if (ypass == 2)
1491 >  if (conf_parser_ctx.pass == 2)
1492      listener_flags |= LISTENER_SSL;
1493   } | HIDDEN
1494   {
1495 <  if (ypass == 2)
1495 >  if (conf_parser_ctx.pass == 2)
1496      listener_flags |= LISTENER_HIDDEN;
1497 + } | T_SERVER
1498 + {
1499 +  if (conf_parser_ctx.pass == 2)
1500 +    listener_flags |= LISTENER_SERVER;
1501   };
1502  
1503 +
1504 +
1505   listen_items:   listen_items listen_item | listen_item;
1506 < listen_item:    listen_port | listen_flags | listen_address | listen_host | error ';' ;
1506 > listen_item:    listen_port | listen_flags | listen_address | listen_host | error ';';
1507  
1508 < listen_port: PORT '=' port_items ';' ;
1508 > listen_port: PORT '=' port_items { listener_flags = 0; } ';';
1509  
1510   port_items: port_items ',' port_item | port_item;
1511  
1512   port_item: NUMBER
1513   {
1514 <  if (ypass == 2)
1514 >  if (conf_parser_ctx.pass == 2)
1515    {
1516      if ((listener_flags & LISTENER_SSL))
1517   #ifdef HAVE_LIBCRYPTO
1518 <      if (!ServerInfo.ctx)
1518 >      if (!ServerInfo.server_ctx)
1519   #endif
1520        {
1521          yyerror("SSL not available - port closed");
1522          break;
1523        }
1524      add_listener($1, listener_address, listener_flags);
1654    listener_flags = 0;
1525    }
1526   } | NUMBER TWODOTS NUMBER
1527   {
1528 <  if (ypass == 2)
1528 >  if (conf_parser_ctx.pass == 2)
1529    {
1530      int i;
1531  
1532      if ((listener_flags & LISTENER_SSL))
1533   #ifdef HAVE_LIBCRYPTO
1534 <      if (!ServerInfo.ctx)
1534 >      if (!ServerInfo.server_ctx)
1535   #endif
1536        {
1537          yyerror("SSL not available - port closed");
# Line 1670 | Line 1540 | port_item: NUMBER
1540  
1541      for (i = $1; i <= $3; ++i)
1542        add_listener(i, listener_address, listener_flags);
1673
1674    listener_flags = 0;
1543    }
1544   };
1545  
1546   listen_address: IP '=' QSTRING ';'
1547   {
1548 <  if (ypass == 2)
1548 >  if (conf_parser_ctx.pass == 2)
1549    {
1550      MyFree(listener_address);
1551      DupString(listener_address, yylval.string);
# Line 1686 | Line 1554 | listen_address: IP '=' QSTRING ';'
1554  
1555   listen_host: HOST '=' QSTRING ';'
1556   {
1557 <  if (ypass == 2)
1557 >  if (conf_parser_ctx.pass == 2)
1558    {
1559      MyFree(listener_address);
1560      DupString(listener_address, yylval.string);
# Line 1698 | Line 1566 | listen_host: HOST '=' QSTRING ';'
1566   ***************************************************************************/
1567   auth_entry: IRCD_AUTH
1568   {
1569 <  if (ypass == 2)
1569 >  if (conf_parser_ctx.pass == 2)
1570    {
1571      yy_conf = make_conf_item(CLIENT_TYPE);
1572      yy_aconf = map_to_conf(yy_conf);
# Line 1710 | Line 1578 | auth_entry: IRCD_AUTH
1578    }
1579   } '{' auth_items '}' ';'
1580   {
1581 <  if (ypass == 2)
1581 >  if (conf_parser_ctx.pass == 2)
1582    {
1583      struct CollectItem *yy_tmp = NULL;
1584      dlink_node *ptr = NULL, *next_ptr = NULL;
# Line 1767 | Line 1635 | auth_entry: IRCD_AUTH
1635  
1636   auth_items:     auth_items auth_item | auth_item;
1637   auth_item:      auth_user | auth_passwd | auth_class | auth_flags |
1638 <                auth_kline_exempt | auth_need_ident |
1639 <                auth_exceed_limit | auth_no_tilde | auth_gline_exempt |
1772 <                auth_spoof | auth_spoof_notice |
1773 <                auth_redir_serv | auth_redir_port | auth_can_flood |
1774 <                auth_need_password | auth_encrypted | error ';' ;
1638 >                auth_spoof | auth_redir_serv | auth_redir_port |
1639 >                auth_encrypted | error ';' ;
1640  
1641   auth_user: USER '=' QSTRING ';'
1642   {
1643 <  if (ypass == 2)
1643 >  if (conf_parser_ctx.pass == 2)
1644    {
1645 <    struct CollectItem *yy_tmp;
1645 >    struct CollectItem *yy_tmp = NULL;
1646 >    struct split_nuh_item nuh;
1647 >
1648 >    nuh.nuhmask  = yylval.string;
1649 >    nuh.nickptr  = NULL;
1650 >    nuh.userptr  = userbuf;
1651 >    nuh.hostptr  = hostbuf;
1652 >
1653 >    nuh.nicksize = 0;
1654 >    nuh.usersize = sizeof(userbuf);
1655 >    nuh.hostsize = sizeof(hostbuf);
1656 >
1657 >    split_nuh(&nuh);
1658  
1659      if (yy_aconf->user == NULL)
1660 <      split_nuh(yylval.string, NULL, &yy_aconf->user, &yy_aconf->host);
1660 >    {
1661 >      DupString(yy_aconf->user, userbuf);
1662 >      DupString(yy_aconf->host, hostbuf);
1663 >    }
1664      else
1665      {
1666        yy_tmp = MyMalloc(sizeof(struct CollectItem));
1667 <      split_nuh(yylval.string, NULL, &yy_tmp->user, &yy_tmp->host);
1667 >
1668 >      DupString(yy_tmp->user, userbuf);
1669 >      DupString(yy_tmp->host, hostbuf);
1670 >
1671        dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1672      }
1673    }
# Line 1794 | Line 1677 | auth_user: USER '=' QSTRING ';'
1677  
1678   auth_passwd: PASSWORD '=' QSTRING ';'
1679   {
1680 <  if (ypass == 2)
1680 >  if (conf_parser_ctx.pass == 2)
1681    {
1682      /* be paranoid */
1683      if (yy_aconf->passwd != NULL)
# Line 1805 | Line 1688 | auth_passwd: PASSWORD '=' QSTRING ';'
1688    }
1689   };
1690  
1808 auth_spoof_notice: SPOOF_NOTICE '=' TBOOL ';'
1809 {
1810  if (ypass == 2)
1811  {
1812    if (yylval.number)
1813      yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1814    else
1815      yy_aconf->flags &= ~CONF_FLAGS_SPOOF_NOTICE;
1816  }
1817 };
1818
1691   auth_class: CLASS '=' QSTRING ';'
1692   {
1693 <  if (ypass == 2)
1693 >  if (conf_parser_ctx.pass == 2)
1694    {
1695      MyFree(class_name);
1696      DupString(class_name, yylval.string);
# Line 1827 | Line 1699 | auth_class: CLASS '=' QSTRING ';'
1699  
1700   auth_encrypted: ENCRYPTED '=' TBOOL ';'
1701   {
1702 <  if (ypass == 2)
1702 >  if (conf_parser_ctx.pass == 2)
1703    {
1704      if (yylval.number)
1705        SetConfEncrypted(yy_aconf);
# Line 1841 | Line 1713 | auth_flags: IRCD_FLAGS
1713   } '='  auth_flags_items ';';
1714  
1715   auth_flags_items: auth_flags_items ',' auth_flags_item | auth_flags_item;
1716 < auth_flags_item: NOT auth_flags_item_atom { not_atom = 1; }
1845 <                | auth_flags_item_atom { not_atom = 0; };
1846 <
1847 < auth_flags_item_atom: SPOOF_NOTICE
1716 > auth_flags_item: SPOOF_NOTICE
1717   {
1718 <  if (ypass == 2)
1719 <  {
1851 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_SPOOF_NOTICE;
1852 <    else yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1853 <  }
1854 <
1718 >  if (conf_parser_ctx.pass == 2)
1719 >    yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1720   } | EXCEED_LIMIT
1721   {
1722 <  if (ypass == 2)
1723 <  {
1859 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NOLIMIT;
1860 <    else yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
1861 <  }
1722 >  if (conf_parser_ctx.pass == 2)
1723 >    yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
1724   } | KLINE_EXEMPT
1725   {
1726 <  if (ypass == 2)
1727 <  {
1866 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTKLINE;
1867 <    else yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
1868 <  }
1726 >  if (conf_parser_ctx.pass == 2)
1727 >    yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
1728   } | NEED_IDENT
1729   {
1730 <  if (ypass == 2)
1731 <  {
1873 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NEED_IDENTD;
1874 <    else yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
1875 <  }
1730 >  if (conf_parser_ctx.pass == 2)
1731 >    yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
1732   } | CAN_FLOOD
1733   {
1734 <  if (ypass == 2)
1735 <  {
1880 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_CAN_FLOOD;
1881 <    else yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
1882 <  }
1883 < } | CAN_IDLE
1884 < {
1885 <  if (ypass == 2)
1886 <  {
1887 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_IDLE_LINED;
1888 <    else yy_aconf->flags |= CONF_FLAGS_IDLE_LINED;
1889 <  }
1734 >  if (conf_parser_ctx.pass == 2)
1735 >    yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
1736   } | NO_TILDE
1737   {
1738 <  if (ypass == 2)
1739 <  {
1894 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NO_TILDE;
1895 <    else yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
1896 <  }
1738 >  if (conf_parser_ctx.pass == 2)
1739 >    yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
1740   } | GLINE_EXEMPT
1741   {
1742 <  if (ypass == 2)
1743 <  {
1901 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTGLINE;
1902 <    else yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
1903 <  }
1742 >  if (conf_parser_ctx.pass == 2)
1743 >    yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
1744   } | RESV_EXEMPT
1745   {
1746 <  if (ypass == 2)
1747 <  {
1908 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTRESV;
1909 <    else yy_aconf->flags |= CONF_FLAGS_EXEMPTRESV;
1910 <  }
1746 >  if (conf_parser_ctx.pass == 2)
1747 >    yy_aconf->flags |= CONF_FLAGS_EXEMPTRESV;
1748   } | NEED_PASSWORD
1749   {
1750 <  if (ypass == 2)
1751 <  {
1915 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NEED_PASSWORD;
1916 <    else yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
1917 <  }
1918 < };
1919 <
1920 < auth_kline_exempt: KLINE_EXEMPT '=' TBOOL ';'
1921 < {
1922 <  if (ypass == 2)
1923 <  {
1924 <    if (yylval.number)
1925 <      yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
1926 <    else
1927 <      yy_aconf->flags &= ~CONF_FLAGS_EXEMPTKLINE;
1928 <  }
1929 < };
1930 <
1931 < auth_need_ident: NEED_IDENT '=' TBOOL ';'
1932 < {
1933 <  if (ypass == 2)
1934 <  {
1935 <    if (yylval.number)
1936 <      yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
1937 <    else
1938 <      yy_aconf->flags &= ~CONF_FLAGS_NEED_IDENTD;
1939 <  }
1940 < };
1941 <
1942 < auth_exceed_limit: EXCEED_LIMIT '=' TBOOL ';'
1943 < {
1944 <  if (ypass == 2)
1945 <  {
1946 <    if (yylval.number)
1947 <      yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
1948 <    else
1949 <      yy_aconf->flags &= ~CONF_FLAGS_NOLIMIT;
1950 <  }
1951 < };
1952 <
1953 < auth_can_flood: CAN_FLOOD '=' TBOOL ';'
1954 < {
1955 <  if (ypass == 2)
1956 <  {
1957 <    if (yylval.number)
1958 <      yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
1959 <    else
1960 <      yy_aconf->flags &= ~CONF_FLAGS_CAN_FLOOD;
1961 <  }
1962 < };
1963 <
1964 < auth_no_tilde: NO_TILDE '=' TBOOL ';'
1965 < {
1966 <  if (ypass == 2)
1967 <  {
1968 <    if (yylval.number)
1969 <      yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
1970 <    else
1971 <      yy_aconf->flags &= ~CONF_FLAGS_NO_TILDE;
1972 <  }
1973 < };
1974 <
1975 < auth_gline_exempt: GLINE_EXEMPT '=' TBOOL ';'
1976 < {
1977 <  if (ypass == 2)
1978 <  {
1979 <    if (yylval.number)
1980 <      yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
1981 <    else
1982 <      yy_aconf->flags &= ~CONF_FLAGS_EXEMPTGLINE;
1983 <  }
1750 >  if (conf_parser_ctx.pass == 2)
1751 >    yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
1752   };
1753  
1754   /* XXX - need check for illegal hostnames here */
1755   auth_spoof: SPOOF '=' QSTRING ';'
1756   {
1757 <  if (ypass == 2)
1757 >  if (conf_parser_ctx.pass == 2)
1758    {
1759      MyFree(yy_conf->name);
1760  
# Line 1997 | Line 1765 | auth_spoof: SPOOF '=' QSTRING ';'
1765      }
1766      else
1767      {
1768 <      ilog(L_ERROR, "Spoofs must be less than %d..ignoring it", HOSTLEN);
1768 >      ilog(LOG_TYPE_IRCD, "Spoofs must be less than %d..ignoring it", HOSTLEN);
1769        yy_conf->name = NULL;
1770      }
1771    }
# Line 2005 | Line 1773 | auth_spoof: SPOOF '=' QSTRING ';'
1773  
1774   auth_redir_serv: REDIRSERV '=' QSTRING ';'
1775   {
1776 <  if (ypass == 2)
1776 >  if (conf_parser_ctx.pass == 2)
1777    {
1778      yy_aconf->flags |= CONF_FLAGS_REDIR;
1779      MyFree(yy_conf->name);
# Line 2015 | Line 1783 | auth_redir_serv: REDIRSERV '=' QSTRING '
1783  
1784   auth_redir_port: REDIRPORT '=' NUMBER ';'
1785   {
1786 <  if (ypass == 2)
1786 >  if (conf_parser_ctx.pass == 2)
1787    {
1788      yy_aconf->flags |= CONF_FLAGS_REDIR;
1789      yy_aconf->port = $3;
1790    }
1791   };
1792  
2025 auth_need_password: NEED_PASSWORD '=' TBOOL ';'
2026 {
2027  if (ypass == 2)
2028  {
2029    if (yylval.number)
2030      yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
2031    else
2032      yy_aconf->flags &= ~CONF_FLAGS_NEED_PASSWORD;
2033  }
2034 };
2035
1793  
1794   /***************************************************************************
1795   *  section resv
1796   ***************************************************************************/
1797   resv_entry: RESV
1798   {
1799 <  if (ypass == 2)
1799 >  if (conf_parser_ctx.pass == 2)
1800    {
1801      MyFree(resv_reason);
1802      resv_reason = NULL;
1803    }
1804   } '{' resv_items '}' ';'
1805   {
1806 <  if (ypass == 2)
1806 >  if (conf_parser_ctx.pass == 2)
1807    {
1808      MyFree(resv_reason);
1809      resv_reason = NULL;
# Line 2058 | Line 1815 | resv_item:     resv_creason | resv_channel |
1815  
1816   resv_creason: REASON '=' QSTRING ';'
1817   {
1818 <  if (ypass == 2)
1818 >  if (conf_parser_ctx.pass == 2)
1819    {
1820      MyFree(resv_reason);
1821      DupString(resv_reason, yylval.string);
# Line 2067 | Line 1824 | resv_creason: REASON '=' QSTRING ';'
1824  
1825   resv_channel: CHANNEL '=' QSTRING ';'
1826   {
1827 <  if (ypass == 2)
1827 >  if (conf_parser_ctx.pass == 2)
1828    {
1829      if (IsChanPrefix(*yylval.string))
1830      {
# Line 2082 | Line 1839 | resv_channel: CHANNEL '=' QSTRING ';'
1839  
1840   resv_nick: NICK '=' QSTRING ';'
1841   {
1842 <  if (ypass == 2)
1842 >  if (conf_parser_ctx.pass == 2)
1843    {
1844      char def_reason[] = "No reason";
1845  
# Line 2091 | Line 1848 | resv_nick: NICK '=' QSTRING ';'
1848   };
1849  
1850   /***************************************************************************
1851 + *  section service
1852 + ***************************************************************************/
1853 + service_entry: T_SERVICE '{' service_items '}' ';';
1854 +
1855 + service_items:     service_items service_item | service_item;
1856 + service_item:      service_name | error;
1857 +
1858 + service_name: NAME '=' QSTRING ';'
1859 + {
1860 +  if (conf_parser_ctx.pass == 2)
1861 +  {
1862 +    if (valid_servname(yylval.string))
1863 +    {
1864 +      yy_conf = make_conf_item(SERVICE_TYPE);
1865 +      DupString(yy_conf->name, yylval.string);
1866 +    }
1867 +  }
1868 + };
1869 +
1870 + /***************************************************************************
1871   *  section shared, for sharing remote klines etc.
1872   ***************************************************************************/
1873   shared_entry: T_SHARED
1874   {
1875 <  if (ypass == 2)
1875 >  if (conf_parser_ctx.pass == 2)
1876    {
1877      yy_conf = make_conf_item(ULINE_TYPE);
1878      yy_match_item = map_to_conf(yy_conf);
# Line 2103 | Line 1880 | shared_entry: T_SHARED
1880    }
1881   } '{' shared_items '}' ';'
1882   {
1883 <  if (ypass == 2)
1883 >  if (conf_parser_ctx.pass == 2)
1884    {
1885      yy_conf = NULL;
1886    }
# Line 2114 | Line 1891 | shared_item:  shared_name | shared_user
1891  
1892   shared_name: NAME '=' QSTRING ';'
1893   {
1894 <  if (ypass == 2)
1894 >  if (conf_parser_ctx.pass == 2)
1895    {
1896      MyFree(yy_conf->name);
1897      DupString(yy_conf->name, yylval.string);
# Line 2123 | Line 1900 | shared_name: NAME '=' QSTRING ';'
1900  
1901   shared_user: USER '=' QSTRING ';'
1902   {
1903 <  if (ypass == 2)
1903 >  if (conf_parser_ctx.pass == 2)
1904    {
1905 <    split_nuh(yylval.string, NULL, &yy_match_item->user, &yy_match_item->host);
1905 >    struct split_nuh_item nuh;
1906 >
1907 >    nuh.nuhmask  = yylval.string;
1908 >    nuh.nickptr  = NULL;
1909 >    nuh.userptr  = userbuf;
1910 >    nuh.hostptr  = hostbuf;
1911 >
1912 >    nuh.nicksize = 0;
1913 >    nuh.usersize = sizeof(userbuf);
1914 >    nuh.hostsize = sizeof(hostbuf);
1915 >
1916 >    split_nuh(&nuh);
1917 >
1918 >    DupString(yy_match_item->user, userbuf);
1919 >    DupString(yy_match_item->host, hostbuf);
1920    }
1921   };
1922  
1923   shared_type: TYPE
1924   {
1925 <  if (ypass == 2)
1925 >  if (conf_parser_ctx.pass == 2)
1926      yy_match_item->action = 0;
1927   } '=' shared_types ';' ;
1928  
1929   shared_types: shared_types ',' shared_type_item | shared_type_item;
1930   shared_type_item: KLINE
1931   {
1932 <  if (ypass == 2)
1932 >  if (conf_parser_ctx.pass == 2)
1933      yy_match_item->action |= SHARED_KLINE;
2143 } | TKLINE
2144 {
2145  if (ypass == 2)
2146    yy_match_item->action |= SHARED_TKLINE;
1934   } | UNKLINE
1935   {
1936 <  if (ypass == 2)
1936 >  if (conf_parser_ctx.pass == 2)
1937      yy_match_item->action |= SHARED_UNKLINE;
1938 + } | T_DLINE
1939 + {
1940 +  if (conf_parser_ctx.pass == 2)
1941 +    yy_match_item->action |= SHARED_DLINE;
1942 + } | T_UNDLINE
1943 + {
1944 +  if (conf_parser_ctx.pass == 2)
1945 +    yy_match_item->action |= SHARED_UNDLINE;
1946   } | XLINE
1947   {
1948 <  if (ypass == 2)
1948 >  if (conf_parser_ctx.pass == 2)
1949      yy_match_item->action |= SHARED_XLINE;
2155 } | TXLINE
2156 {
2157  if (ypass == 2)
2158    yy_match_item->action |= SHARED_TXLINE;
1950   } | T_UNXLINE
1951   {
1952 <  if (ypass == 2)
1952 >  if (conf_parser_ctx.pass == 2)
1953      yy_match_item->action |= SHARED_UNXLINE;
1954   } | RESV
1955   {
1956 <  if (ypass == 2)
1956 >  if (conf_parser_ctx.pass == 2)
1957      yy_match_item->action |= SHARED_RESV;
2167 } | TRESV
2168 {
2169  if (ypass == 2)
2170    yy_match_item->action |= SHARED_TRESV;
1958   } | T_UNRESV
1959   {
1960 <  if (ypass == 2)
1960 >  if (conf_parser_ctx.pass == 2)
1961      yy_match_item->action |= SHARED_UNRESV;
1962   } | T_LOCOPS
1963   {
1964 <  if (ypass == 2)
1964 >  if (conf_parser_ctx.pass == 2)
1965      yy_match_item->action |= SHARED_LOCOPS;
1966   } | T_ALL
1967   {
1968 <  if (ypass == 2)
1968 >  if (conf_parser_ctx.pass == 2)
1969      yy_match_item->action = SHARED_ALL;
1970   };
1971  
# Line 2187 | Line 1974 | shared_type_item: KLINE
1974   ***************************************************************************/
1975   cluster_entry: T_CLUSTER
1976   {
1977 <  if (ypass == 2)
1977 >  if (conf_parser_ctx.pass == 2)
1978    {
1979      yy_conf = make_conf_item(CLUSTER_TYPE);
1980      yy_conf->flags = SHARED_ALL;
1981    }
1982   } '{' cluster_items '}' ';'
1983   {
1984 <  if (ypass == 2)
1984 >  if (conf_parser_ctx.pass == 2)
1985    {
1986      if (yy_conf->name == NULL)
1987        DupString(yy_conf->name, "*");
# Line 2207 | Line 1994 | cluster_item:  cluster_name | cluster_typ
1994  
1995   cluster_name: NAME '=' QSTRING ';'
1996   {
1997 <  if (ypass == 2)
1997 >  if (conf_parser_ctx.pass == 2)
1998      DupString(yy_conf->name, yylval.string);
1999   };
2000  
2001   cluster_type: TYPE
2002   {
2003 <  if (ypass == 2)
2003 >  if (conf_parser_ctx.pass == 2)
2004      yy_conf->flags = 0;
2005   } '=' cluster_types ';' ;
2006  
2007   cluster_types:  cluster_types ',' cluster_type_item | cluster_type_item;
2008   cluster_type_item: KLINE
2009   {
2010 <  if (ypass == 2)
2010 >  if (conf_parser_ctx.pass == 2)
2011      yy_conf->flags |= SHARED_KLINE;
2225 } | TKLINE
2226 {
2227  if (ypass == 2)
2228    yy_conf->flags |= SHARED_TKLINE;
2012   } | UNKLINE
2013   {
2014 <  if (ypass == 2)
2014 >  if (conf_parser_ctx.pass == 2)
2015      yy_conf->flags |= SHARED_UNKLINE;
2016 + } | T_DLINE
2017 + {
2018 +  if (conf_parser_ctx.pass == 2)
2019 +    yy_conf->flags |= SHARED_DLINE;
2020 + } | T_UNDLINE
2021 + {
2022 +  if (conf_parser_ctx.pass == 2)
2023 +    yy_conf->flags |= SHARED_UNDLINE;
2024   } | XLINE
2025   {
2026 <  if (ypass == 2)
2026 >  if (conf_parser_ctx.pass == 2)
2027      yy_conf->flags |= SHARED_XLINE;
2237 } | TXLINE
2238 {
2239  if (ypass == 2)
2240    yy_conf->flags |= SHARED_TXLINE;
2028   } | T_UNXLINE
2029   {
2030 <  if (ypass == 2)
2030 >  if (conf_parser_ctx.pass == 2)
2031      yy_conf->flags |= SHARED_UNXLINE;
2032   } | RESV
2033   {
2034 <  if (ypass == 2)
2034 >  if (conf_parser_ctx.pass == 2)
2035      yy_conf->flags |= SHARED_RESV;
2249 } | TRESV
2250 {
2251  if (ypass == 2)
2252    yy_conf->flags |= SHARED_TRESV;
2036   } | T_UNRESV
2037   {
2038 <  if (ypass == 2)
2038 >  if (conf_parser_ctx.pass == 2)
2039      yy_conf->flags |= SHARED_UNRESV;
2040   } | T_LOCOPS
2041   {
2042 <  if (ypass == 2)
2042 >  if (conf_parser_ctx.pass == 2)
2043      yy_conf->flags |= SHARED_LOCOPS;
2044   } | T_ALL
2045   {
2046 <  if (ypass == 2)
2046 >  if (conf_parser_ctx.pass == 2)
2047      yy_conf->flags = SHARED_ALL;
2048   };
2049  
# Line 2269 | Line 2052 | cluster_type_item: KLINE
2052   ***************************************************************************/
2053   connect_entry: CONNECT  
2054   {
2055 <  if (ypass == 2)
2055 >  if (conf_parser_ctx.pass == 2)
2056    {
2057      yy_conf = make_conf_item(SERVER_TYPE);
2058 <    yy_aconf = (struct AccessItem *)map_to_conf(yy_conf);
2059 <    yy_aconf->passwd = NULL;
2058 >    yy_aconf = map_to_conf(yy_conf);
2059 >
2060      /* defaults */
2061      yy_aconf->port = PORTNUM;
2279
2280    if (ConfigFileEntry.burst_away)
2281      yy_aconf->flags = CONF_FLAGS_BURST_AWAY;
2062    }
2063    else
2064    {
2065      MyFree(class_name);
2066      class_name = NULL;
2067    }
2068 < } connect_name_b '{' connect_items '}' ';'
2068 > } '{' connect_items '}' ';'
2069   {
2070 <  if (ypass == 2)
2070 >  if (conf_parser_ctx.pass == 2)
2071    {
2072      struct CollectItem *yy_hconf=NULL;
2073      struct CollectItem *yy_lconf=NULL;
2074 <    dlink_node *ptr;
2075 <    dlink_node *next_ptr;
2296 < #ifdef HAVE_LIBCRYPTO
2074 >    dlink_node *ptr = NULL, *next_ptr = NULL;
2075 >
2076      if (yy_aconf->host &&
2077 <        ((yy_aconf->passwd && yy_aconf->spasswd) ||
2078 <         (yy_aconf->rsa_public_key && IsConfCryptLink(yy_aconf))))
2079 < #else /* !HAVE_LIBCRYPTO */
2080 <      if (yy_aconf->host && !IsConfCryptLink(yy_aconf) &&
2081 <          yy_aconf->passwd && yy_aconf->spasswd)
2082 < #endif /* !HAVE_LIBCRYPTO */
2083 <        {
2084 <          if (conf_add_server(yy_conf, scount, class_name) >= 0)
2085 <          {
2086 <            ++scount;
2087 <          }
2088 <          else
2089 <          {
2090 <            delete_conf_item(yy_conf);
2091 <            yy_conf = NULL;
2092 <            yy_aconf = NULL;
2093 <          }
2094 <        }
2095 <        else
2096 <        {
2097 <          /* Even if yy_conf ->name is NULL
2098 <           * should still unhook any hub/leaf confs still pending
2099 <           */
2321 <          unhook_hub_leaf_confs();
2322 <
2323 <          if (yy_conf->name != NULL)
2324 <          {
2325 < #ifndef HAVE_LIBCRYPTO
2326 <            if (IsConfCryptLink(yy_aconf))
2327 <              yyerror("Ignoring connect block -- no OpenSSL support");
2328 < #else
2329 <            if (IsConfCryptLink(yy_aconf) && !yy_aconf->rsa_public_key)
2330 <              yyerror("Ignoring connect block -- missing key");
2331 < #endif
2332 <            if (yy_aconf->host == NULL)
2333 <              yyerror("Ignoring connect block -- missing host");
2334 <            else if (!IsConfCryptLink(yy_aconf) &&
2335 <                    (!yy_aconf->passwd || !yy_aconf->spasswd))
2336 <              yyerror("Ignoring connect block -- missing password");
2337 <          }
2338 <
2339 <
2340 <          /* XXX
2341 <           * This fixes a try_connections() core (caused by invalid class_ptr
2342 <           * pointers) reported by metalrock. That's an ugly fix, but there
2343 <           * is currently no better way. The entire config subsystem needs an
2344 <           * rewrite ASAP. make_conf_item() shouldn't really add things onto
2345 <           * a doubly linked list immediately without any sanity checks!  -Michael
2346 <           */
2347 <          delete_conf_item(yy_conf);
2077 >        yy_aconf->passwd && yy_aconf->spasswd)
2078 >    {
2079 >      if (conf_add_server(yy_conf, class_name) == -1)
2080 >      {
2081 >        delete_conf_item(yy_conf);
2082 >        yy_conf = NULL;
2083 >        yy_aconf = NULL;
2084 >      }
2085 >    }
2086 >    else
2087 >    {
2088 >      /* Even if yy_conf ->name is NULL
2089 >       * should still unhook any hub/leaf confs still pending
2090 >       */
2091 >      unhook_hub_leaf_confs();
2092 >
2093 >      if (yy_conf->name != NULL)
2094 >      {
2095 >        if (yy_aconf->host == NULL)
2096 >          yyerror("Ignoring connect block -- missing host");
2097 >        else if (!yy_aconf->passwd || !yy_aconf->spasswd)
2098 >          yyerror("Ignoring connect block -- missing password");
2099 >      }
2100  
2101 <          yy_aconf = NULL;
2102 <          yy_conf = NULL;
2103 <        }
2101 >
2102 >      /* XXX
2103 >       * This fixes a try_connections() core (caused by invalid class_ptr
2104 >       * pointers) reported by metalrock. That's an ugly fix, but there
2105 >       * is currently no better way. The entire config subsystem needs an
2106 >       * rewrite ASAP. make_conf_item() shouldn't really add things onto
2107 >       * a doubly linked list immediately without any sanity checks!  -Michael
2108 >       */
2109 >      delete_conf_item(yy_conf);
2110 >
2111 >      yy_aconf = NULL;
2112 >      yy_conf = NULL;
2113 >    }
2114  
2115        /*
2116         * yy_conf is still pointing at the server that is having
# Line 2417 | Line 2179 | connect_entry: CONNECT
2179    }
2180   };
2181  
2420 connect_name_b: | connect_name_t;
2182   connect_items:  connect_items connect_item | connect_item;
2183   connect_item:   connect_name | connect_host | connect_vhost |
2184                  connect_send_password | connect_accept_password |
2185 <                connect_aftype | connect_port |
2186 <                connect_fakename | connect_flags | connect_hub_mask |
2187 <                connect_leaf_mask | connect_class | connect_auto |
2427 <                connect_encrypted | connect_compressed | connect_cryptlink |
2428 <                connect_rsa_public_key_file | connect_cipher_preference |
2185 >                connect_aftype | connect_port | connect_ssl_cipher_list |
2186 >                connect_flags | connect_hub_mask | connect_leaf_mask |
2187 >                connect_class | connect_encrypted |
2188                  error ';' ;
2189  
2190   connect_name: NAME '=' QSTRING ';'
2191   {
2192 <  if (ypass == 2)
2434 <  {
2435 <    if (yy_conf->name != NULL)
2436 <      yyerror("Multiple connect name entry");
2437 <
2438 <    MyFree(yy_conf->name);
2439 <    DupString(yy_conf->name, yylval.string);
2440 <  }
2441 < };
2442 <
2443 < connect_name_t: QSTRING
2444 < {
2445 <  if (ypass == 2)
2192 >  if (conf_parser_ctx.pass == 2)
2193    {
2194      if (yy_conf->name != NULL)
2195        yyerror("Multiple connect name entry");
# Line 2454 | Line 2201 | connect_name_t: QSTRING
2201  
2202   connect_host: HOST '=' QSTRING ';'
2203   {
2204 <  if (ypass == 2)
2204 >  if (conf_parser_ctx.pass == 2)
2205    {
2206      MyFree(yy_aconf->host);
2207      DupString(yy_aconf->host, yylval.string);
# Line 2463 | Line 2210 | connect_host: HOST '=' QSTRING ';'
2210  
2211   connect_vhost: VHOST '=' QSTRING ';'
2212   {
2213 <  if (ypass == 2)
2213 >  if (conf_parser_ctx.pass == 2)
2214    {
2215      struct addrinfo hints, *res;
2216  
# Line 2473 | Line 2220 | connect_vhost: VHOST '=' QSTRING ';'
2220      hints.ai_socktype = SOCK_STREAM;
2221      hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
2222  
2223 <    if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
2224 <      ilog(L_ERROR, "Invalid netmask for server vhost(%s)", yylval.string);
2223 >    if (getaddrinfo(yylval.string, NULL, &hints, &res))
2224 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", yylval.string);
2225      else
2226      {
2227        assert(res != NULL);
# Line 2482 | Line 2229 | connect_vhost: VHOST '=' QSTRING ';'
2229        memcpy(&yy_aconf->my_ipnum, res->ai_addr, res->ai_addrlen);
2230        yy_aconf->my_ipnum.ss.ss_family = res->ai_family;
2231        yy_aconf->my_ipnum.ss_len = res->ai_addrlen;
2232 <      irc_freeaddrinfo(res);
2232 >      freeaddrinfo(res);
2233      }
2234    }
2235   };
2236  
2237   connect_send_password: SEND_PASSWORD '=' QSTRING ';'
2238   {
2239 <  if (ypass == 2)
2239 >  if (conf_parser_ctx.pass == 2)
2240    {
2241 <    if (yy_aconf->spasswd != NULL)
2242 <      memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd));
2241 >    if ($3[0] == ':')
2242 >      yyerror("Server passwords cannot begin with a colon");
2243 >    else if (strchr($3, ' ') != NULL)
2244 >      yyerror("Server passwords cannot contain spaces");
2245 >    else {
2246 >      if (yy_aconf->spasswd != NULL)
2247 >        memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd));
2248  
2249 <    MyFree(yy_aconf->spasswd);
2250 <    DupString(yy_aconf->spasswd, yylval.string);
2249 >      MyFree(yy_aconf->spasswd);
2250 >      DupString(yy_aconf->spasswd, yylval.string);
2251 >    }
2252    }
2253   };
2254  
2255   connect_accept_password: ACCEPT_PASSWORD '=' QSTRING ';'
2256   {
2257 <  if (ypass == 2)
2257 >  if (conf_parser_ctx.pass == 2)
2258    {
2259 <    if (yy_aconf->passwd != NULL)
2260 <      memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
2259 >    if ($3[0] == ':')
2260 >      yyerror("Server passwords cannot begin with a colon");
2261 >    else if (strchr($3, ' ') != NULL)
2262 >      yyerror("Server passwords cannot contain spaces");
2263 >    else {
2264 >      if (yy_aconf->passwd != NULL)
2265 >        memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
2266  
2267 <    MyFree(yy_aconf->passwd);
2268 <    DupString(yy_aconf->passwd, yylval.string);
2267 >      MyFree(yy_aconf->passwd);
2268 >      DupString(yy_aconf->passwd, yylval.string);
2269 >    }
2270    }
2271   };
2272  
2273   connect_port: PORT '=' NUMBER ';'
2274   {
2275 <  if (ypass == 2)
2275 >  if (conf_parser_ctx.pass == 2)
2276      yy_aconf->port = $3;
2277   };
2278  
2279   connect_aftype: AFTYPE '=' T_IPV4 ';'
2280   {
2281 <  if (ypass == 2)
2281 >  if (conf_parser_ctx.pass == 2)
2282      yy_aconf->aftype = AF_INET;
2283   } | AFTYPE '=' T_IPV6 ';'
2284   {
2285   #ifdef IPV6
2286 <  if (ypass == 2)
2286 >  if (conf_parser_ctx.pass == 2)
2287      yy_aconf->aftype = AF_INET6;
2288   #endif
2289   };
2290  
2532 connect_fakename: FAKENAME '=' QSTRING ';'
2533 {
2534  if (ypass == 2)
2535  {
2536    MyFree(yy_aconf->fakename);
2537    DupString(yy_aconf->fakename, yylval.string);
2538  }
2539 };
2540
2291   connect_flags: IRCD_FLAGS
2292   {
2293   } '='  connect_flags_items ';';
2294  
2295   connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;
2296 < connect_flags_item: NOT connect_flags_item_atom { not_atom = 1; }
2547 <                        | connect_flags_item_atom { not_atom = 0; };
2548 <
2549 < connect_flags_item_atom: LAZYLINK
2550 < {
2551 <  if (ypass == 2)
2552 <  {
2553 <    if (not_atom)ClearConfLazyLink(yy_aconf);
2554 <    else SetConfLazyLink(yy_aconf);
2555 <  }
2556 < } | COMPRESSED
2557 < {
2558 <  if (ypass == 2)
2559 < #ifndef HAVE_LIBZ
2560 <    yyerror("Ignoring flags = compressed; -- no zlib support");
2561 < #else
2562 < {
2563 <   if (not_atom)ClearConfCompressed(yy_aconf);
2564 <   else SetConfCompressed(yy_aconf);
2565 < }
2566 < #endif
2567 < } | CRYPTLINK
2568 < {
2569 <  if (ypass == 2)
2570 <  {
2571 <    if (not_atom)ClearConfCryptLink(yy_aconf);
2572 <    else SetConfCryptLink(yy_aconf);
2573 <  }
2574 < } | AUTOCONN
2296 > connect_flags_item: AUTOCONN
2297   {
2298 <  if (ypass == 2)
2299 <  {
2578 <    if (not_atom)ClearConfAllowAutoConn(yy_aconf);
2579 <    else SetConfAllowAutoConn(yy_aconf);
2580 <  }
2298 >  if (conf_parser_ctx.pass == 2)
2299 >    SetConfAllowAutoConn(yy_aconf);
2300   } | BURST_AWAY
2301   {
2302 <  if (ypass == 2)
2303 <  {
2585 <    if (not_atom)ClearConfAwayBurst(yy_aconf);
2586 <    else SetConfAwayBurst(yy_aconf);
2587 <  }
2302 >  if (conf_parser_ctx.pass == 2)
2303 >    SetConfAwayBurst(yy_aconf);
2304   } | TOPICBURST
2305   {
2306 <  if (ypass == 2)
2307 <  {
2308 <    if (not_atom)ClearConfTopicBurst(yy_aconf);
2593 <    else SetConfTopicBurst(yy_aconf);
2594 <  }
2595 < }
2596 < ;
2597 <
2598 < connect_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
2306 >  if (conf_parser_ctx.pass == 2)
2307 >    SetConfTopicBurst(yy_aconf);
2308 > } | T_SSL
2309   {
2310 < #ifdef HAVE_LIBCRYPTO
2311 <  if (ypass == 2)
2602 <  {
2603 <    BIO *file;
2604 <
2605 <    if (yy_aconf->rsa_public_key != NULL)
2606 <    {
2607 <      RSA_free(yy_aconf->rsa_public_key);
2608 <      yy_aconf->rsa_public_key = NULL;
2609 <    }
2610 <
2611 <    if (yy_aconf->rsa_public_key_file != NULL)
2612 <    {
2613 <      MyFree(yy_aconf->rsa_public_key_file);
2614 <      yy_aconf->rsa_public_key_file = NULL;
2615 <    }
2616 <
2617 <    DupString(yy_aconf->rsa_public_key_file, yylval.string);
2618 <
2619 <    if ((file = BIO_new_file(yylval.string, "r")) == NULL)
2620 <    {
2621 <      yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
2622 <      break;
2623 <    }
2624 <
2625 <    yy_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
2626 <
2627 <    if (yy_aconf->rsa_public_key == NULL)
2628 <    {
2629 <      yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
2630 <      break;
2631 <    }
2632 <      
2633 <    BIO_set_close(file, BIO_CLOSE);
2634 <    BIO_free(file);
2635 <  }
2636 < #endif /* HAVE_LIBCRYPTO */
2310 >  if (conf_parser_ctx.pass == 2)
2311 >    SetConfSSL(yy_aconf);
2312   };
2313  
2314   connect_encrypted: ENCRYPTED '=' TBOOL ';'
2315   {
2316 <  if (ypass == 2)
2316 >  if (conf_parser_ctx.pass == 2)
2317    {
2318      if (yylval.number)
2319        yy_aconf->flags |= CONF_FLAGS_ENCRYPTED;
# Line 2647 | Line 2322 | connect_encrypted: ENCRYPTED '=' TBOOL '
2322    }
2323   };
2324  
2650 connect_cryptlink: CRYPTLINK '=' TBOOL ';'
2651 {
2652  if (ypass == 2)
2653  {
2654    if (yylval.number)
2655      yy_aconf->flags |= CONF_FLAGS_CRYPTLINK;
2656    else
2657      yy_aconf->flags &= ~CONF_FLAGS_CRYPTLINK;
2658  }
2659 };
2660
2661 connect_compressed: COMPRESSED '=' TBOOL ';'
2662 {
2663  if (ypass == 2)
2664  {
2665    if (yylval.number)
2666 #ifndef HAVE_LIBZ
2667      yyerror("Ignoring compressed=yes; -- no zlib support");
2668 #else
2669      yy_aconf->flags |= CONF_FLAGS_COMPRESSED;
2670 #endif
2671    else
2672      yy_aconf->flags &= ~CONF_FLAGS_COMPRESSED;
2673  }
2674 };
2675
2676 connect_auto: AUTOCONN '=' TBOOL ';'
2677 {
2678  if (ypass == 2)
2679  {
2680    if (yylval.number)
2681      yy_aconf->flags |= CONF_FLAGS_ALLOW_AUTO_CONN;
2682    else
2683      yy_aconf->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN;
2684  }
2685 };
2686
2325   connect_hub_mask: HUB_MASK '=' QSTRING ';'
2326   {
2327 <  if (ypass == 2)
2327 >  if (conf_parser_ctx.pass == 2)
2328    {
2329      struct CollectItem *yy_tmp;
2330  
# Line 2699 | Line 2337 | connect_hub_mask: HUB_MASK '=' QSTRING '
2337  
2338   connect_leaf_mask: LEAF_MASK '=' QSTRING ';'
2339   {
2340 <  if (ypass == 2)
2340 >  if (conf_parser_ctx.pass == 2)
2341    {
2342      struct CollectItem *yy_tmp;
2343  
# Line 2712 | Line 2350 | connect_leaf_mask: LEAF_MASK '=' QSTRING
2350  
2351   connect_class: CLASS '=' QSTRING ';'
2352   {
2353 <  if (ypass == 2)
2353 >  if (conf_parser_ctx.pass == 2)
2354    {
2355      MyFree(class_name);
2356      DupString(class_name, yylval.string);
2357    }
2358   };
2359  
2360 < connect_cipher_preference: CIPHER_PREFERENCE '=' QSTRING ';'
2360 > connect_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
2361   {
2362   #ifdef HAVE_LIBCRYPTO
2363 <  if (ypass == 2)
2363 >  if (conf_parser_ctx.pass == 2)
2364    {
2365 <    struct EncCapability *ecap;
2366 <    const char *cipher_name;
2729 <    int found = 0;
2730 <
2731 <    yy_aconf->cipher_preference = NULL;
2732 <    cipher_name = yylval.string;
2733 <
2734 <    for (ecap = CipherTable; ecap->name; ecap++)
2735 <    {
2736 <      if ((irccmp(ecap->name, cipher_name) == 0) &&
2737 <          (ecap->cap & CAP_ENC_MASK))
2738 <      {
2739 <        yy_aconf->cipher_preference = ecap;
2740 <        found = 1;
2741 <        break;
2742 <      }
2743 <    }
2744 <
2745 <    if (!found)
2746 <      yyerror("Invalid cipher");
2365 >    MyFree(yy_aconf->cipher_list);
2366 >    DupString(yy_aconf->cipher_list, yylval.string);
2367    }
2368   #else
2369 <  if (ypass == 2)
2370 <    yyerror("Ignoring cipher_preference -- no OpenSSL support");
2369 >  if (conf_parser_ctx.pass == 2)
2370 >    yyerror("Ignoring connect::ciphers -- no OpenSSL support");
2371   #endif
2372   };
2373  
2374 +
2375   /***************************************************************************
2376   *  section kill
2377   ***************************************************************************/
2378   kill_entry: KILL
2379   {
2380 <  if (ypass == 2)
2380 >  if (conf_parser_ctx.pass == 2)
2381    {
2382      userbuf[0] = hostbuf[0] = reasonbuf[0] = '\0';
2383      regex_ban = 0;
2384    }
2385   } '{' kill_items '}' ';'
2386   {
2387 <  if (ypass == 2)
2387 >  if (conf_parser_ctx.pass == 2)
2388    {
2389      if (userbuf[0] && hostbuf[0])
2390      {
2391        if (regex_ban)
2392        {
2393 <        pcre *exp_user = NULL;
2394 <        pcre *exp_host = NULL;
2393 > #ifdef HAVE_LIBPCRE
2394 >        void *exp_user = NULL;
2395 >        void *exp_host = NULL;
2396          const char *errptr = NULL;
2397  
2398          if (!(exp_user = ircd_pcre_compile(userbuf, &errptr)) ||
2399              !(exp_host = ircd_pcre_compile(hostbuf, &errptr)))
2400          {
2401 <          ilog(L_ERROR, "Failed to add regular expression based K-Line: %s", errptr);
2401 >          ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: %s",
2402 >               errptr);
2403            break;
2404          }
2405  
2406 <        yy_conf = make_conf_item(RKLINE_TYPE);
2406 >        yy_aconf = map_to_conf(make_conf_item(RKLINE_TYPE));
2407          yy_aconf->regexuser = exp_user;
2408          yy_aconf->regexhost = exp_host;
2409  
# Line 2791 | Line 2414 | kill_entry: KILL
2414            DupString(yy_aconf->reason, reasonbuf);
2415          else
2416            DupString(yy_aconf->reason, "No reason");
2417 + #else
2418 +        ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: no PCRE support");
2419 +        break;
2420 + #endif
2421        }
2422        else
2423        {
2424 <        yy_conf = make_conf_item(KLINE_TYPE);
2798 <        yy_aconf = map_to_conf(yy_conf);
2424 >        yy_aconf = map_to_conf(make_conf_item(KLINE_TYPE));
2425  
2426          DupString(yy_aconf->user, userbuf);
2427          DupString(yy_aconf->host, hostbuf);
# Line 2807 | Line 2433 | kill_entry: KILL
2433          add_conf_by_address(CONF_KILL, yy_aconf);
2434        }
2435      }
2810    else
2811      delete_conf_item(yy_conf);
2436  
2813    yy_conf = NULL;
2437      yy_aconf = NULL;
2438    }
2439   };
# Line 2822 | Line 2445 | kill_type: TYPE
2445   kill_type_items: kill_type_items ',' kill_type_item | kill_type_item;
2446   kill_type_item: REGEX_T
2447   {
2448 <  if (ypass == 2)
2448 >  if (conf_parser_ctx.pass == 2)
2449      regex_ban = 1;
2450   };
2451  
# Line 2831 | Line 2454 | kill_item:      kill_user | kill_reason
2454  
2455   kill_user: USER '=' QSTRING ';'
2456   {
2457 <  if (ypass == 2)
2457 >  if (conf_parser_ctx.pass == 2)
2458    {
2459 <    char *user = NULL, *host = NULL;
2459 >    struct split_nuh_item nuh;
2460  
2461 <    split_nuh(yylval.string, NULL, &user, &host);
2461 >    nuh.nuhmask  = yylval.string;
2462 >    nuh.nickptr  = NULL;
2463 >    nuh.userptr  = userbuf;
2464 >    nuh.hostptr  = hostbuf;
2465  
2466 <    strlcpy(userbuf, user, sizeof(userbuf));
2467 <    strlcpy(hostbuf, host, sizeof(hostbuf));
2466 >    nuh.nicksize = 0;
2467 >    nuh.usersize = sizeof(userbuf);
2468 >    nuh.hostsize = sizeof(hostbuf);
2469  
2470 <    MyFree(user);
2844 <    MyFree(host);
2470 >    split_nuh(&nuh);
2471    }
2472   };
2473  
2474   kill_reason: REASON '=' QSTRING ';'
2475   {
2476 <  if (ypass == 2)
2476 >  if (conf_parser_ctx.pass == 2)
2477      strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2478   };
2479  
# Line 2856 | Line 2482 | kill_reason: REASON '=' QSTRING ';'
2482   ***************************************************************************/
2483   deny_entry: DENY
2484   {
2485 <  if (ypass == 2)
2486 <  {
2861 <    yy_conf = make_conf_item(DLINE_TYPE);
2862 <    yy_aconf = map_to_conf(yy_conf);
2863 <    /* default reason */
2864 <    DupString(yy_aconf->reason, "No reason");
2865 <  }
2485 >  if (conf_parser_ctx.pass == 2)
2486 >    hostbuf[0] = reasonbuf[0] = '\0';
2487   } '{' deny_items '}' ';'
2488   {
2489 <  if (ypass == 2)
2489 >  if (conf_parser_ctx.pass == 2)
2490    {
2491 <    if (yy_aconf->host && parse_netmask(yy_aconf->host, NULL, NULL) != HM_HOST)
2491 >    if (hostbuf[0] && parse_netmask(hostbuf, NULL, NULL) != HM_HOST)
2492 >    {
2493 >      yy_aconf = map_to_conf(make_conf_item(DLINE_TYPE));
2494 >      DupString(yy_aconf->host, hostbuf);
2495 >
2496 >      if (reasonbuf[0])
2497 >        DupString(yy_aconf->reason, reasonbuf);
2498 >      else
2499 >        DupString(yy_aconf->reason, "No reason");
2500        add_conf_by_address(CONF_DLINE, yy_aconf);
2501 <    else
2502 <      delete_conf_item(yy_conf);
2874 <    yy_conf = NULL;
2875 <    yy_aconf = NULL;
2501 >      yy_aconf = NULL;
2502 >    }
2503    }
2504   };
2505  
# Line 2881 | Line 2508 | deny_item:      deny_ip | deny_reason |
2508  
2509   deny_ip: IP '=' QSTRING ';'
2510   {
2511 <  if (ypass == 2)
2512 <  {
2886 <    MyFree(yy_aconf->host);
2887 <    DupString(yy_aconf->host, yylval.string);
2888 <  }
2511 >  if (conf_parser_ctx.pass == 2)
2512 >    strlcpy(hostbuf, yylval.string, sizeof(hostbuf));
2513   };
2514  
2515   deny_reason: REASON '=' QSTRING ';'
2516   {
2517 <  if (ypass == 2)
2518 <  {
2895 <    MyFree(yy_aconf->reason);
2896 <    DupString(yy_aconf->reason, yylval.string);
2897 <  }
2517 >  if (conf_parser_ctx.pass == 2)
2518 >    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2519   };
2520  
2521   /***************************************************************************
# Line 2907 | Line 2528 | exempt_item:      exempt_ip | error;
2528  
2529   exempt_ip: IP '=' QSTRING ';'
2530   {
2531 <  if (ypass == 2)
2531 >  if (conf_parser_ctx.pass == 2)
2532    {
2533      if (yylval.string[0] && parse_netmask(yylval.string, NULL, NULL) != HM_HOST)
2534      {
2535 <      yy_conf = make_conf_item(EXEMPTDLINE_TYPE);
2915 <      yy_aconf = map_to_conf(yy_conf);
2535 >      yy_aconf = map_to_conf(make_conf_item(EXEMPTDLINE_TYPE));
2536        DupString(yy_aconf->host, yylval.string);
2537  
2538        add_conf_by_address(CONF_EXEMPTDLINE, yy_aconf);
2919
2920      yy_conf = NULL;
2539        yy_aconf = NULL;
2540      }
2541    }
# Line 2928 | Line 2546 | exempt_ip: IP '=' QSTRING ';'
2546   ***************************************************************************/
2547   gecos_entry: GECOS
2548   {
2549 <  if (ypass == 2)
2549 >  if (conf_parser_ctx.pass == 2)
2550    {
2551      regex_ban = 0;
2552      reasonbuf[0] = gecos_name[0] = '\0';
2553    }
2554   } '{' gecos_items '}' ';'
2555   {
2556 <  if (ypass == 2)
2556 >  if (conf_parser_ctx.pass == 2)
2557    {
2558      if (gecos_name[0])
2559      {
2560        if (regex_ban)
2561        {
2562 <        pcre *exp_p = NULL;
2562 > #ifdef HAVE_LIBPCRE
2563 >        void *exp_p = NULL;
2564          const char *errptr = NULL;
2565  
2566          if (!(exp_p = ircd_pcre_compile(gecos_name, &errptr)))
2567          {
2568 <          ilog(L_ERROR, "Failed to add regular expression based X-Line: %s", errptr);
2568 >          ilog(LOG_TYPE_IRCD, "Failed to add regular expression based X-Line: %s",
2569 >               errptr);
2570            break;
2571          }
2572  
2573          yy_conf = make_conf_item(RXLINE_TYPE);
2574          yy_conf->regexpname = exp_p;
2575 + #else
2576 +        ilog(LOG_TYPE_IRCD, "Failed to add regular expression based X-Line: no PCRE support");
2577 +        break;
2578 + #endif
2579        }
2580        else
2581          yy_conf = make_conf_item(XLINE_TYPE);
# Line 2974 | Line 2598 | gecos_flags: TYPE
2598   gecos_flags_items: gecos_flags_items ',' gecos_flags_item | gecos_flags_item;
2599   gecos_flags_item: REGEX_T
2600   {
2601 <  if (ypass == 2)
2601 >  if (conf_parser_ctx.pass == 2)
2602      regex_ban = 1;
2603   };
2604  
# Line 2983 | Line 2607 | gecos_item:  gecos_name | gecos_reason |
2607  
2608   gecos_name: NAME '=' QSTRING ';'
2609   {
2610 <  if (ypass == 2)
2610 >  if (conf_parser_ctx.pass == 2)
2611      strlcpy(gecos_name, yylval.string, sizeof(gecos_name));
2612   };
2613  
2614   gecos_reason: REASON '=' QSTRING ';'
2615   {
2616 <  if (ypass == 2)
2616 >  if (conf_parser_ctx.pass == 2)
2617      strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2618   };
2619  
# Line 3013 | Line 2637 | general_item:       general_hide_spoof_i
2637                      general_pace_wait_simple | general_stats_P_oper_only |
2638                      general_short_motd | general_no_oper_flood |
2639                      general_true_no_oper_flood | general_oper_pass_resv |
2640 <                    general_idletime | general_message_locale |
2640 >                    general_message_locale |
2641                      general_oper_only_umodes | general_max_targets |
2642                      general_use_egd | general_egdpool_path |
2643                      general_oper_umodes | general_caller_id_wait |
2644                      general_opers_bypass_callerid | general_default_floodcount |
2645                      general_min_nonwildcard | general_min_nonwildcard_simple |
2646 <                    general_servlink_path | general_disable_remote_commands |
2647 <                    general_default_cipher_preference |
3024 <                    general_compression_level | general_client_flood |
2646 >                    general_disable_remote_commands |
2647 >                    general_client_flood |
2648                      general_throttle_time | general_havent_read_conf |
2649 <                    general_dot_in_ip6_addr | general_ping_cookie |
2650 <                    general_disable_auth | general_burst_away |
2649 >                    general_ping_cookie |
2650 >                    general_disable_auth |
2651                      general_tkline_expire_notices | general_gline_min_cidr |
2652                      general_gline_min_cidr6 | general_use_whois_actually |
2653 <                    general_reject_hold_time |
2653 >                    general_reject_hold_time | general_stats_e_disabled |
2654 >                    general_max_watch | general_services_name |
2655                      error;
2656  
2657  
2658 + general_max_watch: MAX_WATCH '=' NUMBER ';'
2659 + {
2660 +  ConfigFileEntry.max_watch = $3;
2661 + };
2662  
2663   general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
2664   {
# Line 3042 | Line 2670 | general_gline_min_cidr6: GLINE_MIN_CIDR6
2670    ConfigFileEntry.gline_min_cidr6 = $3;
2671   };
2672  
3045 general_burst_away: BURST_AWAY '=' TBOOL ';'
3046 {
3047  ConfigFileEntry.burst_away = yylval.number;
3048 };
3049
2673   general_use_whois_actually: USE_WHOIS_ACTUALLY '=' TBOOL ';'
2674   {
2675    ConfigFileEntry.use_whois_actually = yylval.number;
# Line 3062 | Line 2685 | general_tkline_expire_notices: TKLINE_EX
2685    ConfigFileEntry.tkline_expire_notices = yylval.number;
2686   };
2687  
2688 < general_kill_chase_time_limit: KILL_CHASE_TIME_LIMIT '=' NUMBER ';'
2688 > general_kill_chase_time_limit: KILL_CHASE_TIME_LIMIT '=' timespec ';'
2689   {
2690    ConfigFileEntry.kill_chase_time_limit = $3;
2691   };
# Line 3119 | Line 2742 | general_ts_warn_delta: TS_WARN_DELTA '='
2742  
2743   general_ts_max_delta: TS_MAX_DELTA '=' timespec ';'
2744   {
2745 <  if (ypass == 2)
2745 >  if (conf_parser_ctx.pass == 2)
2746      ConfigFileEntry.ts_max_delta = $3;
2747   };
2748  
2749   general_havent_read_conf: HAVENT_READ_CONF '=' NUMBER ';'
2750   {
2751 <  if (($3 > 0) && ypass == 1)
2751 >  if (($3 > 0) && conf_parser_ctx.pass == 1)
2752    {
2753 <    ilog(L_CRIT, "You haven't read your config file properly.");
2754 <    ilog(L_CRIT, "There is a line in the example conf that will kill your server if not removed.");
2755 <    ilog(L_CRIT, "Consider actually reading/editing the conf file, and removing this line.");
2753 >    ilog(LOG_TYPE_IRCD, "You haven't read your config file properly.");
2754 >    ilog(LOG_TYPE_IRCD, "There is a line in the example conf that will kill your server if not removed.");
2755 >    ilog(LOG_TYPE_IRCD, "Consider actually reading/editing the conf file, and removing this line.");
2756      exit(0);
2757    }
2758   };
# Line 3141 | Line 2764 | general_kline_with_reason: KLINE_WITH_RE
2764  
2765   general_kline_reason: KLINE_REASON '=' QSTRING ';'
2766   {
2767 <  if (ypass == 2)
2767 >  if (conf_parser_ctx.pass == 2)
2768    {
2769      MyFree(ConfigFileEntry.kline_reason);
2770      DupString(ConfigFileEntry.kline_reason, yylval.string);
# Line 3158 | Line 2781 | general_warn_no_nline: WARN_NO_NLINE '='
2781    ConfigFileEntry.warn_no_nline = yylval.number;
2782   };
2783  
2784 + general_stats_e_disabled: STATS_E_DISABLED '=' TBOOL ';'
2785 + {
2786 +  ConfigFileEntry.stats_e_disabled = yylval.number;
2787 + };
2788 +
2789   general_stats_o_oper_only: STATS_O_OPER_ONLY '=' TBOOL ';'
2790   {
2791    ConfigFileEntry.stats_o_oper_only = yylval.number;
# Line 3226 | Line 2854 | general_oper_pass_resv: OPER_PASS_RESV '
2854  
2855   general_message_locale: MESSAGE_LOCALE '=' QSTRING ';'
2856   {
2857 <  if (ypass == 2)
2857 >  if (conf_parser_ctx.pass == 2)
2858    {
2859      if (strlen(yylval.string) > LOCALE_LENGTH-2)
2860        yylval.string[LOCALE_LENGTH-1] = '\0';
# Line 3235 | Line 2863 | general_message_locale: MESSAGE_LOCALE '
2863    }
2864   };
2865  
3238 general_idletime: IDLETIME '=' timespec ';'
3239 {
3240  ConfigFileEntry.idletime = $3;
3241 };
3242
2866   general_dots_in_ident: DOTS_IN_IDENT '=' NUMBER ';'
2867   {
2868    ConfigFileEntry.dots_in_ident = $3;
# Line 3250 | Line 2873 | general_max_targets: MAX_TARGETS '=' NUM
2873    ConfigFileEntry.max_targets = $3;
2874   };
2875  
3253 general_servlink_path: SERVLINK_PATH '=' QSTRING ';'
3254 {
3255  if (ypass == 2)
3256  {
3257    MyFree(ConfigFileEntry.servlink_path);
3258    DupString(ConfigFileEntry.servlink_path, yylval.string);
3259  }
3260 };
3261
3262 general_default_cipher_preference: DEFAULT_CIPHER_PREFERENCE '=' QSTRING ';'
3263 {
3264 #ifdef HAVE_LIBCRYPTO
3265  if (ypass == 2)
3266  {
3267    struct EncCapability *ecap;
3268    const char *cipher_name;
3269    int found = 0;
3270
3271    ConfigFileEntry.default_cipher_preference = NULL;
3272    cipher_name = yylval.string;
3273
3274    for (ecap = CipherTable; ecap->name; ecap++)
3275    {
3276      if ((irccmp(ecap->name, cipher_name) == 0) &&
3277          (ecap->cap & CAP_ENC_MASK))
3278      {
3279        ConfigFileEntry.default_cipher_preference = ecap;
3280        found = 1;
3281        break;
3282      }
3283    }
3284
3285    if (!found)
3286      yyerror("Invalid cipher");
3287  }
3288 #else
3289  if (ypass == 2)
3290    yyerror("Ignoring default_cipher_preference -- no OpenSSL support");
3291 #endif
3292 };
3293
3294 general_compression_level: COMPRESSION_LEVEL '=' NUMBER ';'
3295 {
3296  if (ypass == 2)
3297  {
3298    ConfigFileEntry.compression_level = $3;
3299 #ifndef HAVE_LIBZ
3300    yyerror("Ignoring compression_level -- no zlib support");
3301 #else
3302    if ((ConfigFileEntry.compression_level < 1) ||
3303        (ConfigFileEntry.compression_level > 9))
3304    {
3305      yyerror("Ignoring invalid compression_level, using default");
3306      ConfigFileEntry.compression_level = 0;
3307    }
3308 #endif
3309  }
3310 };
3311
2876   general_use_egd: USE_EGD '=' TBOOL ';'
2877   {
2878    ConfigFileEntry.use_egd = yylval.number;
# Line 3316 | Line 2880 | general_use_egd: USE_EGD '=' TBOOL ';'
2880  
2881   general_egdpool_path: EGDPOOL_PATH '=' QSTRING ';'
2882   {
2883 <  if (ypass == 2)
2883 >  if (conf_parser_ctx.pass == 2)
2884    {
2885      MyFree(ConfigFileEntry.egdpool_path);
2886      DupString(ConfigFileEntry.egdpool_path, yylval.string);
2887    }
2888   };
2889  
2890 + general_services_name: T_SERVICES_NAME '=' QSTRING ';'
2891 + {
2892 +  if (conf_parser_ctx.pass == 2 && valid_servname(yylval.string))
2893 +  {
2894 +    MyFree(ConfigFileEntry.service_name);
2895 +    DupString(ConfigFileEntry.service_name, yylval.string);
2896 +  }
2897 + };
2898 +
2899   general_ping_cookie: PING_COOKIE '=' TBOOL ';'
2900   {
2901    ConfigFileEntry.ping_cookie = yylval.number;
# Line 3350 | Line 2923 | umode_oitem:     T_BOTS
2923   } | T_CCONN
2924   {
2925    ConfigFileEntry.oper_umodes |= UMODE_CCONN;
2926 + } | T_CCONN_FULL
2927 + {
2928 +  ConfigFileEntry.oper_umodes |= UMODE_CCONN_FULL;
2929   } | T_DEAF
2930   {
2931    ConfigFileEntry.oper_umodes |= UMODE_DEAF;
# Line 3359 | Line 2935 | umode_oitem:     T_BOTS
2935   } | T_FULL
2936   {
2937    ConfigFileEntry.oper_umodes |= UMODE_FULL;
2938 + } | HIDDEN
2939 + {
2940 +  ConfigFileEntry.oper_umodes |= UMODE_HIDDEN;
2941   } | T_SKILL
2942   {
2943    ConfigFileEntry.oper_umodes |= UMODE_SKILL;
# Line 3412 | Line 2991 | umode_item:    T_BOTS
2991   } | T_CCONN
2992   {
2993    ConfigFileEntry.oper_only_umodes |= UMODE_CCONN;
2994 + } | T_CCONN_FULL
2995 + {
2996 +  ConfigFileEntry.oper_only_umodes |= UMODE_CCONN_FULL;
2997   } | T_DEAF
2998   {
2999    ConfigFileEntry.oper_only_umodes |= UMODE_DEAF;
# Line 3424 | Line 3006 | umode_item:    T_BOTS
3006   } | T_SKILL
3007   {
3008    ConfigFileEntry.oper_only_umodes |= UMODE_SKILL;
3009 + } | HIDDEN
3010 + {
3011 +  ConfigFileEntry.oper_only_umodes |= UMODE_HIDDEN;
3012   } | T_NCHANGE
3013   {
3014    ConfigFileEntry.oper_only_umodes |= UMODE_NCHANGE;
# Line 3482 | Line 3067 | general_client_flood: T_CLIENT_FLOOD '='
3067    ConfigFileEntry.client_flood = $3;
3068   };
3069  
3485 general_dot_in_ip6_addr: DOT_IN_IP6_ADDR '=' TBOOL ';'
3486 {
3487  ConfigFileEntry.dot_in_ip6_addr = yylval.number;
3488 };
3070  
3071   /***************************************************************************
3072   *  section glines
3073   ***************************************************************************/
3074   gline_entry: GLINES
3075   {
3076 <  if (ypass == 2)
3076 >  if (conf_parser_ctx.pass == 2)
3077    {
3078      yy_conf = make_conf_item(GDENY_TYPE);
3079 <    yy_aconf = (struct AccessItem *)map_to_conf(yy_conf);
3499 <    yy_aconf->flags = 0;
3079 >    yy_aconf = map_to_conf(yy_conf);
3080    }
3081   } '{' gline_items '}' ';'
3082   {
3083 <  if (ypass == 2)
3083 >  if (conf_parser_ctx.pass == 2)
3084    {
3085      /*
3086       * since we re-allocate yy_conf/yy_aconf after the end of action=, at the
3087       * end we will have one extra, so we should free it.
3088       */
3089 <    if (yy_conf->name == NULL && gdeny_items.length)
3089 >    if (yy_conf->name == NULL || yy_aconf->user == NULL)
3090      {
3091 <      dlinkDelete(gdeny_items.tail, &gdeny_items);
3512 <      MyFree(yy_conf);
3091 >      delete_conf_item(yy_conf);
3092        yy_conf = NULL;
3093        yy_aconf = NULL;
3094      }
# Line 3527 | Line 3106 | gline_item:         gline_enable |
3106  
3107   gline_enable: ENABLE '=' TBOOL ';'
3108   {
3109 <  if (ypass == 2)
3109 >  if (conf_parser_ctx.pass == 2)
3110      ConfigFileEntry.glines = yylval.number;
3111   };
3112  
3113   gline_duration: DURATION '=' timespec ';'
3114   {
3115 <  if (ypass == 2)
3115 >  if (conf_parser_ctx.pass == 2)
3116      ConfigFileEntry.gline_time = $3;
3117   };
3118  
3119 < gline_logging: LOGGING
3119 > gline_logging: T_LOG
3120   {
3121 <  if (ypass == 2)
3121 >  if (conf_parser_ctx.pass == 2)
3122      ConfigFileEntry.gline_logging = 0;
3123   } '=' gline_logging_types ';';
3124   gline_logging_types:     gline_logging_types ',' gline_logging_type_item | gline_logging_type_item;
3125   gline_logging_type_item: T_REJECT
3126   {
3127 <  if (ypass == 2)
3127 >  if (conf_parser_ctx.pass == 2)
3128      ConfigFileEntry.gline_logging |= GDENY_REJECT;
3129   } | T_BLOCK
3130   {
3131 <  if (ypass == 2)
3131 >  if (conf_parser_ctx.pass == 2)
3132      ConfigFileEntry.gline_logging |= GDENY_BLOCK;
3133   };
3134  
3135   gline_user: USER '=' QSTRING ';'
3136   {
3137 <  if (ypass == 2)
3137 >  if (conf_parser_ctx.pass == 2)
3138    {
3139 <    struct CollectItem *yy_tmp;
3139 >    struct split_nuh_item nuh;
3140 >
3141 >    nuh.nuhmask  = yylval.string;
3142 >    nuh.nickptr  = NULL;
3143 >    nuh.userptr  = userbuf;
3144 >    nuh.hostptr  = hostbuf;
3145 >
3146 >    nuh.nicksize = 0;
3147 >    nuh.usersize = sizeof(userbuf);
3148 >    nuh.hostsize = sizeof(hostbuf);
3149 >
3150 >    split_nuh(&nuh);
3151  
3152      if (yy_aconf->user == NULL)
3153      {
3154 <      split_nuh(yylval.string, NULL, &yy_aconf->user, &yy_aconf->host);
3154 >      DupString(yy_aconf->user, userbuf);
3155 >      DupString(yy_aconf->host, hostbuf);
3156      }
3157      else
3158      {
3159 <      yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
3160 <      split_nuh(yylval.string, NULL, &yy_tmp->user, &yy_tmp->host);
3159 >      struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
3160 >
3161 >      DupString(yy_tmp->user, userbuf);
3162 >      DupString(yy_tmp->host, hostbuf);
3163 >
3164        dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
3165      }
3166    }
# Line 3574 | Line 3168 | gline_user: USER '=' QSTRING ';'
3168  
3169   gline_server: NAME '=' QSTRING ';'
3170   {
3171 <  if (ypass == 2)  
3171 >  if (conf_parser_ctx.pass == 2)  
3172    {
3173      MyFree(yy_conf->name);
3174      DupString(yy_conf->name, yylval.string);
# Line 3583 | Line 3177 | gline_server: NAME '=' QSTRING ';'
3177  
3178   gline_action: ACTION
3179   {
3180 <  if (ypass == 2)
3180 >  if (conf_parser_ctx.pass == 2)
3181      yy_aconf->flags = 0;
3182   } '=' gdeny_types ';'
3183   {
3184 <  if (ypass == 2)
3184 >  if (conf_parser_ctx.pass == 2)
3185    {
3186 <    struct CollectItem *yy_tmp;
3186 >    struct CollectItem *yy_tmp = NULL;
3187      dlink_node *ptr, *next_ptr;
3188  
3189      DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
# Line 3599 | Line 3193 | gline_action: ACTION
3193  
3194        yy_tmp = ptr->data;
3195        new_conf = make_conf_item(GDENY_TYPE);
3196 <      new_aconf = (struct AccessItem *)map_to_conf(new_conf);
3196 >      new_aconf = map_to_conf(new_conf);
3197  
3198        new_aconf->flags = yy_aconf->flags;
3199  
# Line 3618 | Line 3212 | gline_action: ACTION
3212  
3213        dlinkDelete(&yy_tmp->node, &col_conf_list);
3214      }
3215 +
3216 +    /*
3217 +     * In case someone has fed us with more than one action= after user/name
3218 +     * which would leak memory  -Michael
3219 +     */
3220 +    if (yy_conf->name == NULL || yy_aconf->user == NULL)
3221 +      delete_conf_item(yy_conf);
3222 +
3223      yy_conf = make_conf_item(GDENY_TYPE);
3224 <    yy_aconf = (struct AccessItem *)map_to_conf(yy_conf);
3623 <    yy_aconf->flags = 0;
3224 >    yy_aconf = map_to_conf(yy_conf);
3225    }
3226   };
3227  
3228   gdeny_types: gdeny_types ',' gdeny_type_item | gdeny_type_item;
3229   gdeny_type_item: T_REJECT
3230   {
3231 <  if (ypass == 2)
3231 >  if (conf_parser_ctx.pass == 2)
3232      yy_aconf->flags |= GDENY_REJECT;
3233   } | T_BLOCK
3234   {
3235 <  if (ypass == 2)
3235 >  if (conf_parser_ctx.pass == 2)
3236      yy_aconf->flags |= GDENY_BLOCK;
3237   };
3238  
# Line 3645 | Line 3246 | channel_items:      channel_items channe
3246   channel_item:       channel_disable_local_channels | channel_use_except |
3247                      channel_use_invex | channel_use_knock |
3248                      channel_max_bans | channel_knock_delay |
3249 <                    channel_knock_delay_channel | channel_invite_ops_only |
3250 <                    channel_max_chans_per_user | channel_quiet_on_ban |
3251 <                    channel_default_split_user_count |
3252 <                    channel_default_split_server_count |
3253 <                    channel_no_create_on_split | channel_restrict_channels |
3254 <                    channel_no_join_on_split | channel_burst_topicwho |
3255 <                    channel_jflood_count | channel_jflood_time |
3256 <                    error;
3249 >                    channel_knock_delay_channel | channel_max_chans_per_user |
3250 >                    channel_quiet_on_ban | channel_default_split_user_count |
3251 >                    channel_default_split_server_count |
3252 >                    channel_no_create_on_split | channel_restrict_channels |
3253 >                    channel_no_join_on_split | channel_burst_topicwho |
3254 >                    channel_jflood_count | channel_jflood_time |
3255 >                    channel_disable_fake_channels | error;
3256 >
3257 > channel_disable_fake_channels: DISABLE_FAKE_CHANNELS '=' TBOOL ';'
3258 > {
3259 >  ConfigChannel.disable_fake_channels = yylval.number;
3260 > };
3261  
3262   channel_restrict_channels: RESTRICT_CHANNELS '=' TBOOL ';'
3263   {
# Line 3689 | Line 3294 | channel_knock_delay_channel: KNOCK_DELAY
3294    ConfigChannel.knock_delay_channel = $3;
3295   };
3296  
3692 channel_invite_ops_only: INVITE_OPS_ONLY '=' TBOOL ';'
3693 {
3694  ConfigChannel.invite_ops_only = yylval.number;
3695 };
3696
3297   channel_max_chans_per_user: MAX_CHANS_PER_USER '=' NUMBER ';'
3298   {
3299    ConfigChannel.max_chans_per_user = $3;
# Line 3760 | Line 3360 | serverhide_item:    serverhide_flatten_l
3360  
3361   serverhide_flatten_links: FLATTEN_LINKS '=' TBOOL ';'
3362   {
3363 <  if (ypass == 2)
3363 >  if (conf_parser_ctx.pass == 2)
3364      ConfigServerHide.flatten_links = yylval.number;
3365   };
3366  
3367   serverhide_hide_servers: HIDE_SERVERS '=' TBOOL ';'
3368   {
3369 <  if (ypass == 2)
3369 >  if (conf_parser_ctx.pass == 2)
3370      ConfigServerHide.hide_servers = yylval.number;
3371   };
3372  
3373   serverhide_hidden_name: HIDDEN_NAME '=' QSTRING ';'
3374   {
3375 <  if (ypass == 2)
3375 >  if (conf_parser_ctx.pass == 2)
3376    {
3377      MyFree(ConfigServerHide.hidden_name);
3378      DupString(ConfigServerHide.hidden_name, yylval.string);
# Line 3781 | Line 3381 | serverhide_hidden_name: HIDDEN_NAME '='
3381  
3382   serverhide_links_delay: LINKS_DELAY '=' timespec ';'
3383   {
3384 <  if (ypass == 2)
3384 >  if (conf_parser_ctx.pass == 2)
3385    {
3386      if (($3 > 0) && ConfigServerHide.links_disabled == 1)
3387      {
# Line 3795 | Line 3395 | serverhide_links_delay: LINKS_DELAY '='
3395  
3396   serverhide_hidden: HIDDEN '=' TBOOL ';'
3397   {
3398 <  if (ypass == 2)
3398 >  if (conf_parser_ctx.pass == 2)
3399      ConfigServerHide.hidden = yylval.number;
3400   };
3401  
3402   serverhide_disable_hidden: DISABLE_HIDDEN '=' TBOOL ';'
3403   {
3404 <  if (ypass == 2)
3404 >  if (conf_parser_ctx.pass == 2)
3405      ConfigServerHide.disable_hidden = yylval.number;
3406   };
3407  
3408   serverhide_hide_server_ips: HIDE_SERVER_IPS '=' TBOOL ';'
3409   {
3410 <  if (ypass == 2)
3410 >  if (conf_parser_ctx.pass == 2)
3411      ConfigServerHide.hide_server_ips = yylval.number;
3412   };

Diff Legend

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