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

Diff Legend

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