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-7.2/src/ircd_parser.y (file contents), Revision 900 by michael, Sun Nov 4 13:49:52 2007 UTC vs.
ircd-hybrid/trunk/src/conf_parser.y (file contents), Revision 1785 by michael, Sat Jan 26 22:40:55 2013 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"
33   #include "ircd.h"
32 #include "tools.h"
34   #include "list.h"
35 < #include "s_conf.h"
35 > #include "conf.h"
36 > #include "conf_class.h"
37   #include "event.h"
38 < #include "s_log.h"
38 > #include "log.h"
39   #include "client.h"     /* for UMODE_ALL only */
38 #include "pcre.h"
40   #include "irc_string.h"
40 #include "irc_getaddrinfo.h"
41   #include "sprintf_irc.h"
42   #include "memory.h"
43   #include "modules.h"
# Line 53 | Line 53
53   #include <openssl/rsa.h>
54   #include <openssl/bio.h>
55   #include <openssl/pem.h>
56 + #include <openssl/dh.h>
57   #endif
58  
59 < static char *class_name = NULL;
59 < static struct ConfItem *yy_conf = NULL;
60 < static struct AccessItem *yy_aconf = NULL;
61 < static struct MatchItem *yy_match_item = NULL;
62 < static struct ClassItem *yy_class = NULL;
63 < static char *yy_class_name = NULL;
64 <
65 < static dlink_list col_conf_list  = { NULL, NULL, 0 };
66 < static dlink_list hub_conf_list  = { NULL, NULL, 0 };
67 < static dlink_list leaf_conf_list = { NULL, NULL, 0 };
68 < static unsigned int listener_flags = 0;
69 < static unsigned int regex_ban = 0;
70 < static char userbuf[IRCD_BUFSIZE];
71 < static char hostbuf[IRCD_BUFSIZE];
72 < static char reasonbuf[REASONLEN + 1];
73 < static char gecos_name[REALLEN * 4];
74 <
75 < extern dlink_list gdeny_items; /* XXX */
76 <
77 < static char *resv_reason = NULL;
78 < static char *listener_address = NULL;
79 < static int not_atom = 0;
80 <
81 < struct CollectItem
82 < {
83 <  dlink_node node;
84 <  char *name;
85 <  char *user;
86 <  char *host;
87 <  char *passwd;
88 <  int  port;
89 <  int  flags;
90 < #ifdef HAVE_LIBCRYPTO
91 <  char *rsa_public_key_file;
92 <  RSA *rsa_public_key;
93 < #endif
94 < };
59 > #include "rsa.h"
60  
61 < static void
62 < free_collect_item(struct CollectItem *item)
61 > int yylex(void);
62 >
63 > static struct
64   {
65 <  MyFree(item->name);
66 <  MyFree(item->user);
67 <  MyFree(item->host);
68 <  MyFree(item->passwd);
69 < #ifdef HAVE_LIBCRYPTO
70 <  MyFree(item->rsa_public_key_file);
71 < #endif
72 <  MyFree(item);
73 < }
65 >  struct {
66 >    dlink_list list;
67 >  } mask,
68 >    leaf,
69 >    hub;
70 >
71 >  struct {
72 >    char buf[IRCD_BUFSIZE];
73 >  } name,
74 >    user,
75 >    host,
76 >    addr,
77 >    bind,
78 >    file,
79 >    ciph,
80 >    rpass,
81 >    spass,
82 >    class;
83 >
84 >  struct {
85 >    unsigned int value;
86 >  } flags,
87 >    modes,
88 >    size,
89 >    type,
90 >    port,
91 >    aftype,
92 >    ping_freq,
93 >    max_perip,
94 >    con_freq,
95 >    min_idle,
96 >    max_idle,
97 >    max_total,
98 >    max_global,
99 >    max_local,
100 >    max_ident,
101 >    max_sendq,
102 >    max_recvq,
103 >    cidr_bitlen_ipv4,
104 >    cidr_bitlen_ipv6,
105 >    number_per_cidr;
106 > } block_state;
107  
108   static void
109 < unhook_hub_leaf_confs(void)
109 > reset_block_state(void)
110   {
111 <  dlink_node *ptr;
113 <  dlink_node *next_ptr;
114 <  struct CollectItem *yy_hconf;
115 <  struct CollectItem *yy_lconf;
111 >  dlink_node *ptr = NULL, *ptr_next = NULL;
112  
113 <  DLINK_FOREACH_SAFE(ptr, next_ptr, hub_conf_list.head)
113 >  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.mask.list.head)
114    {
115 <    yy_hconf = ptr->data;
116 <    dlinkDelete(&yy_hconf->node, &hub_conf_list);
117 <    free_collect_item(yy_hconf);
115 >    MyFree(ptr->data);
116 >    dlinkDelete(ptr, &block_state.mask.list);
117 >    free_dlink_node(ptr);
118    }
119  
120 <  DLINK_FOREACH_SAFE(ptr, next_ptr, leaf_conf_list.head)
120 >  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.leaf.list.head)
121    {
122 <    yy_lconf = ptr->data;
123 <    dlinkDelete(&yy_lconf->node, &leaf_conf_list);
124 <    free_collect_item(yy_lconf);
122 >    MyFree(ptr->data);
123 >    dlinkDelete(ptr, &block_state.leaf.list);
124 >    free_dlink_node(ptr);
125    }
126 +
127 +  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.hub.list.head)
128 +  {
129 +    MyFree(ptr->data);
130 +    dlinkDelete(ptr, &block_state.hub.list);
131 +    free_dlink_node(ptr);
132 +  }
133 +
134 +  memset(&block_state, 0, sizeof(block_state));
135   }
136  
137   %}
# Line 137 | Line 142 | unhook_hub_leaf_confs(void)
142   }
143  
144   %token  ACCEPT_PASSWORD
140 %token  ACTION
145   %token  ADMIN
146   %token  AFTYPE
143 %token  T_ALLOW
147   %token  ANTI_NICK_FLOOD
148   %token  ANTI_SPAM_EXIT_MESSAGE_TIME
149   %token  AUTOCONN
150 < %token  T_BLOCK
148 < %token  BURST_AWAY
149 < %token  BURST_TOPICWHO
150 < %token  BYTES KBYTES MBYTES GBYTES TBYTES
150 > %token  BYTES KBYTES MBYTES
151   %token  CALLER_ID_WAIT
152   %token  CAN_FLOOD
153 %token  CAN_IDLE
153   %token  CHANNEL
154   %token  CIDR_BITLEN_IPV4
155   %token  CIDR_BITLEN_IPV6
157 %token  CIPHER_PREFERENCE
156   %token  CLASS
159 %token  COMPRESSED
160 %token  COMPRESSION_LEVEL
157   %token  CONNECT
158   %token  CONNECTFREQ
163 %token  CRYPTLINK
164 %token  DEFAULT_CIPHER_PREFERENCE
159   %token  DEFAULT_FLOODCOUNT
160   %token  DEFAULT_SPLIT_SERVER_COUNT
161   %token  DEFAULT_SPLIT_USER_COUNT
# Line 170 | Line 164 | unhook_hub_leaf_confs(void)
164   %token  DIE
165   %token  DISABLE_AUTH
166   %token  DISABLE_FAKE_CHANNELS
173 %token  DISABLE_HIDDEN
174 %token  DISABLE_LOCAL_CHANNELS
167   %token  DISABLE_REMOTE_COMMANDS
176 %token  DOT_IN_IP6_ADDR
168   %token  DOTS_IN_IDENT
178 %token  DURATION
169   %token  EGDPOOL_PATH
170   %token  EMAIL
181 %token  ENABLE
171   %token  ENCRYPTED
172   %token  EXCEED_LIMIT
173   %token  EXEMPT
174   %token  FAILED_OPER_NOTICE
186 %token  FAKENAME
175   %token  IRCD_FLAGS
176   %token  FLATTEN_LINKS
189 %token  FFAILED_OPERLOG
190 %token  FKILLLOG
191 %token  FKLINELOG
192 %token  FGLINELOG
193 %token  FIOERRLOG
194 %token  FOPERLOG
195 %token  FOPERSPYLOG
196 %token  FUSERLOG
177   %token  GECOS
178   %token  GENERAL
179   %token  GLINE
180 < %token  GLINES
180 > %token  GLINE_DURATION
181 > %token  GLINE_ENABLE
182   %token  GLINE_EXEMPT
183 < %token  GLINE_LOG
203 < %token  GLINE_TIME
183 > %token  GLINE_REQUEST_DURATION
184   %token  GLINE_MIN_CIDR
185   %token  GLINE_MIN_CIDR6
186   %token  GLOBAL_KILL
# Line 208 | Line 188 | unhook_hub_leaf_confs(void)
188   %token  NEED_IDENT
189   %token  HAVENT_READ_CONF
190   %token  HIDDEN
211 %token  HIDDEN_ADMIN
191   %token  HIDDEN_NAME
213 %token  HIDDEN_OPER
192   %token  HIDE_SERVER_IPS
193   %token  HIDE_SERVERS
194   %token  HIDE_SPOOF_IPS
195   %token  HOST
196   %token  HUB
197   %token  HUB_MASK
220 %token  IDLETIME
198   %token  IGNORE_BOGUS_TS
199   %token  INVISIBLE_ON_CONNECT
200   %token  IP
# Line 225 | Line 202 | unhook_hub_leaf_confs(void)
202   %token  KILL_CHASE_TIME_LIMIT
203   %token  KLINE
204   %token  KLINE_EXEMPT
228 %token  KLINE_REASON
229 %token  KLINE_WITH_REASON
205   %token  KNOCK_DELAY
206   %token  KNOCK_DELAY_CHANNEL
207   %token  LEAF_MASK
208   %token  LINKS_DELAY
209   %token  LISTEN
210   %token  T_LOG
236 %token  LOGGING
237 %token  LOG_LEVEL
211   %token  MAX_ACCEPT
212   %token  MAX_BANS
213 + %token  MAX_CHANS_PER_OPER
214   %token  MAX_CHANS_PER_USER
215   %token  MAX_GLOBAL
216   %token  MAX_IDENT
217   %token  MAX_LOCAL
218   %token  MAX_NICK_CHANGES
219 + %token  MAX_NICK_LENGTH
220   %token  MAX_NICK_TIME
221   %token  MAX_NUMBER
222   %token  MAX_TARGETS
223 + %token  MAX_TOPIC_LENGTH
224   %token  MAX_WATCH
225   %token  MESSAGE_LOCALE
226   %token  MIN_NONWILDCARD
227   %token  MIN_NONWILDCARD_SIMPLE
228 + %token  MIN_IDLE
229 + %token  MAX_IDLE
230 + %token  RANDOM_IDLE
231 + %token  HIDE_IDLE_FROM_OPERS
232   %token  MODULE
233   %token  MODULES
234   %token  NAME
# Line 261 | Line 241 | unhook_hub_leaf_confs(void)
241   %token  NO_JOIN_ON_SPLIT
242   %token  NO_OPER_FLOOD
243   %token  NO_TILDE
264 %token  NOT
244   %token  NUMBER
266 %token  NUMBER_PER_IDENT
245   %token  NUMBER_PER_CIDR
246   %token  NUMBER_PER_IP
269 %token  NUMBER_PER_IP_GLOBAL
247   %token  OPERATOR
248   %token  OPERS_BYPASS_CALLERID
272 %token  OPER_LOG
249   %token  OPER_ONLY_UMODES
250   %token  OPER_PASS_RESV
251   %token  OPER_SPY_T
# Line 282 | Line 258 | unhook_hub_leaf_confs(void)
258   %token  PATH
259   %token  PING_COOKIE
260   %token  PING_TIME
285 %token  PING_WARNING
261   %token  PORT
262   %token  QSTRING
263   %token  QUIET_ON_BAN
# Line 291 | Line 266 | unhook_hub_leaf_confs(void)
266   %token  REDIRSERV
267   %token  REGEX_T
268   %token  REHASH
294 %token  TREJECT_HOLD_TIME
269   %token  REMOTE
270   %token  REMOTEBAN
271   %token  RESTRICT_CHANNELS
298 %token  RESTRICTED
272   %token  RSA_PRIVATE_KEY_FILE
273   %token  RSA_PUBLIC_KEY_FILE
274   %token  SSL_CERTIFICATE_FILE
275 + %token  SSL_DH_PARAM_FILE
276 + %token  T_SSL_CLIENT_METHOD
277 + %token  T_SSL_SERVER_METHOD
278 + %token  T_SSLV3
279 + %token  T_TLSV1
280   %token  RESV
281   %token  RESV_EXEMPT
282 < %token  SECONDS MINUTES HOURS DAYS WEEKS
282 > %token  SECONDS MINUTES HOURS DAYS WEEKS MONTHS YEARS
283   %token  SENDQ
284   %token  SEND_PASSWORD
285   %token  SERVERHIDE
286   %token  SERVERINFO
309 %token  SERVLINK_PATH
287   %token  IRCD_SID
288   %token  TKLINE_EXPIRE_NOTICES
289   %token  T_SHARED
290   %token  T_CLUSTER
291   %token  TYPE
292   %token  SHORT_MOTD
316 %token  SILENT
293   %token  SPOOF
294   %token  SPOOF_NOTICE
295   %token  STATS_E_DISABLED
# Line 323 | Line 299 | unhook_hub_leaf_confs(void)
299   %token  STATS_P_OPER_ONLY
300   %token  TBOOL
301   %token  TMASKED
326 %token  T_REJECT
302   %token  TS_MAX_DELTA
303   %token  TS_WARN_DELTA
304   %token  TWODOTS
# Line 333 | Line 308 | unhook_hub_leaf_confs(void)
308   %token  T_CALLERID
309   %token  T_CCONN
310   %token  T_CCONN_FULL
311 < %token  T_CLIENT_FLOOD
311 > %token  T_SSL_CIPHER_LIST
312   %token  T_DEAF
313   %token  T_DEBUG
314 < %token  T_DRONE
314 > %token  T_DLINE
315   %token  T_EXTERNAL
316   %token  T_FULL
317   %token  T_INVISIBLE
318   %token  T_IPV4
319   %token  T_IPV6
320   %token  T_LOCOPS
346 %token  T_LOGPATH
347 %token  T_L_CRIT
348 %token  T_L_DEBUG
349 %token  T_L_ERROR
350 %token  T_L_INFO
351 %token  T_L_NOTICE
352 %token  T_L_TRACE
353 %token  T_L_WARN
321   %token  T_MAX_CLIENTS
322   %token  T_NCHANGE
323   %token  T_OPERWALL
324 + %token  T_RECVQ
325   %token  T_REJ
326   %token  T_SERVER
327   %token  T_SERVNOTICE
328 + %token  T_SET
329   %token  T_SKILL
330   %token  T_SPY
331   %token  T_SSL
332   %token  T_UMODES
333   %token  T_UNAUTH
334 + %token  T_UNDLINE
335 + %token  T_UNLIMITED
336   %token  T_UNRESV
337   %token  T_UNXLINE
338 + %token  T_GLOBOPS
339   %token  T_WALLOP
340 + %token  T_WEBIRC
341 + %token  T_RESTART
342 + %token  T_SERVICE
343 + %token  T_SERVICES_NAME
344   %token  THROTTLE_TIME
369 %token  TOPICBURST
345   %token  TRUE_NO_OPER_FLOOD
371 %token  TKLINE
372 %token  TXLINE
373 %token  TRESV
346   %token  UNKLINE
347   %token  USER
348   %token  USE_EGD
377 %token  USE_EXCEPT
378 %token  USE_INVEX
379 %token  USE_KNOCK
349   %token  USE_LOGGING
381 %token  USE_WHOIS_ACTUALLY
350   %token  VHOST
351   %token  VHOST6
352   %token  XLINE
385 %token  WARN
353   %token  WARN_NO_NLINE
354 + %token  T_SIZE
355 + %token  T_FILE
356  
357   %type <string> QSTRING
358   %type <number> NUMBER
# Line 407 | Line 376 | conf_item:        admin_entry
376                  | serverinfo_entry
377                  | serverhide_entry
378                  | resv_entry
379 +                | service_entry
380                  | shared_entry
381                  | cluster_entry
382                  | connect_entry
# Line 414 | Line 384 | conf_item:        admin_entry
384                  | deny_entry
385                  | exempt_entry
386                  | general_entry
417                | gline_entry
387                  | gecos_entry
388                  | modules_entry
389                  | error ';'
# Line 447 | Line 416 | timespec:      NUMBER timespec_
416                  {
417                          $$ = $1 * 60 * 60 * 24 * 7 + $3;
418                  }
419 +                | NUMBER MONTHS timespec_
420 +                {
421 +                        $$ = $1 * 60 * 60 * 24 * 7 * 4 + $3;
422 +                }
423 +                | NUMBER YEARS timespec_
424 +                {
425 +                        $$ = $1 * 60 * 60 * 24 * 365 + $3;
426 +                }
427                  ;
428  
429   sizespec_:      { $$ = 0; } | sizespec;
# Line 468 | Line 445 | modules_item:   modules_module | modules
445  
446   modules_module: MODULE '=' QSTRING ';'
447   {
448 < #ifndef STATIC_MODULES /* NOOP in the static case */
449 <  if (ypass == 2)
473 <  {
474 <    char *m_bn;
475 <
476 <    m_bn = basename(yylval.string);
477 <
478 <    /* I suppose we should just ignore it if it is already loaded(since
479 <     * otherwise we would flood the opers on rehash) -A1kmm.
480 <     */
481 <    add_conf_module(yylval.string);
482 <  }
483 < #endif
448 >  if (conf_parser_ctx.pass == 2)
449 >    add_conf_module(libio_basename(yylval.string));
450   };
451  
452   modules_path: PATH '=' QSTRING ';'
453   {
454 < #ifndef STATIC_MODULES
489 <  if (ypass == 2)
454 >  if (conf_parser_ctx.pass == 2)
455      mod_add_path(yylval.string);
491 #endif
456   };
457  
494 /***************************************************************************
495 *  section serverinfo
496 ***************************************************************************/
497 serverinfo_entry: SERVERINFO
498  '{' serverinfo_items '}' ';';
458  
459 < serverinfo_items:       serverinfo_items serverinfo_item |
460 <                        serverinfo_item ;
459 > serverinfo_entry: SERVERINFO '{' serverinfo_items '}' ';';
460 >
461 > serverinfo_items:       serverinfo_items serverinfo_item | serverinfo_item ;
462   serverinfo_item:        serverinfo_name | serverinfo_vhost |
463                          serverinfo_hub | serverinfo_description |
464                          serverinfo_network_name | serverinfo_network_desc |
465 <                        serverinfo_max_clients |
465 >                        serverinfo_max_clients | serverinfo_max_nick_length |
466 >                        serverinfo_max_topic_length | serverinfo_ssl_dh_param_file |
467                          serverinfo_rsa_private_key_file | serverinfo_vhost6 |
468                          serverinfo_sid | serverinfo_ssl_certificate_file |
469 +                        serverinfo_ssl_client_method | serverinfo_ssl_server_method |
470 +                        serverinfo_ssl_cipher_list |
471                          error ';' ;
472  
473 +
474 + serverinfo_ssl_client_method: T_SSL_CLIENT_METHOD '=' client_method_types ';' ;
475 + serverinfo_ssl_server_method: T_SSL_SERVER_METHOD '=' server_method_types ';' ;
476 +
477 + client_method_types: client_method_types ',' client_method_type_item | client_method_type_item;
478 + client_method_type_item: T_SSLV3
479 + {
480 + #ifdef HAVE_LIBCRYPTO
481 +  if (conf_parser_ctx.pass == 2 && ServerInfo.client_ctx)
482 +    SSL_CTX_clear_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv3);
483 + #endif
484 + } | T_TLSV1
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_TLSv1);
489 + #endif
490 + };
491 +
492 + server_method_types: server_method_types ',' server_method_type_item | server_method_type_item;
493 + server_method_type_item: T_SSLV3
494 + {
495 + #ifdef HAVE_LIBCRYPTO
496 +  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
497 +    SSL_CTX_clear_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv3);
498 + #endif
499 + } | T_TLSV1
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_TLSv1);
504 + #endif
505 + };
506 +
507   serverinfo_ssl_certificate_file: SSL_CERTIFICATE_FILE '=' QSTRING ';'
508   {
509   #ifdef HAVE_LIBCRYPTO
510 <  if (ypass == 2 && ServerInfo.ctx)
510 >  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
511    {
512      if (!ServerInfo.rsa_private_key_file)
513      {
514 <      yyerror("No rsa_private_key_file specified, SSL disabled");
514 >      conf_error_report("No rsa_private_key_file specified, SSL disabled");
515        break;
516      }
517  
518 <    if (SSL_CTX_use_certificate_file(ServerInfo.ctx,
519 <      yylval.string, SSL_FILETYPE_PEM) <= 0)
518 >    if (SSL_CTX_use_certificate_file(ServerInfo.server_ctx, yylval.string,
519 >                                     SSL_FILETYPE_PEM) <= 0 ||
520 >        SSL_CTX_use_certificate_file(ServerInfo.client_ctx, yylval.string,
521 >                                     SSL_FILETYPE_PEM) <= 0)
522      {
523 <      yyerror(ERR_lib_error_string(ERR_get_error()));
523 >      report_crypto_errors();
524 >      conf_error_report("Could not open/read certificate file");
525        break;
526      }
527  
528 <    if (SSL_CTX_use_PrivateKey_file(ServerInfo.ctx,
529 <      ServerInfo.rsa_private_key_file, SSL_FILETYPE_PEM) <= 0)
528 >    if (SSL_CTX_use_PrivateKey_file(ServerInfo.server_ctx, ServerInfo.rsa_private_key_file,
529 >                                    SSL_FILETYPE_PEM) <= 0 ||
530 >        SSL_CTX_use_PrivateKey_file(ServerInfo.client_ctx, ServerInfo.rsa_private_key_file,
531 >                                    SSL_FILETYPE_PEM) <= 0)
532      {
533 <      yyerror(ERR_lib_error_string(ERR_get_error()));
533 >      report_crypto_errors();
534 >      conf_error_report("Could not read RSA private key");
535        break;
536      }
537  
538 <    if (!SSL_CTX_check_private_key(ServerInfo.ctx))
538 >    if (!SSL_CTX_check_private_key(ServerInfo.server_ctx) ||
539 >        !SSL_CTX_check_private_key(ServerInfo.client_ctx))
540      {
541 <      yyerror("RSA private key does not match the SSL certificate public key!");
541 >      report_crypto_errors();
542 >      conf_error_report("Could not read RSA private key");
543        break;
544      }
545    }
# Line 544 | Line 549 | serverinfo_ssl_certificate_file: SSL_CER
549   serverinfo_rsa_private_key_file: RSA_PRIVATE_KEY_FILE '=' QSTRING ';'
550   {
551   #ifdef HAVE_LIBCRYPTO
552 <  if (ypass == 1)
552 >  if (conf_parser_ctx.pass == 1)
553    {
554      BIO *file;
555  
# Line 560 | Line 565 | serverinfo_rsa_private_key_file: RSA_PRI
565        ServerInfo.rsa_private_key_file = NULL;
566      }
567  
568 <    DupString(ServerInfo.rsa_private_key_file, yylval.string);
568 >    ServerInfo.rsa_private_key_file = xstrdup(yylval.string);
569  
570      if ((file = BIO_new_file(yylval.string, "r")) == NULL)
571      {
572 <      yyerror("File open failed, ignoring");
572 >      conf_error_report("File open failed, ignoring");
573        break;
574      }
575  
576 <    ServerInfo.rsa_private_key = (RSA *)PEM_read_bio_RSAPrivateKey(file, NULL,
572 <      0, NULL);
576 >    ServerInfo.rsa_private_key = PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL);
577  
578      BIO_set_close(file, BIO_CLOSE);
579      BIO_free(file);
580  
581      if (ServerInfo.rsa_private_key == NULL)
582      {
583 <      yyerror("Couldn't extract key, ignoring");
583 >      conf_error_report("Couldn't extract key, ignoring");
584        break;
585      }
586  
# Line 585 | Line 589 | serverinfo_rsa_private_key_file: RSA_PRI
589        RSA_free(ServerInfo.rsa_private_key);
590        ServerInfo.rsa_private_key = NULL;
591  
592 <      yyerror("Invalid key, ignoring");
592 >      conf_error_report("Invalid key, ignoring");
593        break;
594      }
595  
# Line 595 | Line 599 | serverinfo_rsa_private_key_file: RSA_PRI
599        RSA_free(ServerInfo.rsa_private_key);
600        ServerInfo.rsa_private_key = NULL;
601  
602 <      yyerror("Not a 2048 bit key, ignoring");
602 >      conf_error_report("Not a 2048 bit key, ignoring");
603 >    }
604 >  }
605 > #endif
606 > };
607 >
608 > serverinfo_ssl_dh_param_file: SSL_DH_PARAM_FILE '=' QSTRING ';'
609 > {
610 > /* TBD - XXX: error reporting */
611 > #ifdef HAVE_LIBCRYPTO
612 >  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
613 >  {
614 >    BIO *file = BIO_new_file(yylval.string, "r");
615 >
616 >    if (file)
617 >    {
618 >      DH *dh = PEM_read_bio_DHparams(file, NULL, NULL, NULL);
619 >
620 >      BIO_free(file);
621 >
622 >      if (dh)
623 >      {
624 >        if (DH_size(dh) < 128)
625 >          conf_error_report("Ignoring serverinfo::ssl_dh_param_file -- need at least a 1024 bit DH prime size");
626 >        else
627 >          SSL_CTX_set_tmp_dh(ServerInfo.server_ctx, dh);
628 >
629 >        DH_free(dh);
630 >      }
631      }
632    }
633   #endif
634   };
635  
636 + serverinfo_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
637 + {
638 + #ifdef HAVE_LIBCRYPTO
639 +  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
640 +    SSL_CTX_set_cipher_list(ServerInfo.server_ctx, yylval.string);
641 + #endif
642 + };
643 +
644   serverinfo_name: NAME '=' QSTRING ';'
645   {
646    /* this isn't rehashable */
647 <  if (ypass == 2)
647 >  if (conf_parser_ctx.pass == 2 && !ServerInfo.name)
648    {
649 <    if (ServerInfo.name == NULL)
649 >    if (valid_servname(yylval.string))
650 >      ServerInfo.name = xstrdup(yylval.string);
651 >    else
652      {
653 <      /* the ircd will exit() in main() if we dont set one */
654 <      if (strlen(yylval.string) <= HOSTLEN)
613 <        DupString(ServerInfo.name, yylval.string);
653 >      conf_error_report("Ignoring serverinfo::name -- invalid name. Aborting.");
654 >      exit(0);
655      }
656    }
657   };
# Line 618 | Line 659 | serverinfo_name: NAME '=' QSTRING ';'
659   serverinfo_sid: IRCD_SID '=' QSTRING ';'
660   {
661    /* this isn't rehashable */
662 <  if (ypass == 2 && !ServerInfo.sid)
662 >  if (conf_parser_ctx.pass == 2 && !ServerInfo.sid)
663    {
664      if (valid_sid(yylval.string))
665 <      DupString(ServerInfo.sid, yylval.string);
665 >      ServerInfo.sid = xstrdup(yylval.string);
666      else
667      {
668 <      ilog(L_ERROR, "Ignoring config file entry SID -- invalid SID. Aborting.");
668 >      conf_error_report("Ignoring serverinfo::sid -- invalid SID. Aborting.");
669        exit(0);
670      }
671    }
# Line 632 | Line 673 | serverinfo_sid: IRCD_SID '=' QSTRING ';'
673  
674   serverinfo_description: DESCRIPTION '=' QSTRING ';'
675   {
676 <  if (ypass == 2)
676 >  if (conf_parser_ctx.pass == 2)
677    {
678      MyFree(ServerInfo.description);
679 <    DupString(ServerInfo.description,yylval.string);
679 >    ServerInfo.description = xstrdup(yylval.string);
680    }
681   };
682  
683   serverinfo_network_name: NETWORK_NAME '=' QSTRING ';'
684   {
685 <  if (ypass == 2)
685 >  if (conf_parser_ctx.pass == 2)
686    {
687      char *p;
688  
# Line 649 | Line 690 | serverinfo_network_name: NETWORK_NAME '=
690        p = '\0';
691  
692      MyFree(ServerInfo.network_name);
693 <    DupString(ServerInfo.network_name, yylval.string);
693 >    ServerInfo.network_name = xstrdup(yylval.string);
694    }
695   };
696  
697   serverinfo_network_desc: NETWORK_DESC '=' QSTRING ';'
698   {
699 <  if (ypass == 2)
699 >  if (conf_parser_ctx.pass == 2)
700    {
701      MyFree(ServerInfo.network_desc);
702 <    DupString(ServerInfo.network_desc, yylval.string);
702 >    ServerInfo.network_desc = xstrdup(yylval.string);
703    }
704   };
705  
706   serverinfo_vhost: VHOST '=' QSTRING ';'
707   {
708 <  if (ypass == 2 && *yylval.string != '*')
708 >  if (conf_parser_ctx.pass == 2 && *yylval.string != '*')
709    {
710      struct addrinfo hints, *res;
711  
# Line 674 | Line 715 | serverinfo_vhost: VHOST '=' QSTRING ';'
715      hints.ai_socktype = SOCK_STREAM;
716      hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
717  
718 <    if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
719 <      ilog(L_ERROR, "Invalid netmask for server vhost(%s)", yylval.string);
718 >    if (getaddrinfo(yylval.string, NULL, &hints, &res))
719 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", yylval.string);
720      else
721      {
722        assert(res != NULL);
# Line 683 | Line 724 | serverinfo_vhost: VHOST '=' QSTRING ';'
724        memcpy(&ServerInfo.ip, res->ai_addr, res->ai_addrlen);
725        ServerInfo.ip.ss.ss_family = res->ai_family;
726        ServerInfo.ip.ss_len = res->ai_addrlen;
727 <      irc_freeaddrinfo(res);
727 >      freeaddrinfo(res);
728  
729        ServerInfo.specific_ipv4_vhost = 1;
730      }
# Line 693 | Line 734 | serverinfo_vhost: VHOST '=' QSTRING ';'
734   serverinfo_vhost6: VHOST6 '=' QSTRING ';'
735   {
736   #ifdef IPV6
737 <  if (ypass == 2 && *yylval.string != '*')
737 >  if (conf_parser_ctx.pass == 2 && *yylval.string != '*')
738    {
739      struct addrinfo hints, *res;
740  
# Line 703 | Line 744 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
744      hints.ai_socktype = SOCK_STREAM;
745      hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
746  
747 <    if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
748 <      ilog(L_ERROR, "Invalid netmask for server vhost6(%s)", yylval.string);
747 >    if (getaddrinfo(yylval.string, NULL, &hints, &res))
748 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost6(%s)", yylval.string);
749      else
750      {
751        assert(res != NULL);
# Line 712 | Line 753 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
753        memcpy(&ServerInfo.ip6, res->ai_addr, res->ai_addrlen);
754        ServerInfo.ip6.ss.ss_family = res->ai_family;
755        ServerInfo.ip6.ss_len = res->ai_addrlen;
756 <      irc_freeaddrinfo(res);
756 >      freeaddrinfo(res);
757  
758        ServerInfo.specific_ipv6_vhost = 1;
759      }
# Line 722 | Line 763 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
763  
764   serverinfo_max_clients: T_MAX_CLIENTS '=' NUMBER ';'
765   {
766 <  if (ypass == 2)
766 >  if (conf_parser_ctx.pass != 2)
767 >    break;
768 >
769 >  if ($3 < MAXCLIENTS_MIN)
770    {
771 <    recalc_fdlimit(NULL);
771 >    char buf[IRCD_BUFSIZE];
772  
773 <    if ($3 < MAXCLIENTS_MIN)
774 <    {
775 <      char buf[IRCD_BUFSIZE];
732 <      ircsprintf(buf, "MAXCLIENTS too low, setting to %d", MAXCLIENTS_MIN);
733 <      yyerror(buf);
734 <    }
735 <    else if ($3 > MAXCLIENTS_MAX)
736 <    {
737 <      char buf[IRCD_BUFSIZE];
738 <      ircsprintf(buf, "MAXCLIENTS too high, setting to %d", MAXCLIENTS_MAX);
739 <      yyerror(buf);
740 <    }
741 <    else
742 <      ServerInfo.max_clients = $3;
773 >    snprintf(buf, sizeof(buf), "MAXCLIENTS too low, setting to %d", MAXCLIENTS_MIN);
774 >    conf_error_report(buf);
775 >    ServerInfo.max_clients = MAXCLIENTS_MIN;
776    }
777 +  else if ($3 > MAXCLIENTS_MAX)
778 +  {
779 +    char buf[IRCD_BUFSIZE];
780 +
781 +    snprintf(buf, sizeof(buf), "MAXCLIENTS too high, setting to %d", MAXCLIENTS_MAX);
782 +    conf_error_report(buf);
783 +    ServerInfo.max_clients = MAXCLIENTS_MAX;
784 +  }
785 +  else
786 +    ServerInfo.max_clients = $3;
787   };
788  
789 < serverinfo_hub: HUB '=' TBOOL ';'
789 > serverinfo_max_nick_length: MAX_NICK_LENGTH '=' NUMBER ';'
790   {
791 <  if (ypass == 2)
791 >  if (conf_parser_ctx.pass != 2)
792 >    break;
793 >
794 >  if ($3 < 9)
795    {
796 <    if (yylval.number)
797 <    {
798 <      ServerInfo.hub = 1;
799 <      delete_capability("HUB");
800 <      add_capability("HUB", CAP_HUB, 1);
801 <    }
756 <    else if (ServerInfo.hub)
757 <    {
796 >    conf_error_report("max_nick_length too low, setting to 9");
797 >    ServerInfo.max_nick_length = 9;
798 >  }
799 >  else if ($3 > NICKLEN)
800 >  {
801 >    char buf[IRCD_BUFSIZE];
802  
803 <      ServerInfo.hub = 0;
804 <      delete_capability("HUB");
805 <    }
803 >    snprintf(buf, sizeof(buf), "max_nick_length too high, setting to %d", NICKLEN);
804 >    conf_error_report(buf);
805 >    ServerInfo.max_nick_length = NICKLEN;
806 >  }
807 >  else
808 >    ServerInfo.max_nick_length = $3;
809 > };
810 >
811 > serverinfo_max_topic_length: MAX_TOPIC_LENGTH '=' NUMBER ';'
812 > {
813 >  if (conf_parser_ctx.pass != 2)
814 >    break;
815 >
816 >  if ($3 < 80)
817 >  {
818 >    conf_error_report("max_topic_length too low, setting to 80");
819 >    ServerInfo.max_topic_length = 80;
820 >  }
821 >  else if ($3 > TOPICLEN)
822 >  {
823 >    char buf[IRCD_BUFSIZE];
824 >
825 >    snprintf(buf, sizeof(buf), "max_topic_length too high, setting to %d", TOPICLEN);
826 >    conf_error_report(buf);
827 >    ServerInfo.max_topic_length = TOPICLEN;
828    }
829 +  else
830 +    ServerInfo.max_topic_length = $3;
831 + };
832 +
833 + serverinfo_hub: HUB '=' TBOOL ';'
834 + {
835 +  if (conf_parser_ctx.pass == 2)
836 +    ServerInfo.hub = yylval.number;
837   };
838  
839   /***************************************************************************
# Line 773 | Line 847 | admin_item:  admin_name | admin_descript
847  
848   admin_name: NAME '=' QSTRING ';'
849   {
850 <  if (ypass == 2)
850 >  if (conf_parser_ctx.pass == 2)
851    {
852      MyFree(AdminInfo.name);
853 <    DupString(AdminInfo.name, yylval.string);
853 >    AdminInfo.name = xstrdup(yylval.string);
854    }
855   };
856  
857   admin_email: EMAIL '=' QSTRING ';'
858   {
859 <  if (ypass == 2)
859 >  if (conf_parser_ctx.pass == 2)
860    {
861      MyFree(AdminInfo.email);
862 <    DupString(AdminInfo.email, yylval.string);
862 >    AdminInfo.email = xstrdup(yylval.string);
863    }
864   };
865  
866   admin_description: DESCRIPTION '=' QSTRING ';'
867   {
868 <  if (ypass == 2)
868 >  if (conf_parser_ctx.pass == 2)
869    {
870      MyFree(AdminInfo.description);
871 <    DupString(AdminInfo.description, yylval.string);
871 >    AdminInfo.description = xstrdup(yylval.string);
872    }
873   };
874  
875   /***************************************************************************
876   *  section logging
877   ***************************************************************************/
878 < /* XXX */
879 < logging_entry:          LOGGING  '{' logging_items '}' ';' ;
878 > logging_entry:          T_LOG  '{' logging_items '}' ';' ;
879 > logging_items:          logging_items logging_item | logging_item ;
880  
881 < logging_items:          logging_items logging_item |
808 <                        logging_item ;
809 <
810 < logging_item:           logging_path | logging_oper_log |
811 <                        logging_log_level |
812 <                        logging_use_logging | logging_fuserlog |
813 <                        logging_foperlog | logging_fglinelog |
814 <                        logging_fklinelog | logging_killlog |
815 <                        logging_foperspylog | logging_ioerrlog |
816 <                        logging_ffailed_operlog |
881 > logging_item:           logging_use_logging | logging_file_entry |
882                          error ';' ;
883  
884 < logging_path:           T_LOGPATH '=' QSTRING ';'
820 <                        {
821 <                        };
822 <
823 < logging_oper_log:       OPER_LOG '=' QSTRING ';'
824 <                        {
825 <                        };
826 <
827 < logging_fuserlog: FUSERLOG '=' QSTRING ';'
884 > logging_use_logging: USE_LOGGING '=' TBOOL ';'
885   {
886 <  if (ypass == 2)
887 <    strlcpy(ConfigLoggingEntry.userlog, yylval.string,
831 <            sizeof(ConfigLoggingEntry.userlog));
886 >  if (conf_parser_ctx.pass == 2)
887 >    ConfigLoggingEntry.use_logging = yylval.number;
888   };
889  
890 < logging_ffailed_operlog: FFAILED_OPERLOG '=' QSTRING ';'
890 > logging_file_entry:
891   {
892 <  if (ypass == 2)
893 <    strlcpy(ConfigLoggingEntry.failed_operlog, yylval.string,
894 <            sizeof(ConfigLoggingEntry.failed_operlog));
839 < };
840 <
841 < logging_foperlog: FOPERLOG '=' QSTRING ';'
892 >  if (conf_parser_ctx.pass == 2)
893 >    reset_block_state();
894 > } T_FILE  '{' logging_file_items '}' ';'
895   {
896 <  if (ypass == 2)
897 <    strlcpy(ConfigLoggingEntry.operlog, yylval.string,
845 <            sizeof(ConfigLoggingEntry.operlog));
846 < };
896 >  if (conf_parser_ctx.pass != 2)
897 >    break;
898  
899 < logging_foperspylog: FOPERSPYLOG '=' QSTRING ';'
900 < {
901 <  if (ypass == 2)
851 <    strlcpy(ConfigLoggingEntry.operspylog, yylval.string,
852 <            sizeof(ConfigLoggingEntry.operspylog));
899 >  if (block_state.type.value && block_state.file.buf[0])
900 >    log_add_file(block_state.type.value, block_state.size.value,
901 >                 block_state.file.buf);
902   };
903  
904 < logging_fglinelog: FGLINELOG '=' QSTRING ';'
905 < {
857 <  if (ypass == 2)
858 <    strlcpy(ConfigLoggingEntry.glinelog, yylval.string,
859 <            sizeof(ConfigLoggingEntry.glinelog));
860 < };
904 > logging_file_items: logging_file_items logging_file_item |
905 >                    logging_file_item ;
906  
907 < logging_fklinelog: FKLINELOG '=' QSTRING ';'
908 < {
864 <  if (ypass == 2)
865 <    strlcpy(ConfigLoggingEntry.klinelog, yylval.string,
866 <            sizeof(ConfigLoggingEntry.klinelog));
867 < };
907 > logging_file_item:  logging_file_name | logging_file_type |
908 >                    logging_file_size | error ';' ;
909  
910 < logging_ioerrlog: FIOERRLOG '=' QSTRING ';'
910 > logging_file_name: NAME '=' QSTRING ';'
911   {
912 <  if (ypass == 2)
913 <    strlcpy(ConfigLoggingEntry.ioerrlog, yylval.string,
914 <            sizeof(ConfigLoggingEntry.ioerrlog));
915 < };
912 >  if (conf_parser_ctx.pass != 2)
913 >    break;
914 >
915 >  strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
916 > }
917  
918 < logging_killlog: FKILLLOG '=' QSTRING ';'
918 > logging_file_size: T_SIZE '=' sizespec ';'
919 > {
920 >  block_state.size.value = $3;
921 > } | T_SIZE '=' T_UNLIMITED ';'
922   {
923 <  if (ypass == 2)
879 <    strlcpy(ConfigLoggingEntry.killlog, yylval.string,
880 <            sizeof(ConfigLoggingEntry.killlog));
923 >  block_state.size.value = 0;
924   };
925  
926 < logging_log_level: LOG_LEVEL '=' T_L_CRIT ';'
884 < {
885 <  if (ypass == 2)
886 <    set_log_level(L_CRIT);
887 < } | LOG_LEVEL '=' T_L_ERROR ';'
888 < {
889 <  if (ypass == 2)
890 <    set_log_level(L_ERROR);
891 < } | LOG_LEVEL '=' T_L_WARN ';'
892 < {
893 <  if (ypass == 2)
894 <    set_log_level(L_WARN);
895 < } | LOG_LEVEL '=' T_L_NOTICE ';'
896 < {
897 <  if (ypass == 2)
898 <    set_log_level(L_NOTICE);
899 < } | LOG_LEVEL '=' T_L_TRACE ';'
900 < {
901 <  if (ypass == 2)
902 <    set_log_level(L_TRACE);
903 < } | LOG_LEVEL '=' T_L_INFO ';'
904 < {
905 <  if (ypass == 2)
906 <    set_log_level(L_INFO);
907 < } | LOG_LEVEL '=' T_L_DEBUG ';'
926 > logging_file_type: TYPE
927   {
928 <  if (ypass == 2)
929 <    set_log_level(L_DEBUG);
930 < };
928 >  if (conf_parser_ctx.pass == 2)
929 >    block_state.type.value = 0;
930 > } '='  logging_file_type_items ';' ;
931  
932 < logging_use_logging: USE_LOGGING '=' TBOOL ';'
932 > logging_file_type_items: logging_file_type_items ',' logging_file_type_item | logging_file_type_item;
933 > logging_file_type_item:  USER
934   {
935 <  if (ypass == 2)
936 <    ConfigLoggingEntry.use_logging = yylval.number;
935 >  if (conf_parser_ctx.pass == 2)
936 >    block_state.type.value = LOG_TYPE_USER;
937 > } | OPERATOR
938 > {
939 >  if (conf_parser_ctx.pass == 2)
940 >    block_state.type.value = LOG_TYPE_OPER;
941 > } | GLINE
942 > {
943 >  if (conf_parser_ctx.pass == 2)
944 >    block_state.type.value = LOG_TYPE_GLINE;
945 > } | T_DLINE
946 > {
947 >  if (conf_parser_ctx.pass == 2)
948 >    block_state.type.value = LOG_TYPE_DLINE;
949 > } | KLINE
950 > {
951 >  if (conf_parser_ctx.pass == 2)
952 >    block_state.type.value = LOG_TYPE_KLINE;
953 > } | KILL
954 > {
955 >  if (conf_parser_ctx.pass == 2)
956 >    block_state.type.value = LOG_TYPE_KILL;
957 > } | T_DEBUG
958 > {
959 >  if (conf_parser_ctx.pass == 2)
960 >    block_state.type.value = LOG_TYPE_DEBUG;
961   };
962  
963 +
964   /***************************************************************************
965   * section oper
966   ***************************************************************************/
967   oper_entry: OPERATOR
968   {
969 <  if (ypass == 2)
970 <  {
971 <    yy_conf = make_conf_item(OPER_TYPE);
972 <    yy_aconf = map_to_conf(yy_conf);
973 <    SetConfEncrypted(yy_aconf); /* Yes, the default is encrypted */
974 <  }
930 <  else
931 <  {
932 <    MyFree(class_name);
933 <    class_name = NULL;
934 <  }
935 < } oper_name_b '{' oper_items '}' ';'
969 >  if (conf_parser_ctx.pass != 2)
970 >    break;
971 >
972 >  reset_block_state();
973 >  block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
974 > } '{' oper_items '}' ';'
975   {
976 <  if (ypass == 2)
938 <  {
939 <    struct CollectItem *yy_tmp;
940 <    dlink_node *ptr;
941 <    dlink_node *next_ptr;
976 >  dlink_node *ptr = NULL;
977  
978 <    conf_add_class_to_conf(yy_conf, class_name);
978 >  if (conf_parser_ctx.pass != 2)
979 >    break;
980  
981 <    /* Now, make sure there is a copy of the "base" given oper
982 <     * block in each of the collected copies
983 <     */
981 >  if (!block_state.name.buf[0])
982 >    break;
983 > #ifdef HAVE_LIBCRYPTO
984 >  if (!(block_state.file.buf[0] ||
985 >        block_state.rpass.buf[0]))
986 >    break;
987 > #else
988 >  if (!block_state.rpass.buf[0])
989 >    break;
990 > #endif
991  
992 <    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
993 <    {
994 <      struct AccessItem *new_aconf;
995 <      struct ConfItem *new_conf;
953 <      yy_tmp = ptr->data;
992 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
993 >  {
994 >    struct MaskItem *conf = NULL;
995 >    struct split_nuh_item nuh;
996  
997 <      new_conf = make_conf_item(OPER_TYPE);
998 <      new_aconf = (struct AccessItem *)map_to_conf(new_conf);
997 >    nuh.nuhmask  = ptr->data;
998 >    nuh.nickptr  = NULL;
999 >    nuh.userptr  = block_state.user.buf;
1000 >    nuh.hostptr  = block_state.host.buf;
1001 >    nuh.nicksize = 0;
1002 >    nuh.usersize = sizeof(block_state.user.buf);
1003 >    nuh.hostsize = sizeof(block_state.host.buf);
1004 >    split_nuh(&nuh);
1005  
1006 <      new_aconf->flags = yy_aconf->flags;
1006 >    conf        = conf_make(CONF_OPER);
1007 >    conf->name  = xstrdup(block_state.name.buf);
1008 >    conf->user  = xstrdup(block_state.user.buf);
1009 >    conf->host  = xstrdup(block_state.host.buf);
1010 >
1011 >    if (block_state.rpass.buf[0])
1012 >      conf->passwd = xstrdup(block_state.rpass.buf);
1013 >
1014 >    conf->flags = block_state.flags.value;
1015 >    conf->modes = block_state.modes.value;
1016 >    conf->port  = block_state.port.value;
1017 >    conf->htype = parse_netmask(conf->host, &conf->addr, &conf->bits);
1018  
1019 <      if (yy_conf->name != NULL)
961 <        DupString(new_conf->name, yy_conf->name);
962 <      if (yy_tmp->user != NULL)
963 <        DupString(new_aconf->user, yy_tmp->user);
964 <      else
965 <        DupString(new_aconf->user, "*");
966 <      if (yy_tmp->host != NULL)
967 <        DupString(new_aconf->host, yy_tmp->host);
968 <      else
969 <        DupString(new_aconf->host, "*");
970 <      conf_add_class_to_conf(new_conf, class_name);
971 <      if (yy_aconf->passwd != NULL)
972 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1019 >    conf_add_class_to_conf(conf, block_state.class.buf);
1020  
974      new_aconf->port = yy_aconf->port;
1021   #ifdef HAVE_LIBCRYPTO
1022 <      if (yy_aconf->rsa_public_key_file != NULL)
1023 <      {
1024 <        BIO *file;
1025 <
980 <        DupString(new_aconf->rsa_public_key_file,
981 <                  yy_aconf->rsa_public_key_file);
982 <
983 <        file = BIO_new_file(yy_aconf->rsa_public_key_file, "r");
984 <        new_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file,
985 <                                                           NULL, 0, NULL);
986 <        BIO_set_close(file, BIO_CLOSE);
987 <        BIO_free(file);
988 <      }
989 < #endif
1022 >    if (block_state.file.buf[0])
1023 >    {
1024 >      BIO *file = NULL;
1025 >      RSA *pkey = NULL;
1026  
1027 < #ifdef HAVE_LIBCRYPTO
992 <      if (yy_tmp->name && (yy_tmp->passwd || yy_aconf->rsa_public_key)
993 <          && yy_tmp->host)
994 < #else
995 <      if (yy_tmp->name && yy_tmp->passwd && yy_tmp->host)
996 < #endif
1027 >      if ((file = BIO_new_file(block_state.file.buf, "r")) == NULL)
1028        {
1029 <        conf_add_class_to_conf(new_conf, class_name);
1030 <        if (yy_tmp->name != NULL)
1000 <          DupString(new_conf->name, yy_tmp->name);
1029 >        conf_error_report("Ignoring rsa_public_key_file -- file doesn't exist");
1030 >        break;
1031        }
1032  
1033 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
1034 <      free_collect_item(yy_tmp);
1005 <    }
1006 <
1007 <    yy_conf = NULL;
1008 <    yy_aconf = NULL;
1009 <
1033 >      if ((pkey = PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL)) == NULL)
1034 >        conf_error_report("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
1035  
1036 <    MyFree(class_name);
1037 <    class_name = NULL;
1036 >      conf->rsa_public_key = pkey;
1037 >      BIO_set_close(file, BIO_CLOSE);
1038 >      BIO_free(file);
1039 >    }
1040 > #endif /* HAVE_LIBCRYPTO */
1041    }
1042 < };
1042 > };
1043  
1016 oper_name_b: | oper_name_t;
1044   oper_items:     oper_items oper_item | oper_item;
1045 < oper_item:      oper_name | oper_user | oper_password | oper_hidden_admin |
1046 <                oper_hidden_oper | oper_umodes |
1047 <                oper_class | oper_global_kill | oper_remote |
1021 <                oper_kline | oper_xline | oper_unkline |
1022 <                oper_gline | oper_nick_changes | oper_remoteban |
1023 <                oper_die | oper_rehash | oper_admin | oper_operwall |
1024 <                oper_encrypted | oper_rsa_public_key_file |
1025 <                oper_flags | error ';' ;
1045 > oper_item:      oper_name | oper_user | oper_password |
1046 >                oper_umodes | oper_class | oper_encrypted |
1047 >                oper_rsa_public_key_file | oper_flags | error ';' ;
1048  
1049   oper_name: NAME '=' QSTRING ';'
1050   {
1051 <  if (ypass == 2)
1052 <  {
1031 <    if (strlen(yylval.string) > OPERNICKLEN)
1032 <      yylval.string[OPERNICKLEN] = '\0';
1033 <
1034 <    MyFree(yy_conf->name);
1035 <    DupString(yy_conf->name, yylval.string);
1036 <  }
1037 < };
1038 <
1039 < oper_name_t: QSTRING
1040 < {
1041 <  if (ypass == 2)
1042 <  {
1043 <    if (strlen(yylval.string) > OPERNICKLEN)
1044 <      yylval.string[OPERNICKLEN] = '\0';
1045 <
1046 <    MyFree(yy_conf->name);
1047 <    DupString(yy_conf->name, yylval.string);
1048 <  }
1051 >  if (conf_parser_ctx.pass == 2)
1052 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1053   };
1054  
1055   oper_user: USER '=' QSTRING ';'
1056   {
1057 <  if (ypass == 2)
1058 <  {
1055 <    struct split_nuh_item nuh;
1056 <
1057 <    nuh.nuhmask  = yylval.string;
1058 <    nuh.nickptr  = NULL;
1059 <    nuh.userptr  = userbuf;
1060 <    nuh.hostptr  = hostbuf;
1061 <
1062 <    nuh.nicksize = 0;
1063 <    nuh.usersize = sizeof(userbuf);
1064 <    nuh.hostsize = sizeof(hostbuf);
1065 <
1066 <    split_nuh(&nuh);
1067 <
1068 <    if (yy_aconf->user == NULL)
1069 <    {
1070 <      DupString(yy_aconf->user, userbuf);
1071 <      DupString(yy_aconf->host, hostbuf);
1072 <    }
1073 <    else
1074 <    {
1075 <      struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
1076 <
1077 <      DupString(yy_tmp->user, userbuf);
1078 <      DupString(yy_tmp->host, hostbuf);
1079 <
1080 <      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1081 <    }
1082 <  }
1057 >  if (conf_parser_ctx.pass == 2)
1058 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1059   };
1060  
1061   oper_password: PASSWORD '=' QSTRING ';'
1062   {
1063 <  if (ypass == 2)
1064 <  {
1089 <    if (yy_aconf->passwd != NULL)
1090 <      memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1091 <
1092 <    MyFree(yy_aconf->passwd);
1093 <    DupString(yy_aconf->passwd, yylval.string);
1094 <  }
1063 >  if (conf_parser_ctx.pass == 2)
1064 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1065   };
1066  
1067   oper_encrypted: ENCRYPTED '=' TBOOL ';'
1068   {
1069 <  if (ypass == 2)
1069 >  if (conf_parser_ctx.pass == 2)
1070    {
1071      if (yylval.number)
1072 <      SetConfEncrypted(yy_aconf);
1072 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1073      else
1074 <      ClearConfEncrypted(yy_aconf);
1074 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1075    }
1076   };
1077  
1078   oper_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
1079   {
1080 < #ifdef HAVE_LIBCRYPTO
1081 <  if (ypass == 2)
1112 <  {
1113 <    BIO *file;
1114 <
1115 <    if (yy_aconf->rsa_public_key != NULL)
1116 <    {
1117 <      RSA_free(yy_aconf->rsa_public_key);
1118 <      yy_aconf->rsa_public_key = NULL;
1119 <    }
1120 <
1121 <    if (yy_aconf->rsa_public_key_file != NULL)
1122 <    {
1123 <      MyFree(yy_aconf->rsa_public_key_file);
1124 <      yy_aconf->rsa_public_key_file = NULL;
1125 <    }
1126 <
1127 <    DupString(yy_aconf->rsa_public_key_file, yylval.string);
1128 <    file = BIO_new_file(yylval.string, "r");
1129 <
1130 <    if (file == NULL)
1131 <    {
1132 <      yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
1133 <      break;
1134 <    }
1135 <
1136 <    yy_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
1137 <
1138 <    if (yy_aconf->rsa_public_key == NULL)
1139 <    {
1140 <      yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
1141 <      break;
1142 <    }
1143 <
1144 <    BIO_set_close(file, BIO_CLOSE);
1145 <    BIO_free(file);
1146 <  }
1147 < #endif /* HAVE_LIBCRYPTO */
1080 >  if (conf_parser_ctx.pass == 2)
1081 >    strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
1082   };
1083  
1084   oper_class: CLASS '=' QSTRING ';'
1085   {
1086 <  if (ypass == 2)
1087 <  {
1154 <    MyFree(class_name);
1155 <    DupString(class_name, yylval.string);
1156 <  }
1086 >  if (conf_parser_ctx.pass == 2)
1087 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1088   };
1089  
1090   oper_umodes: T_UMODES
1091   {
1092 <  if (ypass == 2)
1093 <    yy_aconf->modes = 0;
1092 >  if (conf_parser_ctx.pass == 2)
1093 >    block_state.modes.value = 0;
1094   } '='  oper_umodes_items ';' ;
1095  
1096   oper_umodes_items: oper_umodes_items ',' oper_umodes_item | oper_umodes_item;
1097   oper_umodes_item:  T_BOTS
1098   {
1099 <  if (ypass == 2)
1100 <    yy_aconf->modes |= UMODE_BOTS;
1099 >  if (conf_parser_ctx.pass == 2)
1100 >    block_state.modes.value |= UMODE_BOTS;
1101   } | T_CCONN
1102   {
1103 <  if (ypass == 2)
1104 <    yy_aconf->modes |= UMODE_CCONN;
1103 >  if (conf_parser_ctx.pass == 2)
1104 >    block_state.modes.value |= UMODE_CCONN;
1105   } | T_CCONN_FULL
1106   {
1107 <  if (ypass == 2)
1108 <    yy_aconf->modes |= UMODE_CCONN_FULL;
1107 >  if (conf_parser_ctx.pass == 2)
1108 >    block_state.modes.value |= UMODE_CCONN_FULL;
1109   } | T_DEAF
1110   {
1111 <  if (ypass == 2)
1112 <    yy_aconf->modes |= UMODE_DEAF;
1111 >  if (conf_parser_ctx.pass == 2)
1112 >    block_state.modes.value |= UMODE_DEAF;
1113   } | T_DEBUG
1114   {
1115 <  if (ypass == 2)
1116 <    yy_aconf->modes |= UMODE_DEBUG;
1115 >  if (conf_parser_ctx.pass == 2)
1116 >    block_state.modes.value |= UMODE_DEBUG;
1117   } | T_FULL
1118   {
1119 <  if (ypass == 2)
1120 <    yy_aconf->modes |= UMODE_FULL;
1119 >  if (conf_parser_ctx.pass == 2)
1120 >    block_state.modes.value |= UMODE_FULL;
1121 > } | HIDDEN
1122 > {
1123 >  if (conf_parser_ctx.pass == 2)
1124 >    block_state.modes.value |= UMODE_HIDDEN;
1125   } | T_SKILL
1126   {
1127 <  if (ypass == 2)
1128 <    yy_aconf->modes |= UMODE_SKILL;
1127 >  if (conf_parser_ctx.pass == 2)
1128 >    block_state.modes.value |= UMODE_SKILL;
1129   } | T_NCHANGE
1130   {
1131 <  if (ypass == 2)
1132 <    yy_aconf->modes |= UMODE_NCHANGE;
1131 >  if (conf_parser_ctx.pass == 2)
1132 >    block_state.modes.value |= UMODE_NCHANGE;
1133   } | T_REJ
1134   {
1135 <  if (ypass == 2)
1136 <    yy_aconf->modes |= UMODE_REJ;
1135 >  if (conf_parser_ctx.pass == 2)
1136 >    block_state.modes.value |= UMODE_REJ;
1137   } | T_UNAUTH
1138   {
1139 <  if (ypass == 2)
1140 <    yy_aconf->modes |= UMODE_UNAUTH;
1139 >  if (conf_parser_ctx.pass == 2)
1140 >    block_state.modes.value |= UMODE_UNAUTH;
1141   } | T_SPY
1142   {
1143 <  if (ypass == 2)
1144 <    yy_aconf->modes |= UMODE_SPY;
1143 >  if (conf_parser_ctx.pass == 2)
1144 >    block_state.modes.value |= UMODE_SPY;
1145   } | T_EXTERNAL
1146   {
1147 <  if (ypass == 2)
1148 <    yy_aconf->modes |= UMODE_EXTERNAL;
1147 >  if (conf_parser_ctx.pass == 2)
1148 >    block_state.modes.value |= UMODE_EXTERNAL;
1149   } | T_OPERWALL
1150   {
1151 <  if (ypass == 2)
1152 <    yy_aconf->modes |= UMODE_OPERWALL;
1151 >  if (conf_parser_ctx.pass == 2)
1152 >    block_state.modes.value |= UMODE_OPERWALL;
1153   } | T_SERVNOTICE
1154   {
1155 <  if (ypass == 2)
1156 <    yy_aconf->modes |= UMODE_SERVNOTICE;
1155 >  if (conf_parser_ctx.pass == 2)
1156 >    block_state.modes.value |= UMODE_SERVNOTICE;
1157   } | T_INVISIBLE
1158   {
1159 <  if (ypass == 2)
1160 <    yy_aconf->modes |= UMODE_INVISIBLE;
1159 >  if (conf_parser_ctx.pass == 2)
1160 >    block_state.modes.value |= UMODE_INVISIBLE;
1161   } | T_WALLOP
1162   {
1163 <  if (ypass == 2)
1164 <    yy_aconf->modes |= UMODE_WALLOP;
1163 >  if (conf_parser_ctx.pass == 2)
1164 >    block_state.modes.value |= UMODE_WALLOP;
1165   } | T_SOFTCALLERID
1166   {
1167 <  if (ypass == 2)
1168 <    yy_aconf->modes |= UMODE_SOFTCALLERID;
1167 >  if (conf_parser_ctx.pass == 2)
1168 >    block_state.modes.value |= UMODE_SOFTCALLERID;
1169   } | T_CALLERID
1170   {
1171 <  if (ypass == 2)
1172 <    yy_aconf->modes |= UMODE_CALLERID;
1171 >  if (conf_parser_ctx.pass == 2)
1172 >    block_state.modes.value |= UMODE_CALLERID;
1173   } | T_LOCOPS
1174   {
1175 <  if (ypass == 2)
1176 <    yy_aconf->modes |= UMODE_LOCOPS;
1242 < };
1243 <
1244 < oper_global_kill: GLOBAL_KILL '=' TBOOL ';'
1245 < {
1246 <  if (ypass == 2)
1247 <  {
1248 <    if (yylval.number)
1249 <      yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1250 <    else
1251 <      yy_aconf->port &= ~OPER_FLAG_GLOBAL_KILL;
1252 <  }
1253 < };
1254 <
1255 < oper_remote: REMOTE '=' TBOOL ';'
1256 < {
1257 <  if (ypass == 2)
1258 <  {
1259 <    if (yylval.number)
1260 <      yy_aconf->port |= OPER_FLAG_REMOTE;
1261 <    else
1262 <      yy_aconf->port &= ~OPER_FLAG_REMOTE;
1263 <  }
1264 < };
1265 <
1266 < oper_remoteban: REMOTEBAN '=' TBOOL ';'
1267 < {
1268 <  if (ypass == 2)
1269 <  {
1270 <    if (yylval.number)
1271 <      yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1272 <    else
1273 <      yy_aconf->port &= ~OPER_FLAG_REMOTEBAN;
1274 <  }
1275 < };
1276 <
1277 < oper_kline: KLINE '=' TBOOL ';'
1278 < {
1279 <  if (ypass == 2)
1280 <  {
1281 <    if (yylval.number)
1282 <      yy_aconf->port |= OPER_FLAG_K;
1283 <    else
1284 <      yy_aconf->port &= ~OPER_FLAG_K;
1285 <  }
1286 < };
1287 <
1288 < oper_xline: XLINE '=' TBOOL ';'
1289 < {
1290 <  if (ypass == 2)
1291 <  {
1292 <    if (yylval.number)
1293 <      yy_aconf->port |= OPER_FLAG_X;
1294 <    else
1295 <      yy_aconf->port &= ~OPER_FLAG_X;
1296 <  }
1297 < };
1298 <
1299 < oper_unkline: UNKLINE '=' TBOOL ';'
1300 < {
1301 <  if (ypass == 2)
1302 <  {
1303 <    if (yylval.number)
1304 <      yy_aconf->port |= OPER_FLAG_UNKLINE;
1305 <    else
1306 <      yy_aconf->port &= ~OPER_FLAG_UNKLINE;
1307 <  }
1308 < };
1309 <
1310 < oper_gline: GLINE '=' TBOOL ';'
1311 < {
1312 <  if (ypass == 2)
1313 <  {
1314 <    if (yylval.number)
1315 <      yy_aconf->port |= OPER_FLAG_GLINE;
1316 <    else
1317 <      yy_aconf->port &= ~OPER_FLAG_GLINE;
1318 <  }
1319 < };
1320 <
1321 < oper_nick_changes: NICK_CHANGES '=' TBOOL ';'
1322 < {
1323 <  if (ypass == 2)
1324 <  {
1325 <    if (yylval.number)
1326 <      yy_aconf->port |= OPER_FLAG_N;
1327 <    else
1328 <      yy_aconf->port &= ~OPER_FLAG_N;
1329 <  }
1330 < };
1331 <
1332 < oper_die: DIE '=' TBOOL ';'
1333 < {
1334 <  if (ypass == 2)
1335 <  {
1336 <    if (yylval.number)
1337 <      yy_aconf->port |= OPER_FLAG_DIE;
1338 <    else
1339 <      yy_aconf->port &= ~OPER_FLAG_DIE;
1340 <  }
1341 < };
1342 <
1343 < oper_rehash: REHASH '=' TBOOL ';'
1344 < {
1345 <  if (ypass == 2)
1346 <  {
1347 <    if (yylval.number)
1348 <      yy_aconf->port |= OPER_FLAG_REHASH;
1349 <    else
1350 <      yy_aconf->port &= ~OPER_FLAG_REHASH;
1351 <  }
1352 < };
1353 <
1354 < oper_admin: ADMIN '=' TBOOL ';'
1355 < {
1356 <  if (ypass == 2)
1357 <  {
1358 <    if (yylval.number)
1359 <      yy_aconf->port |= OPER_FLAG_ADMIN;
1360 <    else
1361 <      yy_aconf->port &= ~OPER_FLAG_ADMIN;
1362 <  }
1363 < };
1364 <
1365 < oper_hidden_admin: HIDDEN_ADMIN '=' TBOOL ';'
1366 < {
1367 <  if (ypass == 2)
1368 <  {
1369 <    if (yylval.number)
1370 <      yy_aconf->port |= OPER_FLAG_HIDDEN_ADMIN;
1371 <    else
1372 <      yy_aconf->port &= ~OPER_FLAG_HIDDEN_ADMIN;
1373 <  }
1374 < };
1375 <
1376 < oper_hidden_oper: HIDDEN_OPER '=' TBOOL ';'
1377 < {
1378 <  if (ypass == 2)
1379 <  {
1380 <    if (yylval.number)
1381 <      yy_aconf->port |= OPER_FLAG_HIDDEN_OPER;
1382 <    else
1383 <      yy_aconf->port &= ~OPER_FLAG_HIDDEN_OPER;
1384 <  }
1385 < };
1386 <
1387 < oper_operwall: T_OPERWALL '=' TBOOL ';'
1388 < {
1389 <  if (ypass == 2)
1390 <  {
1391 <    if (yylval.number)
1392 <      yy_aconf->port |= OPER_FLAG_OPERWALL;
1393 <    else
1394 <      yy_aconf->port &= ~OPER_FLAG_OPERWALL;
1395 <  }
1175 >  if (conf_parser_ctx.pass == 2)
1176 >    block_state.modes.value |= UMODE_LOCOPS;
1177   };
1178  
1179   oper_flags: IRCD_FLAGS
1180   {
1181 +  if (conf_parser_ctx.pass == 2)
1182 +    block_state.port.value = 0;
1183   } '='  oper_flags_items ';';
1184  
1185   oper_flags_items: oper_flags_items ',' oper_flags_item | oper_flags_item;
1186 < oper_flags_item: NOT { not_atom = 1; } oper_flags_item_atom
1404 <                | { not_atom = 0; } oper_flags_item_atom;
1405 <
1406 < oper_flags_item_atom: GLOBAL_KILL
1186 > oper_flags_item: GLOBAL_KILL
1187   {
1188 <  if (ypass == 2)
1189 <  {
1410 <    if (not_atom)yy_aconf->port &= ~OPER_FLAG_GLOBAL_KILL;
1411 <    else yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1412 <  }
1188 >  if (conf_parser_ctx.pass == 2)
1189 >    block_state.port.value |= OPER_FLAG_GLOBAL_KILL;
1190   } | REMOTE
1191   {
1192 <  if (ypass == 2)
1193 <  {
1417 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_REMOTE;
1418 <    else yy_aconf->port |= OPER_FLAG_REMOTE;
1419 <  }
1192 >  if (conf_parser_ctx.pass == 2)
1193 >    block_state.port.value |= OPER_FLAG_REMOTE;
1194   } | KLINE
1195   {
1196 <  if (ypass == 2)
1197 <  {
1424 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_K;
1425 <    else yy_aconf->port |= OPER_FLAG_K;
1426 <  }
1196 >  if (conf_parser_ctx.pass == 2)
1197 >    block_state.port.value |= OPER_FLAG_K;
1198   } | UNKLINE
1199   {
1200 <  if (ypass == 2)
1201 <  {
1202 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_UNKLINE;
1203 <    else yy_aconf->port |= OPER_FLAG_UNKLINE;
1204 <  }
1200 >  if (conf_parser_ctx.pass == 2)
1201 >    block_state.port.value |= OPER_FLAG_UNKLINE;
1202 > } | T_DLINE
1203 > {
1204 >  if (conf_parser_ctx.pass == 2)
1205 >    block_state.port.value |= OPER_FLAG_DLINE;
1206 > } | T_UNDLINE
1207 > {
1208 >  if (conf_parser_ctx.pass == 2)
1209 >    block_state.port.value |= OPER_FLAG_UNDLINE;
1210   } | XLINE
1211   {
1212 <  if (ypass == 2)
1213 <  {
1438 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_X;
1439 <    else yy_aconf->port |= OPER_FLAG_X;
1440 <  }
1212 >  if (conf_parser_ctx.pass == 2)
1213 >    block_state.port.value |= OPER_FLAG_X;
1214   } | GLINE
1215   {
1216 <  if (ypass == 2)
1217 <  {
1445 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_GLINE;
1446 <    else yy_aconf->port |= OPER_FLAG_GLINE;
1447 <  }
1216 >  if (conf_parser_ctx.pass == 2)
1217 >    block_state.port.value |= OPER_FLAG_GLINE;
1218   } | DIE
1219   {
1220 <  if (ypass == 2)
1221 <  {
1222 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_DIE;
1223 <    else yy_aconf->port |= OPER_FLAG_DIE;
1224 <  }
1220 >  if (conf_parser_ctx.pass == 2)
1221 >    block_state.port.value |= OPER_FLAG_DIE;
1222 > } | T_RESTART
1223 > {
1224 >  if (conf_parser_ctx.pass == 2)
1225 >    block_state.port.value |= OPER_FLAG_RESTART;
1226   } | REHASH
1227   {
1228 <  if (ypass == 2)
1229 <  {
1459 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_REHASH;
1460 <    else yy_aconf->port |= OPER_FLAG_REHASH;
1461 <  }
1228 >  if (conf_parser_ctx.pass == 2)
1229 >    block_state.port.value |= OPER_FLAG_REHASH;
1230   } | ADMIN
1231   {
1232 <  if (ypass == 2)
1233 <  {
1466 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_ADMIN;
1467 <    else yy_aconf->port |= OPER_FLAG_ADMIN;
1468 <  }
1469 < } | HIDDEN_ADMIN
1470 < {
1471 <  if (ypass == 2)
1472 <  {
1473 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_HIDDEN_ADMIN;
1474 <    else yy_aconf->port |= OPER_FLAG_HIDDEN_ADMIN;
1475 <  }
1232 >  if (conf_parser_ctx.pass == 2)
1233 >    block_state.port.value |= OPER_FLAG_ADMIN;
1234   } | NICK_CHANGES
1235   {
1236 <  if (ypass == 2)
1237 <  {
1480 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_N;
1481 <    else yy_aconf->port |= OPER_FLAG_N;
1482 <  }
1236 >  if (conf_parser_ctx.pass == 2)
1237 >    block_state.port.value |= OPER_FLAG_N;
1238   } | T_OPERWALL
1239   {
1240 <  if (ypass == 2)
1241 <  {
1242 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_OPERWALL;
1488 <    else yy_aconf->port |= OPER_FLAG_OPERWALL;
1489 <  }
1490 < } | OPER_SPY_T
1240 >  if (conf_parser_ctx.pass == 2)
1241 >    block_state.port.value |= OPER_FLAG_OPERWALL;
1242 > } | T_GLOBOPS
1243   {
1244 <  if (ypass == 2)
1245 <  {
1246 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_OPER_SPY;
1495 <    else yy_aconf->port |= OPER_FLAG_OPER_SPY;
1496 <  }
1497 < } | HIDDEN_OPER
1244 >  if (conf_parser_ctx.pass == 2)
1245 >    block_state.port.value |= OPER_FLAG_GLOBOPS;
1246 > } | OPER_SPY_T
1247   {
1248 <  if (ypass == 2)
1249 <  {
1501 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_HIDDEN_OPER;
1502 <    else yy_aconf->port |= OPER_FLAG_HIDDEN_OPER;
1503 <  }
1248 >  if (conf_parser_ctx.pass == 2)
1249 >    block_state.port.value |= OPER_FLAG_OPER_SPY;
1250   } | REMOTEBAN
1251   {
1252 <  if (ypass == 2)
1253 <  {
1254 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_REMOTEBAN;
1255 <    else yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1256 <  }
1257 < } | ENCRYPTED
1252 >  if (conf_parser_ctx.pass == 2)
1253 >    block_state.port.value |= OPER_FLAG_REMOTEBAN;
1254 > } | T_SET
1255 > {
1256 >  if (conf_parser_ctx.pass == 2)
1257 >    block_state.port.value |= OPER_FLAG_SET;
1258 > } | MODULE
1259   {
1260 <  if (ypass == 2)
1261 <  {
1515 <    if (not_atom) ClearConfEncrypted(yy_aconf);
1516 <    else SetConfEncrypted(yy_aconf);
1517 <  }
1260 >  if (conf_parser_ctx.pass == 2)
1261 >    block_state.port.value |= OPER_FLAG_MODULE;
1262   };
1263  
1264  
# Line 1523 | Line 1267 | oper_flags_item_atom: GLOBAL_KILL
1267   ***************************************************************************/
1268   class_entry: CLASS
1269   {
1270 <  if (ypass == 1)
1271 <  {
1528 <    yy_conf = make_conf_item(CLASS_TYPE);
1529 <    yy_class = map_to_conf(yy_conf);
1530 <  }
1531 < } class_name_b '{' class_items '}' ';'
1532 < {
1533 <  if (ypass == 1)
1534 <  {
1535 <    struct ConfItem *cconf = NULL;
1536 <    struct ClassItem *class = NULL;
1537 <
1538 <    if (yy_class_name == NULL)
1539 <      delete_conf_item(yy_conf);
1540 <    else
1541 <    {
1542 <      cconf = find_exact_name_conf(CLASS_TYPE, yy_class_name, NULL, NULL);
1543 <
1544 <      if (cconf != NULL)                /* The class existed already */
1545 <      {
1546 <        int user_count = 0;
1270 >  if (conf_parser_ctx.pass != 1)
1271 >    break;
1272  
1273 <        rebuild_cidr_class(cconf, yy_class);
1273 >  reset_block_state();
1274  
1275 <        class = map_to_conf(cconf);
1276 <
1277 <        user_count = class->curr_user_count;
1278 <        memcpy(class, yy_class, sizeof(*class));
1279 <        class->curr_user_count = user_count;
1280 <        class->active = 1;
1281 <
1282 <        delete_conf_item(yy_conf);
1283 <
1284 <        MyFree(cconf->name);            /* Allows case change of class name */
1285 <        cconf->name = yy_class_name;
1286 <      }
1287 <      else      /* Brand new class */
1288 <      {
1289 <        MyFree(yy_conf->name);          /* just in case it was allocated */
1290 <        yy_conf->name = yy_class_name;
1291 <        yy_class->active = 1;
1292 <      }
1293 <    }
1294 <
1295 <    yy_class_name = NULL;
1296 <  }
1275 >  block_state.ping_freq.value = DEFAULT_PINGFREQUENCY;
1276 >  block_state.con_freq.value  = DEFAULT_CONNECTFREQUENCY;
1277 >  block_state.max_total.value = MAXIMUM_LINKS_DEFAULT;
1278 >  block_state.max_sendq.value = DEFAULT_SENDQ;
1279 >  block_state.max_recvq.value = DEFAULT_RECVQ;
1280 > } '{' class_items '}' ';'
1281 > {
1282 >  struct ClassItem *class = NULL;
1283 >
1284 >  if (conf_parser_ctx.pass != 1)
1285 >    break;
1286 >
1287 >  if (!block_state.class.buf[0])
1288 >    break;
1289 >
1290 >  if (!(class = class_find(block_state.class.buf, 0)))
1291 >    class = class_make();
1292 >
1293 >  class->active = 1;
1294 >  MyFree(class->name);
1295 >  class->name = xstrdup(block_state.class.buf);
1296 >  class->ping_freq = block_state.ping_freq.value;
1297 >  class->max_perip = block_state.max_perip.value;
1298 >  class->con_freq = block_state.con_freq.value;
1299 >  class->max_total = block_state.max_total.value;
1300 >  class->max_global = block_state.max_global.value;
1301 >  class->max_local = block_state.max_local.value;
1302 >  class->max_ident = block_state.max_ident.value;
1303 >  class->max_sendq = block_state.max_sendq.value;
1304 >  class->max_recvq = block_state.max_recvq.value;
1305 >
1306 >  if (block_state.min_idle.value > block_state.max_idle.value)
1307 >  {
1308 >    block_state.min_idle.value = 0;
1309 >    block_state.max_idle.value = 0;
1310 >    block_state.flags.value &= ~CLASS_FLAGS_FAKE_IDLE;
1311 >  }
1312 >
1313 >  class->flags = block_state.flags.value;
1314 >  class->min_idle = block_state.min_idle.value;
1315 >  class->max_idle = block_state.max_idle.value;
1316 >
1317 >  if (class->number_per_cidr && block_state.number_per_cidr.value)
1318 >    if ((class->cidr_bitlen_ipv4 && block_state.cidr_bitlen_ipv4.value) ||
1319 >        (class->cidr_bitlen_ipv6 && block_state.cidr_bitlen_ipv6.value))
1320 >      if ((class->cidr_bitlen_ipv4 != block_state.cidr_bitlen_ipv4.value) ||
1321 >          (class->cidr_bitlen_ipv6 != block_state.cidr_bitlen_ipv6.value))
1322 >        rebuild_cidr_list(class);
1323 >
1324 >  class->cidr_bitlen_ipv4 = block_state.cidr_bitlen_ipv4.value;
1325 >  class->cidr_bitlen_ipv6 = block_state.cidr_bitlen_ipv6.value;
1326 >  class->number_per_cidr = block_state.number_per_cidr.value;
1327   };
1328  
1574 class_name_b: | class_name_t;
1575
1329   class_items:    class_items class_item | class_item;
1330   class_item:     class_name |
1331                  class_cidr_bitlen_ipv4 | class_cidr_bitlen_ipv6 |
1332                  class_ping_time |
1580                class_ping_warning |
1333                  class_number_per_cidr |
1334                  class_number_per_ip |
1335                  class_connectfreq |
# Line 1585 | Line 1337 | class_item:     class_name |
1337                  class_max_global |
1338                  class_max_local |
1339                  class_max_ident |
1340 <                class_sendq |
1340 >                class_sendq | class_recvq |
1341 >                class_min_idle |
1342 >                class_max_idle |
1343 >                class_flags |
1344                  error ';' ;
1345  
1346   class_name: NAME '=' QSTRING ';'
1347   {
1348 <  if (ypass == 1)
1349 <  {
1595 <    MyFree(yy_class_name);
1596 <    DupString(yy_class_name, yylval.string);
1597 <  }
1598 < };
1599 <
1600 < class_name_t: QSTRING
1601 < {
1602 <  if (ypass == 1)
1603 <  {
1604 <    MyFree(yy_class_name);
1605 <    DupString(yy_class_name, yylval.string);
1606 <  }
1348 >  if (conf_parser_ctx.pass == 1)
1349 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1350   };
1351  
1352   class_ping_time: PING_TIME '=' timespec ';'
1353   {
1354 <  if (ypass == 1)
1355 <    PingFreq(yy_class) = $3;
1613 < };
1614 <
1615 < class_ping_warning: PING_WARNING '=' timespec ';'
1616 < {
1617 <  if (ypass == 1)
1618 <    PingWarning(yy_class) = $3;
1354 >  if (conf_parser_ctx.pass == 1)
1355 >    block_state.ping_freq.value = $3;
1356   };
1357  
1358   class_number_per_ip: NUMBER_PER_IP '=' NUMBER ';'
1359   {
1360 <  if (ypass == 1)
1361 <    MaxPerIp(yy_class) = $3;
1360 >  if (conf_parser_ctx.pass == 1)
1361 >    block_state.max_perip.value = $3;
1362   };
1363  
1364   class_connectfreq: CONNECTFREQ '=' timespec ';'
1365   {
1366 <  if (ypass == 1)
1367 <    ConFreq(yy_class) = $3;
1366 >  if (conf_parser_ctx.pass == 1)
1367 >    block_state.con_freq.value = $3;
1368   };
1369  
1370   class_max_number: MAX_NUMBER '=' NUMBER ';'
1371   {
1372 <  if (ypass == 1)
1373 <    MaxTotal(yy_class) = $3;
1372 >  if (conf_parser_ctx.pass == 1)
1373 >    block_state.max_total.value = $3;
1374   };
1375  
1376   class_max_global: MAX_GLOBAL '=' NUMBER ';'
1377   {
1378 <  if (ypass == 1)
1379 <    MaxGlobal(yy_class) = $3;
1378 >  if (conf_parser_ctx.pass == 1)
1379 >    block_state.max_global.value = $3;
1380   };
1381  
1382   class_max_local: MAX_LOCAL '=' NUMBER ';'
1383   {
1384 <  if (ypass == 1)
1385 <    MaxLocal(yy_class) = $3;
1384 >  if (conf_parser_ctx.pass == 1)
1385 >    block_state.max_local.value = $3;
1386   };
1387  
1388   class_max_ident: MAX_IDENT '=' NUMBER ';'
1389   {
1390 <  if (ypass == 1)
1391 <    MaxIdent(yy_class) = $3;
1390 >  if (conf_parser_ctx.pass == 1)
1391 >    block_state.max_ident.value = $3;
1392   };
1393  
1394   class_sendq: SENDQ '=' sizespec ';'
1395   {
1396 <  if (ypass == 1)
1397 <    MaxSendq(yy_class) = $3;
1396 >  if (conf_parser_ctx.pass == 1)
1397 >    block_state.max_sendq.value = $3;
1398 > };
1399 >
1400 > class_recvq: T_RECVQ '=' sizespec ';'
1401 > {
1402 >  if (conf_parser_ctx.pass == 1)
1403 >    if ($3 >= CLIENT_FLOOD_MIN && $3 <= CLIENT_FLOOD_MAX)
1404 >      block_state.max_recvq.value = $3;
1405   };
1406  
1407   class_cidr_bitlen_ipv4: CIDR_BITLEN_IPV4 '=' NUMBER ';'
1408   {
1409 <  if (ypass == 1)
1410 <    CidrBitlenIPV4(yy_class) = $3;
1409 >  if (conf_parser_ctx.pass == 1)
1410 >    block_state.cidr_bitlen_ipv4.value = $3 > 32 ? 32 : $3;
1411   };
1412  
1413   class_cidr_bitlen_ipv6: CIDR_BITLEN_IPV6 '=' NUMBER ';'
1414   {
1415 <  if (ypass == 1)
1416 <    CidrBitlenIPV6(yy_class) = $3;
1415 >  if (conf_parser_ctx.pass == 1)
1416 >    block_state.cidr_bitlen_ipv6.value = $3 > 128 ? 128 : $3;
1417   };
1418  
1419   class_number_per_cidr: NUMBER_PER_CIDR '=' NUMBER ';'
1420   {
1421 <  if (ypass == 1)
1422 <    NumberPerCidr(yy_class) = $3;
1421 >  if (conf_parser_ctx.pass == 1)
1422 >    block_state.number_per_cidr.value = $3;
1423 > };
1424 >
1425 > class_min_idle: MIN_IDLE '=' timespec ';'
1426 > {
1427 >  if (conf_parser_ctx.pass != 1)
1428 >    break;
1429 >
1430 >  block_state.min_idle.value = $3;
1431 >  block_state.flags.value |= CLASS_FLAGS_FAKE_IDLE;
1432 > };
1433 >
1434 > class_max_idle: MAX_IDLE '=' timespec ';'
1435 > {
1436 >  if (conf_parser_ctx.pass != 1)
1437 >    break;
1438 >
1439 >  block_state.max_idle.value = $3;
1440 >  block_state.flags.value |= CLASS_FLAGS_FAKE_IDLE;
1441   };
1442  
1443 + class_flags: IRCD_FLAGS
1444 + {
1445 +  if (conf_parser_ctx.pass == 1)
1446 +    block_state.flags.value &= CLASS_FLAGS_FAKE_IDLE;
1447 + } '='  class_flags_items ';';
1448 +
1449 + class_flags_items: class_flags_items ',' class_flags_item | class_flags_item;
1450 + class_flags_item: RANDOM_IDLE
1451 + {
1452 +  if (conf_parser_ctx.pass == 1)
1453 +    block_state.flags.value |= CLASS_FLAGS_RANDOM_IDLE;
1454 + } | HIDE_IDLE_FROM_OPERS
1455 + {
1456 +  if (conf_parser_ctx.pass == 1)
1457 +    block_state.flags.value |= CLASS_FLAGS_HIDE_IDLE_FROM_OPERS;
1458 + };
1459 +
1460 +
1461   /***************************************************************************
1462   *  section listen
1463   ***************************************************************************/
1464   listen_entry: LISTEN
1465   {
1466 <  if (ypass == 2)
1467 <  {
1468 <    listener_address = NULL;
1689 <    listener_flags = 0;
1690 <  }
1691 < } '{' listen_items '}' ';'
1692 < {
1693 <  if (ypass == 2)
1694 <  {
1695 <    MyFree(listener_address);
1696 <    listener_address = NULL;
1697 <  }
1698 < };
1466 >  if (conf_parser_ctx.pass == 2)
1467 >    reset_block_state();
1468 > } '{' listen_items '}' ';';
1469  
1470   listen_flags: IRCD_FLAGS
1471   {
1472 <  listener_flags = 0;
1472 >  block_state.flags.value = 0;
1473   } '='  listen_flags_items ';';
1474  
1475   listen_flags_items: listen_flags_items ',' listen_flags_item | listen_flags_item;
1476   listen_flags_item: T_SSL
1477   {
1478 <  if (ypass == 2)
1479 <    listener_flags |= LISTENER_SSL;
1478 >  if (conf_parser_ctx.pass == 2)
1479 >    block_state.flags.value |= LISTENER_SSL;
1480   } | HIDDEN
1481   {
1482 <  if (ypass == 2)
1483 <    listener_flags |= LISTENER_HIDDEN;
1482 >  if (conf_parser_ctx.pass == 2)
1483 >    block_state.flags.value |= LISTENER_HIDDEN;
1484   } | T_SERVER
1485   {
1486 <  if (ypass == 2)
1487 <    listener_flags |= LISTENER_SERVER;
1486 >  if (conf_parser_ctx.pass == 2)
1487 >   block_state.flags.value |= LISTENER_SERVER;
1488   };
1489  
1720
1721
1490   listen_items:   listen_items listen_item | listen_item;
1491   listen_item:    listen_port | listen_flags | listen_address | listen_host | error ';';
1492  
1493 < listen_port: PORT '=' port_items { listener_flags = 0; } ';';
1493 > listen_port: PORT '=' port_items { block_state.flags.value = 0; } ';';
1494  
1495   port_items: port_items ',' port_item | port_item;
1496  
1497   port_item: NUMBER
1498   {
1499 <  if (ypass == 2)
1499 >  if (conf_parser_ctx.pass == 2)
1500    {
1501 <    if ((listener_flags & LISTENER_SSL))
1501 >    if (block_state.flags.value & LISTENER_SSL)
1502   #ifdef HAVE_LIBCRYPTO
1503 <      if (!ServerInfo.ctx)
1503 >      if (!ServerInfo.server_ctx)
1504   #endif
1505        {
1506 <        yyerror("SSL not available - port closed");
1506 >        conf_error_report("SSL not available - port closed");
1507          break;
1508        }
1509 <    add_listener($1, listener_address, listener_flags);
1509 >    add_listener($1, block_state.addr.buf, block_state.flags.value);
1510    }
1511   } | NUMBER TWODOTS NUMBER
1512   {
1513 <  if (ypass == 2)
1513 >  if (conf_parser_ctx.pass == 2)
1514    {
1515      int i;
1516  
1517 <    if ((listener_flags & LISTENER_SSL))
1517 >    if (block_state.flags.value & LISTENER_SSL)
1518   #ifdef HAVE_LIBCRYPTO
1519 <      if (!ServerInfo.ctx)
1519 >      if (!ServerInfo.server_ctx)
1520   #endif
1521        {
1522 <        yyerror("SSL not available - port closed");
1522 >        conf_error_report("SSL not available - port closed");
1523          break;
1524        }
1525  
1526      for (i = $1; i <= $3; ++i)
1527 <      add_listener(i, listener_address, listener_flags);
1527 >      add_listener(i, block_state.addr.buf, block_state.flags.value);
1528    }
1529   };
1530  
1531   listen_address: IP '=' QSTRING ';'
1532   {
1533 <  if (ypass == 2)
1534 <  {
1767 <    MyFree(listener_address);
1768 <    DupString(listener_address, yylval.string);
1769 <  }
1533 >  if (conf_parser_ctx.pass == 2)
1534 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
1535   };
1536  
1537   listen_host: HOST '=' QSTRING ';'
1538   {
1539 <  if (ypass == 2)
1540 <  {
1776 <    MyFree(listener_address);
1777 <    DupString(listener_address, yylval.string);
1778 <  }
1539 >  if (conf_parser_ctx.pass == 2)
1540 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
1541   };
1542  
1543   /***************************************************************************
# Line 1783 | Line 1545 | listen_host: HOST '=' QSTRING ';'
1545   ***************************************************************************/
1546   auth_entry: IRCD_AUTH
1547   {
1548 <  if (ypass == 2)
1549 <  {
1788 <    yy_conf = make_conf_item(CLIENT_TYPE);
1789 <    yy_aconf = map_to_conf(yy_conf);
1790 <  }
1791 <  else
1792 <  {
1793 <    MyFree(class_name);
1794 <    class_name = NULL;
1795 <  }
1548 >  if (conf_parser_ctx.pass == 2)
1549 >    reset_block_state();
1550   } '{' auth_items '}' ';'
1551   {
1552 <  if (ypass == 2)
1799 <  {
1800 <    struct CollectItem *yy_tmp = NULL;
1801 <    dlink_node *ptr = NULL, *next_ptr = NULL;
1552 >  dlink_node *ptr = NULL;
1553  
1554 <    if (yy_aconf->user && yy_aconf->host)
1555 <    {
1805 <      conf_add_class_to_conf(yy_conf, class_name);
1806 <      add_conf_by_address(CONF_CLIENT, yy_aconf);
1807 <    }
1808 <    else
1809 <      delete_conf_item(yy_conf);
1810 <
1811 <    /* copy over settings from first struct */
1812 <    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
1813 <    {
1814 <      struct AccessItem *new_aconf;
1815 <      struct ConfItem *new_conf;
1816 <
1817 <      new_conf = make_conf_item(CLIENT_TYPE);
1818 <      new_aconf = map_to_conf(new_conf);
1819 <
1820 <      yy_tmp = ptr->data;
1821 <
1822 <      assert(yy_tmp->user && yy_tmp->host);
1823 <
1824 <      if (yy_aconf->passwd != NULL)
1825 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1826 <      if (yy_conf->name != NULL)
1827 <        DupString(new_conf->name, yy_conf->name);
1828 <      if (yy_aconf->passwd != NULL)
1829 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1830 <
1831 <      new_aconf->flags = yy_aconf->flags;
1832 <      new_aconf->port  = yy_aconf->port;
1833 <
1834 <      DupString(new_aconf->user, yy_tmp->user);
1835 <      collapse(new_aconf->user);
1836 <
1837 <      DupString(new_aconf->host, yy_tmp->host);
1838 <      collapse(new_aconf->host);
1839 <
1840 <      conf_add_class_to_conf(new_conf, class_name);
1841 <      add_conf_by_address(CONF_CLIENT, new_aconf);
1842 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
1843 <      free_collect_item(yy_tmp);
1844 <    }
1845 <
1846 <    MyFree(class_name);
1847 <    class_name = NULL;
1848 <    yy_conf = NULL;
1849 <    yy_aconf = NULL;
1850 <  }
1851 < };
1852 <
1853 < auth_items:     auth_items auth_item | auth_item;
1854 < auth_item:      auth_user | auth_passwd | auth_class | auth_flags |
1855 <                auth_kline_exempt | auth_need_ident |
1856 <                auth_exceed_limit | auth_no_tilde | auth_gline_exempt |
1857 <                auth_spoof | auth_spoof_notice |
1858 <                auth_redir_serv | auth_redir_port | auth_can_flood |
1859 <                auth_need_password | auth_encrypted | error ';' ;
1554 >  if (conf_parser_ctx.pass != 2)
1555 >    break;
1556  
1557 < auth_user: USER '=' QSTRING ';'
1862 < {
1863 <  if (ypass == 2)
1557 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
1558    {
1559 <    struct CollectItem *yy_tmp = NULL;
1559 >    struct MaskItem *conf = NULL;
1560      struct split_nuh_item nuh;
1561  
1562 <    nuh.nuhmask  = yylval.string;
1562 >    nuh.nuhmask  = ptr->data;
1563      nuh.nickptr  = NULL;
1564 <    nuh.userptr  = userbuf;
1565 <    nuh.hostptr  = hostbuf;
1872 <
1564 >    nuh.userptr  = block_state.user.buf;
1565 >    nuh.hostptr  = block_state.host.buf;
1566      nuh.nicksize = 0;
1567 <    nuh.usersize = sizeof(userbuf);
1568 <    nuh.hostsize = sizeof(hostbuf);
1876 <
1567 >    nuh.usersize = sizeof(block_state.user.buf);
1568 >    nuh.hostsize = sizeof(block_state.host.buf);
1569      split_nuh(&nuh);
1570  
1571 <    if (yy_aconf->user == NULL)
1572 <    {
1573 <      DupString(yy_aconf->user, userbuf);
1574 <      DupString(yy_aconf->host, hostbuf);
1575 <    }
1576 <    else
1577 <    {
1578 <      yy_tmp = MyMalloc(sizeof(struct CollectItem));
1571 >    conf        = conf_make(CONF_CLIENT);
1572 >    conf->user  = xstrdup(collapse(block_state.user.buf));
1573 >    conf->host  = xstrdup(collapse(block_state.host.buf));
1574 >
1575 >    if (block_state.rpass.buf[0])
1576 >      conf->passwd = xstrdup(block_state.rpass.buf);
1577 >    if (block_state.name.buf[0])
1578 >      conf->passwd = xstrdup(block_state.name.buf);
1579  
1580 <      DupString(yy_tmp->user, userbuf);
1581 <      DupString(yy_tmp->host, hostbuf);
1580 >    conf->flags = block_state.flags.value;
1581 >    conf->port  = block_state.port.value;
1582  
1583 <      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1584 <    }
1583 >    conf_add_class_to_conf(conf, block_state.class.buf);
1584 >    add_conf_by_address(CONF_CLIENT, conf);
1585    }
1586 < };
1586 > };
1587  
1588 < /* XXX - IP/IPV6 tags don't exist anymore - put IP/IPV6 into user. */
1588 > auth_items:     auth_items auth_item | auth_item;
1589 > auth_item:      auth_user | auth_passwd | auth_class | auth_flags |
1590 >                auth_spoof | auth_redir_serv | auth_redir_port |
1591 >                auth_encrypted | error ';' ;
1592  
1593 < auth_passwd: PASSWORD '=' QSTRING ';'
1593 > auth_user: USER '=' QSTRING ';'
1594   {
1595 <  if (ypass == 2)
1596 <  {
1902 <    /* be paranoid */
1903 <    if (yy_aconf->passwd != NULL)
1904 <      memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1905 <
1906 <    MyFree(yy_aconf->passwd);
1907 <    DupString(yy_aconf->passwd, yylval.string);
1908 <  }
1595 >  if (conf_parser_ctx.pass == 2)
1596 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1597   };
1598  
1599 < auth_spoof_notice: SPOOF_NOTICE '=' TBOOL ';'
1599 > auth_passwd: PASSWORD '=' QSTRING ';'
1600   {
1601 <  if (ypass == 2)
1602 <  {
1915 <    if (yylval.number)
1916 <      yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1917 <    else
1918 <      yy_aconf->flags &= ~CONF_FLAGS_SPOOF_NOTICE;
1919 <  }
1601 >  if (conf_parser_ctx.pass == 2)
1602 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1603   };
1604  
1605   auth_class: CLASS '=' QSTRING ';'
1606   {
1607 <  if (ypass == 2)
1608 <  {
1926 <    MyFree(class_name);
1927 <    DupString(class_name, yylval.string);
1928 <  }
1607 >  if (conf_parser_ctx.pass == 2)
1608 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1609   };
1610  
1611   auth_encrypted: ENCRYPTED '=' TBOOL ';'
1612   {
1613 <  if (ypass == 2)
1613 >  if (conf_parser_ctx.pass == 2)
1614    {
1615      if (yylval.number)
1616 <      SetConfEncrypted(yy_aconf);
1616 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1617      else
1618 <      ClearConfEncrypted(yy_aconf);
1618 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1619    }
1620   };
1621  
1622   auth_flags: IRCD_FLAGS
1623   {
1624 +  if (conf_parser_ctx.pass == 2)
1625 +    block_state.flags.value &= CONF_FLAGS_ENCRYPTED;
1626   } '='  auth_flags_items ';';
1627  
1628   auth_flags_items: auth_flags_items ',' auth_flags_item | auth_flags_item;
1629 < auth_flags_item: NOT { not_atom = 1; } auth_flags_item_atom
1948 <                | { not_atom = 0; } auth_flags_item_atom;
1949 <
1950 < auth_flags_item_atom: SPOOF_NOTICE
1629 > auth_flags_item: SPOOF_NOTICE
1630   {
1631 <  if (ypass == 2)
1632 <  {
1954 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_SPOOF_NOTICE;
1955 <    else yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1956 <  }
1957 <
1631 >  if (conf_parser_ctx.pass == 2)
1632 >    block_state.flags.value |= CONF_FLAGS_SPOOF_NOTICE;
1633   } | EXCEED_LIMIT
1634   {
1635 <  if (ypass == 2)
1636 <  {
1962 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NOLIMIT;
1963 <    else yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
1964 <  }
1635 >  if (conf_parser_ctx.pass == 2)
1636 >    block_state.flags.value |= CONF_FLAGS_NOLIMIT;
1637   } | KLINE_EXEMPT
1638   {
1639 <  if (ypass == 2)
1640 <  {
1969 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTKLINE;
1970 <    else yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
1971 <  }
1639 >  if (conf_parser_ctx.pass == 2)
1640 >    block_state.flags.value |= CONF_FLAGS_EXEMPTKLINE;
1641   } | NEED_IDENT
1642   {
1643 <  if (ypass == 2)
1644 <  {
1976 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NEED_IDENTD;
1977 <    else yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
1978 <  }
1643 >  if (conf_parser_ctx.pass == 2)
1644 >    block_state.flags.value |= CONF_FLAGS_NEED_IDENTD;
1645   } | CAN_FLOOD
1646   {
1647 <  if (ypass == 2)
1648 <  {
1983 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_CAN_FLOOD;
1984 <    else yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
1985 <  }
1986 < } | CAN_IDLE
1987 < {
1988 <  if (ypass == 2)
1989 <  {
1990 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_IDLE_LINED;
1991 <    else yy_aconf->flags |= CONF_FLAGS_IDLE_LINED;
1992 <  }
1647 >  if (conf_parser_ctx.pass == 2)
1648 >    block_state.flags.value |= CONF_FLAGS_CAN_FLOOD;
1649   } | NO_TILDE
1650   {
1651 <  if (ypass == 2)
1652 <  {
1997 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NO_TILDE;
1998 <    else yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
1999 <  }
1651 >  if (conf_parser_ctx.pass == 2)
1652 >    block_state.flags.value |= CONF_FLAGS_NO_TILDE;
1653   } | GLINE_EXEMPT
1654   {
1655 <  if (ypass == 2)
1656 <  {
2004 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTGLINE;
2005 <    else yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
2006 <  }
1655 >  if (conf_parser_ctx.pass == 2)
1656 >    block_state.flags.value |= CONF_FLAGS_EXEMPTGLINE;
1657   } | RESV_EXEMPT
1658   {
1659 <  if (ypass == 2)
1660 <  {
1661 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTRESV;
2012 <    else yy_aconf->flags |= CONF_FLAGS_EXEMPTRESV;
2013 <  }
2014 < } | NEED_PASSWORD
2015 < {
2016 <  if (ypass == 2)
2017 <  {
2018 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NEED_PASSWORD;
2019 <    else yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
2020 <  }
2021 < };
2022 <
2023 < auth_kline_exempt: KLINE_EXEMPT '=' TBOOL ';'
2024 < {
2025 <  if (ypass == 2)
2026 <  {
2027 <    if (yylval.number)
2028 <      yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
2029 <    else
2030 <      yy_aconf->flags &= ~CONF_FLAGS_EXEMPTKLINE;
2031 <  }
2032 < };
2033 <
2034 < auth_need_ident: NEED_IDENT '=' TBOOL ';'
2035 < {
2036 <  if (ypass == 2)
2037 <  {
2038 <    if (yylval.number)
2039 <      yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
2040 <    else
2041 <      yy_aconf->flags &= ~CONF_FLAGS_NEED_IDENTD;
2042 <  }
2043 < };
2044 <
2045 < auth_exceed_limit: EXCEED_LIMIT '=' TBOOL ';'
2046 < {
2047 <  if (ypass == 2)
2048 <  {
2049 <    if (yylval.number)
2050 <      yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
2051 <    else
2052 <      yy_aconf->flags &= ~CONF_FLAGS_NOLIMIT;
2053 <  }
2054 < };
2055 <
2056 < auth_can_flood: CAN_FLOOD '=' TBOOL ';'
2057 < {
2058 <  if (ypass == 2)
2059 <  {
2060 <    if (yylval.number)
2061 <      yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
2062 <    else
2063 <      yy_aconf->flags &= ~CONF_FLAGS_CAN_FLOOD;
2064 <  }
2065 < };
2066 <
2067 < auth_no_tilde: NO_TILDE '=' TBOOL ';'
1659 >  if (conf_parser_ctx.pass == 2)
1660 >    block_state.flags.value |= CONF_FLAGS_EXEMPTRESV;
1661 > } | T_WEBIRC
1662   {
1663 <  if (ypass == 2)
1664 <  {
1665 <    if (yylval.number)
2072 <      yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
2073 <    else
2074 <      yy_aconf->flags &= ~CONF_FLAGS_NO_TILDE;
2075 <  }
2076 < };
2077 <
2078 < auth_gline_exempt: GLINE_EXEMPT '=' TBOOL ';'
1663 >  if (conf_parser_ctx.pass == 2)
1664 >    block_state.flags.value |= CONF_FLAGS_WEBIRC;
1665 > } | NEED_PASSWORD
1666   {
1667 <  if (ypass == 2)
1668 <  {
2082 <    if (yylval.number)
2083 <      yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
2084 <    else
2085 <      yy_aconf->flags &= ~CONF_FLAGS_EXEMPTGLINE;
2086 <  }
1667 >  if (conf_parser_ctx.pass == 2)
1668 >    block_state.flags.value |= CONF_FLAGS_NEED_PASSWORD;
1669   };
1670  
2089 /* XXX - need check for illegal hostnames here */
1671   auth_spoof: SPOOF '=' QSTRING ';'
1672   {
1673 <  if (ypass == 2)
1674 <  {
2094 <    MyFree(yy_conf->name);
1673 >  if (conf_parser_ctx.pass != 2)
1674 >    break;
1675  
1676 <    if (strlen(yylval.string) < HOSTLEN)
1677 <    {    
1678 <      DupString(yy_conf->name, yylval.string);
1679 <      yy_aconf->flags |= CONF_FLAGS_SPOOF_IP;
2100 <    }
2101 <    else
2102 <    {
2103 <      ilog(L_ERROR, "Spoofs must be less than %d..ignoring it", HOSTLEN);
2104 <      yy_conf->name = NULL;
2105 <    }
1676 >  if (strlen(yylval.string) <= HOSTLEN && valid_hostname(yylval.string))
1677 >  {
1678 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1679 >    block_state.flags.value |= CONF_FLAGS_SPOOF_IP;
1680    }
1681 +  else
1682 +    ilog(LOG_TYPE_IRCD, "Spoof either is too long or contains invalid characters. Ignoring it.");
1683   };
1684  
1685   auth_redir_serv: REDIRSERV '=' QSTRING ';'
1686   {
1687 <  if (ypass == 2)
1688 <  {
1689 <    yy_aconf->flags |= CONF_FLAGS_REDIR;
1690 <    MyFree(yy_conf->name);
1691 <    DupString(yy_conf->name, yylval.string);
2116 <  }
1687 >  if (conf_parser_ctx.pass != 2)
1688 >    break;
1689 >
1690 >  strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1691 >  block_state.flags.value |= CONF_FLAGS_REDIR;
1692   };
1693  
1694   auth_redir_port: REDIRPORT '=' NUMBER ';'
1695   {
1696 <  if (ypass == 2)
1697 <  {
2123 <    yy_aconf->flags |= CONF_FLAGS_REDIR;
2124 <    yy_aconf->port = $3;
2125 <  }
2126 < };
1696 >  if (conf_parser_ctx.pass != 2)
1697 >    break;
1698  
1699 < auth_need_password: NEED_PASSWORD '=' TBOOL ';'
1700 < {
2130 <  if (ypass == 2)
2131 <  {
2132 <    if (yylval.number)
2133 <      yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
2134 <    else
2135 <      yy_aconf->flags &= ~CONF_FLAGS_NEED_PASSWORD;
2136 <  }
1699 >  block_state.flags.value |= CONF_FLAGS_REDIR;
1700 >  block_state.port.value = $3;
1701   };
1702  
1703  
# Line 2142 | Line 1706 | auth_need_password: NEED_PASSWORD '=' TB
1706   ***************************************************************************/
1707   resv_entry: RESV
1708   {
1709 <  if (ypass == 2)
1710 <  {
1711 <    MyFree(resv_reason);
1712 <    resv_reason = NULL;
1713 <  }
1714 < } '{' resv_items '}' ';'
2151 < {
2152 <  if (ypass == 2)
2153 <  {
2154 <    MyFree(resv_reason);
2155 <    resv_reason = NULL;
2156 <  }
2157 < };
1709 >  if (conf_parser_ctx.pass != 2)
1710 >    break;
1711 >
1712 >  reset_block_state();
1713 >  strlcpy(block_state.rpass.buf, CONF_NOREASON, sizeof(block_state.rpass.buf));
1714 > } '{' resv_items '}' ';';
1715  
1716   resv_items:     resv_items resv_item | resv_item;
1717   resv_item:      resv_creason | resv_channel | resv_nick | error ';' ;
1718  
1719   resv_creason: REASON '=' QSTRING ';'
1720   {
1721 <  if (ypass == 2)
1722 <  {
2166 <    MyFree(resv_reason);
2167 <    DupString(resv_reason, yylval.string);
2168 <  }
1721 >  if (conf_parser_ctx.pass == 2)
1722 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1723   };
1724  
1725   resv_channel: CHANNEL '=' QSTRING ';'
1726   {
1727 <  if (ypass == 2)
1728 <  {
2175 <    if (IsChanPrefix(*yylval.string))
2176 <    {
2177 <      char def_reason[] = "No reason";
1727 >  if (conf_parser_ctx.pass != 2)
1728 >    break;
1729  
1730 <      create_channel_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
1731 <    }
2181 <  }
2182 <  /* ignore it for now.. but we really should make a warning if
2183 <   * its an erroneous name --fl_ */
1730 >  if (IsChanPrefix(*yylval.string))
1731 >    create_channel_resv(yylval.string, block_state.rpass.buf, 1);
1732   };
1733  
1734   resv_nick: NICK '=' QSTRING ';'
1735   {
1736 <  if (ypass == 2)
1737 <  {
1738 <    char def_reason[] = "No reason";
1736 >  if (conf_parser_ctx.pass == 2)
1737 >    create_nick_resv(yylval.string, block_state.rpass.buf, 1);
1738 > };
1739  
1740 <    create_nick_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
1740 > /***************************************************************************
1741 > *  section service
1742 > ***************************************************************************/
1743 > service_entry: T_SERVICE '{' service_items '}' ';';
1744 >
1745 > service_items:     service_items service_item | service_item;
1746 > service_item:      service_name | error;
1747 >
1748 > service_name: NAME '=' QSTRING ';'
1749 > {
1750 >  if (conf_parser_ctx.pass == 2)
1751 >  {
1752 >    if (valid_servname(yylval.string))
1753 >    {
1754 >      struct MaskItem *conf = conf_make(CONF_SERVICE);
1755 >      conf->name = xstrdup(yylval.string);
1756 >    }
1757    }
1758   };
1759  
# Line 2198 | Line 1762 | resv_nick: NICK '=' QSTRING ';'
1762   ***************************************************************************/
1763   shared_entry: T_SHARED
1764   {
1765 <  if (ypass == 2)
1766 <  {
1767 <    yy_conf = make_conf_item(ULINE_TYPE);
1768 <    yy_match_item = map_to_conf(yy_conf);
1769 <    yy_match_item->action = SHARED_ALL;
1770 <  }
1765 >  if (conf_parser_ctx.pass != 2)
1766 >    break;
1767 >
1768 >  reset_block_state();
1769 >
1770 >  strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1771 >  strlcpy(block_state.user.buf, "*", sizeof(block_state.user.buf));
1772 >  strlcpy(block_state.host.buf, "*", sizeof(block_state.host.buf));
1773 >  block_state.flags.value = SHARED_ALL;
1774   } '{' shared_items '}' ';'
1775   {
1776 <  if (ypass == 2)
1777 <  {
1778 <    yy_conf = NULL;
1779 <  }
1776 >  struct MaskItem *conf = NULL;
1777 >
1778 >  if (conf_parser_ctx.pass != 2)
1779 >    break;
1780 >
1781 >  conf = conf_make(CONF_ULINE);
1782 >  conf->flags = block_state.flags.value;
1783 >  conf->name = xstrdup(block_state.name.buf);
1784 >  conf->user = xstrdup(block_state.user.buf);
1785 >  conf->user = xstrdup(block_state.host.buf);
1786   };
1787  
1788   shared_items: shared_items shared_item | shared_item;
# Line 2217 | Line 1790 | shared_item:  shared_name | shared_user
1790  
1791   shared_name: NAME '=' QSTRING ';'
1792   {
1793 <  if (ypass == 2)
1794 <  {
2222 <    MyFree(yy_conf->name);
2223 <    DupString(yy_conf->name, yylval.string);
2224 <  }
1793 >  if (conf_parser_ctx.pass == 2)
1794 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1795   };
1796  
1797   shared_user: USER '=' QSTRING ';'
1798   {
1799 <  if (ypass == 2)
1799 >  if (conf_parser_ctx.pass == 2)
1800    {
1801      struct split_nuh_item nuh;
1802  
1803      nuh.nuhmask  = yylval.string;
1804      nuh.nickptr  = NULL;
1805 <    nuh.userptr  = userbuf;
1806 <    nuh.hostptr  = hostbuf;
1805 >    nuh.userptr  = block_state.user.buf;
1806 >    nuh.hostptr  = block_state.host.buf;
1807  
1808      nuh.nicksize = 0;
1809 <    nuh.usersize = sizeof(userbuf);
1810 <    nuh.hostsize = sizeof(hostbuf);
1809 >    nuh.usersize = sizeof(block_state.user.buf);
1810 >    nuh.hostsize = sizeof(block_state.host.buf);
1811  
1812      split_nuh(&nuh);
2243
2244    DupString(yy_match_item->user, userbuf);
2245    DupString(yy_match_item->host, hostbuf);
1813    }
1814   };
1815  
1816   shared_type: TYPE
1817   {
1818 <  if (ypass == 2)
1819 <    yy_match_item->action = 0;
1818 >  if (conf_parser_ctx.pass == 2)
1819 >    block_state.flags.value = 0;
1820   } '=' shared_types ';' ;
1821  
1822   shared_types: shared_types ',' shared_type_item | shared_type_item;
1823   shared_type_item: KLINE
1824   {
1825 <  if (ypass == 2)
1826 <    yy_match_item->action |= SHARED_KLINE;
2260 < } | TKLINE
2261 < {
2262 <  if (ypass == 2)
2263 <    yy_match_item->action |= SHARED_TKLINE;
1825 >  if (conf_parser_ctx.pass == 2)
1826 >    block_state.flags.value |= SHARED_KLINE;
1827   } | UNKLINE
1828   {
1829 <  if (ypass == 2)
1830 <    yy_match_item->action |= SHARED_UNKLINE;
1831 < } | XLINE
1829 >  if (conf_parser_ctx.pass == 2)
1830 >    block_state.flags.value |= SHARED_UNKLINE;
1831 > } | T_DLINE
1832 > {
1833 >  if (conf_parser_ctx.pass == 2)
1834 >    block_state.flags.value |= SHARED_DLINE;
1835 > } | T_UNDLINE
1836   {
1837 <  if (ypass == 2)
1838 <    yy_match_item->action |= SHARED_XLINE;
1839 < } | TXLINE
1837 >  if (conf_parser_ctx.pass == 2)
1838 >    block_state.flags.value |= SHARED_UNDLINE;
1839 > } | XLINE
1840   {
1841 <  if (ypass == 2)
1842 <    yy_match_item->action |= SHARED_TXLINE;
1841 >  if (conf_parser_ctx.pass == 2)
1842 >    block_state.flags.value |= SHARED_XLINE;
1843   } | T_UNXLINE
1844   {
1845 <  if (ypass == 2)
1846 <    yy_match_item->action |= SHARED_UNXLINE;
1845 >  if (conf_parser_ctx.pass == 2)
1846 >    block_state.flags.value |= SHARED_UNXLINE;
1847   } | RESV
1848   {
1849 <  if (ypass == 2)
1850 <    yy_match_item->action |= SHARED_RESV;
2284 < } | TRESV
2285 < {
2286 <  if (ypass == 2)
2287 <    yy_match_item->action |= SHARED_TRESV;
1849 >  if (conf_parser_ctx.pass == 2)
1850 >    block_state.flags.value |= SHARED_RESV;
1851   } | T_UNRESV
1852   {
1853 <  if (ypass == 2)
1854 <    yy_match_item->action |= SHARED_UNRESV;
1853 >  if (conf_parser_ctx.pass == 2)
1854 >    block_state.flags.value |= SHARED_UNRESV;
1855   } | T_LOCOPS
1856   {
1857 <  if (ypass == 2)
1858 <    yy_match_item->action |= SHARED_LOCOPS;
1857 >  if (conf_parser_ctx.pass == 2)
1858 >    block_state.flags.value |= SHARED_LOCOPS;
1859   } | T_ALL
1860   {
1861 <  if (ypass == 2)
1862 <    yy_match_item->action = SHARED_ALL;
1861 >  if (conf_parser_ctx.pass == 2)
1862 >    block_state.flags.value = SHARED_ALL;
1863   };
1864  
1865   /***************************************************************************
# Line 2304 | Line 1867 | shared_type_item: KLINE
1867   ***************************************************************************/
1868   cluster_entry: T_CLUSTER
1869   {
1870 <  if (ypass == 2)
1871 <  {
1872 <    yy_conf = make_conf_item(CLUSTER_TYPE);
1873 <    yy_conf->flags = SHARED_ALL;
1874 <  }
1870 >  if (conf_parser_ctx.pass != 2)
1871 >    break;
1872 >
1873 >  reset_block_state();
1874 >
1875 >  strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1876 >  block_state.flags.value = SHARED_ALL;
1877   } '{' cluster_items '}' ';'
1878   {
1879 <  if (ypass == 2)
1880 <  {
1881 <    if (yy_conf->name == NULL)
1882 <      DupString(yy_conf->name, "*");
1883 <    yy_conf = NULL;
1884 <  }
1879 >  struct MaskItem *conf = NULL;
1880 >
1881 >  if (conf_parser_ctx.pass != 2)
1882 >    break;
1883 >
1884 >  conf = conf_make(CONF_CLUSTER);
1885 >  conf->flags = block_state.flags.value;
1886 >  conf->name = xstrdup(block_state.name.buf);
1887   };
1888  
1889   cluster_items:  cluster_items cluster_item | cluster_item;
# Line 2324 | Line 1891 | cluster_item:  cluster_name | cluster_typ
1891  
1892   cluster_name: NAME '=' QSTRING ';'
1893   {
1894 <  if (ypass == 2)
1895 <    DupString(yy_conf->name, yylval.string);
1894 >  if (conf_parser_ctx.pass == 2)
1895 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1896   };
1897  
1898   cluster_type: TYPE
1899   {
1900 <  if (ypass == 2)
1901 <    yy_conf->flags = 0;
1900 >  if (conf_parser_ctx.pass == 2)
1901 >    block_state.flags.value = 0;
1902   } '=' cluster_types ';' ;
1903  
1904   cluster_types:  cluster_types ',' cluster_type_item | cluster_type_item;
1905   cluster_type_item: KLINE
1906   {
1907 <  if (ypass == 2)
1908 <    yy_conf->flags |= SHARED_KLINE;
2342 < } | TKLINE
2343 < {
2344 <  if (ypass == 2)
2345 <    yy_conf->flags |= SHARED_TKLINE;
1907 >  if (conf_parser_ctx.pass == 2)
1908 >    block_state.flags.value |= SHARED_KLINE;
1909   } | UNKLINE
1910   {
1911 <  if (ypass == 2)
1912 <    yy_conf->flags |= SHARED_UNKLINE;
1913 < } | XLINE
1911 >  if (conf_parser_ctx.pass == 2)
1912 >    block_state.flags.value |= SHARED_UNKLINE;
1913 > } | T_DLINE
1914 > {
1915 >  if (conf_parser_ctx.pass == 2)
1916 >    block_state.flags.value |= SHARED_DLINE;
1917 > } | T_UNDLINE
1918   {
1919 <  if (ypass == 2)
1920 <    yy_conf->flags |= SHARED_XLINE;
1921 < } | TXLINE
1919 >  if (conf_parser_ctx.pass == 2)
1920 >    block_state.flags.value |= SHARED_UNDLINE;
1921 > } | XLINE
1922   {
1923 <  if (ypass == 2)
1924 <    yy_conf->flags |= SHARED_TXLINE;
1923 >  if (conf_parser_ctx.pass == 2)
1924 >    block_state.flags.value |= SHARED_XLINE;
1925   } | T_UNXLINE
1926   {
1927 <  if (ypass == 2)
1928 <    yy_conf->flags |= SHARED_UNXLINE;
1927 >  if (conf_parser_ctx.pass == 2)
1928 >    block_state.flags.value |= SHARED_UNXLINE;
1929   } | RESV
1930   {
1931 <  if (ypass == 2)
1932 <    yy_conf->flags |= SHARED_RESV;
2366 < } | TRESV
2367 < {
2368 <  if (ypass == 2)
2369 <    yy_conf->flags |= SHARED_TRESV;
1931 >  if (conf_parser_ctx.pass == 2)
1932 >    block_state.flags.value |= SHARED_RESV;
1933   } | T_UNRESV
1934   {
1935 <  if (ypass == 2)
1936 <    yy_conf->flags |= SHARED_UNRESV;
1935 >  if (conf_parser_ctx.pass == 2)
1936 >    block_state.flags.value |= SHARED_UNRESV;
1937   } | T_LOCOPS
1938   {
1939 <  if (ypass == 2)
1940 <    yy_conf->flags |= SHARED_LOCOPS;
1939 >  if (conf_parser_ctx.pass == 2)
1940 >    block_state.flags.value |= SHARED_LOCOPS;
1941   } | T_ALL
1942   {
1943 <  if (ypass == 2)
1944 <    yy_conf->flags = SHARED_ALL;
1943 >  if (conf_parser_ctx.pass == 2)
1944 >    block_state.flags.value = SHARED_ALL;
1945   };
1946  
1947   /***************************************************************************
# Line 2386 | Line 1949 | cluster_type_item: KLINE
1949   ***************************************************************************/
1950   connect_entry: CONNECT  
1951   {
2389  if (ypass == 2)
2390  {
2391    yy_conf = make_conf_item(SERVER_TYPE);
2392    yy_aconf = (struct AccessItem *)map_to_conf(yy_conf);
2393    yy_aconf->passwd = NULL;
2394    /* defaults */
2395    yy_aconf->port = PORTNUM;
1952  
1953 <    if (ConfigFileEntry.burst_away)
1954 <      yy_aconf->flags = CONF_FLAGS_BURST_AWAY;
2399 <  }
2400 <  else
2401 <  {
2402 <    MyFree(class_name);
2403 <    class_name = NULL;
2404 <  }
2405 < } connect_name_b '{' connect_items '}' ';'
2406 < {
2407 <  if (ypass == 2)
2408 <  {
2409 <    struct CollectItem *yy_hconf=NULL;
2410 <    struct CollectItem *yy_lconf=NULL;
2411 <    dlink_node *ptr;
2412 <    dlink_node *next_ptr;
2413 < #ifdef HAVE_LIBCRYPTO
2414 <    if (yy_aconf->host &&
2415 <        ((yy_aconf->passwd && yy_aconf->spasswd) ||
2416 <         (yy_aconf->rsa_public_key && IsConfCryptLink(yy_aconf))))
2417 < #else /* !HAVE_LIBCRYPTO */
2418 <      if (yy_aconf->host && !IsConfCryptLink(yy_aconf) &&
2419 <          yy_aconf->passwd && yy_aconf->spasswd)
2420 < #endif /* !HAVE_LIBCRYPTO */
2421 <        {
2422 <          if (conf_add_server(yy_conf, class_name) == -1)
2423 <          {
2424 <            delete_conf_item(yy_conf);
2425 <            yy_conf = NULL;
2426 <            yy_aconf = NULL;
2427 <          }
2428 <        }
2429 <        else
2430 <        {
2431 <          /* Even if yy_conf ->name is NULL
2432 <           * should still unhook any hub/leaf confs still pending
2433 <           */
2434 <          unhook_hub_leaf_confs();
2435 <
2436 <          if (yy_conf->name != NULL)
2437 <          {
2438 < #ifndef HAVE_LIBCRYPTO
2439 <            if (IsConfCryptLink(yy_aconf))
2440 <              yyerror("Ignoring connect block -- no OpenSSL support");
2441 < #else
2442 <            if (IsConfCryptLink(yy_aconf) && !yy_aconf->rsa_public_key)
2443 <              yyerror("Ignoring connect block -- missing key");
2444 < #endif
2445 <            if (yy_aconf->host == NULL)
2446 <              yyerror("Ignoring connect block -- missing host");
2447 <            else if (!IsConfCryptLink(yy_aconf) &&
2448 <                    (!yy_aconf->passwd || !yy_aconf->spasswd))
2449 <              yyerror("Ignoring connect block -- missing password");
2450 <          }
2451 <
2452 <
2453 <          /* XXX
2454 <           * This fixes a try_connections() core (caused by invalid class_ptr
2455 <           * pointers) reported by metalrock. That's an ugly fix, but there
2456 <           * is currently no better way. The entire config subsystem needs an
2457 <           * rewrite ASAP. make_conf_item() shouldn't really add things onto
2458 <           * a doubly linked list immediately without any sanity checks!  -Michael
2459 <           */
2460 <          delete_conf_item(yy_conf);
2461 <
2462 <          yy_aconf = NULL;
2463 <          yy_conf = NULL;
2464 <        }
2465 <
2466 <      /*
2467 <       * yy_conf is still pointing at the server that is having
2468 <       * a connect block built for it. This means, y_aconf->name
2469 <       * points to the actual irc name this server will be known as.
2470 <       * Now this new server has a set or even just one hub_mask (or leaf_mask)
2471 <       * given in the link list at yy_hconf. Fill in the HUB confs
2472 <       * from this link list now.
2473 <       */        
2474 <      DLINK_FOREACH_SAFE(ptr, next_ptr, hub_conf_list.head)
2475 <      {
2476 <        struct ConfItem *new_hub_conf;
2477 <        struct MatchItem *match_item;
1953 >  if (conf_parser_ctx.pass != 2)
1954 >    break;
1955  
1956 <        yy_hconf = ptr->data;
1956 >  reset_block_state();
1957 >  block_state.port.value = PORTNUM;
1958 > } '{' connect_items '}' ';'
1959 > {
1960 >  struct MaskItem *conf = NULL;
1961 >  struct addrinfo hints, *res;
1962 >
1963 >  if (conf_parser_ctx.pass != 2)
1964 >    break;
1965 >
1966 >  if (!block_state.name.buf[0] ||
1967 >      !block_state.host.buf[0])
1968 >    break;
1969 >
1970 >  if (!(block_state.rpass.buf[0] ||
1971 >        block_state.spass.buf[0]))
1972 >    break;
1973 >
1974 >  if (has_wildcards(block_state.name.buf) ||
1975 >      has_wildcards(block_state.host.buf))
1976 >    break;
1977 >
1978 >  conf = conf_make(CONF_SERVER);
1979 >  conf->port = block_state.port.value;
1980 >  conf->flags = block_state.flags.value;
1981 >  conf->aftype = block_state.aftype.value;
1982 >  conf->host = xstrdup(block_state.host.buf);
1983 >  conf->name = xstrdup(block_state.name.buf);
1984 >  conf->passwd = xstrdup(block_state.rpass.buf);
1985 >  conf->spasswd = xstrdup(block_state.spass.buf);
1986 >  conf->cipher_list = xstrdup(block_state.ciph.buf);
1987  
1988 <        /* yy_conf == NULL is a fatal error for this connect block! */
1989 <        if ((yy_conf != NULL) && (yy_conf->name != NULL))
2483 <        {
2484 <          new_hub_conf = make_conf_item(HUB_TYPE);
2485 <          match_item = (struct MatchItem *)map_to_conf(new_hub_conf);
2486 <          DupString(new_hub_conf->name, yy_conf->name);
2487 <          if (yy_hconf->user != NULL)
2488 <            DupString(match_item->user, yy_hconf->user);
2489 <          else
2490 <            DupString(match_item->user, "*");
2491 <          if (yy_hconf->host != NULL)
2492 <            DupString(match_item->host, yy_hconf->host);
2493 <          else
2494 <            DupString(match_item->host, "*");
2495 <        }
2496 <        dlinkDelete(&yy_hconf->node, &hub_conf_list);
2497 <        free_collect_item(yy_hconf);
2498 <      }
1988 >  dlinkMoveList(&block_state.leaf.list, &conf->leaf_list);
1989 >  dlinkMoveList(&block_state.hub.list, &conf->hub_list);
1990  
1991 <      /* Ditto for the LEAF confs */
1991 >  if (block_state.bind.buf[0])
1992 >  {
1993 >    memset(&hints, 0, sizeof(hints));
1994  
1995 <      DLINK_FOREACH_SAFE(ptr, next_ptr, leaf_conf_list.head)
1996 <      {
1997 <        struct ConfItem *new_leaf_conf;
2505 <        struct MatchItem *match_item;
1995 >    hints.ai_family   = AF_UNSPEC;
1996 >    hints.ai_socktype = SOCK_STREAM;
1997 >    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
1998  
1999 <        yy_lconf = ptr->data;
1999 >    if (getaddrinfo(block_state.bind.buf, NULL, &hints, &res))
2000 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", block_state.bind.buf);
2001 >    else
2002 >    {
2003 >      assert(res != NULL);
2004  
2005 <        if ((yy_conf != NULL) && (yy_conf->name != NULL))
2006 <        {
2007 <          new_leaf_conf = make_conf_item(LEAF_TYPE);
2008 <          match_item = (struct MatchItem *)map_to_conf(new_leaf_conf);
2009 <          DupString(new_leaf_conf->name, yy_conf->name);
2514 <          if (yy_lconf->user != NULL)
2515 <            DupString(match_item->user, yy_lconf->user);
2516 <          else
2517 <            DupString(match_item->user, "*");
2518 <          if (yy_lconf->host != NULL)
2519 <            DupString(match_item->host, yy_lconf->host);
2520 <          else
2521 <            DupString(match_item->host, "*");
2522 <        }
2523 <        dlinkDelete(&yy_lconf->node, &leaf_conf_list);
2524 <        free_collect_item(yy_lconf);
2525 <      }
2526 <      MyFree(class_name);
2527 <      class_name = NULL;
2528 <      yy_conf = NULL;
2529 <      yy_aconf = NULL;
2005 >      memcpy(&conf->bind, res->ai_addr, res->ai_addrlen);
2006 >      conf->bind.ss.ss_family = res->ai_family;
2007 >      conf->bind.ss_len = res->ai_addrlen;
2008 >      freeaddrinfo(res);
2009 >    }
2010    }
2011 +
2012 +  conf_add_class_to_conf(conf, block_state.class.buf);
2013 +  lookup_confhost(conf);
2014   };
2015  
2533 connect_name_b: | connect_name_t;
2016   connect_items:  connect_items connect_item | connect_item;
2017   connect_item:   connect_name | connect_host | connect_vhost |
2018                  connect_send_password | connect_accept_password |
2019 <                connect_aftype | connect_port |
2020 <                connect_fakename | connect_flags | connect_hub_mask |
2021 <                connect_leaf_mask | connect_class | connect_auto |
2022 <                connect_encrypted | connect_compressed | connect_cryptlink |
2541 <                connect_rsa_public_key_file | connect_cipher_preference |
2542 <                connect_topicburst | error ';' ;
2019 >                connect_aftype | connect_port | connect_ssl_cipher_list |
2020 >                connect_flags | connect_hub_mask | connect_leaf_mask |
2021 >                connect_class | connect_encrypted |
2022 >                error ';' ;
2023  
2024   connect_name: NAME '=' QSTRING ';'
2025   {
2026 <  if (ypass == 2)
2027 <  {
2548 <    if (yy_conf->name != NULL)
2549 <      yyerror("Multiple connect name entry");
2550 <
2551 <    MyFree(yy_conf->name);
2552 <    DupString(yy_conf->name, yylval.string);
2553 <  }
2554 < };
2555 <
2556 < connect_name_t: QSTRING
2557 < {
2558 <  if (ypass == 2)
2559 <  {
2560 <    if (yy_conf->name != NULL)
2561 <      yyerror("Multiple connect name entry");
2562 <
2563 <    MyFree(yy_conf->name);
2564 <    DupString(yy_conf->name, yylval.string);
2565 <  }
2026 >  if (conf_parser_ctx.pass == 2)
2027 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
2028   };
2029  
2030   connect_host: HOST '=' QSTRING ';'
2031   {
2032 <  if (ypass == 2)
2033 <  {
2572 <    MyFree(yy_aconf->host);
2573 <    DupString(yy_aconf->host, yylval.string);
2574 <  }
2032 >  if (conf_parser_ctx.pass == 2)
2033 >    strlcpy(block_state.host.buf, yylval.string, sizeof(block_state.host.buf));
2034   };
2035  
2036   connect_vhost: VHOST '=' QSTRING ';'
2037   {
2038 <  if (ypass == 2)
2039 <  {
2581 <    struct addrinfo hints, *res;
2582 <
2583 <    memset(&hints, 0, sizeof(hints));
2584 <
2585 <    hints.ai_family   = AF_UNSPEC;
2586 <    hints.ai_socktype = SOCK_STREAM;
2587 <    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
2588 <
2589 <    if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
2590 <      ilog(L_ERROR, "Invalid netmask for server vhost(%s)", yylval.string);
2591 <    else
2592 <    {
2593 <      assert(res != NULL);
2594 <
2595 <      memcpy(&yy_aconf->my_ipnum, res->ai_addr, res->ai_addrlen);
2596 <      yy_aconf->my_ipnum.ss.ss_family = res->ai_family;
2597 <      yy_aconf->my_ipnum.ss_len = res->ai_addrlen;
2598 <      irc_freeaddrinfo(res);
2599 <    }
2600 <  }
2038 >  if (conf_parser_ctx.pass == 2)
2039 >    strlcpy(block_state.bind.buf, yylval.string, sizeof(block_state.bind.buf));
2040   };
2041  
2042   connect_send_password: SEND_PASSWORD '=' QSTRING ';'
2043   {
2044 <  if (ypass == 2)
2045 <  {
2607 <    if ($3[0] == ':')
2608 <      yyerror("Server passwords cannot begin with a colon");
2609 <    else if (strchr($3, ' ') != NULL)
2610 <      yyerror("Server passwords cannot contain spaces");
2611 <    else {
2612 <      if (yy_aconf->spasswd != NULL)
2613 <        memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd));
2044 >  if (conf_parser_ctx.pass != 2)
2045 >    break;
2046  
2047 <      MyFree(yy_aconf->spasswd);
2048 <      DupString(yy_aconf->spasswd, yylval.string);
2049 <    }
2050 <  }
2047 >  if ($3[0] == ':')
2048 >    conf_error_report("Server passwords cannot begin with a colon");
2049 >  else if (strchr($3, ' ') != NULL)
2050 >    conf_error_report("Server passwords cannot contain spaces");
2051 >  else
2052 >    strlcpy(block_state.spass.buf, yylval.string, sizeof(block_state.spass.buf));
2053   };
2054  
2055   connect_accept_password: ACCEPT_PASSWORD '=' QSTRING ';'
2056   {
2057 <  if (ypass == 2)
2058 <  {
2625 <    if ($3[0] == ':')
2626 <      yyerror("Server passwords cannot begin with a colon");
2627 <    else if (strchr($3, ' ') != NULL)
2628 <      yyerror("Server passwords cannot contain spaces");
2629 <    else {
2630 <      if (yy_aconf->passwd != NULL)
2631 <        memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
2057 >  if (conf_parser_ctx.pass != 2)
2058 >    break;
2059  
2060 <      MyFree(yy_aconf->passwd);
2061 <      DupString(yy_aconf->passwd, yylval.string);
2062 <    }
2063 <  }
2060 >  if ($3[0] == ':')
2061 >    conf_error_report("Server passwords cannot begin with a colon");
2062 >  else if (strchr($3, ' ') != NULL)
2063 >    conf_error_report("Server passwords cannot contain spaces");
2064 >  else
2065 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2066   };
2067  
2068   connect_port: PORT '=' NUMBER ';'
2069   {
2070 <  if (ypass == 2)
2071 <    yy_aconf->port = $3;
2070 >  if (conf_parser_ctx.pass == 2)
2071 >    block_state.port.value = $3;
2072   };
2073  
2074   connect_aftype: AFTYPE '=' T_IPV4 ';'
2075   {
2076 <  if (ypass == 2)
2077 <    yy_aconf->aftype = AF_INET;
2076 >  if (conf_parser_ctx.pass == 2)
2077 >    block_state.aftype.value = AF_INET;
2078   } | AFTYPE '=' T_IPV6 ';'
2079   {
2080   #ifdef IPV6
2081 <  if (ypass == 2)
2082 <    yy_aconf->aftype = AF_INET6;
2081 >  if (conf_parser_ctx.pass == 2)
2082 >    block_state.aftype.value = AF_INET6;
2083   #endif
2084   };
2085  
2657 connect_fakename: FAKENAME '=' QSTRING ';'
2658 {
2659  if (ypass == 2)
2660  {
2661    MyFree(yy_aconf->fakename);
2662    DupString(yy_aconf->fakename, yylval.string);
2663  }
2664 };
2665
2086   connect_flags: IRCD_FLAGS
2087   {
2088 +  block_state.flags.value &= CONF_FLAGS_ENCRYPTED;
2089   } '='  connect_flags_items ';';
2090  
2091   connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;
2092 < connect_flags_item: NOT  { not_atom = 1; } connect_flags_item_atom
2672 <                        |  { not_atom = 0; } connect_flags_item_atom;
2673 <
2674 < connect_flags_item_atom: COMPRESSED
2675 < {
2676 <  if (ypass == 2)
2677 < #ifndef HAVE_LIBZ
2678 <    yyerror("Ignoring flags = compressed; -- no zlib support");
2679 < #else
2680 < {
2681 <   if (not_atom)ClearConfCompressed(yy_aconf);
2682 <   else SetConfCompressed(yy_aconf);
2683 < }
2684 < #endif
2685 < } | CRYPTLINK
2686 < {
2687 <  if (ypass == 2)
2688 <  {
2689 <    if (not_atom)ClearConfCryptLink(yy_aconf);
2690 <    else SetConfCryptLink(yy_aconf);
2691 <  }
2692 < } | AUTOCONN
2092 > connect_flags_item: AUTOCONN
2093   {
2094 <  if (ypass == 2)
2095 <  {
2096 <    if (not_atom)ClearConfAllowAutoConn(yy_aconf);
2697 <    else SetConfAllowAutoConn(yy_aconf);
2698 <  }
2699 < } | BURST_AWAY
2700 < {
2701 <  if (ypass == 2)
2702 <  {
2703 <    if (not_atom)ClearConfAwayBurst(yy_aconf);
2704 <    else SetConfAwayBurst(yy_aconf);
2705 <  }
2706 < } | TOPICBURST
2707 < {
2708 <  if (ypass == 2)
2709 <  {
2710 <    if (not_atom)ClearConfTopicBurst(yy_aconf);
2711 <    else SetConfTopicBurst(yy_aconf);
2712 <  }
2713 < }
2714 < ;
2715 <
2716 < connect_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
2094 >  if (conf_parser_ctx.pass == 2)
2095 >    block_state.flags.value |= CONF_FLAGS_ALLOW_AUTO_CONN;
2096 > } | T_SSL
2097   {
2098 < #ifdef HAVE_LIBCRYPTO
2099 <  if (ypass == 2)
2720 <  {
2721 <    BIO *file;
2722 <
2723 <    if (yy_aconf->rsa_public_key != NULL)
2724 <    {
2725 <      RSA_free(yy_aconf->rsa_public_key);
2726 <      yy_aconf->rsa_public_key = NULL;
2727 <    }
2728 <
2729 <    if (yy_aconf->rsa_public_key_file != NULL)
2730 <    {
2731 <      MyFree(yy_aconf->rsa_public_key_file);
2732 <      yy_aconf->rsa_public_key_file = NULL;
2733 <    }
2734 <
2735 <    DupString(yy_aconf->rsa_public_key_file, yylval.string);
2736 <
2737 <    if ((file = BIO_new_file(yylval.string, "r")) == NULL)
2738 <    {
2739 <      yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
2740 <      break;
2741 <    }
2742 <
2743 <    yy_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
2744 <
2745 <    if (yy_aconf->rsa_public_key == NULL)
2746 <    {
2747 <      yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
2748 <      break;
2749 <    }
2750 <      
2751 <    BIO_set_close(file, BIO_CLOSE);
2752 <    BIO_free(file);
2753 <  }
2754 < #endif /* HAVE_LIBCRYPTO */
2098 >  if (conf_parser_ctx.pass == 2)
2099 >    block_state.flags.value |= CONF_FLAGS_SSL;
2100   };
2101  
2102   connect_encrypted: ENCRYPTED '=' TBOOL ';'
2103   {
2104 <  if (ypass == 2)
2104 >  if (conf_parser_ctx.pass == 2)
2105    {
2106      if (yylval.number)
2107 <      yy_aconf->flags |= CONF_FLAGS_ENCRYPTED;
2107 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
2108      else
2109 <      yy_aconf->flags &= ~CONF_FLAGS_ENCRYPTED;
2765 <  }
2766 < };
2767 <
2768 < connect_cryptlink: CRYPTLINK '=' TBOOL ';'
2769 < {
2770 <  if (ypass == 2)
2771 <  {
2772 <    if (yylval.number)
2773 <      yy_aconf->flags |= CONF_FLAGS_CRYPTLINK;
2774 <    else
2775 <      yy_aconf->flags &= ~CONF_FLAGS_CRYPTLINK;
2776 <  }
2777 < };
2778 <
2779 < connect_compressed: COMPRESSED '=' TBOOL ';'
2780 < {
2781 <  if (ypass == 2)
2782 <  {
2783 <    if (yylval.number)
2784 < #ifndef HAVE_LIBZ
2785 <      yyerror("Ignoring compressed=yes; -- no zlib support");
2786 < #else
2787 <      yy_aconf->flags |= CONF_FLAGS_COMPRESSED;
2788 < #endif
2789 <    else
2790 <      yy_aconf->flags &= ~CONF_FLAGS_COMPRESSED;
2791 <  }
2792 < };
2793 <
2794 < connect_auto: AUTOCONN '=' TBOOL ';'
2795 < {
2796 <  if (ypass == 2)
2797 <  {
2798 <    if (yylval.number)
2799 <      yy_aconf->flags |= CONF_FLAGS_ALLOW_AUTO_CONN;
2800 <    else
2801 <      yy_aconf->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN;
2802 <  }
2803 < };
2804 <
2805 < connect_topicburst: TOPICBURST '=' TBOOL ';'
2806 < {
2807 <  if (ypass == 2)
2808 <  {
2809 <    if (yylval.number)
2810 <      SetConfTopicBurst(yy_aconf);
2811 <    else
2812 <      ClearConfTopicBurst(yy_aconf);
2109 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
2110    }
2111   };
2112  
2113   connect_hub_mask: HUB_MASK '=' QSTRING ';'
2114   {
2115 <  if (ypass == 2)
2116 <  {
2820 <    struct CollectItem *yy_tmp;
2821 <
2822 <    yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2823 <    DupString(yy_tmp->host, yylval.string);
2824 <    DupString(yy_tmp->user, "*");
2825 <    dlinkAdd(yy_tmp, &yy_tmp->node, &hub_conf_list);
2826 <  }
2115 >  if (conf_parser_ctx.pass == 2)
2116 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.hub.list);
2117   };
2118  
2119   connect_leaf_mask: LEAF_MASK '=' QSTRING ';'
2120   {
2121 <  if (ypass == 2)
2122 <  {
2833 <    struct CollectItem *yy_tmp;
2834 <
2835 <    yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2836 <    DupString(yy_tmp->host, yylval.string);
2837 <    DupString(yy_tmp->user, "*");
2838 <    dlinkAdd(yy_tmp, &yy_tmp->node, &leaf_conf_list);
2839 <  }
2121 >  if (conf_parser_ctx.pass == 2)
2122 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.leaf.list);
2123   };
2124  
2125   connect_class: CLASS '=' QSTRING ';'
2126   {
2127 <  if (ypass == 2)
2128 <  {
2846 <    MyFree(class_name);
2847 <    DupString(class_name, yylval.string);
2848 <  }
2127 >  if (conf_parser_ctx.pass == 2)
2128 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
2129   };
2130  
2131 < connect_cipher_preference: CIPHER_PREFERENCE '=' QSTRING ';'
2131 > connect_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
2132   {
2133   #ifdef HAVE_LIBCRYPTO
2134 <  if (ypass == 2)
2135 <  {
2856 <    struct EncCapability *ecap;
2857 <    const char *cipher_name;
2858 <    int found = 0;
2859 <
2860 <    yy_aconf->cipher_preference = NULL;
2861 <    cipher_name = yylval.string;
2862 <
2863 <    for (ecap = CipherTable; ecap->name; ecap++)
2864 <    {
2865 <      if ((irccmp(ecap->name, cipher_name) == 0) &&
2866 <          (ecap->cap & CAP_ENC_MASK))
2867 <      {
2868 <        yy_aconf->cipher_preference = ecap;
2869 <        found = 1;
2870 <        break;
2871 <      }
2872 <    }
2873 <
2874 <    if (!found)
2875 <      yyerror("Invalid cipher");
2876 <  }
2134 >  if (conf_parser_ctx.pass == 2)
2135 >    strlcpy(block_state.ciph.buf, yylval.string, sizeof(block_state.ciph.buf));
2136   #else
2137 <  if (ypass == 2)
2138 <    yyerror("Ignoring cipher_preference -- no OpenSSL support");
2137 >  if (conf_parser_ctx.pass == 2)
2138 >    conf_error_report("Ignoring connect::ciphers -- no OpenSSL support");
2139   #endif
2140   };
2141  
2142 +
2143   /***************************************************************************
2144   *  section kill
2145   ***************************************************************************/
2146   kill_entry: KILL
2147   {
2148 <  if (ypass == 2)
2149 <  {
2890 <    userbuf[0] = hostbuf[0] = reasonbuf[0] = '\0';
2891 <    regex_ban = 0;
2892 <  }
2148 >  if (conf_parser_ctx.pass == 2)
2149 >    reset_block_state();
2150   } '{' kill_items '}' ';'
2151   {
2152 <  if (ypass == 2)
2152 >  struct MaskItem *conf = NULL;
2153 >
2154 >  if (conf_parser_ctx.pass != 2)
2155 >    break;
2156 >
2157 >  if (!block_state.user.buf[0] ||
2158 >      !block_state.host.buf[0])
2159 >    break;
2160 >
2161 >
2162 >  if (block_state.port.value == 1)
2163    {
2164 <    if (userbuf[0] && hostbuf[0])
2164 > #ifdef HAVE_LIBPCRE
2165 >    void *exp_user = NULL;
2166 >    void *exp_host = NULL;
2167 >    const char *errptr = NULL;
2168 >
2169 >    if (!(exp_user = ircd_pcre_compile(block_state.user.buf, &errptr)) ||
2170 >        !(exp_host = ircd_pcre_compile(block_state.host.buf, &errptr)))
2171      {
2172 <      if (regex_ban)
2173 <      {
2174 <        pcre *exp_user = NULL;
2175 <        pcre *exp_host = NULL;
2903 <        const char *errptr = NULL;
2904 <
2905 <        if (!(exp_user = ircd_pcre_compile(userbuf, &errptr)) ||
2906 <            !(exp_host = ircd_pcre_compile(hostbuf, &errptr)))
2907 <        {
2908 <          ilog(L_ERROR, "Failed to add regular expression based K-Line: %s",
2909 <               errptr);
2910 <          break;
2911 <        }
2912 <
2913 <        yy_conf = make_conf_item(RKLINE_TYPE);
2914 <        yy_aconf = map_to_conf(yy_conf);
2172 >      ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: %s",
2173 >           errptr);
2174 >      break;
2175 >    }
2176  
2177 <        yy_aconf->regexuser = exp_user;
2178 <        yy_aconf->regexhost = exp_host;
2177 >    conf = conf_make(CONF_RKLINE);
2178 >    conf->regexuser = exp_user;
2179 >    conf->regexhost = exp_host;
2180  
2181 <        DupString(yy_aconf->user, userbuf);
2182 <        DupString(yy_aconf->host, hostbuf);
2181 >    conf->user = xstrdup(block_state.user.buf);
2182 >    conf->host = xstrdup(block_state.host.buf);
2183  
2184 <        if (reasonbuf[0])
2185 <          DupString(yy_aconf->reason, reasonbuf);
2186 <        else
2187 <          DupString(yy_aconf->reason, "No reason");
2188 <      }
2189 <      else
2190 <      {
2191 <        yy_conf = make_conf_item(KLINE_TYPE);
2192 <        yy_aconf = map_to_conf(yy_conf);
2184 >    if (block_state.rpass.buf[0])
2185 >      conf->reason = xstrdup(block_state.rpass.buf);
2186 >    else
2187 >      conf->reason = xstrdup(CONF_NOREASON);
2188 > #else
2189 >    ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: no PCRE support");
2190 >    break;
2191 > #endif
2192 >  }
2193 >  else
2194 >  {
2195 >    conf = conf_make(CONF_KLINE);
2196  
2197 <        DupString(yy_aconf->user, userbuf);
2198 <        DupString(yy_aconf->host, hostbuf);
2197 >    conf->user = xstrdup(block_state.user.buf);
2198 >    conf->host = xstrdup(block_state.host.buf);
2199  
2200 <        if (reasonbuf[0])
2201 <          DupString(yy_aconf->reason, reasonbuf);
2937 <        else
2938 <          DupString(yy_aconf->reason, "No reason");
2939 <        add_conf_by_address(CONF_KILL, yy_aconf);
2940 <      }
2941 <    }
2200 >    if (block_state.rpass.buf[0])
2201 >      conf->reason = xstrdup(block_state.rpass.buf);
2202      else
2203 <      delete_conf_item(yy_conf);
2204 <
2945 <    yy_conf = NULL;
2946 <    yy_aconf = NULL;
2203 >      conf->reason = xstrdup(CONF_NOREASON);
2204 >    add_conf_by_address(CONF_KLINE, conf);
2205    }
2206   };
2207  
2208   kill_type: TYPE
2209   {
2210 +  if (conf_parser_ctx.pass == 2)
2211 +    block_state.port.value = 0;
2212   } '='  kill_type_items ';';
2213  
2214   kill_type_items: kill_type_items ',' kill_type_item | kill_type_item;
2215   kill_type_item: REGEX_T
2216   {
2217 <  if (ypass == 2)
2218 <    regex_ban = 1;
2217 >  if (conf_parser_ctx.pass == 2)
2218 >    block_state.port.value = 1;
2219   };
2220  
2221   kill_items:     kill_items kill_item | kill_item;
# Line 2963 | Line 2223 | kill_item:      kill_user | kill_reason
2223  
2224   kill_user: USER '=' QSTRING ';'
2225   {
2226 <  if (ypass == 2)
2226 >
2227 >  if (conf_parser_ctx.pass == 2)
2228    {
2229      struct split_nuh_item nuh;
2230  
2231      nuh.nuhmask  = yylval.string;
2232      nuh.nickptr  = NULL;
2233 <    nuh.userptr  = userbuf;
2234 <    nuh.hostptr  = hostbuf;
2233 >    nuh.userptr  = block_state.user.buf;
2234 >    nuh.hostptr  = block_state.host.buf;
2235  
2236      nuh.nicksize = 0;
2237 <    nuh.usersize = sizeof(userbuf);
2238 <    nuh.hostsize = sizeof(hostbuf);
2237 >    nuh.usersize = sizeof(block_state.user.buf);
2238 >    nuh.hostsize = sizeof(block_state.host.buf);
2239  
2240      split_nuh(&nuh);
2241    }
# Line 2982 | Line 2243 | kill_user: USER '=' QSTRING ';'
2243  
2244   kill_reason: REASON '=' QSTRING ';'
2245   {
2246 <  if (ypass == 2)
2247 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2246 >  if (conf_parser_ctx.pass == 2)
2247 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2248   };
2249  
2250   /***************************************************************************
# Line 2991 | Line 2252 | kill_reason: REASON '=' QSTRING ';'
2252   ***************************************************************************/
2253   deny_entry: DENY
2254   {
2255 <  if (ypass == 2)
2256 <  {
2996 <    yy_conf = make_conf_item(DLINE_TYPE);
2997 <    yy_aconf = map_to_conf(yy_conf);
2998 <    /* default reason */
2999 <    DupString(yy_aconf->reason, "No reason");
3000 <  }
2255 >  if (conf_parser_ctx.pass == 2)
2256 >    reset_block_state();
2257   } '{' deny_items '}' ';'
2258   {
2259 <  if (ypass == 2)
2259 >  struct MaskItem *conf = NULL;
2260 >
2261 >  if (conf_parser_ctx.pass != 2)
2262 >    break;
2263 >
2264 >  if (!block_state.addr.buf[0])
2265 >    break;
2266 >
2267 >  if (parse_netmask(block_state.addr.buf, NULL, NULL) != HM_HOST)
2268    {
2269 <    if (yy_aconf->host && parse_netmask(yy_aconf->host, NULL, NULL) != HM_HOST)
2270 <      add_conf_by_address(CONF_DLINE, yy_aconf);
2269 >    conf = conf_make(CONF_DLINE);
2270 >    conf->host = xstrdup(block_state.addr.buf);
2271 >
2272 >    if (block_state.rpass.buf[0])
2273 >      conf->reason = xstrdup(block_state.rpass.buf);
2274      else
2275 <      delete_conf_item(yy_conf);
2276 <    yy_conf = NULL;
3010 <    yy_aconf = NULL;
2275 >      conf->reason = xstrdup(CONF_NOREASON);
2276 >    add_conf_by_address(CONF_DLINE, conf);
2277    }
2278   };
2279  
# Line 3016 | Line 2282 | deny_item:      deny_ip | deny_reason |
2282  
2283   deny_ip: IP '=' QSTRING ';'
2284   {
2285 <  if (ypass == 2)
2286 <  {
3021 <    MyFree(yy_aconf->host);
3022 <    DupString(yy_aconf->host, yylval.string);
3023 <  }
2285 >  if (conf_parser_ctx.pass == 2)
2286 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
2287   };
2288  
2289   deny_reason: REASON '=' QSTRING ';'
2290   {
2291 <  if (ypass == 2)
2292 <  {
3030 <    MyFree(yy_aconf->reason);
3031 <    DupString(yy_aconf->reason, yylval.string);
3032 <  }
2291 >  if (conf_parser_ctx.pass == 2)
2292 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2293   };
2294  
2295   /***************************************************************************
# Line 3042 | Line 2302 | exempt_item:      exempt_ip | error;
2302  
2303   exempt_ip: IP '=' QSTRING ';'
2304   {
2305 <  if (ypass == 2)
2305 >  if (conf_parser_ctx.pass == 2)
2306    {
2307      if (yylval.string[0] && parse_netmask(yylval.string, NULL, NULL) != HM_HOST)
2308      {
2309 <      yy_conf = make_conf_item(EXEMPTDLINE_TYPE);
2310 <      yy_aconf = map_to_conf(yy_conf);
3051 <      DupString(yy_aconf->host, yylval.string);
2309 >      struct MaskItem *conf = conf_make(CONF_EXEMPT);
2310 >      conf->host = xstrdup(yylval.string);
2311  
2312 <      add_conf_by_address(CONF_EXEMPTDLINE, yy_aconf);
3054 <
3055 <      yy_conf = NULL;
3056 <      yy_aconf = NULL;
2312 >      add_conf_by_address(CONF_EXEMPT, conf);
2313      }
2314    }
2315   };
# Line 3063 | Line 2319 | exempt_ip: IP '=' QSTRING ';'
2319   ***************************************************************************/
2320   gecos_entry: GECOS
2321   {
2322 <  if (ypass == 2)
2323 <  {
3068 <    regex_ban = 0;
3069 <    reasonbuf[0] = gecos_name[0] = '\0';
3070 <  }
2322 >  if (conf_parser_ctx.pass == 2)
2323 >    reset_block_state();
2324   } '{' gecos_items '}' ';'
2325   {
2326 <  if (ypass == 2)
3074 <  {
3075 <    if (gecos_name[0])
3076 <    {
3077 <      if (regex_ban)
3078 <      {
3079 <        pcre *exp_p = NULL;
3080 <        const char *errptr = NULL;
2326 >  struct MaskItem *conf = NULL;
2327  
2328 <        if (!(exp_p = ircd_pcre_compile(gecos_name, &errptr)))
2329 <        {
3084 <          ilog(L_ERROR, "Failed to add regular expression based X-Line: %s",
3085 <               errptr);
3086 <          break;
3087 <        }
2328 >  if (conf_parser_ctx.pass != 2)
2329 >    break;
2330  
2331 <        yy_conf = make_conf_item(RXLINE_TYPE);
2332 <        yy_conf->regexpname = exp_p;
3091 <      }
3092 <      else
3093 <        yy_conf = make_conf_item(XLINE_TYPE);
2331 >  if (!block_state.name.buf[0])
2332 >    break;
2333  
2334 <      yy_match_item = map_to_conf(yy_conf);
2335 <      DupString(yy_conf->name, gecos_name);
2334 >  if (block_state.port.value == 1)
2335 >  {
2336 > #ifdef HAVE_LIBPCRE
2337 >    void *exp_p = NULL;
2338 >    const char *errptr = NULL;
2339  
2340 <      if (reasonbuf[0])
2341 <        DupString(yy_match_item->reason, reasonbuf);
2342 <      else
2343 <        DupString(yy_match_item->reason, "No reason");
2340 >    if (!(exp_p = ircd_pcre_compile(block_state.name.buf, &errptr)))
2341 >    {
2342 >      ilog(LOG_TYPE_IRCD, "Failed to add regular expression based X-Line: %s",
2343 >           errptr);
2344 >      break;
2345      }
2346 +
2347 +    conf = conf_make(CONF_RXLINE);
2348 +    conf->regexuser = exp_p;
2349 + #else
2350 +    conf_error_report("Failed to add regular expression based X-Line: no PCRE support");
2351 +    break;
2352 + #endif
2353    }
2354 +  else
2355 +    conf = conf_make(CONF_XLINE);
2356 +
2357 +  conf->name = xstrdup(block_state.name.buf);
2358 +
2359 +  if (block_state.rpass.buf[0])
2360 +    conf->reason = xstrdup(block_state.rpass.buf);
2361 +  else
2362 +    conf->reason = xstrdup(CONF_NOREASON);
2363   };
2364  
2365   gecos_flags: TYPE
2366   {
2367 +  if (conf_parser_ctx.pass == 2)
2368 +    block_state.port.value = 0;
2369   } '='  gecos_flags_items ';';
2370  
2371   gecos_flags_items: gecos_flags_items ',' gecos_flags_item | gecos_flags_item;
2372   gecos_flags_item: REGEX_T
2373   {
2374 <  if (ypass == 2)
2375 <    regex_ban = 1;
2374 >  if (conf_parser_ctx.pass == 2)
2375 >    block_state.port.value = 1;
2376   };
2377  
2378   gecos_items: gecos_items gecos_item | gecos_item;
# Line 3119 | Line 2380 | gecos_item:  gecos_name | gecos_reason |
2380  
2381   gecos_name: NAME '=' QSTRING ';'
2382   {
2383 <  if (ypass == 2)
2384 <    strlcpy(gecos_name, yylval.string, sizeof(gecos_name));
2383 >  if (conf_parser_ctx.pass == 2)
2384 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
2385   };
2386  
2387   gecos_reason: REASON '=' QSTRING ';'
2388   {
2389 <  if (ypass == 2)
2390 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2389 >  if (conf_parser_ctx.pass == 2)
2390 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2391   };
2392  
2393   /***************************************************************************
# Line 3141 | Line 2402 | general_item:       general_hide_spoof_i
2402                      general_max_nick_time | general_max_nick_changes |
2403                      general_max_accept | general_anti_spam_exit_message_time |
2404                      general_ts_warn_delta | general_ts_max_delta |
2405 <                    general_kill_chase_time_limit | general_kline_with_reason |
2406 <                    general_kline_reason | general_invisible_on_connect |
2405 >                    general_kill_chase_time_limit |
2406 >                    general_invisible_on_connect |
2407                      general_warn_no_nline | general_dots_in_ident |
2408                      general_stats_o_oper_only | general_stats_k_oper_only |
2409                      general_pace_wait | general_stats_i_oper_only |
2410                      general_pace_wait_simple | general_stats_P_oper_only |
2411                      general_short_motd | general_no_oper_flood |
2412                      general_true_no_oper_flood | general_oper_pass_resv |
2413 <                    general_idletime | general_message_locale |
2413 >                    general_message_locale |
2414                      general_oper_only_umodes | general_max_targets |
2415                      general_use_egd | general_egdpool_path |
2416                      general_oper_umodes | general_caller_id_wait |
2417                      general_opers_bypass_callerid | general_default_floodcount |
2418                      general_min_nonwildcard | general_min_nonwildcard_simple |
2419 <                    general_servlink_path | general_disable_remote_commands |
3159 <                    general_default_cipher_preference |
3160 <                    general_compression_level | general_client_flood |
2419 >                    general_disable_remote_commands |
2420                      general_throttle_time | general_havent_read_conf |
2421 <                    general_dot_in_ip6_addr | general_ping_cookie |
2422 <                    general_disable_auth | general_burst_away |
2423 <                    general_tkline_expire_notices | general_gline_min_cidr |
2424 <                    general_gline_min_cidr6 | general_use_whois_actually |
2425 <                    general_reject_hold_time | general_stats_e_disabled |
2426 <                    general_max_watch |
2421 >                    general_ping_cookie |
2422 >                    general_disable_auth |
2423 >                    general_tkline_expire_notices | general_gline_enable |
2424 >                    general_gline_duration | general_gline_request_duration |
2425 >                    general_gline_min_cidr |
2426 >                    general_gline_min_cidr6 |
2427 >                    general_stats_e_disabled |
2428 >                    general_max_watch | general_services_name |
2429                      error;
2430  
2431  
# Line 3173 | Line 2434 | general_max_watch: MAX_WATCH '=' NUMBER
2434    ConfigFileEntry.max_watch = $3;
2435   };
2436  
2437 < general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
2437 > general_gline_enable: GLINE_ENABLE '=' TBOOL ';'
2438   {
2439 <  ConfigFileEntry.gline_min_cidr = $3;
2439 >  if (conf_parser_ctx.pass == 2)
2440 >    ConfigFileEntry.glines = yylval.number;
2441   };
2442  
2443 < general_gline_min_cidr6: GLINE_MIN_CIDR6 '=' NUMBER ';'
2443 > general_gline_duration: GLINE_DURATION '=' timespec ';'
2444   {
2445 <  ConfigFileEntry.gline_min_cidr6 = $3;
2445 >  if (conf_parser_ctx.pass == 2)
2446 >    ConfigFileEntry.gline_time = $3;
2447   };
2448  
2449 < general_burst_away: BURST_AWAY '=' TBOOL ';'
2449 > general_gline_request_duration: GLINE_REQUEST_DURATION '=' timespec ';'
2450   {
2451 <  ConfigFileEntry.burst_away = yylval.number;
2451 >  if (conf_parser_ctx.pass == 2)
2452 >    ConfigFileEntry.gline_request_time = $3;
2453   };
2454  
2455 < general_use_whois_actually: USE_WHOIS_ACTUALLY '=' TBOOL ';'
2455 > general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
2456   {
2457 <  ConfigFileEntry.use_whois_actually = yylval.number;
2457 >  ConfigFileEntry.gline_min_cidr = $3;
2458   };
2459  
2460 < general_reject_hold_time: TREJECT_HOLD_TIME '=' timespec ';'
2460 > general_gline_min_cidr6: GLINE_MIN_CIDR6 '=' NUMBER ';'
2461   {
2462 <  GlobalSetOptions.rejecttime = yylval.number;
2462 >  ConfigFileEntry.gline_min_cidr6 = $3;
2463   };
2464  
2465   general_tkline_expire_notices: TKLINE_EXPIRE_NOTICES '=' TBOOL ';'
# Line 3203 | Line 2467 | general_tkline_expire_notices: TKLINE_EX
2467    ConfigFileEntry.tkline_expire_notices = yylval.number;
2468   };
2469  
2470 < general_kill_chase_time_limit: KILL_CHASE_TIME_LIMIT '=' NUMBER ';'
2470 > general_kill_chase_time_limit: KILL_CHASE_TIME_LIMIT '=' timespec ';'
2471   {
2472    ConfigFileEntry.kill_chase_time_limit = $3;
2473   };
# Line 3260 | Line 2524 | general_ts_warn_delta: TS_WARN_DELTA '='
2524  
2525   general_ts_max_delta: TS_MAX_DELTA '=' timespec ';'
2526   {
2527 <  if (ypass == 2)
2527 >  if (conf_parser_ctx.pass == 2)
2528      ConfigFileEntry.ts_max_delta = $3;
2529   };
2530  
2531   general_havent_read_conf: HAVENT_READ_CONF '=' NUMBER ';'
2532   {
2533 <  if (($3 > 0) && ypass == 1)
2533 >  if (($3 > 0) && conf_parser_ctx.pass == 1)
2534    {
2535 <    ilog(L_CRIT, "You haven't read your config file properly.");
2536 <    ilog(L_CRIT, "There is a line in the example conf that will kill your server if not removed.");
2537 <    ilog(L_CRIT, "Consider actually reading/editing the conf file, and removing this line.");
2535 >    ilog(LOG_TYPE_IRCD, "You haven't read your config file properly.");
2536 >    ilog(LOG_TYPE_IRCD, "There is a line in the example conf that will kill your server if not removed.");
2537 >    ilog(LOG_TYPE_IRCD, "Consider actually reading/editing the conf file, and removing this line.");
2538      exit(0);
2539    }
2540   };
2541  
3278 general_kline_with_reason: KLINE_WITH_REASON '=' TBOOL ';'
3279 {
3280  ConfigFileEntry.kline_with_reason = yylval.number;
3281 };
3282
3283 general_kline_reason: KLINE_REASON '=' QSTRING ';'
3284 {
3285  if (ypass == 2)
3286  {
3287    MyFree(ConfigFileEntry.kline_reason);
3288    DupString(ConfigFileEntry.kline_reason, yylval.string);
3289  }
3290 };
3291
2542   general_invisible_on_connect: INVISIBLE_ON_CONNECT '=' TBOOL ';'
2543   {
2544    ConfigFileEntry.invisible_on_connect = yylval.number;
# Line 3372 | Line 2622 | general_oper_pass_resv: OPER_PASS_RESV '
2622  
2623   general_message_locale: MESSAGE_LOCALE '=' QSTRING ';'
2624   {
2625 <  if (ypass == 2)
2625 >  if (conf_parser_ctx.pass == 2)
2626    {
2627      if (strlen(yylval.string) > LOCALE_LENGTH-2)
2628        yylval.string[LOCALE_LENGTH-1] = '\0';
# Line 3381 | Line 2631 | general_message_locale: MESSAGE_LOCALE '
2631    }
2632   };
2633  
3384 general_idletime: IDLETIME '=' timespec ';'
3385 {
3386  ConfigFileEntry.idletime = $3;
3387 };
3388
2634   general_dots_in_ident: DOTS_IN_IDENT '=' NUMBER ';'
2635   {
2636    ConfigFileEntry.dots_in_ident = $3;
# Line 3396 | Line 2641 | general_max_targets: MAX_TARGETS '=' NUM
2641    ConfigFileEntry.max_targets = $3;
2642   };
2643  
2644 < general_servlink_path: SERVLINK_PATH '=' QSTRING ';'
3400 < {
3401 <  if (ypass == 2)
3402 <  {
3403 <    MyFree(ConfigFileEntry.servlink_path);
3404 <    DupString(ConfigFileEntry.servlink_path, yylval.string);
3405 <  }
3406 < };
3407 <
3408 < general_default_cipher_preference: DEFAULT_CIPHER_PREFERENCE '=' QSTRING ';'
2644 > general_use_egd: USE_EGD '=' TBOOL ';'
2645   {
2646 < #ifdef HAVE_LIBCRYPTO
3411 <  if (ypass == 2)
3412 <  {
3413 <    struct EncCapability *ecap;
3414 <    const char *cipher_name;
3415 <    int found = 0;
3416 <
3417 <    ConfigFileEntry.default_cipher_preference = NULL;
3418 <    cipher_name = yylval.string;
3419 <
3420 <    for (ecap = CipherTable; ecap->name; ecap++)
3421 <    {
3422 <      if ((irccmp(ecap->name, cipher_name) == 0) &&
3423 <          (ecap->cap & CAP_ENC_MASK))
3424 <      {
3425 <        ConfigFileEntry.default_cipher_preference = ecap;
3426 <        found = 1;
3427 <        break;
3428 <      }
3429 <    }
3430 <
3431 <    if (!found)
3432 <      yyerror("Invalid cipher");
3433 <  }
3434 < #else
3435 <  if (ypass == 2)
3436 <    yyerror("Ignoring default_cipher_preference -- no OpenSSL support");
3437 < #endif
2646 >  ConfigFileEntry.use_egd = yylval.number;
2647   };
2648  
2649 < general_compression_level: COMPRESSION_LEVEL '=' NUMBER ';'
2649 > general_egdpool_path: EGDPOOL_PATH '=' QSTRING ';'
2650   {
2651 <  if (ypass == 2)
2651 >  if (conf_parser_ctx.pass == 2)
2652    {
2653 <    ConfigFileEntry.compression_level = $3;
2654 < #ifndef HAVE_LIBZ
3446 <    yyerror("Ignoring compression_level -- no zlib support");
3447 < #else
3448 <    if ((ConfigFileEntry.compression_level < 1) ||
3449 <        (ConfigFileEntry.compression_level > 9))
3450 <    {
3451 <      yyerror("Ignoring invalid compression_level, using default");
3452 <      ConfigFileEntry.compression_level = 0;
3453 <    }
3454 < #endif
2653 >    MyFree(ConfigFileEntry.egdpool_path);
2654 >    ConfigFileEntry.egdpool_path = xstrdup(yylval.string);
2655    }
2656   };
2657  
2658 < general_use_egd: USE_EGD '=' TBOOL ';'
3459 < {
3460 <  ConfigFileEntry.use_egd = yylval.number;
3461 < };
3462 <
3463 < general_egdpool_path: EGDPOOL_PATH '=' QSTRING ';'
2658 > general_services_name: T_SERVICES_NAME '=' QSTRING ';'
2659   {
2660 <  if (ypass == 2)
2660 >  if (conf_parser_ctx.pass == 2 && valid_servname(yylval.string))
2661    {
2662 <    MyFree(ConfigFileEntry.egdpool_path);
2663 <    DupString(ConfigFileEntry.egdpool_path, yylval.string);
2662 >    MyFree(ConfigFileEntry.service_name);
2663 >    ConfigFileEntry.service_name = xstrdup(yylval.string);
2664    }
2665   };
2666  
# Line 3508 | Line 2703 | umode_oitem:     T_BOTS
2703   } | T_FULL
2704   {
2705    ConfigFileEntry.oper_umodes |= UMODE_FULL;
2706 + } | HIDDEN
2707 + {
2708 +  ConfigFileEntry.oper_umodes |= UMODE_HIDDEN;
2709   } | T_SKILL
2710   {
2711    ConfigFileEntry.oper_umodes |= UMODE_SKILL;
# Line 3576 | Line 2774 | umode_item:    T_BOTS
2774   } | T_SKILL
2775   {
2776    ConfigFileEntry.oper_only_umodes |= UMODE_SKILL;
2777 + } | HIDDEN
2778 + {
2779 +  ConfigFileEntry.oper_only_umodes |= UMODE_HIDDEN;
2780   } | T_NCHANGE
2781   {
2782    ConfigFileEntry.oper_only_umodes |= UMODE_NCHANGE;
# Line 3629 | Line 2830 | general_default_floodcount: DEFAULT_FLOO
2830    ConfigFileEntry.default_floodcount = $3;
2831   };
2832  
3632 general_client_flood: T_CLIENT_FLOOD '=' sizespec ';'
3633 {
3634  ConfigFileEntry.client_flood = $3;
3635 };
3636
3637 general_dot_in_ip6_addr: DOT_IN_IP6_ADDR '=' TBOOL ';'
3638 {
3639  ConfigFileEntry.dot_in_ip6_addr = yylval.number;
3640 };
3641
3642 /***************************************************************************
3643 *  section glines
3644 ***************************************************************************/
3645 gline_entry: GLINES
3646 {
3647  if (ypass == 2)
3648  {
3649    yy_conf = make_conf_item(GDENY_TYPE);
3650    yy_aconf = map_to_conf(yy_conf);
3651  }
3652 } '{' gline_items '}' ';'
3653 {
3654  if (ypass == 2)
3655  {
3656    /*
3657     * since we re-allocate yy_conf/yy_aconf after the end of action=, at the
3658     * end we will have one extra, so we should free it.
3659     */
3660    if (yy_conf->name == NULL || yy_aconf->user == NULL)
3661    {
3662      delete_conf_item(yy_conf);
3663      yy_conf = NULL;
3664      yy_aconf = NULL;
3665    }
3666  }
3667 };
3668
3669 gline_items:        gline_items gline_item | gline_item;
3670 gline_item:         gline_enable |
3671                    gline_duration |
3672                    gline_logging |
3673                    gline_user |
3674                    gline_server |
3675                    gline_action |
3676                    error;
3677
3678 gline_enable: ENABLE '=' TBOOL ';'
3679 {
3680  if (ypass == 2)
3681    ConfigFileEntry.glines = yylval.number;
3682 };
3683
3684 gline_duration: DURATION '=' timespec ';'
3685 {
3686  if (ypass == 2)
3687    ConfigFileEntry.gline_time = $3;
3688 };
3689
3690 gline_logging: LOGGING
3691 {
3692  if (ypass == 2)
3693    ConfigFileEntry.gline_logging = 0;
3694 } '=' gline_logging_types ';';
3695 gline_logging_types:     gline_logging_types ',' gline_logging_type_item | gline_logging_type_item;
3696 gline_logging_type_item: T_REJECT
3697 {
3698  if (ypass == 2)
3699    ConfigFileEntry.gline_logging |= GDENY_REJECT;
3700 } | T_BLOCK
3701 {
3702  if (ypass == 2)
3703    ConfigFileEntry.gline_logging |= GDENY_BLOCK;
3704 };
3705
3706 gline_user: USER '=' QSTRING ';'
3707 {
3708  if (ypass == 2)
3709  {
3710    struct split_nuh_item nuh;
3711
3712    nuh.nuhmask  = yylval.string;
3713    nuh.nickptr  = NULL;
3714    nuh.userptr  = userbuf;
3715    nuh.hostptr  = hostbuf;
3716
3717    nuh.nicksize = 0;
3718    nuh.usersize = sizeof(userbuf);
3719    nuh.hostsize = sizeof(hostbuf);
3720
3721    split_nuh(&nuh);
3722
3723    if (yy_aconf->user == NULL)
3724    {
3725      DupString(yy_aconf->user, userbuf);
3726      DupString(yy_aconf->host, hostbuf);
3727    }
3728    else
3729    {
3730      struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
3731
3732      DupString(yy_tmp->user, userbuf);
3733      DupString(yy_tmp->host, hostbuf);
3734
3735      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
3736    }
3737  }
3738 };
3739
3740 gline_server: NAME '=' QSTRING ';'
3741 {
3742  if (ypass == 2)  
3743  {
3744    MyFree(yy_conf->name);
3745    DupString(yy_conf->name, yylval.string);
3746  }
3747 };
3748
3749 gline_action: ACTION
3750 {
3751  if (ypass == 2)
3752    yy_aconf->flags = 0;
3753 } '=' gdeny_types ';'
3754 {
3755  if (ypass == 2)
3756  {
3757    struct CollectItem *yy_tmp = NULL;
3758    dlink_node *ptr, *next_ptr;
3759
3760    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
3761    {
3762      struct AccessItem *new_aconf;
3763      struct ConfItem *new_conf;
3764
3765      yy_tmp = ptr->data;
3766      new_conf = make_conf_item(GDENY_TYPE);
3767      new_aconf = map_to_conf(new_conf);
3768
3769      new_aconf->flags = yy_aconf->flags;
3770
3771      if (yy_conf->name != NULL)
3772        DupString(new_conf->name, yy_conf->name);
3773      else
3774        DupString(new_conf->name, "*");
3775      if (yy_aconf->user != NULL)
3776         DupString(new_aconf->user, yy_tmp->user);
3777      else  
3778        DupString(new_aconf->user, "*");
3779      if (yy_aconf->host != NULL)
3780        DupString(new_aconf->host, yy_tmp->host);
3781      else
3782        DupString(new_aconf->host, "*");
3783
3784      dlinkDelete(&yy_tmp->node, &col_conf_list);
3785    }
3786
3787    /*
3788     * In case someone has fed us with more than one action= after user/name
3789     * which would leak memory  -Michael
3790     */
3791    if (yy_conf->name == NULL || yy_aconf->user == NULL)
3792      delete_conf_item(yy_conf);
3793
3794    yy_conf = make_conf_item(GDENY_TYPE);
3795    yy_aconf = map_to_conf(yy_conf);
3796  }
3797 };
3798
3799 gdeny_types: gdeny_types ',' gdeny_type_item | gdeny_type_item;
3800 gdeny_type_item: T_REJECT
3801 {
3802  if (ypass == 2)
3803    yy_aconf->flags |= GDENY_REJECT;
3804 } | T_BLOCK
3805 {
3806  if (ypass == 2)
3807    yy_aconf->flags |= GDENY_BLOCK;
3808 };
2833  
2834   /***************************************************************************
2835   *  section channel
# Line 3814 | Line 2838 | channel_entry: CHANNEL
2838    '{' channel_items '}' ';';
2839  
2840   channel_items:      channel_items channel_item | channel_item;
2841 < channel_item:       channel_disable_local_channels | channel_use_except |
2842 <                    channel_use_invex | channel_use_knock |
2843 <                    channel_max_bans | channel_knock_delay |
3820 <                    channel_knock_delay_channel | channel_max_chans_per_user |
2841 > channel_item:       channel_max_bans |
2842 >                    channel_knock_delay | channel_knock_delay_channel |
2843 >                    channel_max_chans_per_user | channel_max_chans_per_oper |
2844                      channel_quiet_on_ban | channel_default_split_user_count |
2845                      channel_default_split_server_count |
2846                      channel_no_create_on_split | channel_restrict_channels |
2847 <                    channel_no_join_on_split | channel_burst_topicwho |
2847 >                    channel_no_join_on_split |
2848                      channel_jflood_count | channel_jflood_time |
2849                      channel_disable_fake_channels | error;
2850  
# Line 3835 | Line 2858 | channel_restrict_channels: RESTRICT_CHAN
2858    ConfigChannel.restrict_channels = yylval.number;
2859   };
2860  
3838 channel_disable_local_channels: DISABLE_LOCAL_CHANNELS '=' TBOOL ';'
3839 {
3840  ConfigChannel.disable_local_channels = yylval.number;
3841 };
3842
3843 channel_use_except: USE_EXCEPT '=' TBOOL ';'
3844 {
3845  ConfigChannel.use_except = yylval.number;
3846 };
3847
3848 channel_use_invex: USE_INVEX '=' TBOOL ';'
3849 {
3850  ConfigChannel.use_invex = yylval.number;
3851 };
3852
3853 channel_use_knock: USE_KNOCK '=' TBOOL ';'
3854 {
3855  ConfigChannel.use_knock = yylval.number;
3856 };
3857
2861   channel_knock_delay: KNOCK_DELAY '=' timespec ';'
2862   {
2863    ConfigChannel.knock_delay = $3;
# Line 3870 | Line 2873 | channel_max_chans_per_user: MAX_CHANS_PE
2873    ConfigChannel.max_chans_per_user = $3;
2874   };
2875  
2876 + channel_max_chans_per_oper: MAX_CHANS_PER_OPER '=' NUMBER ';'
2877 + {
2878 +  ConfigChannel.max_chans_per_oper = $3;
2879 + };
2880 +
2881   channel_quiet_on_ban: QUIET_ON_BAN '=' TBOOL ';'
2882   {
2883    ConfigChannel.quiet_on_ban = yylval.number;
# Line 3900 | Line 2908 | channel_no_join_on_split: NO_JOIN_ON_SPL
2908    ConfigChannel.no_join_on_split = yylval.number;
2909   };
2910  
3903 channel_burst_topicwho: BURST_TOPICWHO '=' TBOOL ';'
3904 {
3905  ConfigChannel.burst_topicwho = yylval.number;
3906 };
3907
2911   channel_jflood_count: JOIN_FLOOD_COUNT '=' NUMBER ';'
2912   {
2913    GlobalSetOptions.joinfloodcount = yylval.number;
# Line 3924 | Line 2927 | serverhide_entry: SERVERHIDE
2927   serverhide_items:   serverhide_items serverhide_item | serverhide_item;
2928   serverhide_item:    serverhide_flatten_links | serverhide_hide_servers |
2929                      serverhide_links_delay |
3927                    serverhide_disable_hidden |
2930                      serverhide_hidden | serverhide_hidden_name |
2931                      serverhide_hide_server_ips |
2932                      error;
2933  
2934   serverhide_flatten_links: FLATTEN_LINKS '=' TBOOL ';'
2935   {
2936 <  if (ypass == 2)
2936 >  if (conf_parser_ctx.pass == 2)
2937      ConfigServerHide.flatten_links = yylval.number;
2938   };
2939  
2940   serverhide_hide_servers: HIDE_SERVERS '=' TBOOL ';'
2941   {
2942 <  if (ypass == 2)
2942 >  if (conf_parser_ctx.pass == 2)
2943      ConfigServerHide.hide_servers = yylval.number;
2944   };
2945  
2946   serverhide_hidden_name: HIDDEN_NAME '=' QSTRING ';'
2947   {
2948 <  if (ypass == 2)
2948 >  if (conf_parser_ctx.pass == 2)
2949    {
2950      MyFree(ConfigServerHide.hidden_name);
2951 <    DupString(ConfigServerHide.hidden_name, yylval.string);
2951 >    ConfigServerHide.hidden_name = xstrdup(yylval.string);
2952    }
2953   };
2954  
2955   serverhide_links_delay: LINKS_DELAY '=' timespec ';'
2956   {
2957 <  if (ypass == 2)
2957 >  if (conf_parser_ctx.pass == 2)
2958    {
2959      if (($3 > 0) && ConfigServerHide.links_disabled == 1)
2960      {
# Line 3966 | Line 2968 | serverhide_links_delay: LINKS_DELAY '='
2968  
2969   serverhide_hidden: HIDDEN '=' TBOOL ';'
2970   {
2971 <  if (ypass == 2)
2971 >  if (conf_parser_ctx.pass == 2)
2972      ConfigServerHide.hidden = yylval.number;
2973   };
2974  
3973 serverhide_disable_hidden: DISABLE_HIDDEN '=' TBOOL ';'
3974 {
3975  if (ypass == 2)
3976    ConfigServerHide.disable_hidden = yylval.number;
3977 };
3978
2975   serverhide_hide_server_ips: HIDE_SERVER_IPS '=' TBOOL ';'
2976   {
2977 <  if (ypass == 2)
2977 >  if (conf_parser_ctx.pass == 2)
2978      ConfigServerHide.hide_server_ips = yylval.number;
2979   };

Diff Legend

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