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 136 by db, Sat Oct 15 23:39:54 2005 UTC vs.
ircd-hybrid/trunk/src/conf_parser.y (file contents), Revision 1647 by michael, Fri Nov 9 20:11:58 2012 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  ircd_parser.y: Parses the ircd configuration file.
3 > *  conf_parser.y: Parses the ircd configuration file.
4   *
5   *  Copyright (C) 2005 by the past and present ircd coders, and others.
6   *
# Line 26 | Line 26
26  
27   #define YY_NO_UNPUT
28   #include <sys/types.h>
29 + #include <string.h>
30  
31 + #include "config.h"
32   #include "stdinc.h"
31 #include "dalloca.h"
33   #include "ircd.h"
33 #include "tools.h"
34   #include "list.h"
35 < #include "s_conf.h"
35 > #include "conf.h"
36 > #include "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_RESTART
331 + %token  T_SERVICE
332 + %token  T_SERVICES_NAME
333   %token  THROTTLE_TIME
366 %token  TOPICBURST
334   %token  TRUE_NO_OPER_FLOOD
368 %token  TKLINE
369 %token  TXLINE
370 %token  TRESV
335   %token  UNKLINE
336   %token  USER
337   %token  USE_EGD
374 %token  USE_EXCEPT
375 %token  USE_INVEX
376 %token  USE_KNOCK
338   %token  USE_LOGGING
378 %token  USE_WHOIS_ACTUALLY
339   %token  VHOST
340   %token  VHOST6
341   %token  XLINE
382 %token  WARN
342   %token  WARN_NO_NLINE
343 + %token  T_SIZE
344 + %token  T_FILE
345  
346   %type <string> QSTRING
347   %type <number> NUMBER
# Line 404 | Line 365 | conf_item:        admin_entry
365                  | serverinfo_entry
366                  | serverhide_entry
367                  | resv_entry
368 +                | service_entry
369                  | shared_entry
370                  | cluster_entry
371                  | connect_entry
# Line 411 | Line 373 | conf_item:        admin_entry
373                  | deny_entry
374                  | exempt_entry
375                  | general_entry
414                | gline_entry
376                  | gecos_entry
377                  | modules_entry
378                  | error ';'
# Line 465 | Line 426 | modules_item:   modules_module | modules
426  
427   modules_module: MODULE '=' QSTRING ';'
428   {
429 < #ifndef STATIC_MODULES /* NOOP in the static case */
430 <  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
429 >  if (conf_parser_ctx.pass == 2)
430 >    add_conf_module(libio_basename(yylval.string));
431   };
432  
433   modules_path: PATH '=' QSTRING ';'
434   {
435 < #ifndef STATIC_MODULES
486 <  if (ypass == 2)
435 >  if (conf_parser_ctx.pass == 2)
436      mod_add_path(yylval.string);
488 #endif
437   };
438  
491 /***************************************************************************
492 *  section serverinfo
493 ***************************************************************************/
494 serverinfo_entry: SERVERINFO
495  '{' serverinfo_items '}' ';';
439  
440 < serverinfo_items:       serverinfo_items serverinfo_item |
441 <                        serverinfo_item ;
440 > serverinfo_entry: SERVERINFO '{' serverinfo_items '}' ';';
441 >
442 > serverinfo_items:       serverinfo_items serverinfo_item | serverinfo_item ;
443   serverinfo_item:        serverinfo_name | serverinfo_vhost |
444                          serverinfo_hub | serverinfo_description |
445                          serverinfo_network_name | serverinfo_network_desc |
446 <                        serverinfo_max_clients |
446 >                        serverinfo_max_clients | serverinfo_ssl_dh_param_file |
447                          serverinfo_rsa_private_key_file | serverinfo_vhost6 |
448                          serverinfo_sid | serverinfo_ssl_certificate_file |
449 +                        serverinfo_ssl_client_method | serverinfo_ssl_server_method |
450 +                        serverinfo_ssl_cipher_list |
451                          error ';' ;
452  
453 +
454 + serverinfo_ssl_client_method: T_SSL_CLIENT_METHOD '=' client_method_types ';' ;
455 + serverinfo_ssl_server_method: T_SSL_SERVER_METHOD '=' server_method_types ';' ;
456 +
457 + client_method_types: client_method_types ',' client_method_type_item | client_method_type_item;
458 + client_method_type_item: T_SSLV3
459 + {
460 + #ifdef HAVE_LIBCRYPTO
461 +  if (conf_parser_ctx.pass == 2 && ServerInfo.client_ctx)
462 +    SSL_CTX_clear_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv3);
463 + #endif
464 + } | T_TLSV1
465 + {
466 + #ifdef HAVE_LIBCRYPTO
467 +  if (conf_parser_ctx.pass == 2 && ServerInfo.client_ctx)
468 +    SSL_CTX_clear_options(ServerInfo.client_ctx, SSL_OP_NO_TLSv1);
469 + #endif
470 + };
471 +
472 + server_method_types: server_method_types ',' server_method_type_item | server_method_type_item;
473 + server_method_type_item: T_SSLV3
474 + {
475 + #ifdef HAVE_LIBCRYPTO
476 +  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
477 +    SSL_CTX_clear_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv3);
478 + #endif
479 + } | T_TLSV1
480 + {
481 + #ifdef HAVE_LIBCRYPTO
482 +  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
483 +    SSL_CTX_clear_options(ServerInfo.server_ctx, SSL_OP_NO_TLSv1);
484 + #endif
485 + };
486 +
487   serverinfo_ssl_certificate_file: SSL_CERTIFICATE_FILE '=' QSTRING ';'
488   {
489   #ifdef HAVE_LIBCRYPTO
490 <  if (ypass == 2 && ServerInfo.ctx)
490 >  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
491    {
492      if (!ServerInfo.rsa_private_key_file)
493      {
# Line 515 | Line 495 | serverinfo_ssl_certificate_file: SSL_CER
495        break;
496      }
497  
498 <    if (SSL_CTX_use_certificate_file(ServerInfo.ctx,
499 <      yylval.string, SSL_FILETYPE_PEM) <= 0)
498 >    if (SSL_CTX_use_certificate_file(ServerInfo.server_ctx, yylval.string,
499 >                                     SSL_FILETYPE_PEM) <= 0 ||
500 >        SSL_CTX_use_certificate_file(ServerInfo.client_ctx, yylval.string,
501 >                                     SSL_FILETYPE_PEM) <= 0)
502      {
503        yyerror(ERR_lib_error_string(ERR_get_error()));
504        break;
505      }
506  
507 <    if (SSL_CTX_use_PrivateKey_file(ServerInfo.ctx,
508 <      ServerInfo.rsa_private_key_file, SSL_FILETYPE_PEM) <= 0)
507 >    if (SSL_CTX_use_PrivateKey_file(ServerInfo.server_ctx, ServerInfo.rsa_private_key_file,
508 >                                    SSL_FILETYPE_PEM) <= 0 ||
509 >        SSL_CTX_use_PrivateKey_file(ServerInfo.client_ctx, ServerInfo.rsa_private_key_file,
510 >                                    SSL_FILETYPE_PEM) <= 0)
511      {
512        yyerror(ERR_lib_error_string(ERR_get_error()));
513        break;
514      }
515  
516 <    if (!SSL_CTX_check_private_key(ServerInfo.ctx))
516 >    if (!SSL_CTX_check_private_key(ServerInfo.server_ctx) ||
517 >        !SSL_CTX_check_private_key(ServerInfo.client_ctx))
518      {
519 <      yyerror("RSA private key does not match the SSL certificate public key!");
519 >      yyerror(ERR_lib_error_string(ERR_get_error()));
520        break;
521      }
522    }
# Line 541 | Line 526 | serverinfo_ssl_certificate_file: SSL_CER
526   serverinfo_rsa_private_key_file: RSA_PRIVATE_KEY_FILE '=' QSTRING ';'
527   {
528   #ifdef HAVE_LIBCRYPTO
529 <  if (ypass == 1)
529 >  if (conf_parser_ctx.pass == 1)
530    {
531      BIO *file;
532  
# Line 557 | Line 542 | serverinfo_rsa_private_key_file: RSA_PRI
542        ServerInfo.rsa_private_key_file = NULL;
543      }
544  
545 <    DupString(ServerInfo.rsa_private_key_file, yylval.string);
545 >    ServerInfo.rsa_private_key_file = xstrdup(yylval.string);
546  
547      if ((file = BIO_new_file(yylval.string, "r")) == NULL)
548      {
# Line 565 | Line 550 | serverinfo_rsa_private_key_file: RSA_PRI
550        break;
551      }
552  
553 <    ServerInfo.rsa_private_key = (RSA *)PEM_read_bio_RSAPrivateKey(file, NULL,
569 <      0, NULL);
553 >    ServerInfo.rsa_private_key = PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL);
554  
555      BIO_set_close(file, BIO_CLOSE);
556      BIO_free(file);
# Line 598 | Line 582 | serverinfo_rsa_private_key_file: RSA_PRI
582   #endif
583   };
584  
585 + serverinfo_ssl_dh_param_file: SSL_DH_PARAM_FILE '=' QSTRING ';'
586 + {
587 + /* TBD - XXX: error reporting */
588 + #ifdef HAVE_LIBCRYPTO
589 +  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
590 +  {
591 +    BIO *file = BIO_new_file(yylval.string, "r");
592 +
593 +    if (file)
594 +    {
595 +      DH *dh = PEM_read_bio_DHparams(file, NULL, NULL, NULL);
596 +
597 +      BIO_free(file);
598 +
599 +      if (dh)
600 +      {
601 +        if (DH_size(dh) < 128)
602 +          ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::ssl_dh_param_file -- need at least a 1024 bit DH prime size");
603 +        else
604 +          SSL_CTX_set_tmp_dh(ServerInfo.server_ctx, dh);
605 +
606 +        DH_free(dh);
607 +      }
608 +    }
609 +  }
610 + #endif
611 + };
612 +
613 + serverinfo_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
614 + {
615 + #ifdef HAVE_LIBCRYPTO
616 +  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
617 +    SSL_CTX_set_cipher_list(ServerInfo.server_ctx, yylval.string);
618 + #endif
619 + };
620 +
621   serverinfo_name: NAME '=' QSTRING ';'
622   {
623    /* this isn't rehashable */
624 <  if (ypass == 2)
624 >  if (conf_parser_ctx.pass == 2 && !ServerInfo.name)
625    {
626 <    if (ServerInfo.name == NULL)
626 >    if (valid_servname(yylval.string))
627 >      ServerInfo.name = xstrdup(yylval.string);
628 >    else
629      {
630 <      /* the ircd will exit() in main() if we dont set one */
631 <      if (strlen(yylval.string) <= HOSTLEN)
610 <        DupString(ServerInfo.name, yylval.string);
630 >      ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::name -- invalid name. Aborting.");
631 >      exit(0);
632      }
633    }
634   };
# Line 615 | Line 636 | serverinfo_name: NAME '=' QSTRING ';'
636   serverinfo_sid: IRCD_SID '=' QSTRING ';'
637   {
638    /* this isn't rehashable */
639 <  if (ypass == 2 && !ServerInfo.sid)
639 >  if (conf_parser_ctx.pass == 2 && !ServerInfo.sid)
640    {
641 <    if ((strlen(yylval.string) == IRC_MAXSID) && IsDigit(yylval.string[0])
642 <        && IsAlNum(yylval.string[1]) && IsAlNum(yylval.string[2]))
622 <    {
623 <      DupString(ServerInfo.sid, yylval.string);
624 <    }
641 >    if (valid_sid(yylval.string))
642 >      ServerInfo.sid = xstrdup(yylval.string);
643      else
644      {
645 <      ilog(L_ERROR, "Ignoring config file entry SID -- invalid SID. Aborting.");
645 >      ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::sid -- invalid SID. Aborting.");
646        exit(0);
647      }
648    }
# Line 632 | Line 650 | serverinfo_sid: IRCD_SID '=' QSTRING ';'
650  
651   serverinfo_description: DESCRIPTION '=' QSTRING ';'
652   {
653 <  if (ypass == 2)
653 >  if (conf_parser_ctx.pass == 2)
654    {
655      MyFree(ServerInfo.description);
656 <    DupString(ServerInfo.description,yylval.string);
656 >    ServerInfo.description = xstrdup(yylval.string);
657    }
658   };
659  
660   serverinfo_network_name: NETWORK_NAME '=' QSTRING ';'
661   {
662 <  if (ypass == 2)
662 >  if (conf_parser_ctx.pass == 2)
663    {
664      char *p;
665  
# Line 649 | Line 667 | serverinfo_network_name: NETWORK_NAME '=
667        p = '\0';
668  
669      MyFree(ServerInfo.network_name);
670 <    DupString(ServerInfo.network_name, yylval.string);
670 >    ServerInfo.network_name = xstrdup(yylval.string);
671    }
672   };
673  
674   serverinfo_network_desc: NETWORK_DESC '=' QSTRING ';'
675   {
676 <  if (ypass == 2)
676 >  if (conf_parser_ctx.pass == 2)
677    {
678      MyFree(ServerInfo.network_desc);
679 <    DupString(ServerInfo.network_desc, yylval.string);
679 >    ServerInfo.network_desc = xstrdup(yylval.string);
680    }
681   };
682  
683   serverinfo_vhost: VHOST '=' QSTRING ';'
684   {
685 <  if (ypass == 2 && *yylval.string != '*')
685 >  if (conf_parser_ctx.pass == 2 && *yylval.string != '*')
686    {
687      struct addrinfo hints, *res;
688  
# Line 674 | Line 692 | serverinfo_vhost: VHOST '=' QSTRING ';'
692      hints.ai_socktype = SOCK_STREAM;
693      hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
694  
695 <    if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
696 <      ilog(L_ERROR, "Invalid netmask for server vhost(%s)", yylval.string);
695 >    if (getaddrinfo(yylval.string, NULL, &hints, &res))
696 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", yylval.string);
697      else
698      {
699        assert(res != NULL);
# Line 683 | Line 701 | serverinfo_vhost: VHOST '=' QSTRING ';'
701        memcpy(&ServerInfo.ip, res->ai_addr, res->ai_addrlen);
702        ServerInfo.ip.ss.ss_family = res->ai_family;
703        ServerInfo.ip.ss_len = res->ai_addrlen;
704 <      irc_freeaddrinfo(res);
704 >      freeaddrinfo(res);
705  
706        ServerInfo.specific_ipv4_vhost = 1;
707      }
# Line 693 | Line 711 | serverinfo_vhost: VHOST '=' QSTRING ';'
711   serverinfo_vhost6: VHOST6 '=' QSTRING ';'
712   {
713   #ifdef IPV6
714 <  if (ypass == 2 && *yylval.string != '*')
714 >  if (conf_parser_ctx.pass == 2 && *yylval.string != '*')
715    {
716      struct addrinfo hints, *res;
717  
# Line 703 | Line 721 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
721      hints.ai_socktype = SOCK_STREAM;
722      hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
723  
724 <    if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
725 <      ilog(L_ERROR, "Invalid netmask for server vhost6(%s)", yylval.string);
724 >    if (getaddrinfo(yylval.string, NULL, &hints, &res))
725 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost6(%s)", yylval.string);
726      else
727      {
728        assert(res != NULL);
# Line 712 | Line 730 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
730        memcpy(&ServerInfo.ip6, res->ai_addr, res->ai_addrlen);
731        ServerInfo.ip6.ss.ss_family = res->ai_family;
732        ServerInfo.ip6.ss_len = res->ai_addrlen;
733 <      irc_freeaddrinfo(res);
733 >      freeaddrinfo(res);
734  
735        ServerInfo.specific_ipv6_vhost = 1;
736      }
# Line 722 | Line 740 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
740  
741   serverinfo_max_clients: T_MAX_CLIENTS '=' NUMBER ';'
742   {
743 <  if (ypass == 2)
743 >  if (conf_parser_ctx.pass == 2)
744    {
745      recalc_fdlimit(NULL);
746  
# Line 745 | Line 763 | serverinfo_max_clients: T_MAX_CLIENTS '=
763  
764   serverinfo_hub: HUB '=' TBOOL ';'
765   {
766 <  if (ypass == 2)
767 <  {
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 <  }
766 >  if (conf_parser_ctx.pass == 2)
767 >    ServerInfo.hub = yylval.number;
768   };
769  
770   /***************************************************************************
# Line 801 | Line 778 | admin_item:  admin_name | admin_descript
778  
779   admin_name: NAME '=' QSTRING ';'
780   {
781 <  if (ypass == 2)
781 >  if (conf_parser_ctx.pass == 2)
782    {
783      MyFree(AdminInfo.name);
784 <    DupString(AdminInfo.name, yylval.string);
784 >    AdminInfo.name = xstrdup(yylval.string);
785    }
786   };
787  
788   admin_email: EMAIL '=' QSTRING ';'
789   {
790 <  if (ypass == 2)
790 >  if (conf_parser_ctx.pass == 2)
791    {
792      MyFree(AdminInfo.email);
793 <    DupString(AdminInfo.email, yylval.string);
793 >    AdminInfo.email = xstrdup(yylval.string);
794    }
795   };
796  
797   admin_description: DESCRIPTION '=' QSTRING ';'
798   {
799 <  if (ypass == 2)
799 >  if (conf_parser_ctx.pass == 2)
800    {
801      MyFree(AdminInfo.description);
802 <    DupString(AdminInfo.description, yylval.string);
802 >    AdminInfo.description = xstrdup(yylval.string);
803    }
804   };
805  
806   /***************************************************************************
807   *  section logging
808   ***************************************************************************/
809 < /* XXX */
810 < logging_entry:          LOGGING  '{' logging_items '}' ';' ;
834 <
835 < logging_items:          logging_items logging_item |
836 <                        logging_item ;
809 > logging_entry:          T_LOG  '{' logging_items '}' ';' ;
810 > logging_items:          logging_items logging_item | logging_item ;
811  
812 < 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 |
812 > logging_item:           logging_use_logging | logging_file_entry |
813                          error ';' ;
814  
815 < logging_path:           T_LOGPATH '=' QSTRING ';'
848 <                        {
849 <                        };
850 <
851 < logging_oper_log:       OPER_LOG '=' QSTRING ';'
852 <                        {
853 <                        };
854 <
855 < logging_fuserlog: FUSERLOG '=' QSTRING ';'
815 > logging_use_logging: USE_LOGGING '=' TBOOL ';'
816   {
817 <  if (ypass == 2)
818 <    strlcpy(ConfigLoggingEntry.userlog, yylval.string,
859 <            sizeof(ConfigLoggingEntry.userlog));
817 >  if (conf_parser_ctx.pass == 2)
818 >    ConfigLoggingEntry.use_logging = yylval.number;
819   };
820  
821 < logging_ffailed_operlog: FFAILED_OPERLOG '=' QSTRING ';'
821 > logging_file_entry:
822   {
823 <  if (ypass == 2)
824 <    strlcpy(ConfigLoggingEntry.failed_operlog, yylval.string,
825 <            sizeof(ConfigLoggingEntry.failed_operlog));
867 < };
868 <
869 < logging_foperlog: FOPERLOG '=' QSTRING ';'
823 >  if (conf_parser_ctx.pass == 2)
824 >    reset_block_state();
825 > } T_FILE  '{' logging_file_items '}' ';'
826   {
827 <  if (ypass == 2)
828 <    strlcpy(ConfigLoggingEntry.operlog, yylval.string,
873 <            sizeof(ConfigLoggingEntry.operlog));
874 < };
827 >  if (conf_parser_ctx.pass != 2)
828 >    break;
829  
830 < logging_foperspylog: FOPERSPYLOG '=' QSTRING ';'
831 < {
832 <  if (ypass == 2)
879 <    strlcpy(ConfigLoggingEntry.operspylog, yylval.string,
880 <            sizeof(ConfigLoggingEntry.operspylog));
830 >  if (block_state.type.value && block_state.file.buf[0])
831 >    log_add_file(block_state.type.value, block_state.size.value,
832 >                 block_state.file.buf);
833   };
834  
835 < logging_fglinelog: FGLINELOG '=' QSTRING ';'
836 < {
885 <  if (ypass == 2)
886 <    strlcpy(ConfigLoggingEntry.glinelog, yylval.string,
887 <            sizeof(ConfigLoggingEntry.glinelog));
888 < };
835 > logging_file_items: logging_file_items logging_file_item |
836 >                    logging_file_item ;
837  
838 < logging_fklinelog: FKLINELOG '=' QSTRING ';'
839 < {
892 <  if (ypass == 2)
893 <    strlcpy(ConfigLoggingEntry.klinelog, yylval.string,
894 <            sizeof(ConfigLoggingEntry.klinelog));
895 < };
838 > logging_file_item:  logging_file_name | logging_file_type |
839 >                    logging_file_size | error ';' ;
840  
841 < logging_ioerrlog: FIOERRLOG '=' QSTRING ';'
841 > logging_file_name: NAME '=' QSTRING ';'
842   {
843 <  if (ypass == 2)
844 <    strlcpy(ConfigLoggingEntry.ioerrlog, yylval.string,
901 <            sizeof(ConfigLoggingEntry.ioerrlog));
902 < };
843 >  if (conf_parser_ctx.pass != 2)
844 >    break;
845  
846 < logging_killlog: FKILLLOG '=' QSTRING ';'
846 >  strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
847 > }
848 >
849 > logging_file_size: T_SIZE '=' sizespec ';'
850 > {
851 >  block_state.size.value = $3;
852 > } | T_SIZE '=' T_UNLIMITED ';'
853   {
854 <  if (ypass == 2)
907 <    strlcpy(ConfigLoggingEntry.killlog, yylval.string,
908 <            sizeof(ConfigLoggingEntry.killlog));
854 >  block_state.size.value = 0;
855   };
856  
857 < 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 ';'
857 > logging_file_type: TYPE
858   {
859 <  if (ypass == 2)
860 <    set_log_level(L_DEBUG);
861 < };
859 >  if (conf_parser_ctx.pass == 2)
860 >    block_state.type.value = 0;
861 > } '='  logging_file_type_items ';' ;
862  
863 < logging_use_logging: USE_LOGGING '=' TBOOL ';'
863 > logging_file_type_items: logging_file_type_items ',' logging_file_type_item | logging_file_type_item;
864 > logging_file_type_item:  USER
865   {
866 <  if (ypass == 2)
867 <    ConfigLoggingEntry.use_logging = yylval.number;
866 >  if (conf_parser_ctx.pass == 2)
867 >    block_state.type.value = LOG_TYPE_USER;
868 > } | OPERATOR
869 > {
870 >  if (conf_parser_ctx.pass == 2)
871 >    block_state.type.value = LOG_TYPE_OPER;
872 > } | GLINE
873 > {
874 >  if (conf_parser_ctx.pass == 2)
875 >    block_state.type.value = LOG_TYPE_GLINE;
876 > } | T_DLINE
877 > {
878 >  if (conf_parser_ctx.pass == 2)
879 >    block_state.type.value = LOG_TYPE_DLINE;
880 > } | KLINE
881 > {
882 >  if (conf_parser_ctx.pass == 2)
883 >    block_state.type.value = LOG_TYPE_KLINE;
884 > } | KILL
885 > {
886 >  if (conf_parser_ctx.pass == 2)
887 >    block_state.type.value = LOG_TYPE_KILL;
888 > } | T_DEBUG
889 > {
890 >  if (conf_parser_ctx.pass == 2)
891 >    block_state.type.value = LOG_TYPE_DEBUG;
892   };
893  
894 +
895   /***************************************************************************
896   * section oper
897   ***************************************************************************/
898   oper_entry: OPERATOR
899   {
900 <  if (ypass == 2)
901 <  {
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;
900 >  if (conf_parser_ctx.pass != 2)
901 >    break;
902  
903 <    conf_add_class_to_conf(yy_conf, class_name);
903 >  reset_block_state();
904 >  block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
905 > } '{' oper_items '}' ';'
906 > {
907 >  dlink_node *ptr = NULL;
908  
909 <    /* Now, make sure there is a copy of the "base" given oper
910 <     * block in each of the collected copies
975 <     */
909 >  if (conf_parser_ctx.pass != 2)
910 >    break;
911  
912 <    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
913 <    {
914 <      struct AccessItem *new_aconf;
915 <      struct ConfItem *new_conf;
916 <      yy_tmp = ptr->data;
912 >  if (!block_state.name.buf[0])
913 >    break;
914 > #ifdef HAVE_LIBCRYPTO
915 >  if (!(block_state.file.buf[0] ||
916 >        block_state.rpass.buf[0]))
917 >    break;
918 > #else
919 >  if (!block_state.rpass.buf[0])
920 >    break;
921 > #endif
922  
923 <      new_conf = make_conf_item(OPER_TYPE);
924 <      new_aconf = (struct AccessItem *)map_to_conf(new_conf);
923 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
924 >  {
925 >    struct MaskItem *conf = NULL;
926 >    struct split_nuh_item nuh;
927  
928 <      new_aconf->flags = yy_aconf->flags;
928 >    nuh.nuhmask  = ptr->data;
929 >    nuh.nickptr  = NULL;
930 >    nuh.userptr  = block_state.user.buf;
931 >    nuh.hostptr  = block_state.host.buf;
932 >    nuh.nicksize = 0;
933 >    nuh.usersize = sizeof(block_state.user.buf);
934 >    nuh.hostsize = sizeof(block_state.host.buf);
935 >    split_nuh(&nuh);
936 >
937 >    conf        = conf_make(CONF_OPER);
938 >    conf->user  = xstrdup(block_state.user.buf);
939 >    conf->host  = xstrdup(block_state.host.buf);
940 >
941 >    if (block_state.rpass.buf[0])
942 >      conf->passwd = xstrdup(block_state.rpass.buf);
943 >
944 >    conf->flags = block_state.flags.value;
945 >    conf->modes = block_state.modes.value;
946 >    conf->port  = block_state.port.value;
947 >    conf->htype = parse_netmask(conf->host, &conf->addr, &conf->bits);
948  
949 <      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);
949 >    conf_add_class_to_conf(conf, block_state.class.buf);
950  
1002      new_aconf->port = yy_aconf->port;
951   #ifdef HAVE_LIBCRYPTO
952 <      if (yy_aconf->rsa_public_key_file != NULL)
953 <      {
954 <        BIO *file;
955 <
1008 <        DupString(new_aconf->rsa_public_key_file,
1009 <                  yy_aconf->rsa_public_key_file);
952 >    if (block_state.file.buf[0])
953 >    {
954 >      BIO *file = NULL;
955 >      RSA *pkey = NULL;
956  
957 <        file = BIO_new_file(yy_aconf->rsa_public_key_file, "r");
958 <        new_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file,
959 <                                                           NULL, 0, NULL);
960 <        BIO_set_close(file, BIO_CLOSE);
1015 <        BIO_free(file);
957 >      if ((file = BIO_new_file(block_state.file.buf, "r")) == NULL)
958 >      {
959 >        yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
960 >        break;
961        }
1017 #endif
962  
963 < #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
963 >      if ((pkey = PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL)) == NULL)
964        {
965 <        conf_add_class_to_conf(new_conf, class_name);
966 <        if (yy_tmp->name != NULL)
1028 <          DupString(new_conf->name, yy_tmp->name);
965 >        yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
966 >        break;
967        }
968  
969 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
970 <      free_collect_item(yy_tmp);
969 >      conf->rsa_public_key = pkey;
970 >      BIO_set_close(file, BIO_CLOSE);
971 >      BIO_free(file);
972      }
973 <
1035 <    yy_conf = NULL;
1036 <    yy_aconf = NULL;
1037 <
1038 <
1039 <    MyFree(class_name);
1040 <    class_name = NULL;
973 > #endif /* HAVE_LIBCRYPTO */
974    }
975 < };
975 > };
976  
1044 oper_name_b: | oper_name_t;
977   oper_items:     oper_items oper_item | oper_item;
978 < oper_item:      oper_name | oper_user | oper_password | oper_hidden_admin |
979 <                oper_hidden_oper | oper_umodes |
980 <                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 ';' ;
978 > oper_item:      oper_name | oper_user | oper_password |
979 >                oper_umodes | oper_class | oper_encrypted |
980 >                oper_rsa_public_key_file | oper_flags | error ';' ;
981  
982   oper_name: NAME '=' QSTRING ';'
983   {
984 <  if (ypass == 2)
985 <  {
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 <  }
984 >  if (conf_parser_ctx.pass == 2)
985 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
986   };
987  
988   oper_user: USER '=' QSTRING ';'
989   {
990 <  if (ypass == 2)
991 <  {
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 <  }
990 >  if (conf_parser_ctx.pass == 2)
991 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
992   };
993  
994   oper_password: PASSWORD '=' QSTRING ';'
995   {
996 <  if (ypass == 2)
997 <  {
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 <  }
996 >  if (conf_parser_ctx.pass == 2)
997 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
998   };
999  
1000   oper_encrypted: ENCRYPTED '=' TBOOL ';'
1001   {
1002 <  if (ypass == 2)
1002 >  if (conf_parser_ctx.pass == 2)
1003    {
1004      if (yylval.number)
1005 <      SetConfEncrypted(yy_aconf);
1005 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1006      else
1007 <      ClearConfEncrypted(yy_aconf);
1007 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1008    }
1009   };
1010  
1011   oper_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
1012   {
1013 < #ifdef HAVE_LIBCRYPTO
1014 <  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 */
1013 >  if (conf_parser_ctx.pass == 2)
1014 >    strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
1015   };
1016  
1017   oper_class: CLASS '=' QSTRING ';'
1018   {
1019 <  if (ypass == 2)
1020 <  {
1167 <    MyFree(class_name);
1168 <    DupString(class_name, yylval.string);
1169 <  }
1019 >  if (conf_parser_ctx.pass == 2)
1020 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1021   };
1022  
1023   oper_umodes: T_UMODES
1024   {
1025 <  yy_aconf->modes = 0;
1025 >  if (conf_parser_ctx.pass == 2)
1026 >    block_state.modes.value = 0;
1027   } '='  oper_umodes_items ';' ;
1028  
1029   oper_umodes_items: oper_umodes_items ',' oper_umodes_item | oper_umodes_item;
1030   oper_umodes_item:  T_BOTS
1031   {
1032 <  yy_aconf->modes |= UMODE_BOTS;
1032 >  if (conf_parser_ctx.pass == 2)
1033 >    block_state.modes.value |= UMODE_BOTS;
1034   } | T_CCONN
1035   {
1036 <  yy_aconf->modes |= UMODE_CCONN;
1036 >  if (conf_parser_ctx.pass == 2)
1037 >    block_state.modes.value |= UMODE_CCONN;
1038 > } | T_CCONN_FULL
1039 > {
1040 >  if (conf_parser_ctx.pass == 2)
1041 >    block_state.modes.value |= UMODE_CCONN_FULL;
1042   } | T_DEAF
1043   {
1044 <  yy_aconf->modes |= UMODE_DEAF;
1044 >  if (conf_parser_ctx.pass == 2)
1045 >    block_state.modes.value |= UMODE_DEAF;
1046   } | T_DEBUG
1047   {
1048 <  yy_aconf->modes |= UMODE_DEBUG;
1048 >  if (conf_parser_ctx.pass == 2)
1049 >    block_state.modes.value |= UMODE_DEBUG;
1050   } | T_FULL
1051   {
1052 <  yy_aconf->modes |= UMODE_FULL;
1052 >  if (conf_parser_ctx.pass == 2)
1053 >    block_state.modes.value |= UMODE_FULL;
1054 > } | HIDDEN
1055 > {
1056 >  if (conf_parser_ctx.pass == 2)
1057 >    block_state.modes.value |= UMODE_HIDDEN;
1058   } | T_SKILL
1059   {
1060 <  yy_aconf->modes |= UMODE_SKILL;
1060 >  if (conf_parser_ctx.pass == 2)
1061 >    block_state.modes.value |= UMODE_SKILL;
1062   } | T_NCHANGE
1063   {
1064 <  yy_aconf->modes |= UMODE_NCHANGE;
1064 >  if (conf_parser_ctx.pass == 2)
1065 >    block_state.modes.value |= UMODE_NCHANGE;
1066   } | T_REJ
1067   {
1068 <  yy_aconf->modes |= UMODE_REJ;
1068 >  if (conf_parser_ctx.pass == 2)
1069 >    block_state.modes.value |= UMODE_REJ;
1070   } | T_UNAUTH
1071   {
1072 <  yy_aconf->modes |= UMODE_UNAUTH;
1072 >  if (conf_parser_ctx.pass == 2)
1073 >    block_state.modes.value |= UMODE_UNAUTH;
1074   } | T_SPY
1075   {
1076 <  yy_aconf->modes |= UMODE_SPY;
1076 >  if (conf_parser_ctx.pass == 2)
1077 >    block_state.modes.value |= UMODE_SPY;
1078   } | T_EXTERNAL
1079   {
1080 <  yy_aconf->modes |= UMODE_EXTERNAL;
1080 >  if (conf_parser_ctx.pass == 2)
1081 >    block_state.modes.value |= UMODE_EXTERNAL;
1082   } | T_OPERWALL
1083   {
1084 <  yy_aconf->modes |= UMODE_OPERWALL;
1084 >  if (conf_parser_ctx.pass == 2)
1085 >    block_state.modes.value |= UMODE_OPERWALL;
1086   } | T_SERVNOTICE
1087   {
1088 <  yy_aconf->modes |= UMODE_SERVNOTICE;
1088 >  if (conf_parser_ctx.pass == 2)
1089 >    block_state.modes.value |= UMODE_SERVNOTICE;
1090   } | T_INVISIBLE
1091   {
1092 <  yy_aconf->modes |= UMODE_INVISIBLE;
1092 >  if (conf_parser_ctx.pass == 2)
1093 >    block_state.modes.value |= UMODE_INVISIBLE;
1094   } | T_WALLOP
1095   {
1096 <  yy_aconf->modes |= UMODE_WALLOP;
1096 >  if (conf_parser_ctx.pass == 2)
1097 >    block_state.modes.value |= UMODE_WALLOP;
1098   } | T_SOFTCALLERID
1099   {
1100 <  yy_aconf->modes |= UMODE_SOFTCALLERID;
1100 >  if (conf_parser_ctx.pass == 2)
1101 >    block_state.modes.value |= UMODE_SOFTCALLERID;
1102   } | T_CALLERID
1103   {
1104 <  yy_aconf->modes |= UMODE_CALLERID;
1104 >  if (conf_parser_ctx.pass == 2)
1105 >    block_state.modes.value |= UMODE_CALLERID;
1106   } | T_LOCOPS
1107   {
1108 <  yy_aconf->modes |= UMODE_LOCOPS;
1109 < };
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 <  }
1108 >  if (conf_parser_ctx.pass == 2)
1109 >    block_state.modes.value |= UMODE_LOCOPS;
1110   };
1111  
1112   oper_flags: IRCD_FLAGS
1113   {
1114 +  if (conf_parser_ctx.pass == 2)
1115 +    block_state.port.value = 0;
1116   } '='  oper_flags_items ';';
1117  
1118   oper_flags_items: oper_flags_items ',' oper_flags_item | oper_flags_item;
1119 < oper_flags_item: NOT { not_atom = 1; } oper_flags_item_atom
1394 <                | { not_atom = 0; } oper_flags_item_atom;
1395 <
1396 < oper_flags_item_atom: GLOBAL_KILL
1119 > oper_flags_item: GLOBAL_KILL
1120   {
1121 <  if (ypass == 2)
1122 <  {
1400 <    if (not_atom)yy_aconf->port &= ~OPER_FLAG_GLOBAL_KILL;
1401 <    else yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1402 <  }
1121 >  if (conf_parser_ctx.pass == 2)
1122 >    block_state.port.value |= OPER_FLAG_GLOBAL_KILL;
1123   } | REMOTE
1124   {
1125 <  if (ypass == 2)
1126 <  {
1407 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_REMOTE;
1408 <    else yy_aconf->port |= OPER_FLAG_REMOTE;
1409 <  }
1125 >  if (conf_parser_ctx.pass == 2)
1126 >    block_state.port.value |= OPER_FLAG_REMOTE;
1127   } | KLINE
1128   {
1129 <  if (ypass == 2)
1130 <  {
1414 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_K;
1415 <    else yy_aconf->port |= OPER_FLAG_K;
1416 <  }
1129 >  if (conf_parser_ctx.pass == 2)
1130 >    block_state.port.value |= OPER_FLAG_K;
1131   } | UNKLINE
1132   {
1133 <  if (ypass == 2)
1134 <  {
1135 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_UNKLINE;
1136 <    else yy_aconf->port |= OPER_FLAG_UNKLINE;
1137 <  }
1133 >  if (conf_parser_ctx.pass == 2)
1134 >    block_state.port.value |= OPER_FLAG_UNKLINE;
1135 > } | T_DLINE
1136 > {
1137 >  if (conf_parser_ctx.pass == 2)
1138 >    block_state.port.value |= OPER_FLAG_DLINE;
1139 > } | T_UNDLINE
1140 > {
1141 >  if (conf_parser_ctx.pass == 2)
1142 >    block_state.port.value |= OPER_FLAG_UNDLINE;
1143   } | XLINE
1144   {
1145 <  if (ypass == 2)
1146 <  {
1428 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_X;
1429 <    else yy_aconf->port |= OPER_FLAG_X;
1430 <  }
1145 >  if (conf_parser_ctx.pass == 2)
1146 >    block_state.port.value |= OPER_FLAG_X;
1147   } | GLINE
1148   {
1149 <  if (ypass == 2)
1150 <  {
1435 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_GLINE;
1436 <    else yy_aconf->port |= OPER_FLAG_GLINE;
1437 <  }
1149 >  if (conf_parser_ctx.pass == 2)
1150 >    block_state.port.value |= OPER_FLAG_GLINE;
1151   } | DIE
1152   {
1153 <  if (ypass == 2)
1154 <  {
1155 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_DIE;
1156 <    else yy_aconf->port |= OPER_FLAG_DIE;
1157 <  }
1153 >  if (conf_parser_ctx.pass == 2)
1154 >    block_state.port.value |= OPER_FLAG_DIE;
1155 > } | T_RESTART
1156 > {
1157 >  if (conf_parser_ctx.pass == 2)
1158 >    block_state.port.value |= OPER_FLAG_RESTART;
1159   } | REHASH
1160   {
1161 <  if (ypass == 2)
1162 <  {
1449 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_REHASH;
1450 <    else yy_aconf->port |= OPER_FLAG_REHASH;
1451 <  }
1161 >  if (conf_parser_ctx.pass == 2)
1162 >    block_state.port.value |= OPER_FLAG_REHASH;
1163   } | ADMIN
1164   {
1165 <  if (ypass == 2)
1166 <  {
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 <  }
1165 >  if (conf_parser_ctx.pass == 2)
1166 >    block_state.port.value |= OPER_FLAG_ADMIN;
1167   } | NICK_CHANGES
1168   {
1169 <  if (ypass == 2)
1170 <  {
1470 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_N;
1471 <    else yy_aconf->port |= OPER_FLAG_N;
1472 <  }
1169 >  if (conf_parser_ctx.pass == 2)
1170 >    block_state.port.value |= OPER_FLAG_N;
1171   } | T_OPERWALL
1172   {
1173 <  if (ypass == 2)
1174 <  {
1175 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_OPERWALL;
1478 <    else yy_aconf->port |= OPER_FLAG_OPERWALL;
1479 <  }
1480 < } | OPER_SPY_T
1173 >  if (conf_parser_ctx.pass == 2)
1174 >    block_state.port.value |= OPER_FLAG_OPERWALL;
1175 > } | T_GLOBOPS
1176   {
1177 <  if (ypass == 2)
1178 <  {
1179 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_OPER_SPY;
1485 <    else yy_aconf->port |= OPER_FLAG_OPER_SPY;
1486 <  }
1487 < } | HIDDEN_OPER
1177 >  if (conf_parser_ctx.pass == 2)
1178 >    block_state.port.value |= OPER_FLAG_GLOBOPS;
1179 > } | OPER_SPY_T
1180   {
1181 <  if (ypass == 2)
1182 <  {
1491 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_HIDDEN_OPER;
1492 <    else yy_aconf->port |= OPER_FLAG_HIDDEN_OPER;
1493 <  }
1181 >  if (conf_parser_ctx.pass == 2)
1182 >    block_state.port.value |= OPER_FLAG_OPER_SPY;
1183   } | REMOTEBAN
1184   {
1185 <  if (ypass == 2)
1186 <  {
1187 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_REMOTEBAN;
1188 <    else yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1189 <  }
1190 < } | ENCRYPTED
1185 >  if (conf_parser_ctx.pass == 2)
1186 >    block_state.port.value |= OPER_FLAG_REMOTEBAN;
1187 > } | T_SET
1188 > {
1189 >  if (conf_parser_ctx.pass == 2)
1190 >    block_state.port.value |= OPER_FLAG_SET;
1191 > } | MODULE
1192   {
1193 <  if (ypass == 2)
1194 <  {
1505 <    if (not_atom) ClearConfEncrypted(yy_aconf);
1506 <    else SetConfEncrypted(yy_aconf);
1507 <  }
1193 >  if (conf_parser_ctx.pass == 2)
1194 >    block_state.port.value |= OPER_FLAG_MODULE;
1195   };
1196  
1197  
# Line 1513 | Line 1200 | oper_flags_item_atom: GLOBAL_KILL
1200   ***************************************************************************/
1201   class_entry: CLASS
1202   {
1203 <  if (ypass == 1)
1204 <  {
1205 <    yy_conf = make_conf_item(CLASS_TYPE);
1206 <    yy_class = (struct ClassItem *)map_to_conf(yy_conf);
1207 <  }
1208 < } class_name_b '{' class_items '}' ';'
1209 < {
1210 <  if (ypass == 1)
1211 <  {
1212 <    struct ConfItem *cconf;
1213 <    struct ClassItem *class = NULL;
1214 <
1215 <    if (yy_class_name == NULL)
1216 <    {
1217 <      delete_conf_item(yy_conf);
1218 <    }
1219 <    else
1220 <    {
1221 <      cconf = find_exact_name_conf(CLASS_TYPE, yy_class_name, NULL, NULL);
1222 <
1223 <      if (cconf != NULL)                /* The class existed already */
1224 <      {
1225 <        rebuild_cidr_class(cconf, yy_class);
1226 <        class = (struct ClassItem *) map_to_conf(cconf);
1227 <        *class = *yy_class;
1228 <        delete_conf_item(yy_conf);
1229 <
1230 <        MyFree(cconf->name);            /* Allows case change of class name */
1231 <        cconf->name = yy_class_name;
1232 <      }
1233 <      else      /* Brand new class */
1234 <      {
1235 <        MyFree(yy_conf->name);          /* just in case it was allocated */
1236 <        yy_conf->name = yy_class_name;
1237 <      }
1238 <    }
1239 <    yy_class_name = NULL;
1240 <  }
1203 >  if (conf_parser_ctx.pass == 1)
1204 >    reset_block_state();
1205 > } '{' class_items '}' ';'
1206 > {
1207 >  struct ClassItem *class = NULL;
1208 >
1209 >  if (conf_parser_ctx.pass != 1)
1210 >    break;
1211 >
1212 >  if (!block_state.class.buf[0])
1213 >    break;
1214 >
1215 >  if (!(class = class_find(block_state.class.buf, 0)))
1216 >    class = class_make();
1217 >
1218 >  class->active = 1;
1219 >  MyFree(class->name);
1220 >  class->name = xstrdup(block_state.class.buf);
1221 >  class->ping_freq = block_state.ping_freq.value;
1222 >  class->max_perip = block_state.max_perip.value;
1223 >  class->con_freq = block_state.con_freq.value;
1224 >  class->max_total = block_state.max_total.value;
1225 >  class->max_global = block_state.max_global.value;
1226 >  class->max_local = block_state.max_local.value;
1227 >  class->max_ident = block_state.max_ident.value;
1228 >  class->max_sendq = block_state.max_sendq.value;
1229 >  class->max_recvq = block_state.max_recvq.value;
1230 >
1231 >  if (class->number_per_cidr && block_state.number_per_cidr.value)
1232 >    if ((class->cidr_bitlen_ipv4 && block_state.cidr_bitlen_ipv4.value) ||
1233 >        (class->cidr_bitlen_ipv6 && block_state.cidr_bitlen_ipv6.value))
1234 >      if ((class->cidr_bitlen_ipv4 != block_state.cidr_bitlen_ipv4.value) ||
1235 >          (class->cidr_bitlen_ipv6 != block_state.cidr_bitlen_ipv6.value))
1236 >        rebuild_cidr_list(class);
1237 >
1238 >  class->cidr_bitlen_ipv4 = block_state.cidr_bitlen_ipv4.value;
1239 >  class->cidr_bitlen_ipv6 = block_state.cidr_bitlen_ipv6.value;
1240 >  class->number_per_cidr = block_state.number_per_cidr.value;
1241   };
1242  
1556 class_name_b: | class_name_t;
1557
1243   class_items:    class_items class_item | class_item;
1244   class_item:     class_name |
1245                  class_cidr_bitlen_ipv4 | class_cidr_bitlen_ipv6 |
1246                  class_ping_time |
1562                class_ping_warning |
1247                  class_number_per_cidr |
1248                  class_number_per_ip |
1249                  class_connectfreq |
# Line 1567 | Line 1251 | class_item:     class_name |
1251                  class_max_global |
1252                  class_max_local |
1253                  class_max_ident |
1254 <                class_sendq |
1254 >                class_sendq | class_recvq |
1255                  error ';' ;
1256  
1257   class_name: NAME '=' QSTRING ';'
1258   {
1259 <  if (ypass == 1)
1260 <  {
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 <  }
1259 >  if (conf_parser_ctx.pass == 1)
1260 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1261   };
1262  
1263   class_ping_time: PING_TIME '=' timespec ';'
1264   {
1265 <  if (ypass == 1)
1266 <    PingFreq(yy_class) = $3;
1595 < };
1596 <
1597 < class_ping_warning: PING_WARNING '=' timespec ';'
1598 < {
1599 <  if (ypass == 1)
1600 <    PingWarning(yy_class) = $3;
1265 >  if (conf_parser_ctx.pass == 1)
1266 >    block_state.ping_freq.value = $3;
1267   };
1268  
1269   class_number_per_ip: NUMBER_PER_IP '=' NUMBER ';'
1270   {
1271 <  if (ypass == 1)
1272 <    MaxPerIp(yy_class) = $3;
1271 >  if (conf_parser_ctx.pass == 1)
1272 >    block_state.max_perip.value = $3;
1273   };
1274  
1275   class_connectfreq: CONNECTFREQ '=' timespec ';'
1276   {
1277 <  if (ypass == 1)
1278 <    ConFreq(yy_class) = $3;
1277 >  if (conf_parser_ctx.pass == 1)
1278 >    block_state.con_freq.value = $3;
1279   };
1280  
1281   class_max_number: MAX_NUMBER '=' NUMBER ';'
1282   {
1283 <  if (ypass == 1)
1284 <    MaxTotal(yy_class) = $3;
1283 >  if (conf_parser_ctx.pass == 1)
1284 >    block_state.max_total.value = $3;
1285   };
1286  
1287   class_max_global: MAX_GLOBAL '=' NUMBER ';'
1288   {
1289 <  if (ypass == 1)
1290 <    MaxGlobal(yy_class) = $3;
1289 >  if (conf_parser_ctx.pass == 1)
1290 >    block_state.max_global.value = $3;
1291   };
1292  
1293   class_max_local: MAX_LOCAL '=' NUMBER ';'
1294   {
1295 <  if (ypass == 1)
1296 <    MaxLocal(yy_class) = $3;
1295 >  if (conf_parser_ctx.pass == 1)
1296 >    block_state.max_local.value = $3;
1297   };
1298  
1299   class_max_ident: MAX_IDENT '=' NUMBER ';'
1300   {
1301 <  if (ypass == 1)
1302 <    MaxIdent(yy_class) = $3;
1301 >  if (conf_parser_ctx.pass == 1)
1302 >    block_state.max_ident.value = $3;
1303   };
1304  
1305   class_sendq: SENDQ '=' sizespec ';'
1306   {
1307 <  if (ypass == 1)
1308 <    MaxSendq(yy_class) = $3;
1307 >  if (conf_parser_ctx.pass == 1)
1308 >    block_state.max_sendq.value = $3;
1309 > };
1310 >
1311 > class_recvq: T_RECVQ '=' sizespec ';'
1312 > {
1313 >  if (conf_parser_ctx.pass == 1)
1314 >    if ($3 >= CLIENT_FLOOD_MIN && $3 <= CLIENT_FLOOD_MAX)
1315 >      block_state.max_recvq.value = $3;
1316   };
1317  
1318   class_cidr_bitlen_ipv4: CIDR_BITLEN_IPV4 '=' NUMBER ';'
1319   {
1320 <  if (ypass == 1)
1321 <    CidrBitlenIPV4(yy_class) = $3;
1320 >  if (conf_parser_ctx.pass == 1)
1321 >    block_state.cidr_bitlen_ipv4.value = $3 > 32 ? 32 : $3;
1322   };
1323  
1324   class_cidr_bitlen_ipv6: CIDR_BITLEN_IPV6 '=' NUMBER ';'
1325   {
1326 <  if (ypass == 1)
1327 <    CidrBitlenIPV6(yy_class) = $3;
1326 >  if (conf_parser_ctx.pass == 1)
1327 >    block_state.cidr_bitlen_ipv6.value = $3 > 128 ? 128 : $3;
1328   };
1329  
1330   class_number_per_cidr: NUMBER_PER_CIDR '=' NUMBER ';'
1331   {
1332 <  if (ypass == 1)
1333 <    NumberPerCidr(yy_class) = $3;
1332 >  if (conf_parser_ctx.pass == 1)
1333 >    block_state.number_per_cidr.value = $3;
1334   };
1335  
1336   /***************************************************************************
# Line 1665 | Line 1338 | class_number_per_cidr: NUMBER_PER_CIDR '
1338   ***************************************************************************/
1339   listen_entry: LISTEN
1340   {
1341 <  if (ypass == 2)
1342 <  {
1343 <    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 < };
1341 >  if (conf_parser_ctx.pass == 2)
1342 >    reset_block_state();
1343 > } '{' listen_items '}' ';';
1344  
1345   listen_flags: IRCD_FLAGS
1346   {
1347 +  block_state.flags.value = 0;
1348   } '='  listen_flags_items ';';
1349  
1350   listen_flags_items: listen_flags_items ',' listen_flags_item | listen_flags_item;
1351   listen_flags_item: T_SSL
1352   {
1353 <  if (ypass == 2)
1354 <    listener_flags |= LISTENER_SSL;
1353 >  if (conf_parser_ctx.pass == 2)
1354 >    block_state.flags.value |= LISTENER_SSL;
1355   } | HIDDEN
1356   {
1357 <  if (ypass == 2)
1358 <    listener_flags |= LISTENER_HIDDEN;
1357 >  if (conf_parser_ctx.pass == 2)
1358 >    block_state.flags.value |= LISTENER_HIDDEN;
1359 > } | T_SERVER
1360 > {
1361 >  if (conf_parser_ctx.pass == 2)
1362 >   block_state.flags.value |= LISTENER_SERVER;
1363   };
1364  
1365   listen_items:   listen_items listen_item | listen_item;
1366 < listen_item:    listen_port | listen_flags | listen_address | listen_host | error ';' ;
1366 > listen_item:    listen_port | listen_flags | listen_address | listen_host | error ';';
1367  
1368 < listen_port: PORT '=' port_items ';' ;
1368 > listen_port: PORT '=' port_items { block_state.flags.value |= 0; } ';';
1369  
1370   port_items: port_items ',' port_item | port_item;
1371  
1372   port_item: NUMBER
1373   {
1374 <  if (ypass == 2)
1374 >  if (conf_parser_ctx.pass == 2)
1375    {
1376 <    if ((listener_flags & LISTENER_SSL))
1376 >    if (block_state.flags.value & LISTENER_SSL)
1377   #ifdef HAVE_LIBCRYPTO
1378 <      if (!ServerInfo.ctx)
1378 >      if (!ServerInfo.server_ctx)
1379   #endif
1380        {
1381          yyerror("SSL not available - port closed");
1382          break;
1383        }
1384 <    add_listener($1, listener_address, listener_flags);
1717 <    listener_flags = 0;
1384 >    add_listener($1, block_state.addr.buf, block_state.flags.value);
1385    }
1386   } | NUMBER TWODOTS NUMBER
1387   {
1388 <  if (ypass == 2)
1388 >  if (conf_parser_ctx.pass == 2)
1389    {
1390      int i;
1391  
1392 <    if ((listener_flags & LISTENER_SSL))
1392 >    if (block_state.flags.value & LISTENER_SSL)
1393   #ifdef HAVE_LIBCRYPTO
1394 <      if (!ServerInfo.ctx)
1394 >      if (!ServerInfo.server_ctx)
1395   #endif
1396        {
1397          yyerror("SSL not available - port closed");
# Line 1732 | Line 1399 | port_item: NUMBER
1399        }
1400  
1401      for (i = $1; i <= $3; ++i)
1402 <      add_listener(i, listener_address, listener_flags);
1736 <
1737 <    listener_flags = 0;
1402 >      add_listener(i, block_state.addr.buf, block_state.flags.value);
1403    }
1404   };
1405  
1406   listen_address: IP '=' QSTRING ';'
1407   {
1408 <  if (ypass == 2)
1409 <  {
1745 <    MyFree(listener_address);
1746 <    DupString(listener_address, yylval.string);
1747 <  }
1408 >  if (conf_parser_ctx.pass == 2)
1409 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
1410   };
1411  
1412   listen_host: HOST '=' QSTRING ';'
1413   {
1414 <  if (ypass == 2)
1415 <  {
1754 <    MyFree(listener_address);
1755 <    DupString(listener_address, yylval.string);
1756 <  }
1414 >  if (conf_parser_ctx.pass == 2)
1415 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
1416   };
1417  
1418   /***************************************************************************
# Line 1761 | Line 1420 | listen_host: HOST '=' QSTRING ';'
1420   ***************************************************************************/
1421   auth_entry: IRCD_AUTH
1422   {
1423 <  if (ypass == 2)
1424 <  {
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 <  }
1423 >  if (conf_parser_ctx.pass == 2)
1424 >    reset_block_state();
1425   } '{' auth_items '}' ';'
1426   {
1427 <  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;
1794 <
1795 <      new_conf = make_conf_item(CLIENT_TYPE);
1796 <      new_aconf = map_to_conf(new_conf);
1797 <
1798 <      yy_tmp = ptr->data;
1799 <
1800 <      assert(yy_tmp->user && yy_tmp->host);
1427 >  dlink_node *ptr = NULL;
1428  
1429 <      if (yy_aconf->passwd != NULL)
1430 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1804 <      if (yy_conf->name != NULL)
1805 <        DupString(new_conf->name, yy_conf->name);
1806 <      if (yy_aconf->passwd != NULL)
1807 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1429 >  if (conf_parser_ctx.pass != 2)
1430 >    break;
1431  
1432 <      new_aconf->flags = yy_aconf->flags;
1433 <      new_aconf->port  = yy_aconf->port;
1434 <
1435 <      DupString(new_aconf->user, yy_tmp->user);
1436 <      collapse(new_aconf->user);
1437 <
1438 <      DupString(new_aconf->host, yy_tmp->host);
1439 <      collapse(new_aconf->host);
1432 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
1433 >  {
1434 >    struct MaskItem *conf = NULL;
1435 >    struct split_nuh_item nuh;
1436 >
1437 >    nuh.nuhmask  = ptr->data;
1438 >    nuh.nickptr  = NULL;
1439 >    nuh.userptr  = block_state.user.buf;
1440 >    nuh.hostptr  = block_state.host.buf;
1441 >    nuh.nicksize = 0;
1442 >    nuh.usersize = sizeof(block_state.user.buf);
1443 >    nuh.hostsize = sizeof(block_state.host.buf);
1444 >    split_nuh(&nuh);
1445 >
1446 >    conf        = conf_make(CONF_CLIENT);
1447 >    conf->user  = xstrdup(collapse(block_state.user.buf));
1448 >    conf->host  = xstrdup(collapse(block_state.host.buf));
1449 >
1450 >    if (block_state.rpass.buf[0])
1451 >      conf->passwd = xstrdup(block_state.rpass.buf);
1452 >    if (block_state.name.buf[0])
1453 >      conf->passwd = xstrdup(block_state.name.buf);
1454  
1455 <      conf_add_class_to_conf(new_conf, class_name);
1456 <      add_conf_by_address(CONF_CLIENT, new_aconf);
1820 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
1821 <      free_collect_item(yy_tmp);
1822 <    }
1455 >    conf->flags = block_state.flags.value;
1456 >    conf->port  = block_state.port.value;
1457  
1458 <    MyFree(class_name);
1459 <    class_name = NULL;
1826 <    yy_conf = NULL;
1827 <    yy_aconf = NULL;
1458 >    conf_add_class_to_conf(conf, block_state.class.buf);
1459 >    add_conf_by_address(CONF_CLIENT, conf);
1460    }
1461   };
1462  
1463   auth_items:     auth_items auth_item | auth_item;
1464   auth_item:      auth_user | auth_passwd | auth_class | auth_flags |
1465 <                auth_kline_exempt | auth_need_ident |
1466 <                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 ';' ;
1465 >                auth_spoof | auth_redir_serv | auth_redir_port |
1466 >                auth_encrypted | error ';' ;
1467  
1468   auth_user: USER '=' QSTRING ';'
1469   {
1470 <  if (ypass == 2)
1471 <  {
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 <  }
1470 >  if (conf_parser_ctx.pass == 2)
1471 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1472   };
1473  
1856 /* XXX - IP/IPV6 tags don't exist anymore - put IP/IPV6 into user. */
1857
1474   auth_passwd: PASSWORD '=' QSTRING ';'
1475   {
1476 <  if (ypass == 2)
1477 <  {
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 <  }
1476 >  if (conf_parser_ctx.pass == 2)
1477 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1478   };
1479  
1480   auth_class: CLASS '=' QSTRING ';'
1481   {
1482 <  if (ypass == 2)
1483 <  {
1886 <    MyFree(class_name);
1887 <    DupString(class_name, yylval.string);
1888 <  }
1482 >  if (conf_parser_ctx.pass == 2)
1483 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1484   };
1485  
1486   auth_encrypted: ENCRYPTED '=' TBOOL ';'
1487   {
1488 <  if (ypass == 2)
1488 >  if (conf_parser_ctx.pass == 2)
1489    {
1490      if (yylval.number)
1491 <      SetConfEncrypted(yy_aconf);
1491 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1492      else
1493 <      ClearConfEncrypted(yy_aconf);
1493 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1494    }
1495   };
1496  
1497   auth_flags: IRCD_FLAGS
1498   {
1499 +  if (conf_parser_ctx.pass == 2)
1500 +    block_state.flags.value = 0;
1501   } '='  auth_flags_items ';';
1502  
1503   auth_flags_items: auth_flags_items ',' auth_flags_item | auth_flags_item;
1504 < auth_flags_item: NOT { not_atom = 1; } auth_flags_item_atom
1908 <                | { not_atom = 0; } auth_flags_item_atom;
1909 <
1910 < auth_flags_item_atom: SPOOF_NOTICE
1504 > auth_flags_item: SPOOF_NOTICE
1505   {
1506 <  if (ypass == 2)
1507 <  {
1914 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_SPOOF_NOTICE;
1915 <    else yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1916 <  }
1917 <
1506 >  if (conf_parser_ctx.pass == 2)
1507 >    block_state.flags.value |= CONF_FLAGS_SPOOF_NOTICE;
1508   } | EXCEED_LIMIT
1509   {
1510 <  if (ypass == 2)
1511 <  {
1922 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NOLIMIT;
1923 <    else yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
1924 <  }
1510 >  if (conf_parser_ctx.pass == 2)
1511 >    block_state.flags.value |= CONF_FLAGS_NOLIMIT;
1512   } | KLINE_EXEMPT
1513   {
1514 <  if (ypass == 2)
1515 <  {
1929 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTKLINE;
1930 <    else yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
1931 <  }
1514 >  if (conf_parser_ctx.pass == 2)
1515 >    block_state.flags.value |= CONF_FLAGS_EXEMPTKLINE;
1516   } | NEED_IDENT
1517   {
1518 <  if (ypass == 2)
1519 <  {
1936 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NEED_IDENTD;
1937 <    else yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
1938 <  }
1518 >  if (conf_parser_ctx.pass == 2)
1519 >    block_state.flags.value |= CONF_FLAGS_NEED_IDENTD;
1520   } | CAN_FLOOD
1521   {
1522 <  if (ypass == 2)
1523 <  {
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 <  }
1522 >  if (conf_parser_ctx.pass == 2)
1523 >    block_state.flags.value |= CONF_FLAGS_CAN_FLOOD;
1524   } | NO_TILDE
1525   {
1526 <  if (ypass == 2)
1527 <  {
1957 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NO_TILDE;
1958 <    else yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
1959 <  }
1526 >  if (conf_parser_ctx.pass == 2)
1527 >    block_state.flags.value |= CONF_FLAGS_NO_TILDE;
1528   } | GLINE_EXEMPT
1529   {
1530 <  if (ypass == 2)
1531 <  {
1964 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTGLINE;
1965 <    else yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
1966 <  }
1530 >  if (conf_parser_ctx.pass == 2)
1531 >    block_state.flags.value |= CONF_FLAGS_EXEMPTGLINE;
1532   } | RESV_EXEMPT
1533   {
1534 <  if (ypass == 2)
1535 <  {
1971 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTRESV;
1972 <    else yy_aconf->flags |= CONF_FLAGS_EXEMPTRESV;
1973 <  }
1534 >  if (conf_parser_ctx.pass == 2)
1535 >    block_state.flags.value |= CONF_FLAGS_EXEMPTRESV;
1536   } | NEED_PASSWORD
1537   {
1538 <  if (ypass == 2)
1539 <  {
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 ';'
2028 < {
2029 <  if (ypass == 2)
2030 <  {
2031 <    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 ';'
2039 < {
2040 <  if (ypass == 2)
2041 <  {
2042 <    if (yylval.number)
2043 <      yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
2044 <    else
2045 <      yy_aconf->flags &= ~CONF_FLAGS_EXEMPTGLINE;
2046 <  }
1538 >  if (conf_parser_ctx.pass == 2)
1539 >    block_state.flags.value |= CONF_FLAGS_NEED_PASSWORD;
1540   };
1541  
2049 /* XXX - need check for illegal hostnames here */
1542   auth_spoof: SPOOF '=' QSTRING ';'
1543   {
1544 <  if (ypass == 2)
1545 <  {
2054 <    MyFree(yy_conf->name);
1544 >  if (conf_parser_ctx.pass != 2)
1545 >    break;
1546  
1547 <    if (strlen(yylval.string) < HOSTLEN)
1548 <    {    
1549 <      DupString(yy_conf->name, yylval.string);
1550 <      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 <    }
1547 >  if (strlen(yylval.string) <= HOSTLEN && valid_hostname(yylval.string))
1548 >  {
1549 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1550 >    block_state.flags.value |= CONF_FLAGS_SPOOF_IP;
1551    }
1552 +  else
1553 +    ilog(LOG_TYPE_IRCD, "Spoof either is too long or contains invalid characters. Ignoring it.");
1554   };
1555  
1556   auth_redir_serv: REDIRSERV '=' QSTRING ';'
1557   {
1558 <  if (ypass == 2)
1559 <  {
1560 <    yy_aconf->flags |= CONF_FLAGS_REDIR;
1561 <    MyFree(yy_conf->name);
1562 <    DupString(yy_conf->name, yylval.string);
2076 <  }
1558 >  if (conf_parser_ctx.pass != 2)
1559 >    break;
1560 >
1561 >  strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1562 >  block_state.flags.value |= CONF_FLAGS_REDIR;
1563   };
1564  
1565   auth_redir_port: REDIRPORT '=' NUMBER ';'
1566   {
1567 <  if (ypass == 2)
1568 <  {
2083 <    yy_aconf->flags |= CONF_FLAGS_REDIR;
2084 <    yy_aconf->port = $3;
2085 <  }
2086 < };
1567 >  if (conf_parser_ctx.pass != 2)
1568 >    break;
1569  
1570 < auth_need_password: NEED_PASSWORD '=' TBOOL ';'
1571 < {
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 <  }
1570 >  block_state.flags.value |= CONF_FLAGS_REDIR;
1571 >  block_state.port.value = $3;
1572   };
1573  
1574  
# Line 2102 | Line 1577 | auth_need_password: NEED_PASSWORD '=' TB
1577   ***************************************************************************/
1578   resv_entry: RESV
1579   {
1580 <  if (ypass == 2)
1581 <  {
1582 <    MyFree(resv_reason);
1583 <    resv_reason = NULL;
1584 <  }
1585 < } '{' resv_items '}' ';'
2111 < {
2112 <  if (ypass == 2)
2113 <  {
2114 <    MyFree(resv_reason);
2115 <    resv_reason = NULL;
2116 <  }
2117 < };
1580 >  if (conf_parser_ctx.pass != 2)
1581 >    break;
1582 >
1583 >  reset_block_state();
1584 >  strlcpy(block_state.rpass.buf, CONF_NOREASON, sizeof(block_state.rpass.buf));
1585 > } '{' resv_items '}' ';';
1586  
1587   resv_items:     resv_items resv_item | resv_item;
1588   resv_item:      resv_creason | resv_channel | resv_nick | error ';' ;
1589  
1590   resv_creason: REASON '=' QSTRING ';'
1591   {
1592 <  if (ypass == 2)
1593 <  {
2126 <    MyFree(resv_reason);
2127 <    DupString(resv_reason, yylval.string);
2128 <  }
1592 >  if (conf_parser_ctx.pass == 2)
1593 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1594   };
1595  
1596   resv_channel: CHANNEL '=' QSTRING ';'
1597   {
1598 <  if (ypass == 2)
1599 <  {
2135 <    if (IsChanPrefix(*yylval.string))
2136 <    {
2137 <      char def_reason[] = "No reason";
1598 >  if (conf_parser_ctx.pass != 2)
1599 >    break;
1600  
1601 <      create_channel_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
1602 <    }
2141 <  }
2142 <  /* ignore it for now.. but we really should make a warning if
2143 <   * its an erroneous name --fl_ */
1601 >  if (IsChanPrefix(*yylval.string))
1602 >    create_channel_resv(yylval.string, block_state.rpass.buf, 1);
1603   };
1604  
1605   resv_nick: NICK '=' QSTRING ';'
1606   {
1607 <  if (ypass == 2)
1608 <  {
1609 <    char def_reason[] = "No reason";
1607 >  if (conf_parser_ctx.pass == 2)
1608 >    create_nick_resv(yylval.string, block_state.rpass.buf, 1);
1609 > };
1610 >
1611 > /***************************************************************************
1612 > *  section service
1613 > ***************************************************************************/
1614 > service_entry: T_SERVICE '{' service_items '}' ';';
1615  
1616 <    create_nick_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
1616 > service_items:     service_items service_item | service_item;
1617 > service_item:      service_name | error;
1618 >
1619 > service_name: NAME '=' QSTRING ';'
1620 > {
1621 >  if (conf_parser_ctx.pass == 2)
1622 >  {
1623 >    if (valid_servname(yylval.string))
1624 >    {
1625 >      struct MaskItem *conf = conf_make(CONF_SERVICE);
1626 >      conf->name = xstrdup(yylval.string);
1627 >    }
1628    }
1629   };
1630  
# Line 2158 | Line 1633 | resv_nick: NICK '=' QSTRING ';'
1633   ***************************************************************************/
1634   shared_entry: T_SHARED
1635   {
1636 <  if (ypass == 2)
1637 <  {
1638 <    yy_conf = make_conf_item(ULINE_TYPE);
1639 <    yy_match_item = map_to_conf(yy_conf);
1640 <    yy_match_item->action = SHARED_ALL;
1641 <  }
1636 >  if (conf_parser_ctx.pass != 2)
1637 >    break;
1638 >
1639 >  reset_block_state();
1640 >
1641 >  strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1642 >  strlcpy(block_state.user.buf, "*", sizeof(block_state.user.buf));
1643 >  strlcpy(block_state.host.buf, "*", sizeof(block_state.host.buf));
1644 >  block_state.flags.value = SHARED_ALL;
1645   } '{' shared_items '}' ';'
1646   {
1647 <  if (ypass == 2)
1648 <  {
1649 <    yy_conf = NULL;
1650 <  }
1647 >  struct MaskItem *conf = NULL;
1648 >
1649 >  if (conf_parser_ctx.pass != 2)
1650 >    break;
1651 >
1652 >  conf = conf_make(CONF_ULINE);
1653 >  conf->flags = block_state.flags.value;
1654 >  conf->name = xstrdup(block_state.name.buf);
1655 >  conf->user = xstrdup(block_state.user.buf);
1656 >  conf->user = xstrdup(block_state.host.buf);
1657   };
1658  
1659   shared_items: shared_items shared_item | shared_item;
# Line 2177 | Line 1661 | shared_item:  shared_name | shared_user
1661  
1662   shared_name: NAME '=' QSTRING ';'
1663   {
1664 <  if (ypass == 2)
1665 <  {
2182 <    MyFree(yy_conf->name);
2183 <    DupString(yy_conf->name, yylval.string);
2184 <  }
1664 >  if (conf_parser_ctx.pass == 2)
1665 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1666   };
1667  
1668   shared_user: USER '=' QSTRING ';'
1669   {
1670 <  if (ypass == 2)
1670 >  if (conf_parser_ctx.pass == 2)
1671    {
1672 <    split_nuh(yylval.string, NULL, &yy_match_item->user, &yy_match_item->host);
1672 >    struct split_nuh_item nuh;
1673 >
1674 >    nuh.nuhmask  = yylval.string;
1675 >    nuh.nickptr  = NULL;
1676 >    nuh.userptr  = block_state.user.buf;
1677 >    nuh.hostptr  = block_state.host.buf;
1678 >
1679 >    nuh.nicksize = 0;
1680 >    nuh.usersize = sizeof(block_state.user.buf);
1681 >    nuh.hostsize = sizeof(block_state.host.buf);
1682 >
1683 >    split_nuh(&nuh);
1684    }
1685   };
1686  
1687   shared_type: TYPE
1688   {
1689 <  if (ypass == 2)
1690 <    yy_match_item->action = 0;
1689 >  if (conf_parser_ctx.pass == 2)
1690 >    block_state.flags.value = 0;
1691   } '=' shared_types ';' ;
1692  
1693   shared_types: shared_types ',' shared_type_item | shared_type_item;
1694   shared_type_item: KLINE
1695   {
1696 <  if (ypass == 2)
1697 <    yy_match_item->action |= SHARED_KLINE;
2206 < } | TKLINE
2207 < {
2208 <  if (ypass == 2)
2209 <    yy_match_item->action |= SHARED_TKLINE;
1696 >  if (conf_parser_ctx.pass == 2)
1697 >    block_state.flags.value |= SHARED_KLINE;
1698   } | UNKLINE
1699   {
1700 <  if (ypass == 2)
1701 <    yy_match_item->action |= SHARED_UNKLINE;
1702 < } | XLINE
1700 >  if (conf_parser_ctx.pass == 2)
1701 >    block_state.flags.value |= SHARED_UNKLINE;
1702 > } | T_DLINE
1703 > {
1704 >  if (conf_parser_ctx.pass == 2)
1705 >    block_state.flags.value |= SHARED_DLINE;
1706 > } | T_UNDLINE
1707   {
1708 <  if (ypass == 2)
1709 <    yy_match_item->action |= SHARED_XLINE;
1710 < } | TXLINE
1708 >  if (conf_parser_ctx.pass == 2)
1709 >    block_state.flags.value |= SHARED_UNDLINE;
1710 > } | XLINE
1711   {
1712 <  if (ypass == 2)
1713 <    yy_match_item->action |= SHARED_TXLINE;
1712 >  if (conf_parser_ctx.pass == 2)
1713 >    block_state.flags.value |= SHARED_XLINE;
1714   } | T_UNXLINE
1715   {
1716 <  if (ypass == 2)
1717 <    yy_match_item->action |= SHARED_UNXLINE;
1716 >  if (conf_parser_ctx.pass == 2)
1717 >    block_state.flags.value |= SHARED_UNXLINE;
1718   } | RESV
1719   {
1720 <  if (ypass == 2)
1721 <    yy_match_item->action |= SHARED_RESV;
2230 < } | TRESV
2231 < {
2232 <  if (ypass == 2)
2233 <    yy_match_item->action |= SHARED_TRESV;
1720 >  if (conf_parser_ctx.pass == 2)
1721 >    block_state.flags.value |= SHARED_RESV;
1722   } | T_UNRESV
1723   {
1724 <  if (ypass == 2)
1725 <    yy_match_item->action |= SHARED_UNRESV;
1724 >  if (conf_parser_ctx.pass == 2)
1725 >    block_state.flags.value |= SHARED_UNRESV;
1726   } | T_LOCOPS
1727   {
1728 <  if (ypass == 2)
1729 <    yy_match_item->action |= SHARED_LOCOPS;
1728 >  if (conf_parser_ctx.pass == 2)
1729 >    block_state.flags.value |= SHARED_LOCOPS;
1730   } | T_ALL
1731   {
1732 <  if (ypass == 2)
1733 <    yy_match_item->action = SHARED_ALL;
1732 >  if (conf_parser_ctx.pass == 2)
1733 >    block_state.flags.value = SHARED_ALL;
1734   };
1735  
1736   /***************************************************************************
# Line 2250 | Line 1738 | shared_type_item: KLINE
1738   ***************************************************************************/
1739   cluster_entry: T_CLUSTER
1740   {
1741 <  if (ypass == 2)
1742 <  {
1743 <    yy_conf = make_conf_item(CLUSTER_TYPE);
1744 <    yy_conf->flags = SHARED_ALL;
1745 <  }
1741 >  if (conf_parser_ctx.pass != 2)
1742 >    break;
1743 >
1744 >  reset_block_state();
1745 >
1746 >  strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1747 >  block_state.flags.value = SHARED_ALL;
1748   } '{' cluster_items '}' ';'
1749   {
1750 <  if (ypass == 2)
1751 <  {
1752 <    if (yy_conf->name == NULL)
1753 <      DupString(yy_conf->name, "*");
1754 <    yy_conf = NULL;
1755 <  }
1750 >  struct MaskItem *conf = NULL;
1751 >
1752 >  if (conf_parser_ctx.pass != 2)
1753 >    break;
1754 >
1755 >  conf = conf_make(CONF_CLUSTER);
1756 >  conf->flags = block_state.flags.value;
1757 >  conf->name = xstrdup(block_state.name.buf);
1758   };
1759  
1760   cluster_items:  cluster_items cluster_item | cluster_item;
# Line 2270 | Line 1762 | cluster_item:  cluster_name | cluster_typ
1762  
1763   cluster_name: NAME '=' QSTRING ';'
1764   {
1765 <  if (ypass == 2)
1766 <    DupString(yy_conf->name, yylval.string);
1765 >  if (conf_parser_ctx.pass == 2)
1766 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1767   };
1768  
1769   cluster_type: TYPE
1770   {
1771 <  if (ypass == 2)
1772 <    yy_conf->flags = 0;
1771 >  if (conf_parser_ctx.pass == 2)
1772 >    block_state.flags.value = 0;
1773   } '=' cluster_types ';' ;
1774  
1775   cluster_types:  cluster_types ',' cluster_type_item | cluster_type_item;
1776   cluster_type_item: KLINE
1777   {
1778 <  if (ypass == 2)
1779 <    yy_conf->flags |= SHARED_KLINE;
2288 < } | TKLINE
2289 < {
2290 <  if (ypass == 2)
2291 <    yy_conf->flags |= SHARED_TKLINE;
1778 >  if (conf_parser_ctx.pass == 2)
1779 >    block_state.flags.value |= SHARED_KLINE;
1780   } | UNKLINE
1781   {
1782 <  if (ypass == 2)
1783 <    yy_conf->flags |= SHARED_UNKLINE;
1784 < } | XLINE
1782 >  if (conf_parser_ctx.pass == 2)
1783 >    block_state.flags.value |= SHARED_UNKLINE;
1784 > } | T_DLINE
1785 > {
1786 >  if (conf_parser_ctx.pass == 2)
1787 >    block_state.flags.value |= SHARED_DLINE;
1788 > } | T_UNDLINE
1789   {
1790 <  if (ypass == 2)
1791 <    yy_conf->flags |= SHARED_XLINE;
1792 < } | TXLINE
1790 >  if (conf_parser_ctx.pass == 2)
1791 >    block_state.flags.value |= SHARED_UNDLINE;
1792 > } | XLINE
1793   {
1794 <  if (ypass == 2)
1795 <    yy_conf->flags |= SHARED_TXLINE;
1794 >  if (conf_parser_ctx.pass == 2)
1795 >    block_state.flags.value |= SHARED_XLINE;
1796   } | T_UNXLINE
1797   {
1798 <  if (ypass == 2)
1799 <    yy_conf->flags |= SHARED_UNXLINE;
1798 >  if (conf_parser_ctx.pass == 2)
1799 >    block_state.flags.value |= SHARED_UNXLINE;
1800   } | RESV
1801   {
1802 <  if (ypass == 2)
1803 <    yy_conf->flags |= SHARED_RESV;
2312 < } | TRESV
2313 < {
2314 <  if (ypass == 2)
2315 <    yy_conf->flags |= SHARED_TRESV;
1802 >  if (conf_parser_ctx.pass == 2)
1803 >    block_state.flags.value |= SHARED_RESV;
1804   } | T_UNRESV
1805   {
1806 <  if (ypass == 2)
1807 <    yy_conf->flags |= SHARED_UNRESV;
1806 >  if (conf_parser_ctx.pass == 2)
1807 >    block_state.flags.value |= SHARED_UNRESV;
1808   } | T_LOCOPS
1809   {
1810 <  if (ypass == 2)
1811 <    yy_conf->flags |= SHARED_LOCOPS;
1810 >  if (conf_parser_ctx.pass == 2)
1811 >    block_state.flags.value |= SHARED_LOCOPS;
1812   } | T_ALL
1813   {
1814 <  if (ypass == 2)
1815 <    yy_conf->flags = SHARED_ALL;
1814 >  if (conf_parser_ctx.pass == 2)
1815 >    block_state.flags.value = SHARED_ALL;
1816   };
1817  
1818   /***************************************************************************
# Line 2332 | Line 1820 | cluster_type_item: KLINE
1820   ***************************************************************************/
1821   connect_entry: CONNECT  
1822   {
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;
1823  
1824 <    if (ConfigFileEntry.burst_away)
1825 <      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;
1824 >  if (conf_parser_ctx.pass != 2)
1825 >    break;
1826  
1827 <        yy_hconf = ptr->data;
1827 >  reset_block_state();
1828 >  block_state.port.value = PORTNUM;
1829 > } '{' connect_items '}' ';'
1830 > {
1831 >  struct MaskItem *conf = NULL;
1832 >  struct addrinfo hints, *res;
1833 >
1834 >  if (conf_parser_ctx.pass != 2)
1835 >    break;
1836 >
1837 >  if (!(block_state.name.buf[0] ||
1838 >        block_state.host.buf[0]))
1839 >    break;
1840 >
1841 >  if (!(block_state.rpass.buf[0] ||
1842 >        block_state.spass.buf[0]))
1843 >    break;
1844 >
1845 >  if (has_wildcards(block_state.name.buf) ||
1846 >      has_wildcards(block_state.host.buf))
1847 >    break;
1848 >
1849 >  conf = conf_make(CONF_SERVER);
1850 >  conf->port = block_state.port.value;
1851 >  conf->flags = block_state.flags.value;
1852 >  conf->aftype = block_state.aftype.value;
1853 >  conf->host = xstrdup(block_state.host.buf);
1854 >  conf->name = xstrdup(block_state.name.buf);
1855 >  conf->passwd = xstrdup(block_state.rpass.buf);
1856 >  conf->spasswd = xstrdup(block_state.spass.buf);
1857 >  conf->cipher_list = xstrdup(block_state.ciph.buf);
1858  
1859 <        /* yy_conf == NULL is a fatal error for this connect block! */
1860 <        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 <      }
1859 >  dlinkMoveList(&block_state.leaf.list, &conf->leaf_list);
1860 >  dlinkMoveList(&block_state.hub.list, &conf->hub_list);
1861  
1862 <      /* Ditto for the LEAF confs */
1862 >  if (block_state.bind.buf[0])
1863 >  {
1864 >    memset(&hints, 0, sizeof(hints));
1865  
1866 <      DLINK_FOREACH_SAFE(ptr, next_ptr, leaf_conf_list.head)
1867 <      {
1868 <        struct ConfItem *new_leaf_conf;
2455 <        struct MatchItem *match_item;
1866 >    hints.ai_family   = AF_UNSPEC;
1867 >    hints.ai_socktype = SOCK_STREAM;
1868 >    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
1869  
1870 <        yy_lconf = ptr->data;
1870 >    if (getaddrinfo(block_state.bind.buf, NULL, &hints, &res))
1871 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", block_state.bind.buf);
1872 >    else
1873 >    {
1874 >      assert(res != NULL);
1875  
1876 <        if ((yy_conf != NULL) && (yy_conf->name != NULL))
1877 <        {
1878 <          new_leaf_conf = make_conf_item(LEAF_TYPE);
1879 <          match_item = (struct MatchItem *)map_to_conf(new_leaf_conf);
1880 <          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;
1876 >      memcpy(&conf->bind, res->ai_addr, res->ai_addrlen);
1877 >      conf->bind.ss.ss_family = res->ai_family;
1878 >      conf->bind.ss_len = res->ai_addrlen;
1879 >      freeaddrinfo(res);
1880 >    }
1881    }
1882 +
1883 +  conf_add_class_to_conf(conf, block_state.class.buf);
1884 +  lookup_confhost(conf);
1885   };
1886  
2483 connect_name_b: | connect_name_t;
1887   connect_items:  connect_items connect_item | connect_item;
1888   connect_item:   connect_name | connect_host | connect_vhost |
1889                  connect_send_password | connect_accept_password |
1890 <                connect_aftype | connect_port |
1891 <                connect_fakename | connect_flags | connect_hub_mask |
1892 <                connect_leaf_mask | connect_class | connect_auto |
2490 <                connect_encrypted | connect_compressed | connect_cryptlink |
2491 <                connect_rsa_public_key_file | connect_cipher_preference |
1890 >                connect_aftype | connect_port | connect_ssl_cipher_list |
1891 >                connect_flags | connect_hub_mask | connect_leaf_mask |
1892 >                connect_class | connect_encrypted |
1893                  error ';' ;
1894  
1895   connect_name: NAME '=' QSTRING ';'
1896   {
1897 <  if (ypass == 2)
1898 <  {
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 <  }
1897 >  if (conf_parser_ctx.pass == 2)
1898 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1899   };
1900  
1901   connect_host: HOST '=' QSTRING ';'
1902   {
1903 <  if (ypass == 2)
1904 <  {
2522 <    MyFree(yy_aconf->host);
2523 <    DupString(yy_aconf->host, yylval.string);
2524 <  }
1903 >  if (conf_parser_ctx.pass == 2)
1904 >    strlcpy(block_state.host.buf, yylval.string, sizeof(block_state.host.buf));
1905   };
1906  
1907   connect_vhost: VHOST '=' QSTRING ';'
1908   {
1909 <  if (ypass == 2)
1910 <  {
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 <  }
1909 >  if (conf_parser_ctx.pass == 2)
1910 >    strlcpy(block_state.bind.buf, yylval.string, sizeof(block_state.bind.buf));
1911   };
1912  
1913   connect_send_password: SEND_PASSWORD '=' QSTRING ';'
1914   {
1915 <  if (ypass == 2)
1916 <  {
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));
1915 >  if (conf_parser_ctx.pass != 2)
1916 >    break;
1917  
1918 <      MyFree(yy_aconf->spasswd);
1919 <      DupString(yy_aconf->spasswd, yylval.string);
1920 <    }
1921 <  }
1918 >  if ($3[0] == ':')
1919 >    yyerror("Server passwords cannot begin with a colon");
1920 >  else if (strchr($3, ' ') != NULL)
1921 >    yyerror("Server passwords cannot contain spaces");
1922 >  else
1923 >    strlcpy(block_state.spass.buf, yylval.string, sizeof(block_state.spass.buf));
1924   };
1925  
1926   connect_accept_password: ACCEPT_PASSWORD '=' QSTRING ';'
1927   {
1928 <  if (ypass == 2)
1929 <  {
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));
1928 >  if (conf_parser_ctx.pass != 2)
1929 >    break;
1930  
1931 <      MyFree(yy_aconf->passwd);
1932 <      DupString(yy_aconf->passwd, yylval.string);
1933 <    }
1934 <  }
1931 >  if ($3[0] == ':')
1932 >    yyerror("Server passwords cannot begin with a colon");
1933 >  else if (strchr($3, ' ') != NULL)
1934 >    yyerror("Server passwords cannot contain spaces");
1935 >  else
1936 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1937   };
1938  
1939   connect_port: PORT '=' NUMBER ';'
1940   {
1941 <  if (ypass == 2)
1942 <    yy_aconf->port = $3;
1941 >  if (conf_parser_ctx.pass == 2)
1942 >    block_state.port.value = $3;
1943   };
1944  
1945   connect_aftype: AFTYPE '=' T_IPV4 ';'
1946   {
1947 <  if (ypass == 2)
1948 <    yy_aconf->aftype = AF_INET;
1947 >  if (conf_parser_ctx.pass == 2)
1948 >    block_state.aftype.value = AF_INET;
1949   } | AFTYPE '=' T_IPV6 ';'
1950   {
1951   #ifdef IPV6
1952 <  if (ypass == 2)
1953 <    yy_aconf->aftype = AF_INET6;
1952 >  if (conf_parser_ctx.pass == 2)
1953 >    block_state.aftype.value = AF_INET6;
1954   #endif
1955   };
1956  
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
1957   connect_flags: IRCD_FLAGS
1958   {
1959 + /* XXX */
1960   } '='  connect_flags_items ';';
1961  
1962   connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;
1963 < connect_flags_item: NOT  { not_atom = 1; } connect_flags_item_atom
2622 <                        |  { not_atom = 0; } connect_flags_item_atom;
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
2650 < {
2651 <  if (ypass == 2)
2652 <  {
2653 <    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
1963 > connect_flags_item: AUTOCONN
1964   {
1965 <  if (ypass == 2)
1966 <  {
1967 <    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 ';'
1965 >  if (conf_parser_ctx.pass == 2)
1966 >    block_state.flags.value |= CONF_FLAGS_ALLOW_AUTO_CONN;
1967 > } | T_SSL
1968   {
1969 < #ifdef HAVE_LIBCRYPTO
1970 <  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 */
1969 >  if (conf_parser_ctx.pass == 2)
1970 >    block_state.flags.value |= CONF_FLAGS_SSL;
1971   };
1972  
1973   connect_encrypted: ENCRYPTED '=' TBOOL ';'
1974   {
1975 <  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)
1975 >  if (conf_parser_ctx.pass == 2)
1976    {
1977      if (yylval.number)
1978 <      yy_aconf->flags |= CONF_FLAGS_ALLOW_AUTO_CONN;
1978 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1979      else
1980 <      yy_aconf->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN;
1980 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1981    }
1982   };
1983  
1984   connect_hub_mask: HUB_MASK '=' QSTRING ';'
1985   {
1986 <  if (ypass == 2)
1987 <  {
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 <  }
1986 >  if (conf_parser_ctx.pass == 2)
1987 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.hub.list);
1988   };
1989  
1990   connect_leaf_mask: LEAF_MASK '=' QSTRING ';'
1991   {
1992 <  if (ypass == 2)
1993 <  {
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 <  }
1992 >  if (conf_parser_ctx.pass == 2)
1993 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.leaf.list);
1994   };
1995  
1996   connect_class: CLASS '=' QSTRING ';'
1997   {
1998 <  if (ypass == 2)
1999 <  {
2792 <    MyFree(class_name);
2793 <    DupString(class_name, yylval.string);
2794 <  }
1998 >  if (conf_parser_ctx.pass == 2)
1999 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
2000   };
2001  
2002 < connect_cipher_preference: CIPHER_PREFERENCE '=' QSTRING ';'
2002 > connect_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
2003   {
2004   #ifdef HAVE_LIBCRYPTO
2005 <  if (ypass == 2)
2006 <  {
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 <  }
2005 >  if (conf_parser_ctx.pass == 2)
2006 >    strlcpy(block_state.ciph.buf, yylval.string, sizeof(block_state.ciph.buf));
2007   #else
2008 <  if (ypass == 2)
2009 <    yyerror("Ignoring cipher_preference -- no OpenSSL support");
2008 >  if (conf_parser_ctx.pass == 2)
2009 >    yyerror("Ignoring connect::ciphers -- no OpenSSL support");
2010   #endif
2011   };
2012  
2013 +
2014   /***************************************************************************
2015   *  section kill
2016   ***************************************************************************/
2017   kill_entry: KILL
2018   {
2019 <  if (ypass == 2)
2020 <  {
2836 <    userbuf[0] = hostbuf[0] = reasonbuf[0] = '\0';
2837 <    regex_ban = 0;
2838 <  }
2019 >  if (conf_parser_ctx.pass == 2)
2020 >    reset_block_state();
2021   } '{' kill_items '}' ';'
2022   {
2023 <  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;
2023 >  struct MaskItem *conf = NULL;
2024  
2025 <        DupString(yy_aconf->user, userbuf);
2026 <        DupString(yy_aconf->host, hostbuf);
2025 >  if (conf_parser_ctx.pass != 2)
2026 >    break;
2027  
2028 <        if (reasonbuf[0])
2029 <          DupString(yy_aconf->reason, reasonbuf);
2030 <        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);
2028 >  if (!block_state.user.buf[0] ||
2029 >      !block_state.host.buf[0])
2030 >    break;
2031  
2875        DupString(yy_aconf->user, userbuf);
2876        DupString(yy_aconf->host, hostbuf);
2032  
2033 <        if (reasonbuf[0])
2034 <          DupString(yy_aconf->reason, reasonbuf);
2035 <        else
2036 <          DupString(yy_aconf->reason, "No reason");
2037 <        add_conf_by_address(CONF_KILL, yy_aconf);
2038 <      }
2033 >  if (block_state.port.value == 1)
2034 >  {
2035 > #ifdef HAVE_LIBPCRE
2036 >    void *exp_user = NULL;
2037 >    void *exp_host = NULL;
2038 >    const char *errptr = NULL;
2039 >
2040 >    if (!(exp_user = ircd_pcre_compile(block_state.user.buf, &errptr)) ||
2041 >        !(exp_host = ircd_pcre_compile(block_state.host.buf, &errptr)))
2042 >    {
2043 >      ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: %s",
2044 >           errptr);
2045 >      break;
2046      }
2047 +
2048 +    conf = conf_make(CONF_RKLINE);
2049 +    conf->regexuser = exp_user;
2050 +    conf->regexhost = exp_host;
2051 +
2052 +    conf->user = xstrdup(block_state.user.buf);
2053 +    conf->host = xstrdup(block_state.host.buf);
2054 +
2055 +    if (block_state.rpass.buf[0])
2056 +      conf->reason = xstrdup(block_state.rpass.buf);
2057      else
2058 <      delete_conf_item(yy_conf);
2058 >      conf->reason = xstrdup(CONF_NOREASON);
2059 > #else
2060 >    ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: no PCRE support");
2061 >    break;
2062 > #endif
2063 >  }
2064 >  else
2065 >  {
2066 >    conf = conf_make(CONF_KLINE);
2067 >
2068 >    conf->user = xstrdup(block_state.user.buf);
2069 >    conf->host = xstrdup(block_state.host.buf);
2070  
2071 <    yy_conf = NULL;
2072 <    yy_aconf = NULL;
2071 >    if (block_state.rpass.buf[0])
2072 >      conf->reason = xstrdup(block_state.rpass.buf);
2073 >    else
2074 >      conf->reason = xstrdup(CONF_NOREASON);
2075 >    add_conf_by_address(CONF_KLINE, conf);
2076    }
2077   };
2078  
2079   kill_type: TYPE
2080   {
2081 +  if (conf_parser_ctx.pass == 2)
2082 +    block_state.port.value = 0;
2083   } '='  kill_type_items ';';
2084  
2085   kill_type_items: kill_type_items ',' kill_type_item | kill_type_item;
2086   kill_type_item: REGEX_T
2087   {
2088 <  if (ypass == 2)
2089 <    regex_ban = 1;
2088 >  if (conf_parser_ctx.pass == 2)
2089 >    block_state.port.value = 1;
2090   };
2091  
2092   kill_items:     kill_items kill_item | kill_item;
# Line 2906 | Line 2094 | kill_item:      kill_user | kill_reason
2094  
2095   kill_user: USER '=' QSTRING ';'
2096   {
2097 <  if (ypass == 2)
2097 >
2098 >  if (conf_parser_ctx.pass == 2)
2099    {
2100 <    char *user = NULL, *host = NULL;
2100 >    struct split_nuh_item nuh;
2101  
2102 <    split_nuh(yylval.string, NULL, &user, &host);
2102 >    nuh.nuhmask  = yylval.string;
2103 >    nuh.nickptr  = NULL;
2104 >    nuh.userptr  = block_state.user.buf;
2105 >    nuh.hostptr  = block_state.host.buf;
2106  
2107 <    strlcpy(userbuf, user, sizeof(userbuf));
2108 <    strlcpy(hostbuf, host, sizeof(hostbuf));
2107 >    nuh.nicksize = 0;
2108 >    nuh.usersize = sizeof(block_state.user.buf);
2109 >    nuh.hostsize = sizeof(block_state.host.buf);
2110  
2111 <    MyFree(user);
2919 <    MyFree(host);
2111 >    split_nuh(&nuh);
2112    }
2113   };
2114  
2115   kill_reason: REASON '=' QSTRING ';'
2116   {
2117 <  if (ypass == 2)
2118 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2117 >  if (conf_parser_ctx.pass == 2)
2118 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2119   };
2120  
2121   /***************************************************************************
# Line 2931 | Line 2123 | kill_reason: REASON '=' QSTRING ';'
2123   ***************************************************************************/
2124   deny_entry: DENY
2125   {
2126 <  if (ypass == 2)
2127 <  {
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 <  }
2126 >  if (conf_parser_ctx.pass == 2)
2127 >    reset_block_state();
2128   } '{' deny_items '}' ';'
2129   {
2130 <  if (ypass == 2)
2130 >  struct MaskItem *conf = NULL;
2131 >
2132 >  if (conf_parser_ctx.pass != 2)
2133 >    break;
2134 >
2135 >  if (!block_state.addr.buf[0])
2136 >    break;
2137 >
2138 >  if (parse_netmask(block_state.addr.buf, NULL, NULL) != HM_HOST)
2139    {
2140 <    if (yy_aconf->host && parse_netmask(yy_aconf->host, NULL, NULL) != HM_HOST)
2141 <      add_conf_by_address(CONF_DLINE, yy_aconf);
2140 >    conf = conf_make(CONF_DLINE);
2141 >    conf->host = xstrdup(block_state.addr.buf);
2142 >
2143 >    if (block_state.rpass.buf[0])
2144 >      conf->reason = xstrdup(block_state.rpass.buf);
2145      else
2146 <      delete_conf_item(yy_conf);
2147 <    yy_conf = NULL;
2950 <    yy_aconf = NULL;
2146 >      conf->reason = xstrdup(CONF_NOREASON);
2147 >    add_conf_by_address(CONF_DLINE, conf);
2148    }
2149   };
2150  
# Line 2956 | Line 2153 | deny_item:      deny_ip | deny_reason |
2153  
2154   deny_ip: IP '=' QSTRING ';'
2155   {
2156 <  if (ypass == 2)
2157 <  {
2961 <    MyFree(yy_aconf->host);
2962 <    DupString(yy_aconf->host, yylval.string);
2963 <  }
2156 >  if (conf_parser_ctx.pass == 2)
2157 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
2158   };
2159  
2160   deny_reason: REASON '=' QSTRING ';'
2161   {
2162 <  if (ypass == 2)
2163 <  {
2970 <    MyFree(yy_aconf->reason);
2971 <    DupString(yy_aconf->reason, yylval.string);
2972 <  }
2162 >  if (conf_parser_ctx.pass == 2)
2163 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2164   };
2165  
2166   /***************************************************************************
# Line 2982 | Line 2173 | exempt_item:      exempt_ip | error;
2173  
2174   exempt_ip: IP '=' QSTRING ';'
2175   {
2176 <  if (ypass == 2)
2176 >  if (conf_parser_ctx.pass == 2)
2177    {
2178      if (yylval.string[0] && parse_netmask(yylval.string, NULL, NULL) != HM_HOST)
2179      {
2180 <      yy_conf = make_conf_item(EXEMPTDLINE_TYPE);
2181 <      yy_aconf = map_to_conf(yy_conf);
2991 <      DupString(yy_aconf->host, yylval.string);
2180 >      struct MaskItem *conf = conf_make(CONF_EXEMPT);
2181 >      conf->host = xstrdup(yylval.string);
2182  
2183 <      add_conf_by_address(CONF_EXEMPTDLINE, yy_aconf);
2994 <
2995 <      yy_conf = NULL;
2996 <      yy_aconf = NULL;
2183 >      add_conf_by_address(CONF_EXEMPT, conf);
2184      }
2185    }
2186   };
# Line 3003 | Line 2190 | exempt_ip: IP '=' QSTRING ';'
2190   ***************************************************************************/
2191   gecos_entry: GECOS
2192   {
2193 <  if (ypass == 2)
2194 <  {
3008 <    regex_ban = 0;
3009 <    reasonbuf[0] = gecos_name[0] = '\0';
3010 <  }
2193 >  if (conf_parser_ctx.pass == 2)
2194 >    reset_block_state();
2195   } '{' gecos_items '}' ';'
2196   {
2197 <  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;
2197 >  struct MaskItem *conf = NULL;
2198  
2199 <        if (!(exp_p = ircd_pcre_compile(gecos_name, &errptr)))
2200 <        {
3024 <          ilog(L_ERROR, "Failed to add regular expression based X-Line: %s", errptr);
3025 <          break;
3026 <        }
2199 >  if (conf_parser_ctx.pass != 2)
2200 >    break;
2201  
2202 <        yy_conf = make_conf_item(RXLINE_TYPE);
2203 <        yy_conf->regexpname = exp_p;
3030 <      }
3031 <      else
3032 <        yy_conf = make_conf_item(XLINE_TYPE);
2202 >  if (!block_state.name.buf[0])
2203 >    break;
2204  
2205 <      yy_match_item = map_to_conf(yy_conf);
2206 <      DupString(yy_conf->name, gecos_name);
2205 >  if (block_state.port.value == 1)
2206 >  {
2207 > #ifdef HAVE_LIBPCRE
2208 >    void *exp_p = NULL;
2209 >    const char *errptr = NULL;
2210  
2211 <      if (reasonbuf[0])
2212 <        DupString(yy_match_item->reason, reasonbuf);
2213 <      else
2214 <        DupString(yy_match_item->reason, "No reason");
2211 >    if (!(exp_p = ircd_pcre_compile(block_state.name.buf, &errptr)))
2212 >    {
2213 >      ilog(LOG_TYPE_IRCD, "Failed to add regular expression based X-Line: %s",
2214 >           errptr);
2215 >      break;
2216      }
2217 +
2218 +    conf = conf_make(CONF_RXLINE);
2219 +    conf->regexuser = exp_p;
2220 + #else
2221 +    ilog(LOG_TYPE_IRCD, "Failed to add regular expression based X-Line: no PCRE support");
2222 +    break;
2223 + #endif
2224    }
2225 +  else
2226 +    conf = conf_make(CONF_XLINE);
2227 +
2228 +  conf->name = xstrdup(block_state.name.buf);
2229 +
2230 +  if (block_state.rpass.buf[0])
2231 +    conf->reason = xstrdup(block_state.rpass.buf);
2232 +  else
2233 +    conf->reason = xstrdup(CONF_NOREASON);
2234   };
2235  
2236   gecos_flags: TYPE
2237   {
2238 +  if (conf_parser_ctx.pass == 2)
2239 +    block_state.port.value = 0;
2240   } '='  gecos_flags_items ';';
2241  
2242   gecos_flags_items: gecos_flags_items ',' gecos_flags_item | gecos_flags_item;
2243   gecos_flags_item: REGEX_T
2244   {
2245 <  if (ypass == 2)
2246 <    regex_ban = 1;
2245 >  if (conf_parser_ctx.pass == 2)
2246 >    block_state.port.value = 1;
2247   };
2248  
2249   gecos_items: gecos_items gecos_item | gecos_item;
# Line 3058 | Line 2251 | gecos_item:  gecos_name | gecos_reason |
2251  
2252   gecos_name: NAME '=' QSTRING ';'
2253   {
2254 <  if (ypass == 2)
2255 <    strlcpy(gecos_name, yylval.string, sizeof(gecos_name));
2254 >  if (conf_parser_ctx.pass == 2)
2255 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
2256   };
2257  
2258   gecos_reason: REASON '=' QSTRING ';'
2259   {
2260 <  if (ypass == 2)
2261 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2260 >  if (conf_parser_ctx.pass == 2)
2261 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2262   };
2263  
2264   /***************************************************************************
# Line 3080 | Line 2273 | general_item:       general_hide_spoof_i
2273                      general_max_nick_time | general_max_nick_changes |
2274                      general_max_accept | general_anti_spam_exit_message_time |
2275                      general_ts_warn_delta | general_ts_max_delta |
2276 <                    general_kill_chase_time_limit | general_kline_with_reason |
2277 <                    general_kline_reason | general_invisible_on_connect |
2276 >                    general_kill_chase_time_limit |
2277 >                    general_invisible_on_connect |
2278                      general_warn_no_nline | general_dots_in_ident |
2279                      general_stats_o_oper_only | general_stats_k_oper_only |
2280                      general_pace_wait | general_stats_i_oper_only |
2281                      general_pace_wait_simple | general_stats_P_oper_only |
2282                      general_short_motd | general_no_oper_flood |
2283                      general_true_no_oper_flood | general_oper_pass_resv |
2284 <                    general_idletime | general_message_locale |
2284 >                    general_message_locale |
2285                      general_oper_only_umodes | general_max_targets |
2286                      general_use_egd | general_egdpool_path |
2287                      general_oper_umodes | general_caller_id_wait |
2288                      general_opers_bypass_callerid | general_default_floodcount |
2289                      general_min_nonwildcard | general_min_nonwildcard_simple |
2290 <                    general_servlink_path | general_disable_remote_commands |
3098 <                    general_default_cipher_preference |
3099 <                    general_compression_level | general_client_flood |
2290 >                    general_disable_remote_commands |
2291                      general_throttle_time | general_havent_read_conf |
2292 <                    general_dot_in_ip6_addr | general_ping_cookie |
2293 <                    general_disable_auth | general_burst_away |
2294 <                    general_tkline_expire_notices | general_gline_min_cidr |
2295 <                    general_gline_min_cidr6 | general_use_whois_actually |
2296 <                    general_reject_hold_time |
2292 >                    general_ping_cookie |
2293 >                    general_disable_auth |
2294 >                    general_tkline_expire_notices | general_gline_enable |
2295 >                    general_gline_duration | general_gline_request_duration |
2296 >                    general_gline_min_cidr |
2297 >                    general_gline_min_cidr6 |
2298 >                    general_stats_e_disabled |
2299 >                    general_max_watch | general_services_name |
2300                      error;
2301  
2302  
2303 + general_max_watch: MAX_WATCH '=' NUMBER ';'
2304 + {
2305 +  ConfigFileEntry.max_watch = $3;
2306 + };
2307  
2308 < general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
2308 > general_gline_enable: GLINE_ENABLE '=' TBOOL ';'
2309   {
2310 <  ConfigFileEntry.gline_min_cidr = $3;
2310 >  if (conf_parser_ctx.pass == 2)
2311 >    ConfigFileEntry.glines = yylval.number;
2312   };
2313  
2314 < general_gline_min_cidr6: GLINE_MIN_CIDR6 '=' NUMBER ';'
2314 > general_gline_duration: GLINE_DURATION '=' timespec ';'
2315   {
2316 <  ConfigFileEntry.gline_min_cidr6 = $3;
2316 >  if (conf_parser_ctx.pass == 2)
2317 >    ConfigFileEntry.gline_time = $3;
2318   };
2319  
2320 < general_burst_away: BURST_AWAY '=' TBOOL ';'
2320 > general_gline_request_duration: GLINE_REQUEST_DURATION '=' timespec ';'
2321   {
2322 <  ConfigFileEntry.burst_away = yylval.number;
2322 >  if (conf_parser_ctx.pass == 2)
2323 >    ConfigFileEntry.gline_request_time = $3;
2324   };
2325  
2326 < general_use_whois_actually: USE_WHOIS_ACTUALLY '=' TBOOL ';'
2326 > general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
2327   {
2328 <  ConfigFileEntry.use_whois_actually = yylval.number;
2328 >  ConfigFileEntry.gline_min_cidr = $3;
2329   };
2330  
2331 < general_reject_hold_time: TREJECT_HOLD_TIME '=' timespec ';'
2331 > general_gline_min_cidr6: GLINE_MIN_CIDR6 '=' NUMBER ';'
2332   {
2333 <  GlobalSetOptions.rejecttime = yylval.number;
2333 >  ConfigFileEntry.gline_min_cidr6 = $3;
2334   };
2335  
2336   general_tkline_expire_notices: TKLINE_EXPIRE_NOTICES '=' TBOOL ';'
# Line 3137 | Line 2338 | general_tkline_expire_notices: TKLINE_EX
2338    ConfigFileEntry.tkline_expire_notices = yylval.number;
2339   };
2340  
2341 < general_kill_chase_time_limit: KILL_CHASE_TIME_LIMIT '=' NUMBER ';'
2341 > general_kill_chase_time_limit: KILL_CHASE_TIME_LIMIT '=' timespec ';'
2342   {
2343    ConfigFileEntry.kill_chase_time_limit = $3;
2344   };
# Line 3194 | Line 2395 | general_ts_warn_delta: TS_WARN_DELTA '='
2395  
2396   general_ts_max_delta: TS_MAX_DELTA '=' timespec ';'
2397   {
2398 <  if (ypass == 2)
2398 >  if (conf_parser_ctx.pass == 2)
2399      ConfigFileEntry.ts_max_delta = $3;
2400   };
2401  
2402   general_havent_read_conf: HAVENT_READ_CONF '=' NUMBER ';'
2403   {
2404 <  if (($3 > 0) && ypass == 1)
2404 >  if (($3 > 0) && conf_parser_ctx.pass == 1)
2405    {
2406 <    ilog(L_CRIT, "You haven't read your config file properly.");
2407 <    ilog(L_CRIT, "There is a line in the example conf that will kill your server if not removed.");
2408 <    ilog(L_CRIT, "Consider actually reading/editing the conf file, and removing this line.");
2406 >    ilog(LOG_TYPE_IRCD, "You haven't read your config file properly.");
2407 >    ilog(LOG_TYPE_IRCD, "There is a line in the example conf that will kill your server if not removed.");
2408 >    ilog(LOG_TYPE_IRCD, "Consider actually reading/editing the conf file, and removing this line.");
2409      exit(0);
2410    }
2411   };
2412  
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
2413   general_invisible_on_connect: INVISIBLE_ON_CONNECT '=' TBOOL ';'
2414   {
2415    ConfigFileEntry.invisible_on_connect = yylval.number;
# Line 3233 | Line 2420 | general_warn_no_nline: WARN_NO_NLINE '='
2420    ConfigFileEntry.warn_no_nline = yylval.number;
2421   };
2422  
2423 + general_stats_e_disabled: STATS_E_DISABLED '=' TBOOL ';'
2424 + {
2425 +  ConfigFileEntry.stats_e_disabled = yylval.number;
2426 + };
2427 +
2428   general_stats_o_oper_only: STATS_O_OPER_ONLY '=' TBOOL ';'
2429   {
2430    ConfigFileEntry.stats_o_oper_only = yylval.number;
# Line 3301 | Line 2493 | general_oper_pass_resv: OPER_PASS_RESV '
2493  
2494   general_message_locale: MESSAGE_LOCALE '=' QSTRING ';'
2495   {
2496 <  if (ypass == 2)
2496 >  if (conf_parser_ctx.pass == 2)
2497    {
2498      if (strlen(yylval.string) > LOCALE_LENGTH-2)
2499        yylval.string[LOCALE_LENGTH-1] = '\0';
# Line 3310 | Line 2502 | general_message_locale: MESSAGE_LOCALE '
2502    }
2503   };
2504  
3313 general_idletime: IDLETIME '=' timespec ';'
3314 {
3315  ConfigFileEntry.idletime = $3;
3316 };
3317
2505   general_dots_in_ident: DOTS_IN_IDENT '=' NUMBER ';'
2506   {
2507    ConfigFileEntry.dots_in_ident = $3;
# Line 3325 | Line 2512 | general_max_targets: MAX_TARGETS '=' NUM
2512    ConfigFileEntry.max_targets = $3;
2513   };
2514  
2515 < 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 ';'
2515 > general_use_egd: USE_EGD '=' TBOOL ';'
2516   {
2517 < #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
2517 >  ConfigFileEntry.use_egd = yylval.number;
2518   };
2519  
2520 < general_compression_level: COMPRESSION_LEVEL '=' NUMBER ';'
2520 > general_egdpool_path: EGDPOOL_PATH '=' QSTRING ';'
2521   {
2522 <  if (ypass == 2)
2522 >  if (conf_parser_ctx.pass == 2)
2523    {
2524 <    ConfigFileEntry.compression_level = $3;
2525 < #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
2524 >    MyFree(ConfigFileEntry.egdpool_path);
2525 >    ConfigFileEntry.egdpool_path = xstrdup(yylval.string);
2526    }
2527   };
2528  
2529 < general_use_egd: USE_EGD '=' TBOOL ';'
3388 < {
3389 <  ConfigFileEntry.use_egd = yylval.number;
3390 < };
3391 <
3392 < general_egdpool_path: EGDPOOL_PATH '=' QSTRING ';'
2529 > general_services_name: T_SERVICES_NAME '=' QSTRING ';'
2530   {
2531 <  if (ypass == 2)
2531 >  if (conf_parser_ctx.pass == 2 && valid_servname(yylval.string))
2532    {
2533 <    MyFree(ConfigFileEntry.egdpool_path);
2534 <    DupString(ConfigFileEntry.egdpool_path, yylval.string);
2533 >    MyFree(ConfigFileEntry.service_name);
2534 >    ConfigFileEntry.service_name = xstrdup(yylval.string);
2535    }
2536   };
2537  
# Line 3425 | Line 2562 | umode_oitem:     T_BOTS
2562   } | T_CCONN
2563   {
2564    ConfigFileEntry.oper_umodes |= UMODE_CCONN;
2565 + } | T_CCONN_FULL
2566 + {
2567 +  ConfigFileEntry.oper_umodes |= UMODE_CCONN_FULL;
2568   } | T_DEAF
2569   {
2570    ConfigFileEntry.oper_umodes |= UMODE_DEAF;
# Line 3434 | Line 2574 | umode_oitem:     T_BOTS
2574   } | T_FULL
2575   {
2576    ConfigFileEntry.oper_umodes |= UMODE_FULL;
2577 + } | HIDDEN
2578 + {
2579 +  ConfigFileEntry.oper_umodes |= UMODE_HIDDEN;
2580   } | T_SKILL
2581   {
2582    ConfigFileEntry.oper_umodes |= UMODE_SKILL;
# Line 3487 | Line 2630 | umode_item:    T_BOTS
2630   } | T_CCONN
2631   {
2632    ConfigFileEntry.oper_only_umodes |= UMODE_CCONN;
2633 + } | T_CCONN_FULL
2634 + {
2635 +  ConfigFileEntry.oper_only_umodes |= UMODE_CCONN_FULL;
2636   } | T_DEAF
2637   {
2638    ConfigFileEntry.oper_only_umodes |= UMODE_DEAF;
# Line 3499 | Line 2645 | umode_item:    T_BOTS
2645   } | T_SKILL
2646   {
2647    ConfigFileEntry.oper_only_umodes |= UMODE_SKILL;
2648 + } | HIDDEN
2649 + {
2650 +  ConfigFileEntry.oper_only_umodes |= UMODE_HIDDEN;
2651   } | T_NCHANGE
2652   {
2653    ConfigFileEntry.oper_only_umodes |= UMODE_NCHANGE;
# Line 3552 | Line 2701 | general_default_floodcount: DEFAULT_FLOO
2701    ConfigFileEntry.default_floodcount = $3;
2702   };
2703  
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 = map_to_conf(yy_conf);
3574  }
3575 } '{' gline_items '}' ';'
3576 {
3577  if (ypass == 2)
3578  {
3579    /*
3580     * since we re-allocate yy_conf/yy_aconf after the end of action=, at the
3581     * end we will have one extra, so we should free it.
3582     */
3583    if (yy_conf->name == NULL || yy_aconf->user == NULL)
3584    {
3585      delete_conf_item(yy_conf);
3586      yy_conf = NULL;
3587      yy_aconf = NULL;
3588    }
3589  }
3590 };
3591
3592 gline_items:        gline_items gline_item | gline_item;
3593 gline_item:         gline_enable |
3594                    gline_duration |
3595                    gline_logging |
3596                    gline_user |
3597                    gline_server |
3598                    gline_action |
3599                    error;
3600
3601 gline_enable: ENABLE '=' TBOOL ';'
3602 {
3603  if (ypass == 2)
3604    ConfigFileEntry.glines = yylval.number;
3605 };
3606
3607 gline_duration: DURATION '=' timespec ';'
3608 {
3609  if (ypass == 2)
3610    ConfigFileEntry.gline_time = $3;
3611 };
3612
3613 gline_logging: LOGGING
3614 {
3615  if (ypass == 2)
3616    ConfigFileEntry.gline_logging = 0;
3617 } '=' gline_logging_types ';';
3618 gline_logging_types:     gline_logging_types ',' gline_logging_type_item | gline_logging_type_item;
3619 gline_logging_type_item: T_REJECT
3620 {
3621  if (ypass == 2)
3622    ConfigFileEntry.gline_logging |= GDENY_REJECT;
3623 } | T_BLOCK
3624 {
3625  if (ypass == 2)
3626    ConfigFileEntry.gline_logging |= GDENY_BLOCK;
3627 };
3628
3629 gline_user: USER '=' QSTRING ';'
3630 {
3631  if (ypass == 2)
3632  {
3633    struct CollectItem *yy_tmp = NULL;
3634
3635    if (yy_aconf->user == NULL)
3636    {
3637      split_nuh(yylval.string, NULL, &yy_aconf->user, &yy_aconf->host);
3638    }
3639    else
3640    {
3641      yy_tmp = MyMalloc(sizeof(struct CollectItem));
3642      split_nuh(yylval.string, NULL, &yy_tmp->user, &yy_tmp->host);
3643      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
3644    }
3645  }
3646 };
3647
3648 gline_server: NAME '=' QSTRING ';'
3649 {
3650  if (ypass == 2)  
3651  {
3652    MyFree(yy_conf->name);
3653    DupString(yy_conf->name, yylval.string);
3654  }
3655 };
3656
3657 gline_action: ACTION
3658 {
3659  if (ypass == 2)
3660    yy_aconf->flags = 0;
3661 } '=' gdeny_types ';'
3662 {
3663  if (ypass == 2)
3664  {
3665    struct CollectItem *yy_tmp = NULL;
3666    dlink_node *ptr, *next_ptr;
3667
3668    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
3669    {
3670      struct AccessItem *new_aconf;
3671      struct ConfItem *new_conf;
3672
3673      yy_tmp = ptr->data;
3674      new_conf = make_conf_item(GDENY_TYPE);
3675      new_aconf = map_to_conf(new_conf);
3676
3677      new_aconf->flags = yy_aconf->flags;
3678
3679      if (yy_conf->name != NULL)
3680        DupString(new_conf->name, yy_conf->name);
3681      else
3682        DupString(new_conf->name, "*");
3683      if (yy_aconf->user != NULL)
3684         DupString(new_aconf->user, yy_tmp->user);
3685      else  
3686        DupString(new_aconf->user, "*");
3687      if (yy_aconf->host != NULL)
3688        DupString(new_aconf->host, yy_tmp->host);
3689      else
3690        DupString(new_aconf->host, "*");
3691
3692      dlinkDelete(&yy_tmp->node, &col_conf_list);
3693    }
3694
3695    /*
3696     * In case someone has fed us with more than one action= after user/name
3697     * which would leak memory  -Michael
3698     */
3699    if (yy_conf->name == NULL || yy_aconf->user == NULL)
3700      delete_conf_item(yy_conf);
3701
3702    yy_conf = make_conf_item(GDENY_TYPE);
3703    yy_aconf = map_to_conf(yy_conf);
3704  }
3705 };
3706
3707 gdeny_types: gdeny_types ',' gdeny_type_item | gdeny_type_item;
3708 gdeny_type_item: T_REJECT
3709 {
3710  if (ypass == 2)
3711    yy_aconf->flags |= GDENY_REJECT;
3712 } | T_BLOCK
3713 {
3714  if (ypass == 2)
3715    yy_aconf->flags |= GDENY_BLOCK;
3716 };
2704  
2705   /***************************************************************************
2706   *  section channel
# Line 3722 | Line 2709 | channel_entry: CHANNEL
2709    '{' channel_items '}' ';';
2710  
2711   channel_items:      channel_items channel_item | channel_item;
2712 < channel_item:       channel_disable_local_channels | channel_use_except |
2713 <                    channel_use_invex | channel_use_knock |
2714 <                    channel_max_bans | channel_knock_delay |
2715 <                    channel_knock_delay_channel | channel_invite_ops_only |
2716 <                    channel_max_chans_per_user | channel_quiet_on_ban |
2717 <                    channel_default_split_user_count |
2718 <                    channel_default_split_server_count |
2719 <                    channel_no_create_on_split | channel_restrict_channels |
2720 <                    channel_no_join_on_split | channel_burst_topicwho |
3734 <                    channel_jflood_count | channel_jflood_time |
3735 <                    error;
3736 <
3737 < channel_restrict_channels: RESTRICT_CHANNELS '=' TBOOL ';'
3738 < {
3739 <  ConfigChannel.restrict_channels = yylval.number;
3740 < };
2712 > channel_item:       channel_max_bans |
2713 >                    channel_knock_delay | channel_knock_delay_channel |
2714 >                    channel_max_chans_per_user | channel_max_chans_per_oper |
2715 >                    channel_quiet_on_ban | channel_default_split_user_count |
2716 >                    channel_default_split_server_count |
2717 >                    channel_no_create_on_split | channel_restrict_channels |
2718 >                    channel_no_join_on_split |
2719 >                    channel_jflood_count | channel_jflood_time |
2720 >                    channel_disable_fake_channels | error;
2721  
2722 < channel_disable_local_channels: DISABLE_LOCAL_CHANNELS '=' TBOOL ';'
2722 > channel_disable_fake_channels: DISABLE_FAKE_CHANNELS '=' TBOOL ';'
2723   {
2724 <  ConfigChannel.disable_local_channels = yylval.number;
2724 >  ConfigChannel.disable_fake_channels = yylval.number;
2725   };
2726  
2727 < channel_use_except: USE_EXCEPT '=' TBOOL ';'
3748 < {
3749 <  ConfigChannel.use_except = yylval.number;
3750 < };
3751 <
3752 < channel_use_invex: USE_INVEX '=' TBOOL ';'
3753 < {
3754 <  ConfigChannel.use_invex = yylval.number;
3755 < };
3756 <
3757 < channel_use_knock: USE_KNOCK '=' TBOOL ';'
2727 > channel_restrict_channels: RESTRICT_CHANNELS '=' TBOOL ';'
2728   {
2729 <  ConfigChannel.use_knock = yylval.number;
2729 >  ConfigChannel.restrict_channels = yylval.number;
2730   };
2731  
2732   channel_knock_delay: KNOCK_DELAY '=' timespec ';'
# Line 3769 | Line 2739 | channel_knock_delay_channel: KNOCK_DELAY
2739    ConfigChannel.knock_delay_channel = $3;
2740   };
2741  
2742 < channel_invite_ops_only: INVITE_OPS_ONLY '=' TBOOL ';'
2742 > channel_max_chans_per_user: MAX_CHANS_PER_USER '=' NUMBER ';'
2743   {
2744 <  ConfigChannel.invite_ops_only = yylval.number;
2744 >  ConfigChannel.max_chans_per_user = $3;
2745   };
2746  
2747 < channel_max_chans_per_user: MAX_CHANS_PER_USER '=' NUMBER ';'
2747 > channel_max_chans_per_oper: MAX_CHANS_PER_OPER '=' NUMBER ';'
2748   {
2749 <  ConfigChannel.max_chans_per_user = $3;
2749 >  ConfigChannel.max_chans_per_oper = $3;
2750   };
2751  
2752   channel_quiet_on_ban: QUIET_ON_BAN '=' TBOOL ';'
# Line 3809 | Line 2779 | channel_no_join_on_split: NO_JOIN_ON_SPL
2779    ConfigChannel.no_join_on_split = yylval.number;
2780   };
2781  
3812 channel_burst_topicwho: BURST_TOPICWHO '=' TBOOL ';'
3813 {
3814  ConfigChannel.burst_topicwho = yylval.number;
3815 };
3816
2782   channel_jflood_count: JOIN_FLOOD_COUNT '=' NUMBER ';'
2783   {
2784    GlobalSetOptions.joinfloodcount = yylval.number;
# Line 3833 | Line 2798 | serverhide_entry: SERVERHIDE
2798   serverhide_items:   serverhide_items serverhide_item | serverhide_item;
2799   serverhide_item:    serverhide_flatten_links | serverhide_hide_servers |
2800                      serverhide_links_delay |
3836                    serverhide_disable_hidden |
2801                      serverhide_hidden | serverhide_hidden_name |
2802                      serverhide_hide_server_ips |
2803                      error;
2804  
2805   serverhide_flatten_links: FLATTEN_LINKS '=' TBOOL ';'
2806   {
2807 <  if (ypass == 2)
2807 >  if (conf_parser_ctx.pass == 2)
2808      ConfigServerHide.flatten_links = yylval.number;
2809   };
2810  
2811   serverhide_hide_servers: HIDE_SERVERS '=' TBOOL ';'
2812   {
2813 <  if (ypass == 2)
2813 >  if (conf_parser_ctx.pass == 2)
2814      ConfigServerHide.hide_servers = yylval.number;
2815   };
2816  
2817   serverhide_hidden_name: HIDDEN_NAME '=' QSTRING ';'
2818   {
2819 <  if (ypass == 2)
2819 >  if (conf_parser_ctx.pass == 2)
2820    {
2821      MyFree(ConfigServerHide.hidden_name);
2822 <    DupString(ConfigServerHide.hidden_name, yylval.string);
2822 >    ConfigServerHide.hidden_name = xstrdup(yylval.string);
2823    }
2824   };
2825  
2826   serverhide_links_delay: LINKS_DELAY '=' timespec ';'
2827   {
2828 <  if (ypass == 2)
2828 >  if (conf_parser_ctx.pass == 2)
2829    {
2830      if (($3 > 0) && ConfigServerHide.links_disabled == 1)
2831      {
# Line 3875 | Line 2839 | serverhide_links_delay: LINKS_DELAY '='
2839  
2840   serverhide_hidden: HIDDEN '=' TBOOL ';'
2841   {
2842 <  if (ypass == 2)
2842 >  if (conf_parser_ctx.pass == 2)
2843      ConfigServerHide.hidden = yylval.number;
2844   };
2845  
3882 serverhide_disable_hidden: DISABLE_HIDDEN '=' TBOOL ';'
3883 {
3884  if (ypass == 2)
3885    ConfigServerHide.disable_hidden = yylval.number;
3886 };
3887
2846   serverhide_hide_server_ips: HIDE_SERVER_IPS '=' TBOOL ';'
2847   {
2848 <  if (ypass == 2)
2848 >  if (conf_parser_ctx.pass == 2)
2849      ConfigServerHide.hide_server_ips = yylval.number;
2850   };

Diff Legend

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