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-8/src/ircd_parser.y (file contents), Revision 1250 by michael, Sat Oct 1 10:48:16 2011 UTC vs.
ircd-hybrid/trunk/src/conf_parser.y (file contents), Revision 1992 by michael, Fri May 10 18:32:26 2013 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  ircd_parser.y: Parses the ircd configuration file.
3 > *  conf_parser.y: Parses the ircd configuration file.
4   *
5   *  Copyright (C) 2005 by the past and present ircd coders, and others.
6   *
# Line 32 | Line 32
32   #include "stdinc.h"
33   #include "ircd.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 */
40   #include "irc_string.h"
40 #include "sprintf_irc.h"
41   #include "memory.h"
42   #include "modules.h"
43   #include "s_serv.h"
# Line 52 | Line 52
52   #include <openssl/rsa.h>
53   #include <openssl/bio.h>
54   #include <openssl/pem.h>
55 + #include <openssl/dh.h>
56   #endif
57  
58 < static char *class_name = NULL;
58 < static struct ConfItem *yy_conf = NULL;
59 < static struct AccessItem *yy_aconf = NULL;
60 < static struct MatchItem *yy_match_item = NULL;
61 < static struct ClassItem *yy_class = NULL;
62 < static char *yy_class_name = NULL;
63 <
64 < static dlink_list col_conf_list  = { NULL, NULL, 0 };
65 < static dlink_list hub_conf_list  = { NULL, NULL, 0 };
66 < static dlink_list leaf_conf_list = { NULL, NULL, 0 };
67 < static unsigned int listener_flags = 0;
68 < static unsigned int regex_ban = 0;
69 < static char userbuf[IRCD_BUFSIZE];
70 < static char hostbuf[IRCD_BUFSIZE];
71 < static char reasonbuf[REASONLEN + 1];
72 < static char gecos_name[REALLEN * 4];
73 < static char lfile[IRCD_BUFSIZE];
74 < static unsigned int ltype = 0;
75 < static unsigned int lsize = 0;
76 < static char *resv_reason = NULL;
77 < static char *listener_address = NULL;
78 <
79 < struct CollectItem
80 < {
81 <  dlink_node node;
82 <  char *name;
83 <  char *user;
84 <  char *host;
85 <  char *passwd;
86 <  int  port;
87 <  int  flags;
88 < #ifdef HAVE_LIBCRYPTO
89 <  char *rsa_public_key_file;
90 <  RSA *rsa_public_key;
91 < #endif
92 < };
58 > #include "rsa.h"
59  
60 < static void
61 < free_collect_item(struct CollectItem *item)
60 > int yylex(void);
61 >
62 > static struct
63   {
64 <  MyFree(item->name);
65 <  MyFree(item->user);
66 <  MyFree(item->host);
67 <  MyFree(item->passwd);
68 < #ifdef HAVE_LIBCRYPTO
69 <  MyFree(item->rsa_public_key_file);
70 < #endif
71 <  MyFree(item);
72 < }
64 >  struct {
65 >    dlink_list list;
66 >  } mask,
67 >    leaf,
68 >    hub;
69 >
70 >  struct {
71 >    char buf[IRCD_BUFSIZE];
72 >  } name,
73 >    user,
74 >    host,
75 >    addr,
76 >    bind,
77 >    file,
78 >    ciph,
79 >    rpass,
80 >    spass,
81 >    class;
82 >
83 >  struct {
84 >    unsigned int value;
85 >  } flags,
86 >    modes,
87 >    size,
88 >    type,
89 >    port,
90 >    aftype,
91 >    ping_freq,
92 >    max_perip,
93 >    con_freq,
94 >    min_idle,
95 >    max_idle,
96 >    max_total,
97 >    max_global,
98 >    max_local,
99 >    max_ident,
100 >    max_sendq,
101 >    max_recvq,
102 >    cidr_bitlen_ipv4,
103 >    cidr_bitlen_ipv6,
104 >    number_per_cidr;
105 > } block_state;
106  
107   static void
108 < unhook_hub_leaf_confs(void)
108 > reset_block_state(void)
109   {
110 <  dlink_node *ptr;
111 <  dlink_node *next_ptr;
112 <  struct CollectItem *yy_hconf;
113 <  struct CollectItem *yy_lconf;
110 >  dlink_node *ptr = NULL, *ptr_next = NULL;
111 >
112 >  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.mask.list.head)
113 >  {
114 >    MyFree(ptr->data);
115 >    dlinkDelete(ptr, &block_state.mask.list);
116 >    free_dlink_node(ptr);
117 >  }
118  
119 <  DLINK_FOREACH_SAFE(ptr, next_ptr, hub_conf_list.head)
119 >  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.leaf.list.head)
120    {
121 <    yy_hconf = ptr->data;
122 <    dlinkDelete(&yy_hconf->node, &hub_conf_list);
123 <    free_collect_item(yy_hconf);
121 >    MyFree(ptr->data);
122 >    dlinkDelete(ptr, &block_state.leaf.list);
123 >    free_dlink_node(ptr);
124    }
125  
126 <  DLINK_FOREACH_SAFE(ptr, next_ptr, leaf_conf_list.head)
126 >  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.hub.list.head)
127    {
128 <    yy_lconf = ptr->data;
129 <    dlinkDelete(&yy_lconf->node, &leaf_conf_list);
130 <    free_collect_item(yy_lconf);
128 >    MyFree(ptr->data);
129 >    dlinkDelete(ptr, &block_state.hub.list);
130 >    free_dlink_node(ptr);
131    }
132 +
133 +  memset(&block_state, 0, sizeof(block_state));
134   }
135  
136   %}
# Line 135 | Line 141 | unhook_hub_leaf_confs(void)
141   }
142  
143   %token  ACCEPT_PASSWORD
138 %token  ACTION
144   %token  ADMIN
145   %token  AFTYPE
141 %token  T_ALLOW
146   %token  ANTI_NICK_FLOOD
147   %token  ANTI_SPAM_EXIT_MESSAGE_TIME
148   %token  AUTOCONN
149 < %token  T_BLOCK
146 < %token  BURST_AWAY
147 < %token  BURST_TOPICWHO
148 < %token  BYTES KBYTES MBYTES GBYTES TBYTES
149 > %token  BYTES KBYTES MBYTES
150   %token  CALLER_ID_WAIT
151   %token  CAN_FLOOD
152   %token  CHANNEL
153   %token  CIDR_BITLEN_IPV4
154   %token  CIDR_BITLEN_IPV6
154 %token  CIPHER_PREFERENCE
155   %token  CLASS
156 %token  COMPRESSED
157 %token  COMPRESSION_LEVEL
156   %token  CONNECT
157   %token  CONNECTFREQ
160 %token  CRYPTLINK
161 %token  DEFAULT_CIPHER_PREFERENCE
158   %token  DEFAULT_FLOODCOUNT
159   %token  DEFAULT_SPLIT_SERVER_COUNT
160   %token  DEFAULT_SPLIT_USER_COUNT
# Line 167 | Line 163 | unhook_hub_leaf_confs(void)
163   %token  DIE
164   %token  DISABLE_AUTH
165   %token  DISABLE_FAKE_CHANNELS
170 %token  DISABLE_HIDDEN
171 %token  DISABLE_LOCAL_CHANNELS
166   %token  DISABLE_REMOTE_COMMANDS
167   %token  DOTS_IN_IDENT
174 %token  DURATION
168   %token  EGDPOOL_PATH
169   %token  EMAIL
177 %token  ENABLE
170   %token  ENCRYPTED
171   %token  EXCEED_LIMIT
172   %token  EXEMPT
# Line 184 | Line 176 | unhook_hub_leaf_confs(void)
176   %token  GECOS
177   %token  GENERAL
178   %token  GLINE
179 < %token  GLINES
179 > %token  GLINE_DURATION
180 > %token  GLINE_ENABLE
181   %token  GLINE_EXEMPT
182 < %token  GLINE_TIME
182 > %token  GLINE_REQUEST_DURATION
183   %token  GLINE_MIN_CIDR
184   %token  GLINE_MIN_CIDR6
185   %token  GLOBAL_KILL
# Line 194 | Line 187 | unhook_hub_leaf_confs(void)
187   %token  NEED_IDENT
188   %token  HAVENT_READ_CONF
189   %token  HIDDEN
197 %token  HIDDEN_ADMIN
190   %token  HIDDEN_NAME
199 %token  HIDDEN_OPER
191   %token  HIDE_SERVER_IPS
192   %token  HIDE_SERVERS
193 + %token  HIDE_SERVICES
194   %token  HIDE_SPOOF_IPS
195   %token  HOST
196   %token  HUB
# Line 210 | Line 202 | unhook_hub_leaf_confs(void)
202   %token  KILL_CHASE_TIME_LIMIT
203   %token  KLINE
204   %token  KLINE_EXEMPT
213 %token  KLINE_REASON
214 %token  KLINE_WITH_REASON
205   %token  KNOCK_DELAY
206   %token  KNOCK_DELAY_CHANNEL
207   %token  LEAF_MASK
208   %token  LINKS_DELAY
209   %token  LISTEN
210   %token  T_LOG
211 + %token  MASK
212   %token  MAX_ACCEPT
213   %token  MAX_BANS
214 + %token  MAX_CHANS_PER_OPER
215   %token  MAX_CHANS_PER_USER
216   %token  MAX_GLOBAL
217   %token  MAX_IDENT
218   %token  MAX_LOCAL
219   %token  MAX_NICK_CHANGES
220 + %token  MAX_NICK_LENGTH
221   %token  MAX_NICK_TIME
222   %token  MAX_NUMBER
223   %token  MAX_TARGETS
224 + %token  MAX_TOPIC_LENGTH
225   %token  MAX_WATCH
232 %token  MESSAGE_LOCALE
226   %token  MIN_NONWILDCARD
227   %token  MIN_NONWILDCARD_SIMPLE
228 + %token  MIN_IDLE
229 + %token  MAX_IDLE
230 + %token  RANDOM_IDLE
231 + %token  HIDE_IDLE_FROM_OPERS
232   %token  MODULE
233   %token  MODULES
234   %token  NAME
# Line 239 | Line 236 | unhook_hub_leaf_confs(void)
236   %token  NETWORK_DESC
237   %token  NETWORK_NAME
238   %token  NICK
242 %token  NICK_CHANGES
239   %token  NO_CREATE_ON_SPLIT
240   %token  NO_JOIN_ON_SPLIT
241   %token  NO_OPER_FLOOD
242   %token  NO_TILDE
243   %token  NUMBER
248 %token  NUMBER_PER_IDENT
244   %token  NUMBER_PER_CIDR
245   %token  NUMBER_PER_IP
251 %token  NUMBER_PER_IP_GLOBAL
246   %token  OPERATOR
247   %token  OPERS_BYPASS_CALLERID
248   %token  OPER_ONLY_UMODES
249   %token  OPER_PASS_RESV
256 %token  OPER_SPY_T
250   %token  OPER_UMODES
251   %token  JOIN_FLOOD_COUNT
252   %token  JOIN_FLOOD_TIME
# Line 263 | Line 256 | unhook_hub_leaf_confs(void)
256   %token  PATH
257   %token  PING_COOKIE
258   %token  PING_TIME
266 %token  PING_WARNING
259   %token  PORT
260   %token  QSTRING
269 %token  QUIET_ON_BAN
261   %token  REASON
262   %token  REDIRPORT
263   %token  REDIRSERV
273 %token  REGEX_T
264   %token  REHASH
275 %token  TREJECT_HOLD_TIME
265   %token  REMOTE
266   %token  REMOTEBAN
278 %token  RESTRICT_CHANNELS
279 %token  RESTRICTED
267   %token  RSA_PRIVATE_KEY_FILE
268   %token  RSA_PUBLIC_KEY_FILE
269   %token  SSL_CERTIFICATE_FILE
270 < %token  T_SSL_CONNECTION_METHOD
270 > %token  SSL_DH_PARAM_FILE
271 > %token  T_SSL_CLIENT_METHOD
272 > %token  T_SSL_SERVER_METHOD
273   %token  T_SSLV3
274   %token  T_TLSV1
275   %token  RESV
276   %token  RESV_EXEMPT
277 < %token  SECONDS MINUTES HOURS DAYS WEEKS
277 > %token  SECONDS MINUTES HOURS DAYS WEEKS MONTHS YEARS
278   %token  SENDQ
279   %token  SEND_PASSWORD
280   %token  SERVERHIDE
281   %token  SERVERINFO
293 %token  SERVLINK_PATH
282   %token  IRCD_SID
283   %token  TKLINE_EXPIRE_NOTICES
284   %token  T_SHARED
285   %token  T_CLUSTER
286   %token  TYPE
287   %token  SHORT_MOTD
300 %token  SILENT
288   %token  SPOOF
289   %token  SPOOF_NOTICE
290   %token  STATS_E_DISABLED
# Line 307 | Line 294 | unhook_hub_leaf_confs(void)
294   %token  STATS_P_OPER_ONLY
295   %token  TBOOL
296   %token  TMASKED
310 %token  T_REJECT
297   %token  TS_MAX_DELTA
298   %token  TS_WARN_DELTA
299   %token  TWODOTS
# Line 317 | Line 303 | unhook_hub_leaf_confs(void)
303   %token  T_CALLERID
304   %token  T_CCONN
305   %token  T_CCONN_FULL
306 < %token  T_CLIENT_FLOOD
306 > %token  T_SSL_CIPHER_LIST
307   %token  T_DEAF
308   %token  T_DEBUG
309   %token  T_DLINE
324 %token  T_DRONE
310   %token  T_EXTERNAL
311 + %token  T_FARCONNECT
312   %token  T_FULL
313   %token  T_INVISIBLE
314   %token  T_IPV4
# Line 330 | Line 316 | unhook_hub_leaf_confs(void)
316   %token  T_LOCOPS
317   %token  T_MAX_CLIENTS
318   %token  T_NCHANGE
319 + %token  T_NONONREG
320   %token  T_OPERWALL
321 + %token  T_RECVQ
322   %token  T_REJ
323   %token  T_SERVER
324   %token  T_SERVNOTICE
325 + %token  T_SET
326   %token  T_SKILL
327   %token  T_SPY
328   %token  T_SSL
329   %token  T_UMODES
330   %token  T_UNAUTH
331 + %token  T_UNDLINE
332   %token  T_UNLIMITED
333   %token  T_UNRESV
334   %token  T_UNXLINE
335   %token  T_GLOBOPS
336   %token  T_WALLOP
337 + %token  T_WEBIRC
338   %token  T_RESTART
339   %token  T_SERVICE
340   %token  T_SERVICES_NAME
350 %token  T_TIMESTAMP
341   %token  THROTTLE_TIME
352 %token  TOPICBURST
342   %token  TRUE_NO_OPER_FLOOD
354 %token  TKLINE
355 %token  TXLINE
356 %token  TRESV
343   %token  UNKLINE
344   %token  USER
345   %token  USE_EGD
360 %token  USE_EXCEPT
361 %token  USE_INVEX
362 %token  USE_KNOCK
346   %token  USE_LOGGING
364 %token  USE_WHOIS_ACTUALLY
347   %token  VHOST
348   %token  VHOST6
349   %token  XLINE
368 %token  WARN
350   %token  WARN_NO_NLINE
351   %token  T_SIZE
352   %token  T_FILE
# Line 400 | Line 381 | conf_item:        admin_entry
381                  | deny_entry
382                  | exempt_entry
383                  | general_entry
403                | gline_entry
384                  | gecos_entry
385                  | modules_entry
386                  | error ';'
# Line 433 | Line 413 | timespec:      NUMBER timespec_
413                  {
414                          $$ = $1 * 60 * 60 * 24 * 7 + $3;
415                  }
416 +                | NUMBER MONTHS timespec_
417 +                {
418 +                        $$ = $1 * 60 * 60 * 24 * 7 * 4 + $3;
419 +                }
420 +                | NUMBER YEARS timespec_
421 +                {
422 +                        $$ = $1 * 60 * 60 * 24 * 365 + $3;
423 +                }
424                  ;
425  
426   sizespec_:      { $$ = 0; } | sizespec;
# Line 471 | Line 459 | serverinfo_items:       serverinfo_items
459   serverinfo_item:        serverinfo_name | serverinfo_vhost |
460                          serverinfo_hub | serverinfo_description |
461                          serverinfo_network_name | serverinfo_network_desc |
462 <                        serverinfo_max_clients |
462 >                        serverinfo_max_clients | serverinfo_max_nick_length |
463 >                        serverinfo_max_topic_length | serverinfo_ssl_dh_param_file |
464                          serverinfo_rsa_private_key_file | serverinfo_vhost6 |
465                          serverinfo_sid | serverinfo_ssl_certificate_file |
466 <                        serverinfo_ssl_connection_method |
466 >                        serverinfo_ssl_client_method | serverinfo_ssl_server_method |
467 >                        serverinfo_ssl_cipher_list |
468                          error ';' ;
469  
470  
471 < serverinfo_ssl_connection_method: T_SSL_CONNECTION_METHOD
471 > serverinfo_ssl_client_method: T_SSL_CLIENT_METHOD '=' client_method_types ';' ;
472 > serverinfo_ssl_server_method: T_SSL_SERVER_METHOD '=' server_method_types ';' ;
473 >
474 > client_method_types: client_method_types ',' client_method_type_item | client_method_type_item;
475 > client_method_type_item: T_SSLV3
476   {
477   #ifdef HAVE_LIBCRYPTO
478 <  if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
479 <    ServerInfo.tls_version = 0;
478 >  if (conf_parser_ctx.pass == 2 && ServerInfo.client_ctx)
479 >    SSL_CTX_clear_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv3);
480   #endif
481 < } '=' method_types ';'
481 > } | T_TLSV1
482   {
483   #ifdef HAVE_LIBCRYPTO
484 <  if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
485 <  {
492 <    if (!(ServerInfo.tls_version & CONF_SERVER_INFO_TLS_VERSION_SSLV3))
493 <      SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv3);
494 <    if (!(ServerInfo.tls_version & CONF_SERVER_INFO_TLS_VERSION_TLSV1))
495 <      SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_TLSv1);
496 <  }
484 >  if (conf_parser_ctx.pass == 2 && ServerInfo.client_ctx)
485 >    SSL_CTX_clear_options(ServerInfo.client_ctx, SSL_OP_NO_TLSv1);
486   #endif
487   };
488  
489 < method_types: method_types ',' method_type_item | method_type_item;
490 < method_type_item: T_SSLV3
489 > server_method_types: server_method_types ',' server_method_type_item | server_method_type_item;
490 > server_method_type_item: T_SSLV3
491   {
492   #ifdef HAVE_LIBCRYPTO
493 <  if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
494 <    ServerInfo.tls_version |= CONF_SERVER_INFO_TLS_VERSION_SSLV3;
493 >  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
494 >    SSL_CTX_clear_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv3);
495   #endif
496   } | T_TLSV1
497   {
498   #ifdef HAVE_LIBCRYPTO
499 <  if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
500 <    ServerInfo.tls_version |= CONF_SERVER_INFO_TLS_VERSION_TLSV1;
499 >  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
500 >    SSL_CTX_clear_options(ServerInfo.server_ctx, SSL_OP_NO_TLSv1);
501   #endif
502   };
503  
# Line 519 | Line 508 | serverinfo_ssl_certificate_file: SSL_CER
508    {
509      if (!ServerInfo.rsa_private_key_file)
510      {
511 <      yyerror("No rsa_private_key_file specified, SSL disabled");
511 >      conf_error_report("No rsa_private_key_file specified, SSL disabled");
512        break;
513      }
514  
515      if (SSL_CTX_use_certificate_file(ServerInfo.server_ctx, yylval.string,
516 +                                     SSL_FILETYPE_PEM) <= 0 ||
517 +        SSL_CTX_use_certificate_file(ServerInfo.client_ctx, yylval.string,
518                                       SSL_FILETYPE_PEM) <= 0)
519      {
520 <      yyerror(ERR_lib_error_string(ERR_get_error()));
520 >      report_crypto_errors();
521 >      conf_error_report("Could not open/read certificate file");
522        break;
523      }
524  
525      if (SSL_CTX_use_PrivateKey_file(ServerInfo.server_ctx, ServerInfo.rsa_private_key_file,
526 +                                    SSL_FILETYPE_PEM) <= 0 ||
527 +        SSL_CTX_use_PrivateKey_file(ServerInfo.client_ctx, ServerInfo.rsa_private_key_file,
528                                      SSL_FILETYPE_PEM) <= 0)
529      {
530 <      yyerror(ERR_lib_error_string(ERR_get_error()));
530 >      report_crypto_errors();
531 >      conf_error_report("Could not read RSA private key");
532        break;
533      }
534  
535 <    if (!SSL_CTX_check_private_key(ServerInfo.server_ctx))
535 >    if (!SSL_CTX_check_private_key(ServerInfo.server_ctx) ||
536 >        !SSL_CTX_check_private_key(ServerInfo.client_ctx))
537      {
538 <      yyerror(ERR_lib_error_string(ERR_get_error()));
538 >      report_crypto_errors();
539 >      conf_error_report("Could not read RSA private key");
540        break;
541      }
542    }
# Line 565 | Line 562 | serverinfo_rsa_private_key_file: RSA_PRI
562        ServerInfo.rsa_private_key_file = NULL;
563      }
564  
565 <    DupString(ServerInfo.rsa_private_key_file, yylval.string);
565 >    ServerInfo.rsa_private_key_file = xstrdup(yylval.string);
566  
567      if ((file = BIO_new_file(yylval.string, "r")) == NULL)
568      {
569 <      yyerror("File open failed, ignoring");
569 >      conf_error_report("File open failed, ignoring");
570        break;
571      }
572  
573 <    ServerInfo.rsa_private_key = (RSA *)PEM_read_bio_RSAPrivateKey(file, NULL,
577 <      0, NULL);
573 >    ServerInfo.rsa_private_key = PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL);
574  
575      BIO_set_close(file, BIO_CLOSE);
576      BIO_free(file);
577  
578      if (ServerInfo.rsa_private_key == NULL)
579      {
580 <      yyerror("Couldn't extract key, ignoring");
580 >      conf_error_report("Couldn't extract key, ignoring");
581        break;
582      }
583  
# Line 590 | Line 586 | serverinfo_rsa_private_key_file: RSA_PRI
586        RSA_free(ServerInfo.rsa_private_key);
587        ServerInfo.rsa_private_key = NULL;
588  
589 <      yyerror("Invalid key, ignoring");
589 >      conf_error_report("Invalid key, ignoring");
590        break;
591      }
592  
# Line 600 | Line 596 | serverinfo_rsa_private_key_file: RSA_PRI
596        RSA_free(ServerInfo.rsa_private_key);
597        ServerInfo.rsa_private_key = NULL;
598  
599 <      yyerror("Not a 2048 bit key, ignoring");
599 >      conf_error_report("Not a 2048 bit key, ignoring");
600 >    }
601 >  }
602 > #endif
603 > };
604 >
605 > serverinfo_ssl_dh_param_file: SSL_DH_PARAM_FILE '=' QSTRING ';'
606 > {
607 > /* TBD - XXX: error reporting */
608 > #ifdef HAVE_LIBCRYPTO
609 >  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
610 >  {
611 >    BIO *file = BIO_new_file(yylval.string, "r");
612 >
613 >    if (file)
614 >    {
615 >      DH *dh = PEM_read_bio_DHparams(file, NULL, NULL, NULL);
616 >
617 >      BIO_free(file);
618 >
619 >      if (dh)
620 >      {
621 >        if (DH_size(dh) < 128)
622 >          conf_error_report("Ignoring serverinfo::ssl_dh_param_file -- need at least a 1024 bit DH prime size");
623 >        else
624 >          SSL_CTX_set_tmp_dh(ServerInfo.server_ctx, dh);
625 >
626 >        DH_free(dh);
627 >      }
628      }
629    }
630   #endif
631   };
632  
633 + serverinfo_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
634 + {
635 + #ifdef HAVE_LIBCRYPTO
636 +  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
637 +    SSL_CTX_set_cipher_list(ServerInfo.server_ctx, yylval.string);
638 + #endif
639 + };
640 +
641   serverinfo_name: NAME '=' QSTRING ';'
642   {
643    /* this isn't rehashable */
644    if (conf_parser_ctx.pass == 2 && !ServerInfo.name)
645    {
646      if (valid_servname(yylval.string))
647 <      DupString(ServerInfo.name, yylval.string);
647 >      ServerInfo.name = xstrdup(yylval.string);
648      else
649      {
650 <      ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::name -- invalid name. Aborting.");
650 >      conf_error_report("Ignoring serverinfo::name -- invalid name. Aborting.");
651        exit(0);
652      }
653    }
# Line 627 | Line 659 | serverinfo_sid: IRCD_SID '=' QSTRING ';'
659    if (conf_parser_ctx.pass == 2 && !ServerInfo.sid)
660    {
661      if (valid_sid(yylval.string))
662 <      DupString(ServerInfo.sid, yylval.string);
662 >      ServerInfo.sid = xstrdup(yylval.string);
663      else
664      {
665 <      ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::sid -- invalid SID. Aborting.");
665 >      conf_error_report("Ignoring serverinfo::sid -- invalid SID. Aborting.");
666        exit(0);
667      }
668    }
# Line 641 | Line 673 | serverinfo_description: DESCRIPTION '='
673    if (conf_parser_ctx.pass == 2)
674    {
675      MyFree(ServerInfo.description);
676 <    DupString(ServerInfo.description,yylval.string);
676 >    ServerInfo.description = xstrdup(yylval.string);
677    }
678   };
679  
# Line 655 | Line 687 | serverinfo_network_name: NETWORK_NAME '=
687        p = '\0';
688  
689      MyFree(ServerInfo.network_name);
690 <    DupString(ServerInfo.network_name, yylval.string);
690 >    ServerInfo.network_name = xstrdup(yylval.string);
691    }
692   };
693  
# Line 664 | Line 696 | serverinfo_network_desc: NETWORK_DESC '=
696    if (conf_parser_ctx.pass == 2)
697    {
698      MyFree(ServerInfo.network_desc);
699 <    DupString(ServerInfo.network_desc, yylval.string);
699 >    ServerInfo.network_desc = xstrdup(yylval.string);
700    }
701   };
702  
# Line 728 | Line 760 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
760  
761   serverinfo_max_clients: T_MAX_CLIENTS '=' NUMBER ';'
762   {
763 <  if (conf_parser_ctx.pass == 2)
763 >  if (conf_parser_ctx.pass != 2)
764 >    break;
765 >
766 >  if ($3 < MAXCLIENTS_MIN)
767    {
768 <    recalc_fdlimit(NULL);
768 >    char buf[IRCD_BUFSIZE];
769  
770 <    if ($3 < MAXCLIENTS_MIN)
771 <    {
772 <      char buf[IRCD_BUFSIZE];
738 <      ircsprintf(buf, "MAXCLIENTS too low, setting to %d", MAXCLIENTS_MIN);
739 <      yyerror(buf);
740 <    }
741 <    else if ($3 > MAXCLIENTS_MAX)
742 <    {
743 <      char buf[IRCD_BUFSIZE];
744 <      ircsprintf(buf, "MAXCLIENTS too high, setting to %d", MAXCLIENTS_MAX);
745 <      yyerror(buf);
746 <    }
747 <    else
748 <      ServerInfo.max_clients = $3;
770 >    snprintf(buf, sizeof(buf), "MAXCLIENTS too low, setting to %d", MAXCLIENTS_MIN);
771 >    conf_error_report(buf);
772 >    ServerInfo.max_clients = MAXCLIENTS_MIN;
773    }
774 +  else if ($3 > MAXCLIENTS_MAX)
775 +  {
776 +    char buf[IRCD_BUFSIZE];
777 +
778 +    snprintf(buf, sizeof(buf), "MAXCLIENTS too high, setting to %d", MAXCLIENTS_MAX);
779 +    conf_error_report(buf);
780 +    ServerInfo.max_clients = MAXCLIENTS_MAX;
781 +  }
782 +  else
783 +    ServerInfo.max_clients = $3;
784 + };
785 +
786 + serverinfo_max_nick_length: MAX_NICK_LENGTH '=' NUMBER ';'
787 + {
788 +  if (conf_parser_ctx.pass != 2)
789 +    break;
790 +
791 +  if ($3 < 9)
792 +  {
793 +    conf_error_report("max_nick_length too low, setting to 9");
794 +    ServerInfo.max_nick_length = 9;
795 +  }
796 +  else if ($3 > NICKLEN)
797 +  {
798 +    char buf[IRCD_BUFSIZE];
799 +
800 +    snprintf(buf, sizeof(buf), "max_nick_length too high, setting to %d", NICKLEN);
801 +    conf_error_report(buf);
802 +    ServerInfo.max_nick_length = NICKLEN;
803 +  }
804 +  else
805 +    ServerInfo.max_nick_length = $3;
806 + };
807 +
808 + serverinfo_max_topic_length: MAX_TOPIC_LENGTH '=' NUMBER ';'
809 + {
810 +  if (conf_parser_ctx.pass != 2)
811 +    break;
812 +
813 +  if ($3 < 80)
814 +  {
815 +    conf_error_report("max_topic_length too low, setting to 80");
816 +    ServerInfo.max_topic_length = 80;
817 +  }
818 +  else if ($3 > TOPICLEN)
819 +  {
820 +    char buf[IRCD_BUFSIZE];
821 +
822 +    snprintf(buf, sizeof(buf), "max_topic_length too high, setting to %d", TOPICLEN);
823 +    conf_error_report(buf);
824 +    ServerInfo.max_topic_length = TOPICLEN;
825 +  }
826 +  else
827 +    ServerInfo.max_topic_length = $3;
828   };
829  
830   serverinfo_hub: HUB '=' TBOOL ';'
# Line 769 | Line 847 | admin_name: NAME '=' QSTRING ';'
847    if (conf_parser_ctx.pass == 2)
848    {
849      MyFree(AdminInfo.name);
850 <    DupString(AdminInfo.name, yylval.string);
850 >    AdminInfo.name = xstrdup(yylval.string);
851    }
852   };
853  
# Line 778 | Line 856 | admin_email: EMAIL '=' QSTRING ';'
856    if (conf_parser_ctx.pass == 2)
857    {
858      MyFree(AdminInfo.email);
859 <    DupString(AdminInfo.email, yylval.string);
859 >    AdminInfo.email = xstrdup(yylval.string);
860    }
861   };
862  
# Line 787 | Line 865 | admin_description: DESCRIPTION '=' QSTRI
865    if (conf_parser_ctx.pass == 2)
866    {
867      MyFree(AdminInfo.description);
868 <    DupString(AdminInfo.description, yylval.string);
868 >    AdminInfo.description = xstrdup(yylval.string);
869    }
870   };
871  
# Line 797 | Line 875 | admin_description: DESCRIPTION '=' QSTRI
875   logging_entry:          T_LOG  '{' logging_items '}' ';' ;
876   logging_items:          logging_items logging_item | logging_item ;
877  
878 < logging_item:           logging_use_logging | logging_timestamp | logging_file_entry |
878 > logging_item:           logging_use_logging | logging_file_entry |
879                          error ';' ;
880  
881   logging_use_logging: USE_LOGGING '=' TBOOL ';'
# Line 806 | Line 884 | logging_use_logging: USE_LOGGING '=' TBO
884      ConfigLoggingEntry.use_logging = yylval.number;
885   };
886  
809 logging_timestamp: T_TIMESTAMP '=' TBOOL ';'
810 {
811  if (conf_parser_ctx.pass == 2)
812    ConfigLoggingEntry.timestamp = yylval.number;
813 };
814
887   logging_file_entry:
888   {
889 <  lfile[0] = '\0';
890 <  ltype = 0;
819 <  lsize = 0;
889 >  if (conf_parser_ctx.pass == 2)
890 >    reset_block_state();
891   } T_FILE  '{' logging_file_items '}' ';'
892   {
893 <  if (conf_parser_ctx.pass == 2 && ltype > 0)
894 <    log_add_file(ltype, lsize, lfile);
893 >  if (conf_parser_ctx.pass != 2)
894 >    break;
895 >
896 >  if (block_state.type.value && block_state.file.buf[0])
897 >    log_set_file(block_state.type.value, block_state.size.value,
898 >                 block_state.file.buf);
899   };
900  
901   logging_file_items: logging_file_items logging_file_item |
# Line 831 | Line 906 | logging_file_item:  logging_file_name |
906  
907   logging_file_name: NAME '=' QSTRING ';'
908   {
909 <  strlcpy(lfile, yylval.string, sizeof(lfile));
909 >  if (conf_parser_ctx.pass != 2)
910 >    break;
911 >
912 >  strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
913   }
914  
915   logging_file_size: T_SIZE '=' sizespec ';'
916   {
917 <  lsize = $3;
917 >  block_state.size.value = $3;
918   } | T_SIZE '=' T_UNLIMITED ';'
919   {
920 <  lsize = 0;
920 >  block_state.size.value = 0;
921   };
922  
923   logging_file_type: TYPE
924   {
925    if (conf_parser_ctx.pass == 2)
926 <    ltype = 0;
926 >    block_state.type.value = 0;
927   } '='  logging_file_type_items ';' ;
928  
929   logging_file_type_items: logging_file_type_items ',' logging_file_type_item | logging_file_type_item;
930   logging_file_type_item:  USER
931   {
932    if (conf_parser_ctx.pass == 2)
933 <    ltype = LOG_TYPE_USER;
933 >    block_state.type.value = LOG_TYPE_USER;
934   } | OPERATOR
935   {
936    if (conf_parser_ctx.pass == 2)
937 <    ltype = LOG_TYPE_OPER;
937 >    block_state.type.value = LOG_TYPE_OPER;
938   } | GLINE
939   {
940    if (conf_parser_ctx.pass == 2)
941 <    ltype = LOG_TYPE_GLINE;
941 >    block_state.type.value = LOG_TYPE_GLINE;
942   } | T_DLINE
943   {
944    if (conf_parser_ctx.pass == 2)
945 <    ltype = LOG_TYPE_DLINE;
945 >    block_state.type.value = LOG_TYPE_DLINE;
946   } | KLINE
947   {
948    if (conf_parser_ctx.pass == 2)
949 <    ltype = LOG_TYPE_KLINE;
949 >    block_state.type.value = LOG_TYPE_KLINE;
950   } | KILL
951   {
952    if (conf_parser_ctx.pass == 2)
953 <    ltype = LOG_TYPE_KILL;
953 >    block_state.type.value = LOG_TYPE_KILL;
954   } | T_DEBUG
955   {
956    if (conf_parser_ctx.pass == 2)
957 <    ltype = LOG_TYPE_DEBUG;
957 >    block_state.type.value = LOG_TYPE_DEBUG;
958   };
959  
960  
# Line 885 | Line 963 | logging_file_type_item:  USER
963   ***************************************************************************/
964   oper_entry: OPERATOR
965   {
966 <  if (conf_parser_ctx.pass == 2)
967 <  {
968 <    yy_conf = make_conf_item(OPER_TYPE);
969 <    yy_aconf = map_to_conf(yy_conf);
970 <    SetConfEncrypted(yy_aconf); /* Yes, the default is encrypted */
971 <  }
894 <  else
895 <  {
896 <    MyFree(class_name);
897 <    class_name = NULL;
898 <  }
899 < } oper_name_b '{' oper_items '}' ';'
966 >  if (conf_parser_ctx.pass != 2)
967 >    break;
968 >
969 >  reset_block_state();
970 >  block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
971 > } '{' oper_items '}' ';'
972   {
973 <  if (conf_parser_ctx.pass == 2)
902 <  {
903 <    struct CollectItem *yy_tmp;
904 <    dlink_node *ptr;
905 <    dlink_node *next_ptr;
973 >  dlink_node *ptr = NULL;
974  
975 <    conf_add_class_to_conf(yy_conf, class_name);
975 >  if (conf_parser_ctx.pass != 2)
976 >    break;
977  
978 <    /* Now, make sure there is a copy of the "base" given oper
979 <     * block in each of the collected copies
980 <     */
978 >  if (!block_state.name.buf[0])
979 >    break;
980 > #ifdef HAVE_LIBCRYPTO
981 >  if (!(block_state.file.buf[0] ||
982 >        block_state.rpass.buf[0]))
983 >    break;
984 > #else
985 >  if (!block_state.rpass.buf[0])
986 >    break;
987 > #endif
988  
989 <    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
990 <    {
991 <      struct AccessItem *new_aconf;
992 <      struct ConfItem *new_conf;
917 <      yy_tmp = ptr->data;
918 <
919 <      new_conf = make_conf_item(OPER_TYPE);
920 <      new_aconf = (struct AccessItem *)map_to_conf(new_conf);
921 <
922 <      new_aconf->flags = yy_aconf->flags;
923 <
924 <      if (yy_conf->name != NULL)
925 <        DupString(new_conf->name, yy_conf->name);
926 <      if (yy_tmp->user != NULL)
927 <        DupString(new_aconf->user, yy_tmp->user);
928 <      else
929 <        DupString(new_aconf->user, "*");
930 <      if (yy_tmp->host != NULL)
931 <        DupString(new_aconf->host, yy_tmp->host);
932 <      else
933 <        DupString(new_aconf->host, "*");
934 <      conf_add_class_to_conf(new_conf, class_name);
935 <      if (yy_aconf->passwd != NULL)
936 <        DupString(new_aconf->passwd, yy_aconf->passwd);
989 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
990 >  {
991 >    struct MaskItem *conf = NULL;
992 >    struct split_nuh_item nuh;
993  
994 <      new_aconf->port = yy_aconf->port;
995 < #ifdef HAVE_LIBCRYPTO
996 <      if (yy_aconf->rsa_public_key_file != NULL)
997 <      {
998 <        BIO *file;
994 >    nuh.nuhmask  = ptr->data;
995 >    nuh.nickptr  = NULL;
996 >    nuh.userptr  = block_state.user.buf;
997 >    nuh.hostptr  = block_state.host.buf;
998 >    nuh.nicksize = 0;
999 >    nuh.usersize = sizeof(block_state.user.buf);
1000 >    nuh.hostsize = sizeof(block_state.host.buf);
1001 >    split_nuh(&nuh);
1002  
1003 <        DupString(new_aconf->rsa_public_key_file,
1004 <                  yy_aconf->rsa_public_key_file);
1003 >    conf        = conf_make(CONF_OPER);
1004 >    conf->name  = xstrdup(block_state.name.buf);
1005 >    conf->user  = xstrdup(block_state.user.buf);
1006 >    conf->host  = xstrdup(block_state.host.buf);
1007 >
1008 >    if (block_state.rpass.buf[0])
1009 >      conf->passwd = xstrdup(block_state.rpass.buf);
1010 >
1011 >    conf->flags = block_state.flags.value;
1012 >    conf->modes = block_state.modes.value;
1013 >    conf->port  = block_state.port.value;
1014 >    conf->htype = parse_netmask(conf->host, &conf->addr, &conf->bits);
1015  
1016 <        file = BIO_new_file(yy_aconf->rsa_public_key_file, "r");
948 <        new_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file,
949 <                                                           NULL, 0, NULL);
950 <        BIO_set_close(file, BIO_CLOSE);
951 <        BIO_free(file);
952 <      }
953 < #endif
1016 >    conf_add_class_to_conf(conf, block_state.class.buf);
1017  
1018   #ifdef HAVE_LIBCRYPTO
1019 <      if (yy_tmp->name && (yy_tmp->passwd || yy_aconf->rsa_public_key)
1020 <          && yy_tmp->host)
1021 < #else
1022 <      if (yy_tmp->name && yy_tmp->passwd && yy_tmp->host)
1023 < #endif
1019 >    if (block_state.file.buf[0])
1020 >    {
1021 >      BIO *file = NULL;
1022 >      RSA *pkey = NULL;
1023 >
1024 >      if ((file = BIO_new_file(block_state.file.buf, "r")) == NULL)
1025        {
1026 <        conf_add_class_to_conf(new_conf, class_name);
1027 <        if (yy_tmp->name != NULL)
964 <          DupString(new_conf->name, yy_tmp->name);
1026 >        conf_error_report("Ignoring rsa_public_key_file -- file doesn't exist");
1027 >        break;
1028        }
1029  
1030 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
1031 <      free_collect_item(yy_tmp);
969 <    }
1030 >      if ((pkey = PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL)) == NULL)
1031 >        conf_error_report("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
1032  
1033 <    yy_conf = NULL;
1034 <    yy_aconf = NULL;
1035 <
1036 <
1037 <    MyFree(class_name);
976 <    class_name = NULL;
1033 >      conf->rsa_public_key = pkey;
1034 >      BIO_set_close(file, BIO_CLOSE);
1035 >      BIO_free(file);
1036 >    }
1037 > #endif /* HAVE_LIBCRYPTO */
1038    }
1039 < };
1039 > };
1040  
980 oper_name_b: | oper_name_t;
1041   oper_items:     oper_items oper_item | oper_item;
1042   oper_item:      oper_name | oper_user | oper_password |
1043                  oper_umodes | oper_class | oper_encrypted |
# Line 986 | Line 1046 | oper_item:      oper_name | oper_user |
1046   oper_name: NAME '=' QSTRING ';'
1047   {
1048    if (conf_parser_ctx.pass == 2)
1049 <  {
990 <    if (strlen(yylval.string) > OPERNICKLEN)
991 <      yylval.string[OPERNICKLEN] = '\0';
992 <
993 <    MyFree(yy_conf->name);
994 <    DupString(yy_conf->name, yylval.string);
995 <  }
996 < };
997 <
998 < oper_name_t: QSTRING
999 < {
1000 <  if (conf_parser_ctx.pass == 2)
1001 <  {
1002 <    if (strlen(yylval.string) > OPERNICKLEN)
1003 <      yylval.string[OPERNICKLEN] = '\0';
1004 <
1005 <    MyFree(yy_conf->name);
1006 <    DupString(yy_conf->name, yylval.string);
1007 <  }
1049 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1050   };
1051  
1052   oper_user: USER '=' QSTRING ';'
1053   {
1054    if (conf_parser_ctx.pass == 2)
1055 <  {
1014 <    struct split_nuh_item nuh;
1015 <
1016 <    nuh.nuhmask  = yylval.string;
1017 <    nuh.nickptr  = NULL;
1018 <    nuh.userptr  = userbuf;
1019 <    nuh.hostptr  = hostbuf;
1020 <
1021 <    nuh.nicksize = 0;
1022 <    nuh.usersize = sizeof(userbuf);
1023 <    nuh.hostsize = sizeof(hostbuf);
1024 <
1025 <    split_nuh(&nuh);
1026 <
1027 <    if (yy_aconf->user == NULL)
1028 <    {
1029 <      DupString(yy_aconf->user, userbuf);
1030 <      DupString(yy_aconf->host, hostbuf);
1031 <    }
1032 <    else
1033 <    {
1034 <      struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
1035 <
1036 <      DupString(yy_tmp->user, userbuf);
1037 <      DupString(yy_tmp->host, hostbuf);
1038 <
1039 <      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1040 <    }
1041 <  }
1055 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1056   };
1057  
1058   oper_password: PASSWORD '=' QSTRING ';'
1059   {
1060    if (conf_parser_ctx.pass == 2)
1061 <  {
1048 <    if (yy_aconf->passwd != NULL)
1049 <      memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1050 <
1051 <    MyFree(yy_aconf->passwd);
1052 <    DupString(yy_aconf->passwd, yylval.string);
1053 <  }
1061 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1062   };
1063  
1064   oper_encrypted: ENCRYPTED '=' TBOOL ';'
# Line 1058 | Line 1066 | oper_encrypted: ENCRYPTED '=' TBOOL ';'
1066    if (conf_parser_ctx.pass == 2)
1067    {
1068      if (yylval.number)
1069 <      SetConfEncrypted(yy_aconf);
1069 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1070      else
1071 <      ClearConfEncrypted(yy_aconf);
1071 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1072    }
1073   };
1074  
1075   oper_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
1076   {
1069 #ifdef HAVE_LIBCRYPTO
1077    if (conf_parser_ctx.pass == 2)
1078 <  {
1072 <    BIO *file;
1073 <
1074 <    if (yy_aconf->rsa_public_key != NULL)
1075 <    {
1076 <      RSA_free(yy_aconf->rsa_public_key);
1077 <      yy_aconf->rsa_public_key = NULL;
1078 <    }
1079 <
1080 <    if (yy_aconf->rsa_public_key_file != NULL)
1081 <    {
1082 <      MyFree(yy_aconf->rsa_public_key_file);
1083 <      yy_aconf->rsa_public_key_file = NULL;
1084 <    }
1085 <
1086 <    DupString(yy_aconf->rsa_public_key_file, yylval.string);
1087 <    file = BIO_new_file(yylval.string, "r");
1088 <
1089 <    if (file == NULL)
1090 <    {
1091 <      yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
1092 <      break;
1093 <    }
1094 <
1095 <    yy_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
1096 <
1097 <    if (yy_aconf->rsa_public_key == NULL)
1098 <    {
1099 <      yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
1100 <      break;
1101 <    }
1102 <
1103 <    BIO_set_close(file, BIO_CLOSE);
1104 <    BIO_free(file);
1105 <  }
1106 < #endif /* HAVE_LIBCRYPTO */
1078 >    strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
1079   };
1080  
1081   oper_class: CLASS '=' QSTRING ';'
1082   {
1083    if (conf_parser_ctx.pass == 2)
1084 <  {
1113 <    MyFree(class_name);
1114 <    DupString(class_name, yylval.string);
1115 <  }
1084 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1085   };
1086  
1087   oper_umodes: T_UMODES
1088   {
1089    if (conf_parser_ctx.pass == 2)
1090 <    yy_aconf->modes = 0;
1090 >    block_state.modes.value = 0;
1091   } '='  oper_umodes_items ';' ;
1092  
1093   oper_umodes_items: oper_umodes_items ',' oper_umodes_item | oper_umodes_item;
1094   oper_umodes_item:  T_BOTS
1095   {
1096    if (conf_parser_ctx.pass == 2)
1097 <    yy_aconf->modes |= UMODE_BOTS;
1097 >    block_state.modes.value |= UMODE_BOTS;
1098   } | T_CCONN
1099   {
1100    if (conf_parser_ctx.pass == 2)
1101 <    yy_aconf->modes |= UMODE_CCONN;
1101 >    block_state.modes.value |= UMODE_CCONN;
1102   } | T_CCONN_FULL
1103   {
1104    if (conf_parser_ctx.pass == 2)
1105 <    yy_aconf->modes |= UMODE_CCONN_FULL;
1105 >    block_state.modes.value |= UMODE_CCONN_FULL;
1106   } | T_DEAF
1107   {
1108    if (conf_parser_ctx.pass == 2)
1109 <    yy_aconf->modes |= UMODE_DEAF;
1109 >    block_state.modes.value |= UMODE_DEAF;
1110   } | T_DEBUG
1111   {
1112    if (conf_parser_ctx.pass == 2)
1113 <    yy_aconf->modes |= UMODE_DEBUG;
1113 >    block_state.modes.value |= UMODE_DEBUG;
1114   } | T_FULL
1115   {
1116    if (conf_parser_ctx.pass == 2)
1117 <    yy_aconf->modes |= UMODE_FULL;
1117 >    block_state.modes.value |= UMODE_FULL;
1118 > } | HIDDEN
1119 > {
1120 >  if (conf_parser_ctx.pass == 2)
1121 >    block_state.modes.value |= UMODE_HIDDEN;
1122   } | T_SKILL
1123   {
1124    if (conf_parser_ctx.pass == 2)
1125 <    yy_aconf->modes |= UMODE_SKILL;
1125 >    block_state.modes.value |= UMODE_SKILL;
1126   } | T_NCHANGE
1127   {
1128    if (conf_parser_ctx.pass == 2)
1129 <    yy_aconf->modes |= UMODE_NCHANGE;
1129 >    block_state.modes.value |= UMODE_NCHANGE;
1130   } | T_REJ
1131   {
1132    if (conf_parser_ctx.pass == 2)
1133 <    yy_aconf->modes |= UMODE_REJ;
1133 >    block_state.modes.value |= UMODE_REJ;
1134   } | T_UNAUTH
1135   {
1136    if (conf_parser_ctx.pass == 2)
1137 <    yy_aconf->modes |= UMODE_UNAUTH;
1137 >    block_state.modes.value |= UMODE_UNAUTH;
1138   } | T_SPY
1139   {
1140    if (conf_parser_ctx.pass == 2)
1141 <    yy_aconf->modes |= UMODE_SPY;
1141 >    block_state.modes.value |= UMODE_SPY;
1142   } | T_EXTERNAL
1143   {
1144    if (conf_parser_ctx.pass == 2)
1145 <    yy_aconf->modes |= UMODE_EXTERNAL;
1145 >    block_state.modes.value |= UMODE_EXTERNAL;
1146   } | T_OPERWALL
1147   {
1148    if (conf_parser_ctx.pass == 2)
1149 <    yy_aconf->modes |= UMODE_OPERWALL;
1149 >    block_state.modes.value |= UMODE_OPERWALL;
1150   } | T_SERVNOTICE
1151   {
1152    if (conf_parser_ctx.pass == 2)
1153 <    yy_aconf->modes |= UMODE_SERVNOTICE;
1153 >    block_state.modes.value |= UMODE_SERVNOTICE;
1154   } | T_INVISIBLE
1155   {
1156    if (conf_parser_ctx.pass == 2)
1157 <    yy_aconf->modes |= UMODE_INVISIBLE;
1157 >    block_state.modes.value |= UMODE_INVISIBLE;
1158   } | T_WALLOP
1159   {
1160    if (conf_parser_ctx.pass == 2)
1161 <    yy_aconf->modes |= UMODE_WALLOP;
1161 >    block_state.modes.value |= UMODE_WALLOP;
1162   } | T_SOFTCALLERID
1163   {
1164    if (conf_parser_ctx.pass == 2)
1165 <    yy_aconf->modes |= UMODE_SOFTCALLERID;
1165 >    block_state.modes.value |= UMODE_SOFTCALLERID;
1166   } | T_CALLERID
1167   {
1168    if (conf_parser_ctx.pass == 2)
1169 <    yy_aconf->modes |= UMODE_CALLERID;
1169 >    block_state.modes.value |= UMODE_CALLERID;
1170   } | T_LOCOPS
1171   {
1172    if (conf_parser_ctx.pass == 2)
1173 <    yy_aconf->modes |= UMODE_LOCOPS;
1173 >    block_state.modes.value |= UMODE_LOCOPS;
1174 > } | T_NONONREG
1175 > {
1176 >  if (conf_parser_ctx.pass == 2)
1177 >    block_state.modes.value |= UMODE_REGONLY;
1178 > } | T_FARCONNECT
1179 > {
1180 >  if (conf_parser_ctx.pass == 2)
1181 >    block_state.modes.value |= UMODE_FARCONNECT;
1182   };
1183  
1184   oper_flags: IRCD_FLAGS
1185   {
1186    if (conf_parser_ctx.pass == 2)
1187 <    yy_aconf->port = 0;
1187 >    block_state.port.value = 0;
1188   } '='  oper_flags_items ';';
1189  
1190   oper_flags_items: oper_flags_items ',' oper_flags_item | oper_flags_item;
1191   oper_flags_item: GLOBAL_KILL
1192   {
1193    if (conf_parser_ctx.pass == 2)
1194 <    yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1194 >    block_state.port.value |= OPER_FLAG_GLOBAL_KILL;
1195   } | REMOTE
1196   {
1197    if (conf_parser_ctx.pass == 2)
1198 <    yy_aconf->port |= OPER_FLAG_REMOTE;
1198 >    block_state.port.value |= OPER_FLAG_REMOTE;
1199   } | KLINE
1200   {
1201    if (conf_parser_ctx.pass == 2)
1202 <    yy_aconf->port |= OPER_FLAG_K;
1202 >    block_state.port.value |= OPER_FLAG_K;
1203   } | UNKLINE
1204   {
1205    if (conf_parser_ctx.pass == 2)
1206 <    yy_aconf->port |= OPER_FLAG_UNKLINE;
1206 >    block_state.port.value |= OPER_FLAG_UNKLINE;
1207 > } | T_DLINE
1208 > {
1209 >  if (conf_parser_ctx.pass == 2)
1210 >    block_state.port.value |= OPER_FLAG_DLINE;
1211 > } | T_UNDLINE
1212 > {
1213 >  if (conf_parser_ctx.pass == 2)
1214 >    block_state.port.value |= OPER_FLAG_UNDLINE;
1215   } | XLINE
1216   {
1217    if (conf_parser_ctx.pass == 2)
1218 <    yy_aconf->port |= OPER_FLAG_X;
1218 >    block_state.port.value |= OPER_FLAG_X;
1219   } | GLINE
1220   {
1221    if (conf_parser_ctx.pass == 2)
1222 <    yy_aconf->port |= OPER_FLAG_GLINE;
1222 >    block_state.port.value |= OPER_FLAG_GLINE;
1223   } | DIE
1224   {
1225    if (conf_parser_ctx.pass == 2)
1226 <    yy_aconf->port |= OPER_FLAG_DIE;
1226 >    block_state.port.value |= OPER_FLAG_DIE;
1227   } | T_RESTART
1228   {
1229    if (conf_parser_ctx.pass == 2)
1230 <    yy_aconf->port |= OPER_FLAG_RESTART;
1230 >    block_state.port.value |= OPER_FLAG_RESTART;
1231   } | REHASH
1232   {
1233    if (conf_parser_ctx.pass == 2)
1234 <    yy_aconf->port |= OPER_FLAG_REHASH;
1234 >    block_state.port.value |= OPER_FLAG_REHASH;
1235   } | ADMIN
1236   {
1237    if (conf_parser_ctx.pass == 2)
1238 <    yy_aconf->port |= OPER_FLAG_ADMIN;
1250 < } | HIDDEN_ADMIN
1251 < {
1252 <  if (conf_parser_ctx.pass == 2)
1253 <    yy_aconf->port |= OPER_FLAG_HIDDEN_ADMIN;
1254 < } | NICK_CHANGES
1255 < {
1256 <  if (conf_parser_ctx.pass == 2)
1257 <    yy_aconf->port |= OPER_FLAG_N;
1238 >    block_state.port.value |= OPER_FLAG_ADMIN;
1239   } | T_OPERWALL
1240   {
1241    if (conf_parser_ctx.pass == 2)
1242 <    yy_aconf->port |= OPER_FLAG_OPERWALL;
1242 >    block_state.port.value |= OPER_FLAG_OPERWALL;
1243   } | T_GLOBOPS
1244   {
1245    if (conf_parser_ctx.pass == 2)
1246 <    yy_aconf->port |= OPER_FLAG_GLOBOPS;
1247 < } | OPER_SPY_T
1267 < {
1268 <  if (conf_parser_ctx.pass == 2)
1269 <    yy_aconf->port |= OPER_FLAG_OPER_SPY;
1270 < } | HIDDEN_OPER
1246 >    block_state.port.value |= OPER_FLAG_GLOBOPS;
1247 > } | REMOTEBAN
1248   {
1249    if (conf_parser_ctx.pass == 2)
1250 <    yy_aconf->port |= OPER_FLAG_HIDDEN_OPER;
1251 < } | REMOTEBAN
1250 >    block_state.port.value |= OPER_FLAG_REMOTEBAN;
1251 > } | T_SET
1252   {
1253    if (conf_parser_ctx.pass == 2)
1254 <    yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1254 >    block_state.port.value |= OPER_FLAG_SET;
1255   } | MODULE
1256   {
1257    if (conf_parser_ctx.pass == 2)
1258 <    yy_aconf->port |= OPER_FLAG_MODULE;
1258 >    block_state.port.value |= OPER_FLAG_MODULE;
1259   };
1260  
1261  
# Line 1287 | Line 1264 | oper_flags_item: GLOBAL_KILL
1264   ***************************************************************************/
1265   class_entry: CLASS
1266   {
1267 <  if (conf_parser_ctx.pass == 1)
1268 <  {
1292 <    yy_conf = make_conf_item(CLASS_TYPE);
1293 <    yy_class = map_to_conf(yy_conf);
1294 <  }
1295 < } class_name_b '{' class_items '}' ';'
1296 < {
1297 <  if (conf_parser_ctx.pass == 1)
1298 <  {
1299 <    struct ConfItem *cconf = NULL;
1300 <    struct ClassItem *class = NULL;
1267 >  if (conf_parser_ctx.pass != 1)
1268 >    break;
1269  
1270 <    if (yy_class_name == NULL)
1303 <      delete_conf_item(yy_conf);
1304 <    else
1305 <    {
1306 <      cconf = find_exact_name_conf(CLASS_TYPE, yy_class_name, NULL, NULL);
1307 <
1308 <      if (cconf != NULL)                /* The class existed already */
1309 <      {
1310 <        int user_count = 0;
1311 <
1312 <        rebuild_cidr_class(cconf, yy_class);
1313 <
1314 <        class = map_to_conf(cconf);
1315 <
1316 <        user_count = class->curr_user_count;
1317 <        memcpy(class, yy_class, sizeof(*class));
1318 <        class->curr_user_count = user_count;
1319 <        class->active = 1;
1320 <
1321 <        delete_conf_item(yy_conf);
1322 <
1323 <        MyFree(cconf->name);            /* Allows case change of class name */
1324 <        cconf->name = yy_class_name;
1325 <      }
1326 <      else      /* Brand new class */
1327 <      {
1328 <        MyFree(yy_conf->name);          /* just in case it was allocated */
1329 <        yy_conf->name = yy_class_name;
1330 <        yy_class->active = 1;
1331 <      }
1332 <    }
1270 >  reset_block_state();
1271  
1272 <    yy_class_name = NULL;
1273 <  }
1272 >  block_state.ping_freq.value = DEFAULT_PINGFREQUENCY;
1273 >  block_state.con_freq.value  = DEFAULT_CONNECTFREQUENCY;
1274 >  block_state.max_total.value = MAXIMUM_LINKS_DEFAULT;
1275 >  block_state.max_sendq.value = DEFAULT_SENDQ;
1276 >  block_state.max_recvq.value = DEFAULT_RECVQ;
1277 > } '{' class_items '}' ';'
1278 > {
1279 >  struct ClassItem *class = NULL;
1280 >
1281 >  if (conf_parser_ctx.pass != 1)
1282 >    break;
1283 >
1284 >  if (!block_state.class.buf[0])
1285 >    break;
1286 >
1287 >  if (!(class = class_find(block_state.class.buf, 0)))
1288 >    class = class_make();
1289 >
1290 >  class->active = 1;
1291 >  MyFree(class->name);
1292 >  class->name = xstrdup(block_state.class.buf);
1293 >  class->ping_freq = block_state.ping_freq.value;
1294 >  class->max_perip = block_state.max_perip.value;
1295 >  class->con_freq = block_state.con_freq.value;
1296 >  class->max_total = block_state.max_total.value;
1297 >  class->max_global = block_state.max_global.value;
1298 >  class->max_local = block_state.max_local.value;
1299 >  class->max_ident = block_state.max_ident.value;
1300 >  class->max_sendq = block_state.max_sendq.value;
1301 >  class->max_recvq = block_state.max_recvq.value;
1302 >
1303 >  if (block_state.min_idle.value > block_state.max_idle.value)
1304 >  {
1305 >    block_state.min_idle.value = 0;
1306 >    block_state.max_idle.value = 0;
1307 >    block_state.flags.value &= ~CLASS_FLAGS_FAKE_IDLE;
1308 >  }
1309 >
1310 >  class->flags = block_state.flags.value;
1311 >  class->min_idle = block_state.min_idle.value;
1312 >  class->max_idle = block_state.max_idle.value;
1313 >
1314 >  if (class->number_per_cidr && block_state.number_per_cidr.value)
1315 >    if ((class->cidr_bitlen_ipv4 && block_state.cidr_bitlen_ipv4.value) ||
1316 >        (class->cidr_bitlen_ipv6 && block_state.cidr_bitlen_ipv6.value))
1317 >      if ((class->cidr_bitlen_ipv4 != block_state.cidr_bitlen_ipv4.value) ||
1318 >          (class->cidr_bitlen_ipv6 != block_state.cidr_bitlen_ipv6.value))
1319 >        rebuild_cidr_list(class);
1320 >
1321 >  class->cidr_bitlen_ipv4 = block_state.cidr_bitlen_ipv4.value;
1322 >  class->cidr_bitlen_ipv6 = block_state.cidr_bitlen_ipv6.value;
1323 >  class->number_per_cidr = block_state.number_per_cidr.value;
1324   };
1325  
1338 class_name_b: | class_name_t;
1339
1326   class_items:    class_items class_item | class_item;
1327   class_item:     class_name |
1328                  class_cidr_bitlen_ipv4 | class_cidr_bitlen_ipv6 |
1329                  class_ping_time |
1344                class_ping_warning |
1330                  class_number_per_cidr |
1331                  class_number_per_ip |
1332                  class_connectfreq |
# Line 1349 | Line 1334 | class_item:     class_name |
1334                  class_max_global |
1335                  class_max_local |
1336                  class_max_ident |
1337 <                class_sendq |
1337 >                class_sendq | class_recvq |
1338 >                class_min_idle |
1339 >                class_max_idle |
1340 >                class_flags |
1341                  error ';' ;
1342  
1343   class_name: NAME '=' QSTRING ';'
1344   {
1345    if (conf_parser_ctx.pass == 1)
1346 <  {
1359 <    MyFree(yy_class_name);
1360 <    DupString(yy_class_name, yylval.string);
1361 <  }
1362 < };
1363 <
1364 < class_name_t: QSTRING
1365 < {
1366 <  if (conf_parser_ctx.pass == 1)
1367 <  {
1368 <    MyFree(yy_class_name);
1369 <    DupString(yy_class_name, yylval.string);
1370 <  }
1346 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1347   };
1348  
1349   class_ping_time: PING_TIME '=' timespec ';'
1350   {
1351    if (conf_parser_ctx.pass == 1)
1352 <    PingFreq(yy_class) = $3;
1377 < };
1378 <
1379 < class_ping_warning: PING_WARNING '=' timespec ';'
1380 < {
1381 <  if (conf_parser_ctx.pass == 1)
1382 <    PingWarning(yy_class) = $3;
1352 >    block_state.ping_freq.value = $3;
1353   };
1354  
1355   class_number_per_ip: NUMBER_PER_IP '=' NUMBER ';'
1356   {
1357    if (conf_parser_ctx.pass == 1)
1358 <    MaxPerIp(yy_class) = $3;
1358 >    block_state.max_perip.value = $3;
1359   };
1360  
1361   class_connectfreq: CONNECTFREQ '=' timespec ';'
1362   {
1363    if (conf_parser_ctx.pass == 1)
1364 <    ConFreq(yy_class) = $3;
1364 >    block_state.con_freq.value = $3;
1365   };
1366  
1367   class_max_number: MAX_NUMBER '=' NUMBER ';'
1368   {
1369    if (conf_parser_ctx.pass == 1)
1370 <    MaxTotal(yy_class) = $3;
1370 >    block_state.max_total.value = $3;
1371   };
1372  
1373   class_max_global: MAX_GLOBAL '=' NUMBER ';'
1374   {
1375    if (conf_parser_ctx.pass == 1)
1376 <    MaxGlobal(yy_class) = $3;
1376 >    block_state.max_global.value = $3;
1377   };
1378  
1379   class_max_local: MAX_LOCAL '=' NUMBER ';'
1380   {
1381    if (conf_parser_ctx.pass == 1)
1382 <    MaxLocal(yy_class) = $3;
1382 >    block_state.max_local.value = $3;
1383   };
1384  
1385   class_max_ident: MAX_IDENT '=' NUMBER ';'
1386   {
1387    if (conf_parser_ctx.pass == 1)
1388 <    MaxIdent(yy_class) = $3;
1388 >    block_state.max_ident.value = $3;
1389   };
1390  
1391   class_sendq: SENDQ '=' sizespec ';'
1392   {
1393    if (conf_parser_ctx.pass == 1)
1394 <    MaxSendq(yy_class) = $3;
1394 >    block_state.max_sendq.value = $3;
1395 > };
1396 >
1397 > class_recvq: T_RECVQ '=' sizespec ';'
1398 > {
1399 >  if (conf_parser_ctx.pass == 1)
1400 >    if ($3 >= CLIENT_FLOOD_MIN && $3 <= CLIENT_FLOOD_MAX)
1401 >      block_state.max_recvq.value = $3;
1402   };
1403  
1404   class_cidr_bitlen_ipv4: CIDR_BITLEN_IPV4 '=' NUMBER ';'
1405   {
1406    if (conf_parser_ctx.pass == 1)
1407 <    CidrBitlenIPV4(yy_class) = $3;
1407 >    block_state.cidr_bitlen_ipv4.value = $3 > 32 ? 32 : $3;
1408   };
1409  
1410   class_cidr_bitlen_ipv6: CIDR_BITLEN_IPV6 '=' NUMBER ';'
1411   {
1412    if (conf_parser_ctx.pass == 1)
1413 <    CidrBitlenIPV6(yy_class) = $3;
1413 >    block_state.cidr_bitlen_ipv6.value = $3 > 128 ? 128 : $3;
1414   };
1415  
1416   class_number_per_cidr: NUMBER_PER_CIDR '=' NUMBER ';'
1417   {
1418    if (conf_parser_ctx.pass == 1)
1419 <    NumberPerCidr(yy_class) = $3;
1419 >    block_state.number_per_cidr.value = $3;
1420   };
1421  
1422 + class_min_idle: MIN_IDLE '=' timespec ';'
1423 + {
1424 +  if (conf_parser_ctx.pass != 1)
1425 +    break;
1426 +
1427 +  block_state.min_idle.value = $3;
1428 +  block_state.flags.value |= CLASS_FLAGS_FAKE_IDLE;
1429 + };
1430 +
1431 + class_max_idle: MAX_IDLE '=' timespec ';'
1432 + {
1433 +  if (conf_parser_ctx.pass != 1)
1434 +    break;
1435 +
1436 +  block_state.max_idle.value = $3;
1437 +  block_state.flags.value |= CLASS_FLAGS_FAKE_IDLE;
1438 + };
1439 +
1440 + class_flags: IRCD_FLAGS
1441 + {
1442 +  if (conf_parser_ctx.pass == 1)
1443 +    block_state.flags.value &= CLASS_FLAGS_FAKE_IDLE;
1444 + } '='  class_flags_items ';';
1445 +
1446 + class_flags_items: class_flags_items ',' class_flags_item | class_flags_item;
1447 + class_flags_item: RANDOM_IDLE
1448 + {
1449 +  if (conf_parser_ctx.pass == 1)
1450 +    block_state.flags.value |= CLASS_FLAGS_RANDOM_IDLE;
1451 + } | HIDE_IDLE_FROM_OPERS
1452 + {
1453 +  if (conf_parser_ctx.pass == 1)
1454 +    block_state.flags.value |= CLASS_FLAGS_HIDE_IDLE_FROM_OPERS;
1455 + };
1456 +
1457 +
1458   /***************************************************************************
1459   *  section listen
1460   ***************************************************************************/
1461   listen_entry: LISTEN
1462   {
1463    if (conf_parser_ctx.pass == 2)
1464 <  {
1465 <    listener_address = NULL;
1453 <    listener_flags = 0;
1454 <  }
1455 < } '{' listen_items '}' ';'
1456 < {
1457 <  if (conf_parser_ctx.pass == 2)
1458 <  {
1459 <    MyFree(listener_address);
1460 <    listener_address = NULL;
1461 <  }
1462 < };
1464 >    reset_block_state();
1465 > } '{' listen_items '}' ';';
1466  
1467   listen_flags: IRCD_FLAGS
1468   {
1469 <  listener_flags = 0;
1469 >  block_state.flags.value = 0;
1470   } '='  listen_flags_items ';';
1471  
1472   listen_flags_items: listen_flags_items ',' listen_flags_item | listen_flags_item;
1473   listen_flags_item: T_SSL
1474   {
1475    if (conf_parser_ctx.pass == 2)
1476 <    listener_flags |= LISTENER_SSL;
1476 >    block_state.flags.value |= LISTENER_SSL;
1477   } | HIDDEN
1478   {
1479    if (conf_parser_ctx.pass == 2)
1480 <    listener_flags |= LISTENER_HIDDEN;
1480 >    block_state.flags.value |= LISTENER_HIDDEN;
1481   } | T_SERVER
1482   {
1483    if (conf_parser_ctx.pass == 2)
1484 <    listener_flags |= LISTENER_SERVER;
1484 >   block_state.flags.value |= LISTENER_SERVER;
1485   };
1486  
1484
1485
1487   listen_items:   listen_items listen_item | listen_item;
1488   listen_item:    listen_port | listen_flags | listen_address | listen_host | error ';';
1489  
1490 < listen_port: PORT '=' port_items { listener_flags = 0; } ';';
1490 > listen_port: PORT '=' port_items { block_state.flags.value = 0; } ';';
1491  
1492   port_items: port_items ',' port_item | port_item;
1493  
# Line 1494 | Line 1495 | port_item: NUMBER
1495   {
1496    if (conf_parser_ctx.pass == 2)
1497    {
1498 <    if ((listener_flags & LISTENER_SSL))
1498 >    if (block_state.flags.value & LISTENER_SSL)
1499   #ifdef HAVE_LIBCRYPTO
1500        if (!ServerInfo.server_ctx)
1501   #endif
1502        {
1503 <        yyerror("SSL not available - port closed");
1503 >        conf_error_report("SSL not available - port closed");
1504          break;
1505        }
1506 <    add_listener($1, listener_address, listener_flags);
1506 >    add_listener($1, block_state.addr.buf, block_state.flags.value);
1507    }
1508   } | NUMBER TWODOTS NUMBER
1509   {
# Line 1510 | Line 1511 | port_item: NUMBER
1511    {
1512      int i;
1513  
1514 <    if ((listener_flags & LISTENER_SSL))
1514 >    if (block_state.flags.value & LISTENER_SSL)
1515   #ifdef HAVE_LIBCRYPTO
1516        if (!ServerInfo.server_ctx)
1517   #endif
1518        {
1519 <        yyerror("SSL not available - port closed");
1519 >        conf_error_report("SSL not available - port closed");
1520          break;
1521        }
1522  
1523      for (i = $1; i <= $3; ++i)
1524 <      add_listener(i, listener_address, listener_flags);
1524 >      add_listener(i, block_state.addr.buf, block_state.flags.value);
1525    }
1526   };
1527  
1528   listen_address: IP '=' QSTRING ';'
1529   {
1530    if (conf_parser_ctx.pass == 2)
1531 <  {
1531 <    MyFree(listener_address);
1532 <    DupString(listener_address, yylval.string);
1533 <  }
1531 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
1532   };
1533  
1534   listen_host: HOST '=' QSTRING ';'
1535   {
1536    if (conf_parser_ctx.pass == 2)
1537 <  {
1540 <    MyFree(listener_address);
1541 <    DupString(listener_address, yylval.string);
1542 <  }
1537 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
1538   };
1539  
1540   /***************************************************************************
# Line 1548 | Line 1543 | listen_host: HOST '=' QSTRING ';'
1543   auth_entry: IRCD_AUTH
1544   {
1545    if (conf_parser_ctx.pass == 2)
1546 <  {
1552 <    yy_conf = make_conf_item(CLIENT_TYPE);
1553 <    yy_aconf = map_to_conf(yy_conf);
1554 <  }
1555 <  else
1556 <  {
1557 <    MyFree(class_name);
1558 <    class_name = NULL;
1559 <  }
1546 >    reset_block_state();
1547   } '{' auth_items '}' ';'
1548   {
1549 <  if (conf_parser_ctx.pass == 2)
1563 <  {
1564 <    struct CollectItem *yy_tmp = NULL;
1565 <    dlink_node *ptr = NULL, *next_ptr = NULL;
1566 <
1567 <    if (yy_aconf->user && yy_aconf->host)
1568 <    {
1569 <      conf_add_class_to_conf(yy_conf, class_name);
1570 <      add_conf_by_address(CONF_CLIENT, yy_aconf);
1571 <    }
1572 <    else
1573 <      delete_conf_item(yy_conf);
1574 <
1575 <    /* copy over settings from first struct */
1576 <    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
1577 <    {
1578 <      struct AccessItem *new_aconf;
1579 <      struct ConfItem *new_conf;
1580 <
1581 <      new_conf = make_conf_item(CLIENT_TYPE);
1582 <      new_aconf = map_to_conf(new_conf);
1549 >  dlink_node *ptr = NULL;
1550  
1551 <      yy_tmp = ptr->data;
1551 >  if (conf_parser_ctx.pass != 2)
1552 >    break;
1553  
1554 <      assert(yy_tmp->user && yy_tmp->host);
1555 <
1556 <      if (yy_aconf->passwd != NULL)
1557 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1590 <      if (yy_conf->name != NULL)
1591 <        DupString(new_conf->name, yy_conf->name);
1592 <      if (yy_aconf->passwd != NULL)
1593 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1594 <
1595 <      new_aconf->flags = yy_aconf->flags;
1596 <      new_aconf->port  = yy_aconf->port;
1554 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
1555 >  {
1556 >    struct MaskItem *conf = NULL;
1557 >    struct split_nuh_item nuh;
1558  
1559 <      DupString(new_aconf->user, yy_tmp->user);
1560 <      collapse(new_aconf->user);
1559 >    nuh.nuhmask  = ptr->data;
1560 >    nuh.nickptr  = NULL;
1561 >    nuh.userptr  = block_state.user.buf;
1562 >    nuh.hostptr  = block_state.host.buf;
1563 >    nuh.nicksize = 0;
1564 >    nuh.usersize = sizeof(block_state.user.buf);
1565 >    nuh.hostsize = sizeof(block_state.host.buf);
1566 >    split_nuh(&nuh);
1567  
1568 <      DupString(new_aconf->host, yy_tmp->host);
1569 <      collapse(new_aconf->host);
1568 >    conf        = conf_make(CONF_CLIENT);
1569 >    conf->user  = xstrdup(collapse(block_state.user.buf));
1570 >    conf->host  = xstrdup(collapse(block_state.host.buf));
1571 >
1572 >    if (block_state.rpass.buf[0])
1573 >      conf->passwd = xstrdup(block_state.rpass.buf);
1574 >    if (block_state.name.buf[0])
1575 >      conf->name = xstrdup(block_state.name.buf);
1576  
1577 <      conf_add_class_to_conf(new_conf, class_name);
1578 <      add_conf_by_address(CONF_CLIENT, new_aconf);
1606 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
1607 <      free_collect_item(yy_tmp);
1608 <    }
1577 >    conf->flags = block_state.flags.value;
1578 >    conf->port  = block_state.port.value;
1579  
1580 <    MyFree(class_name);
1581 <    class_name = NULL;
1612 <    yy_conf = NULL;
1613 <    yy_aconf = NULL;
1580 >    conf_add_class_to_conf(conf, block_state.class.buf);
1581 >    add_conf_by_address(CONF_CLIENT, conf);
1582    }
1583   };
1584  
# Line 1622 | Line 1590 | auth_item:      auth_user | auth_passwd
1590   auth_user: USER '=' QSTRING ';'
1591   {
1592    if (conf_parser_ctx.pass == 2)
1593 <  {
1626 <    struct CollectItem *yy_tmp = NULL;
1627 <    struct split_nuh_item nuh;
1628 <
1629 <    nuh.nuhmask  = yylval.string;
1630 <    nuh.nickptr  = NULL;
1631 <    nuh.userptr  = userbuf;
1632 <    nuh.hostptr  = hostbuf;
1633 <
1634 <    nuh.nicksize = 0;
1635 <    nuh.usersize = sizeof(userbuf);
1636 <    nuh.hostsize = sizeof(hostbuf);
1637 <
1638 <    split_nuh(&nuh);
1639 <
1640 <    if (yy_aconf->user == NULL)
1641 <    {
1642 <      DupString(yy_aconf->user, userbuf);
1643 <      DupString(yy_aconf->host, hostbuf);
1644 <    }
1645 <    else
1646 <    {
1647 <      yy_tmp = MyMalloc(sizeof(struct CollectItem));
1648 <
1649 <      DupString(yy_tmp->user, userbuf);
1650 <      DupString(yy_tmp->host, hostbuf);
1651 <
1652 <      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1653 <    }
1654 <  }
1593 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1594   };
1595  
1657 /* XXX - IP/IPV6 tags don't exist anymore - put IP/IPV6 into user. */
1658
1596   auth_passwd: PASSWORD '=' QSTRING ';'
1597   {
1598    if (conf_parser_ctx.pass == 2)
1599 <  {
1663 <    /* be paranoid */
1664 <    if (yy_aconf->passwd != NULL)
1665 <      memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1666 <
1667 <    MyFree(yy_aconf->passwd);
1668 <    DupString(yy_aconf->passwd, yylval.string);
1669 <  }
1599 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1600   };
1601  
1602   auth_class: CLASS '=' QSTRING ';'
1603   {
1604    if (conf_parser_ctx.pass == 2)
1605 <  {
1676 <    MyFree(class_name);
1677 <    DupString(class_name, yylval.string);
1678 <  }
1605 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1606   };
1607  
1608   auth_encrypted: ENCRYPTED '=' TBOOL ';'
# Line 1683 | Line 1610 | auth_encrypted: ENCRYPTED '=' TBOOL ';'
1610    if (conf_parser_ctx.pass == 2)
1611    {
1612      if (yylval.number)
1613 <      SetConfEncrypted(yy_aconf);
1613 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1614      else
1615 <      ClearConfEncrypted(yy_aconf);
1615 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1616    }
1617   };
1618  
1619   auth_flags: IRCD_FLAGS
1620   {
1621 +  if (conf_parser_ctx.pass == 2)
1622 +    block_state.flags.value &= CONF_FLAGS_ENCRYPTED;
1623   } '='  auth_flags_items ';';
1624  
1625   auth_flags_items: auth_flags_items ',' auth_flags_item | auth_flags_item;
1626   auth_flags_item: SPOOF_NOTICE
1627   {
1628    if (conf_parser_ctx.pass == 2)
1629 <    yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1629 >    block_state.flags.value |= CONF_FLAGS_SPOOF_NOTICE;
1630   } | EXCEED_LIMIT
1631   {
1632    if (conf_parser_ctx.pass == 2)
1633 <    yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
1633 >    block_state.flags.value |= CONF_FLAGS_NOLIMIT;
1634   } | KLINE_EXEMPT
1635   {
1636    if (conf_parser_ctx.pass == 2)
1637 <    yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
1637 >    block_state.flags.value |= CONF_FLAGS_EXEMPTKLINE;
1638   } | NEED_IDENT
1639   {
1640    if (conf_parser_ctx.pass == 2)
1641 <    yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
1641 >    block_state.flags.value |= CONF_FLAGS_NEED_IDENTD;
1642   } | CAN_FLOOD
1643   {
1644    if (conf_parser_ctx.pass == 2)
1645 <    yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
1645 >    block_state.flags.value |= CONF_FLAGS_CAN_FLOOD;
1646   } | NO_TILDE
1647   {
1648    if (conf_parser_ctx.pass == 2)
1649 <    yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
1649 >    block_state.flags.value |= CONF_FLAGS_NO_TILDE;
1650   } | GLINE_EXEMPT
1651   {
1652    if (conf_parser_ctx.pass == 2)
1653 <    yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
1653 >    block_state.flags.value |= CONF_FLAGS_EXEMPTGLINE;
1654   } | RESV_EXEMPT
1655   {
1656    if (conf_parser_ctx.pass == 2)
1657 <    yy_aconf->flags |= CONF_FLAGS_EXEMPTRESV;
1657 >    block_state.flags.value |= CONF_FLAGS_EXEMPTRESV;
1658 > } | T_WEBIRC
1659 > {
1660 >  if (conf_parser_ctx.pass == 2)
1661 >    block_state.flags.value |= CONF_FLAGS_WEBIRC;
1662   } | NEED_PASSWORD
1663   {
1664    if (conf_parser_ctx.pass == 2)
1665 <    yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
1665 >    block_state.flags.value |= CONF_FLAGS_NEED_PASSWORD;
1666   };
1667  
1735 /* XXX - need check for illegal hostnames here */
1668   auth_spoof: SPOOF '=' QSTRING ';'
1669   {
1670 <  if (conf_parser_ctx.pass == 2)
1671 <  {
1740 <    MyFree(yy_conf->name);
1670 >  if (conf_parser_ctx.pass != 2)
1671 >    break;
1672  
1673 <    if (strlen(yylval.string) < HOSTLEN)
1674 <    {    
1675 <      DupString(yy_conf->name, yylval.string);
1676 <      yy_aconf->flags |= CONF_FLAGS_SPOOF_IP;
1746 <    }
1747 <    else
1748 <    {
1749 <      ilog(LOG_TYPE_IRCD, "Spoofs must be less than %d..ignoring it", HOSTLEN);
1750 <      yy_conf->name = NULL;
1751 <    }
1673 >  if (strlen(yylval.string) <= HOSTLEN && valid_hostname(yylval.string))
1674 >  {
1675 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1676 >    block_state.flags.value |= CONF_FLAGS_SPOOF_IP;
1677    }
1678 +  else
1679 +    ilog(LOG_TYPE_IRCD, "Spoof either is too long or contains invalid characters. Ignoring it.");
1680   };
1681  
1682   auth_redir_serv: REDIRSERV '=' QSTRING ';'
1683   {
1684 <  if (conf_parser_ctx.pass == 2)
1685 <  {
1686 <    yy_aconf->flags |= CONF_FLAGS_REDIR;
1687 <    MyFree(yy_conf->name);
1688 <    DupString(yy_conf->name, yylval.string);
1762 <  }
1684 >  if (conf_parser_ctx.pass != 2)
1685 >    break;
1686 >
1687 >  strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1688 >  block_state.flags.value |= CONF_FLAGS_REDIR;
1689   };
1690  
1691   auth_redir_port: REDIRPORT '=' NUMBER ';'
1692   {
1693 <  if (conf_parser_ctx.pass == 2)
1694 <  {
1695 <    yy_aconf->flags |= CONF_FLAGS_REDIR;
1696 <    yy_aconf->port = $3;
1697 <  }
1693 >  if (conf_parser_ctx.pass != 2)
1694 >    break;
1695 >
1696 >  block_state.flags.value |= CONF_FLAGS_REDIR;
1697 >  block_state.port.value = $3;
1698   };
1699  
1700  
# Line 1777 | Line 1703 | auth_redir_port: REDIRPORT '=' NUMBER ';
1703   ***************************************************************************/
1704   resv_entry: RESV
1705   {
1706 <  if (conf_parser_ctx.pass == 2)
1707 <  {
1708 <    MyFree(resv_reason);
1709 <    resv_reason = NULL;
1710 <  }
1706 >  if (conf_parser_ctx.pass != 2)
1707 >    break;
1708 >
1709 >  reset_block_state();
1710 >  strlcpy(block_state.rpass.buf, CONF_NOREASON, sizeof(block_state.rpass.buf));
1711   } '{' resv_items '}' ';'
1712   {
1713 <  if (conf_parser_ctx.pass == 2)
1714 <  {
1715 <    MyFree(resv_reason);
1716 <    resv_reason = NULL;
1791 <  }
1713 >  if (conf_parser_ctx.pass != 2)
1714 >    break;
1715 >
1716 >  create_resv(block_state.name.buf, block_state.rpass.buf, &block_state.mask.list);
1717   };
1718  
1719   resv_items:     resv_items resv_item | resv_item;
1720 < resv_item:      resv_creason | resv_channel | resv_nick | error ';' ;
1720 > resv_item:      resv_mask | resv_reason | resv_exempt | error ';' ;
1721  
1722 < resv_creason: REASON '=' QSTRING ';'
1722 > resv_mask: MASK '=' QSTRING ';'
1723   {
1724    if (conf_parser_ctx.pass == 2)
1725 <  {
1801 <    MyFree(resv_reason);
1802 <    DupString(resv_reason, yylval.string);
1803 <  }
1725 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1726   };
1727  
1728 < resv_channel: CHANNEL '=' QSTRING ';'
1728 > resv_reason: REASON '=' QSTRING ';'
1729   {
1730    if (conf_parser_ctx.pass == 2)
1731 <  {
1810 <    if (IsChanPrefix(*yylval.string))
1811 <    {
1812 <      char def_reason[] = "No reason";
1813 <
1814 <      create_channel_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
1815 <    }
1816 <  }
1817 <  /* ignore it for now.. but we really should make a warning if
1818 <   * its an erroneous name --fl_ */
1731 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1732   };
1733  
1734 < resv_nick: NICK '=' QSTRING ';'
1734 > resv_exempt: EXEMPT '=' QSTRING ';'
1735   {
1736    if (conf_parser_ctx.pass == 2)
1737 <  {
1825 <    char def_reason[] = "No reason";
1826 <
1827 <    create_nick_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
1828 <  }
1737 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1738   };
1739  
1740 +
1741   /***************************************************************************
1742   *  section service
1743   ***************************************************************************/
# Line 1842 | Line 1752 | service_name: NAME '=' QSTRING ';'
1752    {
1753      if (valid_servname(yylval.string))
1754      {
1755 <      yy_conf = make_conf_item(SERVICE_TYPE);
1756 <      DupString(yy_conf->name, yylval.string);
1755 >      struct MaskItem *conf = conf_make(CONF_SERVICE);
1756 >      conf->name = xstrdup(yylval.string);
1757      }
1758    }
1759   };
# Line 1853 | Line 1763 | service_name: NAME '=' QSTRING ';'
1763   ***************************************************************************/
1764   shared_entry: T_SHARED
1765   {
1766 <  if (conf_parser_ctx.pass == 2)
1767 <  {
1768 <    yy_conf = make_conf_item(ULINE_TYPE);
1769 <    yy_match_item = map_to_conf(yy_conf);
1770 <    yy_match_item->action = SHARED_ALL;
1771 <  }
1766 >  if (conf_parser_ctx.pass != 2)
1767 >    break;
1768 >
1769 >  reset_block_state();
1770 >
1771 >  strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1772 >  strlcpy(block_state.user.buf, "*", sizeof(block_state.user.buf));
1773 >  strlcpy(block_state.host.buf, "*", sizeof(block_state.host.buf));
1774 >  block_state.flags.value = SHARED_ALL;
1775   } '{' shared_items '}' ';'
1776   {
1777 <  if (conf_parser_ctx.pass == 2)
1778 <  {
1779 <    yy_conf = NULL;
1780 <  }
1777 >  struct MaskItem *conf = NULL;
1778 >
1779 >  if (conf_parser_ctx.pass != 2)
1780 >    break;
1781 >
1782 >  conf = conf_make(CONF_ULINE);
1783 >  conf->flags = block_state.flags.value;
1784 >  conf->name = xstrdup(block_state.name.buf);
1785 >  conf->user = xstrdup(block_state.user.buf);
1786 >  conf->host = xstrdup(block_state.host.buf);
1787   };
1788  
1789   shared_items: shared_items shared_item | shared_item;
# Line 1873 | Line 1792 | shared_item:  shared_name | shared_user
1792   shared_name: NAME '=' QSTRING ';'
1793   {
1794    if (conf_parser_ctx.pass == 2)
1795 <  {
1877 <    MyFree(yy_conf->name);
1878 <    DupString(yy_conf->name, yylval.string);
1879 <  }
1795 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1796   };
1797  
1798   shared_user: USER '=' QSTRING ';'
# Line 1887 | Line 1803 | shared_user: USER '=' QSTRING ';'
1803  
1804      nuh.nuhmask  = yylval.string;
1805      nuh.nickptr  = NULL;
1806 <    nuh.userptr  = userbuf;
1807 <    nuh.hostptr  = hostbuf;
1806 >    nuh.userptr  = block_state.user.buf;
1807 >    nuh.hostptr  = block_state.host.buf;
1808  
1809      nuh.nicksize = 0;
1810 <    nuh.usersize = sizeof(userbuf);
1811 <    nuh.hostsize = sizeof(hostbuf);
1810 >    nuh.usersize = sizeof(block_state.user.buf);
1811 >    nuh.hostsize = sizeof(block_state.host.buf);
1812  
1813      split_nuh(&nuh);
1898
1899    DupString(yy_match_item->user, userbuf);
1900    DupString(yy_match_item->host, hostbuf);
1814    }
1815   };
1816  
1817   shared_type: TYPE
1818   {
1819    if (conf_parser_ctx.pass == 2)
1820 <    yy_match_item->action = 0;
1820 >    block_state.flags.value = 0;
1821   } '=' shared_types ';' ;
1822  
1823   shared_types: shared_types ',' shared_type_item | shared_type_item;
1824   shared_type_item: KLINE
1825   {
1826    if (conf_parser_ctx.pass == 2)
1827 <    yy_match_item->action |= SHARED_KLINE;
1828 < } | TKLINE
1827 >    block_state.flags.value |= SHARED_KLINE;
1828 > } | UNKLINE
1829   {
1830    if (conf_parser_ctx.pass == 2)
1831 <    yy_match_item->action |= SHARED_TKLINE;
1832 < } | UNKLINE
1831 >    block_state.flags.value |= SHARED_UNKLINE;
1832 > } | T_DLINE
1833   {
1834    if (conf_parser_ctx.pass == 2)
1835 <    yy_match_item->action |= SHARED_UNKLINE;
1836 < } | XLINE
1835 >    block_state.flags.value |= SHARED_DLINE;
1836 > } | T_UNDLINE
1837   {
1838    if (conf_parser_ctx.pass == 2)
1839 <    yy_match_item->action |= SHARED_XLINE;
1840 < } | TXLINE
1839 >    block_state.flags.value |= SHARED_UNDLINE;
1840 > } | XLINE
1841   {
1842    if (conf_parser_ctx.pass == 2)
1843 <    yy_match_item->action |= SHARED_TXLINE;
1843 >    block_state.flags.value |= SHARED_XLINE;
1844   } | T_UNXLINE
1845   {
1846    if (conf_parser_ctx.pass == 2)
1847 <    yy_match_item->action |= SHARED_UNXLINE;
1847 >    block_state.flags.value |= SHARED_UNXLINE;
1848   } | RESV
1849   {
1850    if (conf_parser_ctx.pass == 2)
1851 <    yy_match_item->action |= SHARED_RESV;
1939 < } | TRESV
1940 < {
1941 <  if (conf_parser_ctx.pass == 2)
1942 <    yy_match_item->action |= SHARED_TRESV;
1851 >    block_state.flags.value |= SHARED_RESV;
1852   } | T_UNRESV
1853   {
1854    if (conf_parser_ctx.pass == 2)
1855 <    yy_match_item->action |= SHARED_UNRESV;
1855 >    block_state.flags.value |= SHARED_UNRESV;
1856   } | T_LOCOPS
1857   {
1858    if (conf_parser_ctx.pass == 2)
1859 <    yy_match_item->action |= SHARED_LOCOPS;
1859 >    block_state.flags.value |= SHARED_LOCOPS;
1860   } | T_ALL
1861   {
1862    if (conf_parser_ctx.pass == 2)
1863 <    yy_match_item->action = SHARED_ALL;
1863 >    block_state.flags.value = SHARED_ALL;
1864   };
1865  
1866   /***************************************************************************
# Line 1959 | Line 1868 | shared_type_item: KLINE
1868   ***************************************************************************/
1869   cluster_entry: T_CLUSTER
1870   {
1871 <  if (conf_parser_ctx.pass == 2)
1872 <  {
1873 <    yy_conf = make_conf_item(CLUSTER_TYPE);
1874 <    yy_conf->flags = SHARED_ALL;
1875 <  }
1871 >  if (conf_parser_ctx.pass != 2)
1872 >    break;
1873 >
1874 >  reset_block_state();
1875 >
1876 >  strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1877 >  block_state.flags.value = SHARED_ALL;
1878   } '{' cluster_items '}' ';'
1879   {
1880 <  if (conf_parser_ctx.pass == 2)
1881 <  {
1882 <    if (yy_conf->name == NULL)
1883 <      DupString(yy_conf->name, "*");
1884 <    yy_conf = NULL;
1885 <  }
1880 >  struct MaskItem *conf = NULL;
1881 >
1882 >  if (conf_parser_ctx.pass != 2)
1883 >    break;
1884 >
1885 >  conf = conf_make(CONF_CLUSTER);
1886 >  conf->flags = block_state.flags.value;
1887 >  conf->name = xstrdup(block_state.name.buf);
1888   };
1889  
1890   cluster_items:  cluster_items cluster_item | cluster_item;
# Line 1980 | Line 1893 | cluster_item:  cluster_name | cluster_typ
1893   cluster_name: NAME '=' QSTRING ';'
1894   {
1895    if (conf_parser_ctx.pass == 2)
1896 <    DupString(yy_conf->name, yylval.string);
1896 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1897   };
1898  
1899   cluster_type: TYPE
1900   {
1901    if (conf_parser_ctx.pass == 2)
1902 <    yy_conf->flags = 0;
1902 >    block_state.flags.value = 0;
1903   } '=' cluster_types ';' ;
1904  
1905   cluster_types:  cluster_types ',' cluster_type_item | cluster_type_item;
1906   cluster_type_item: KLINE
1907   {
1908    if (conf_parser_ctx.pass == 2)
1909 <    yy_conf->flags |= SHARED_KLINE;
1910 < } | TKLINE
1909 >    block_state.flags.value |= SHARED_KLINE;
1910 > } | UNKLINE
1911   {
1912    if (conf_parser_ctx.pass == 2)
1913 <    yy_conf->flags |= SHARED_TKLINE;
1914 < } | UNKLINE
1913 >    block_state.flags.value |= SHARED_UNKLINE;
1914 > } | T_DLINE
1915   {
1916    if (conf_parser_ctx.pass == 2)
1917 <    yy_conf->flags |= SHARED_UNKLINE;
1918 < } | XLINE
1917 >    block_state.flags.value |= SHARED_DLINE;
1918 > } | T_UNDLINE
1919   {
1920    if (conf_parser_ctx.pass == 2)
1921 <    yy_conf->flags |= SHARED_XLINE;
1922 < } | TXLINE
1921 >    block_state.flags.value |= SHARED_UNDLINE;
1922 > } | XLINE
1923   {
1924    if (conf_parser_ctx.pass == 2)
1925 <    yy_conf->flags |= SHARED_TXLINE;
1925 >    block_state.flags.value |= SHARED_XLINE;
1926   } | T_UNXLINE
1927   {
1928    if (conf_parser_ctx.pass == 2)
1929 <    yy_conf->flags |= SHARED_UNXLINE;
1929 >    block_state.flags.value |= SHARED_UNXLINE;
1930   } | RESV
1931   {
1932    if (conf_parser_ctx.pass == 2)
1933 <    yy_conf->flags |= SHARED_RESV;
2021 < } | TRESV
2022 < {
2023 <  if (conf_parser_ctx.pass == 2)
2024 <    yy_conf->flags |= SHARED_TRESV;
1933 >    block_state.flags.value |= SHARED_RESV;
1934   } | T_UNRESV
1935   {
1936    if (conf_parser_ctx.pass == 2)
1937 <    yy_conf->flags |= SHARED_UNRESV;
1937 >    block_state.flags.value |= SHARED_UNRESV;
1938   } | T_LOCOPS
1939   {
1940    if (conf_parser_ctx.pass == 2)
1941 <    yy_conf->flags |= SHARED_LOCOPS;
1941 >    block_state.flags.value |= SHARED_LOCOPS;
1942   } | T_ALL
1943   {
1944    if (conf_parser_ctx.pass == 2)
1945 <    yy_conf->flags = SHARED_ALL;
1945 >    block_state.flags.value = SHARED_ALL;
1946   };
1947  
1948   /***************************************************************************
# Line 2041 | Line 1950 | cluster_type_item: KLINE
1950   ***************************************************************************/
1951   connect_entry: CONNECT  
1952   {
2044  if (conf_parser_ctx.pass == 2)
2045  {
2046    yy_conf = make_conf_item(SERVER_TYPE);
2047    yy_aconf = (struct AccessItem *)map_to_conf(yy_conf);
2048    yy_aconf->passwd = NULL;
2049    /* defaults */
2050    yy_aconf->port = PORTNUM;
1953  
1954 <    if (ConfigFileEntry.burst_away)
1955 <      yy_aconf->flags = CONF_FLAGS_BURST_AWAY;
2054 <  }
2055 <  else
2056 <  {
2057 <    MyFree(class_name);
2058 <    class_name = NULL;
2059 <  }
2060 < } connect_name_b '{' connect_items '}' ';'
2061 < {
2062 <  if (conf_parser_ctx.pass == 2)
2063 <  {
2064 <    struct CollectItem *yy_hconf=NULL;
2065 <    struct CollectItem *yy_lconf=NULL;
2066 <    dlink_node *ptr;
2067 <    dlink_node *next_ptr;
2068 < #ifdef HAVE_LIBCRYPTO
2069 <    if (yy_aconf->host &&
2070 <        ((yy_aconf->passwd && yy_aconf->spasswd) ||
2071 <         (yy_aconf->rsa_public_key && IsConfCryptLink(yy_aconf))))
2072 < #else /* !HAVE_LIBCRYPTO */
2073 <      if (yy_aconf->host && !IsConfCryptLink(yy_aconf) &&
2074 <          yy_aconf->passwd && yy_aconf->spasswd)
2075 < #endif /* !HAVE_LIBCRYPTO */
2076 <        {
2077 <          if (conf_add_server(yy_conf, class_name) == -1)
2078 <          {
2079 <            delete_conf_item(yy_conf);
2080 <            yy_conf = NULL;
2081 <            yy_aconf = NULL;
2082 <          }
2083 <        }
2084 <        else
2085 <        {
2086 <          /* Even if yy_conf ->name is NULL
2087 <           * should still unhook any hub/leaf confs still pending
2088 <           */
2089 <          unhook_hub_leaf_confs();
2090 <
2091 <          if (yy_conf->name != NULL)
2092 <          {
2093 < #ifndef HAVE_LIBCRYPTO
2094 <            if (IsConfCryptLink(yy_aconf))
2095 <              yyerror("Ignoring connect block -- no OpenSSL support");
2096 < #else
2097 <            if (IsConfCryptLink(yy_aconf) && !yy_aconf->rsa_public_key)
2098 <              yyerror("Ignoring connect block -- missing key");
2099 < #endif
2100 <            if (yy_aconf->host == NULL)
2101 <              yyerror("Ignoring connect block -- missing host");
2102 <            else if (!IsConfCryptLink(yy_aconf) &&
2103 <                    (!yy_aconf->passwd || !yy_aconf->spasswd))
2104 <              yyerror("Ignoring connect block -- missing password");
2105 <          }
2106 <
2107 <
2108 <          /* XXX
2109 <           * This fixes a try_connections() core (caused by invalid class_ptr
2110 <           * pointers) reported by metalrock. That's an ugly fix, but there
2111 <           * is currently no better way. The entire config subsystem needs an
2112 <           * rewrite ASAP. make_conf_item() shouldn't really add things onto
2113 <           * a doubly linked list immediately without any sanity checks!  -Michael
2114 <           */
2115 <          delete_conf_item(yy_conf);
2116 <
2117 <          yy_aconf = NULL;
2118 <          yy_conf = NULL;
2119 <        }
2120 <
2121 <      /*
2122 <       * yy_conf is still pointing at the server that is having
2123 <       * a connect block built for it. This means, y_aconf->name
2124 <       * points to the actual irc name this server will be known as.
2125 <       * Now this new server has a set or even just one hub_mask (or leaf_mask)
2126 <       * given in the link list at yy_hconf. Fill in the HUB confs
2127 <       * from this link list now.
2128 <       */        
2129 <      DLINK_FOREACH_SAFE(ptr, next_ptr, hub_conf_list.head)
2130 <      {
2131 <        struct ConfItem *new_hub_conf;
2132 <        struct MatchItem *match_item;
1954 >  if (conf_parser_ctx.pass != 2)
1955 >    break;
1956  
1957 <        yy_hconf = ptr->data;
1957 >  reset_block_state();
1958 >  block_state.port.value = PORTNUM;
1959 > } '{' connect_items '}' ';'
1960 > {
1961 >  struct MaskItem *conf = NULL;
1962 >  struct addrinfo hints, *res;
1963 >
1964 >  if (conf_parser_ctx.pass != 2)
1965 >    break;
1966 >
1967 >  if (!block_state.name.buf[0] ||
1968 >      !block_state.host.buf[0])
1969 >    break;
1970 >
1971 >  if (!(block_state.rpass.buf[0] ||
1972 >        block_state.spass.buf[0]))
1973 >    break;
1974 >
1975 >  if (has_wildcards(block_state.name.buf) ||
1976 >      has_wildcards(block_state.host.buf))
1977 >    break;
1978 >
1979 >  conf = conf_make(CONF_SERVER);
1980 >  conf->port = block_state.port.value;
1981 >  conf->flags = block_state.flags.value;
1982 >  conf->aftype = block_state.aftype.value;
1983 >  conf->host = xstrdup(block_state.host.buf);
1984 >  conf->name = xstrdup(block_state.name.buf);
1985 >  conf->passwd = xstrdup(block_state.rpass.buf);
1986 >  conf->spasswd = xstrdup(block_state.spass.buf);
1987 >  conf->cipher_list = xstrdup(block_state.ciph.buf);
1988  
1989 <        /* yy_conf == NULL is a fatal error for this connect block! */
1990 <        if ((yy_conf != NULL) && (yy_conf->name != NULL))
2138 <        {
2139 <          new_hub_conf = make_conf_item(HUB_TYPE);
2140 <          match_item = (struct MatchItem *)map_to_conf(new_hub_conf);
2141 <          DupString(new_hub_conf->name, yy_conf->name);
2142 <          if (yy_hconf->user != NULL)
2143 <            DupString(match_item->user, yy_hconf->user);
2144 <          else
2145 <            DupString(match_item->user, "*");
2146 <          if (yy_hconf->host != NULL)
2147 <            DupString(match_item->host, yy_hconf->host);
2148 <          else
2149 <            DupString(match_item->host, "*");
2150 <        }
2151 <        dlinkDelete(&yy_hconf->node, &hub_conf_list);
2152 <        free_collect_item(yy_hconf);
2153 <      }
1989 >  dlinkMoveList(&block_state.leaf.list, &conf->leaf_list);
1990 >  dlinkMoveList(&block_state.hub.list, &conf->hub_list);
1991  
1992 <      /* Ditto for the LEAF confs */
1992 >  if (block_state.bind.buf[0])
1993 >  {
1994 >    memset(&hints, 0, sizeof(hints));
1995  
1996 <      DLINK_FOREACH_SAFE(ptr, next_ptr, leaf_conf_list.head)
1997 <      {
1998 <        struct ConfItem *new_leaf_conf;
2160 <        struct MatchItem *match_item;
1996 >    hints.ai_family   = AF_UNSPEC;
1997 >    hints.ai_socktype = SOCK_STREAM;
1998 >    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
1999  
2000 <        yy_lconf = ptr->data;
2000 >    if (getaddrinfo(block_state.bind.buf, NULL, &hints, &res))
2001 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", block_state.bind.buf);
2002 >    else
2003 >    {
2004 >      assert(res != NULL);
2005  
2006 <        if ((yy_conf != NULL) && (yy_conf->name != NULL))
2007 <        {
2008 <          new_leaf_conf = make_conf_item(LEAF_TYPE);
2009 <          match_item = (struct MatchItem *)map_to_conf(new_leaf_conf);
2010 <          DupString(new_leaf_conf->name, yy_conf->name);
2169 <          if (yy_lconf->user != NULL)
2170 <            DupString(match_item->user, yy_lconf->user);
2171 <          else
2172 <            DupString(match_item->user, "*");
2173 <          if (yy_lconf->host != NULL)
2174 <            DupString(match_item->host, yy_lconf->host);
2175 <          else
2176 <            DupString(match_item->host, "*");
2177 <        }
2178 <        dlinkDelete(&yy_lconf->node, &leaf_conf_list);
2179 <        free_collect_item(yy_lconf);
2180 <      }
2181 <      MyFree(class_name);
2182 <      class_name = NULL;
2183 <      yy_conf = NULL;
2184 <      yy_aconf = NULL;
2006 >      memcpy(&conf->bind, res->ai_addr, res->ai_addrlen);
2007 >      conf->bind.ss.ss_family = res->ai_family;
2008 >      conf->bind.ss_len = res->ai_addrlen;
2009 >      freeaddrinfo(res);
2010 >    }
2011    }
2012 +
2013 +  conf_add_class_to_conf(conf, block_state.class.buf);
2014 +  lookup_confhost(conf);
2015   };
2016  
2188 connect_name_b: | connect_name_t;
2017   connect_items:  connect_items connect_item | connect_item;
2018   connect_item:   connect_name | connect_host | connect_vhost |
2019                  connect_send_password | connect_accept_password |
2020 <                connect_aftype | connect_port |
2020 >                connect_aftype | connect_port | connect_ssl_cipher_list |
2021                  connect_flags | connect_hub_mask | connect_leaf_mask |
2022 <                connect_class | connect_encrypted |
2195 <                connect_rsa_public_key_file | connect_cipher_preference |
2022 >                connect_class | connect_encrypted |
2023                  error ';' ;
2024  
2025   connect_name: NAME '=' QSTRING ';'
2026   {
2027    if (conf_parser_ctx.pass == 2)
2028 <  {
2202 <    if (yy_conf->name != NULL)
2203 <      yyerror("Multiple connect name entry");
2204 <
2205 <    MyFree(yy_conf->name);
2206 <    DupString(yy_conf->name, yylval.string);
2207 <  }
2208 < };
2209 <
2210 < connect_name_t: QSTRING
2211 < {
2212 <  if (conf_parser_ctx.pass == 2)
2213 <  {
2214 <    if (yy_conf->name != NULL)
2215 <      yyerror("Multiple connect name entry");
2216 <
2217 <    MyFree(yy_conf->name);
2218 <    DupString(yy_conf->name, yylval.string);
2219 <  }
2028 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
2029   };
2030  
2031   connect_host: HOST '=' QSTRING ';'
2032   {
2033    if (conf_parser_ctx.pass == 2)
2034 <  {
2226 <    MyFree(yy_aconf->host);
2227 <    DupString(yy_aconf->host, yylval.string);
2228 <  }
2034 >    strlcpy(block_state.host.buf, yylval.string, sizeof(block_state.host.buf));
2035   };
2036  
2037   connect_vhost: VHOST '=' QSTRING ';'
2038   {
2039    if (conf_parser_ctx.pass == 2)
2040 <  {
2235 <    struct addrinfo hints, *res;
2236 <
2237 <    memset(&hints, 0, sizeof(hints));
2238 <
2239 <    hints.ai_family   = AF_UNSPEC;
2240 <    hints.ai_socktype = SOCK_STREAM;
2241 <    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
2242 <
2243 <    if (getaddrinfo(yylval.string, NULL, &hints, &res))
2244 <      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", yylval.string);
2245 <    else
2246 <    {
2247 <      assert(res != NULL);
2248 <
2249 <      memcpy(&yy_aconf->my_ipnum, res->ai_addr, res->ai_addrlen);
2250 <      yy_aconf->my_ipnum.ss.ss_family = res->ai_family;
2251 <      yy_aconf->my_ipnum.ss_len = res->ai_addrlen;
2252 <      freeaddrinfo(res);
2253 <    }
2254 <  }
2040 >    strlcpy(block_state.bind.buf, yylval.string, sizeof(block_state.bind.buf));
2041   };
2042  
2043   connect_send_password: SEND_PASSWORD '=' QSTRING ';'
2044   {
2045 <  if (conf_parser_ctx.pass == 2)
2046 <  {
2261 <    if ($3[0] == ':')
2262 <      yyerror("Server passwords cannot begin with a colon");
2263 <    else if (strchr($3, ' ') != NULL)
2264 <      yyerror("Server passwords cannot contain spaces");
2265 <    else {
2266 <      if (yy_aconf->spasswd != NULL)
2267 <        memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd));
2045 >  if (conf_parser_ctx.pass != 2)
2046 >    break;
2047  
2048 <      MyFree(yy_aconf->spasswd);
2049 <      DupString(yy_aconf->spasswd, yylval.string);
2050 <    }
2051 <  }
2048 >  if ($3[0] == ':')
2049 >    conf_error_report("Server passwords cannot begin with a colon");
2050 >  else if (strchr($3, ' ') != NULL)
2051 >    conf_error_report("Server passwords cannot contain spaces");
2052 >  else
2053 >    strlcpy(block_state.spass.buf, yylval.string, sizeof(block_state.spass.buf));
2054   };
2055  
2056   connect_accept_password: ACCEPT_PASSWORD '=' QSTRING ';'
2057   {
2058 <  if (conf_parser_ctx.pass == 2)
2059 <  {
2279 <    if ($3[0] == ':')
2280 <      yyerror("Server passwords cannot begin with a colon");
2281 <    else if (strchr($3, ' ') != NULL)
2282 <      yyerror("Server passwords cannot contain spaces");
2283 <    else {
2284 <      if (yy_aconf->passwd != NULL)
2285 <        memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
2058 >  if (conf_parser_ctx.pass != 2)
2059 >    break;
2060  
2061 <      MyFree(yy_aconf->passwd);
2062 <      DupString(yy_aconf->passwd, yylval.string);
2063 <    }
2064 <  }
2061 >  if ($3[0] == ':')
2062 >    conf_error_report("Server passwords cannot begin with a colon");
2063 >  else if (strchr($3, ' ') != NULL)
2064 >    conf_error_report("Server passwords cannot contain spaces");
2065 >  else
2066 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2067   };
2068  
2069   connect_port: PORT '=' NUMBER ';'
2070   {
2071    if (conf_parser_ctx.pass == 2)
2072 <    yy_aconf->port = $3;
2072 >    block_state.port.value = $3;
2073   };
2074  
2075   connect_aftype: AFTYPE '=' T_IPV4 ';'
2076   {
2077    if (conf_parser_ctx.pass == 2)
2078 <    yy_aconf->aftype = AF_INET;
2078 >    block_state.aftype.value = AF_INET;
2079   } | AFTYPE '=' T_IPV6 ';'
2080   {
2081   #ifdef IPV6
2082    if (conf_parser_ctx.pass == 2)
2083 <    yy_aconf->aftype = AF_INET6;
2083 >    block_state.aftype.value = AF_INET6;
2084   #endif
2085   };
2086  
2087   connect_flags: IRCD_FLAGS
2088   {
2089 +  block_state.flags.value &= CONF_FLAGS_ENCRYPTED;
2090   } '='  connect_flags_items ';';
2091  
2092   connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;
2093 < connect_flags_item: COMPRESSED
2317 < {
2318 <  if (conf_parser_ctx.pass == 2)
2319 < #ifndef HAVE_LIBZ
2320 <    yyerror("Ignoring flags = compressed; -- no zlib support");
2321 < #else
2322 < {
2323 <   SetConfCompressed(yy_aconf);
2324 < }
2325 < #endif
2326 < } | CRYPTLINK
2327 < {
2328 <  if (conf_parser_ctx.pass == 2)
2329 <    SetConfCryptLink(yy_aconf);
2330 < } | AUTOCONN
2331 < {
2332 <  if (conf_parser_ctx.pass == 2)
2333 <    SetConfAllowAutoConn(yy_aconf);
2334 < } | BURST_AWAY
2093 > connect_flags_item: AUTOCONN
2094   {
2095    if (conf_parser_ctx.pass == 2)
2096 <    SetConfAwayBurst(yy_aconf);
2097 < } | TOPICBURST
2096 >    block_state.flags.value |= CONF_FLAGS_ALLOW_AUTO_CONN;
2097 > } | T_SSL
2098   {
2099    if (conf_parser_ctx.pass == 2)
2100 <    SetConfTopicBurst(yy_aconf);
2342 < };
2343 <
2344 < connect_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
2345 < {
2346 < #ifdef HAVE_LIBCRYPTO
2347 <  if (conf_parser_ctx.pass == 2)
2348 <  {
2349 <    BIO *file;
2350 <
2351 <    if (yy_aconf->rsa_public_key != NULL)
2352 <    {
2353 <      RSA_free(yy_aconf->rsa_public_key);
2354 <      yy_aconf->rsa_public_key = NULL;
2355 <    }
2356 <
2357 <    if (yy_aconf->rsa_public_key_file != NULL)
2358 <    {
2359 <      MyFree(yy_aconf->rsa_public_key_file);
2360 <      yy_aconf->rsa_public_key_file = NULL;
2361 <    }
2362 <
2363 <    DupString(yy_aconf->rsa_public_key_file, yylval.string);
2364 <
2365 <    if ((file = BIO_new_file(yylval.string, "r")) == NULL)
2366 <    {
2367 <      yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
2368 <      break;
2369 <    }
2370 <
2371 <    yy_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
2372 <
2373 <    if (yy_aconf->rsa_public_key == NULL)
2374 <    {
2375 <      yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
2376 <      break;
2377 <    }
2378 <      
2379 <    BIO_set_close(file, BIO_CLOSE);
2380 <    BIO_free(file);
2381 <  }
2382 < #endif /* HAVE_LIBCRYPTO */
2100 >    block_state.flags.value |= CONF_FLAGS_SSL;
2101   };
2102  
2103   connect_encrypted: ENCRYPTED '=' TBOOL ';'
# Line 2387 | Line 2105 | connect_encrypted: ENCRYPTED '=' TBOOL '
2105    if (conf_parser_ctx.pass == 2)
2106    {
2107      if (yylval.number)
2108 <      yy_aconf->flags |= CONF_FLAGS_ENCRYPTED;
2108 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
2109      else
2110 <      yy_aconf->flags &= ~CONF_FLAGS_ENCRYPTED;
2110 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
2111    }
2112   };
2113  
2114   connect_hub_mask: HUB_MASK '=' QSTRING ';'
2115   {
2116    if (conf_parser_ctx.pass == 2)
2117 <  {
2400 <    struct CollectItem *yy_tmp;
2401 <
2402 <    yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2403 <    DupString(yy_tmp->host, yylval.string);
2404 <    DupString(yy_tmp->user, "*");
2405 <    dlinkAdd(yy_tmp, &yy_tmp->node, &hub_conf_list);
2406 <  }
2117 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.hub.list);
2118   };
2119  
2120   connect_leaf_mask: LEAF_MASK '=' QSTRING ';'
2121   {
2122    if (conf_parser_ctx.pass == 2)
2123 <  {
2413 <    struct CollectItem *yy_tmp;
2414 <
2415 <    yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2416 <    DupString(yy_tmp->host, yylval.string);
2417 <    DupString(yy_tmp->user, "*");
2418 <    dlinkAdd(yy_tmp, &yy_tmp->node, &leaf_conf_list);
2419 <  }
2123 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.leaf.list);
2124   };
2125  
2126   connect_class: CLASS '=' QSTRING ';'
2127   {
2128    if (conf_parser_ctx.pass == 2)
2129 <  {
2426 <    MyFree(class_name);
2427 <    DupString(class_name, yylval.string);
2428 <  }
2129 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
2130   };
2131  
2132 < connect_cipher_preference: CIPHER_PREFERENCE '=' QSTRING ';'
2132 > connect_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
2133   {
2134   #ifdef HAVE_LIBCRYPTO
2135    if (conf_parser_ctx.pass == 2)
2136 <  {
2436 <    struct EncCapability *ecap;
2437 <    const char *cipher_name;
2438 <    int found = 0;
2439 <
2440 <    yy_aconf->cipher_preference = NULL;
2441 <    cipher_name = yylval.string;
2442 <
2443 <    for (ecap = CipherTable; ecap->name; ecap++)
2444 <    {
2445 <      if ((irccmp(ecap->name, cipher_name) == 0) &&
2446 <          (ecap->cap & CAP_ENC_MASK))
2447 <      {
2448 <        yy_aconf->cipher_preference = ecap;
2449 <        found = 1;
2450 <        break;
2451 <      }
2452 <    }
2453 <
2454 <    if (!found)
2455 <      yyerror("Invalid cipher");
2456 <  }
2136 >    strlcpy(block_state.ciph.buf, yylval.string, sizeof(block_state.ciph.buf));
2137   #else
2138    if (conf_parser_ctx.pass == 2)
2139 <    yyerror("Ignoring cipher_preference -- no OpenSSL support");
2139 >    conf_error_report("Ignoring connect::ciphers -- no OpenSSL support");
2140   #endif
2141   };
2142  
2143 +
2144   /***************************************************************************
2145   *  section kill
2146   ***************************************************************************/
2147   kill_entry: KILL
2148   {
2149    if (conf_parser_ctx.pass == 2)
2150 <  {
2470 <    userbuf[0] = hostbuf[0] = reasonbuf[0] = '\0';
2471 <    regex_ban = 0;
2472 <  }
2150 >    reset_block_state();
2151   } '{' kill_items '}' ';'
2152   {
2153 <  if (conf_parser_ctx.pass == 2)
2476 <  {
2477 <    if (userbuf[0] && hostbuf[0])
2478 <    {
2479 <      if (regex_ban)
2480 <      {
2481 < #ifdef HAVE_LIBPCRE
2482 <        void *exp_user = NULL;
2483 <        void *exp_host = NULL;
2484 <        const char *errptr = NULL;
2485 <
2486 <        if (!(exp_user = ircd_pcre_compile(userbuf, &errptr)) ||
2487 <            !(exp_host = ircd_pcre_compile(hostbuf, &errptr)))
2488 <        {
2489 <          ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: %s",
2490 <               errptr);
2491 <          break;
2492 <        }
2493 <
2494 <        yy_aconf = map_to_conf(make_conf_item(RKLINE_TYPE));
2495 <        yy_aconf->regexuser = exp_user;
2496 <        yy_aconf->regexhost = exp_host;
2497 <
2498 <        DupString(yy_aconf->user, userbuf);
2499 <        DupString(yy_aconf->host, hostbuf);
2153 >  struct MaskItem *conf = NULL;
2154  
2155 <        if (reasonbuf[0])
2156 <          DupString(yy_aconf->reason, reasonbuf);
2503 <        else
2504 <          DupString(yy_aconf->reason, "No reason");
2505 < #else
2506 <        ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: no PCRE support");
2507 <        break;
2508 < #endif
2509 <      }
2510 <      else
2511 <      {
2512 <        yy_aconf = map_to_conf(make_conf_item(KLINE_TYPE));
2155 >  if (conf_parser_ctx.pass != 2)
2156 >    break;
2157  
2158 <        DupString(yy_aconf->user, userbuf);
2159 <        DupString(yy_aconf->host, hostbuf);
2158 >  if (!block_state.user.buf[0] ||
2159 >      !block_state.host.buf[0])
2160 >    break;
2161  
2162 <        if (reasonbuf[0])
2163 <          DupString(yy_aconf->reason, reasonbuf);
2164 <        else
2520 <          DupString(yy_aconf->reason, "No reason");
2521 <        add_conf_by_address(CONF_KILL, yy_aconf);
2522 <      }
2523 <    }
2162 >  conf = conf_make(CONF_KLINE);
2163 >  conf->user = xstrdup(block_state.user.buf);
2164 >  conf->host = xstrdup(block_state.host.buf);
2165  
2166 <    yy_aconf = NULL;
2167 <  }
2166 >  if (block_state.rpass.buf[0])
2167 >    conf->reason = xstrdup(block_state.rpass.buf);
2168 >  else
2169 >    conf->reason = xstrdup(CONF_NOREASON);
2170 >  add_conf_by_address(CONF_KLINE, conf);
2171   };
2172  
2529 kill_type: TYPE
2530 {
2531 } '='  kill_type_items ';';
2532
2533 kill_type_items: kill_type_items ',' kill_type_item | kill_type_item;
2534 kill_type_item: REGEX_T
2535 {
2536  if (conf_parser_ctx.pass == 2)
2537    regex_ban = 1;
2538 };
2539
2173   kill_items:     kill_items kill_item | kill_item;
2174 < kill_item:      kill_user | kill_reason | kill_type | error;
2174 > kill_item:      kill_user | kill_reason | error;
2175  
2176   kill_user: USER '=' QSTRING ';'
2177   {
2178 +
2179    if (conf_parser_ctx.pass == 2)
2180    {
2181      struct split_nuh_item nuh;
2182  
2183      nuh.nuhmask  = yylval.string;
2184      nuh.nickptr  = NULL;
2185 <    nuh.userptr  = userbuf;
2186 <    nuh.hostptr  = hostbuf;
2185 >    nuh.userptr  = block_state.user.buf;
2186 >    nuh.hostptr  = block_state.host.buf;
2187  
2188      nuh.nicksize = 0;
2189 <    nuh.usersize = sizeof(userbuf);
2190 <    nuh.hostsize = sizeof(hostbuf);
2189 >    nuh.usersize = sizeof(block_state.user.buf);
2190 >    nuh.hostsize = sizeof(block_state.host.buf);
2191  
2192      split_nuh(&nuh);
2193    }
# Line 2562 | Line 2196 | kill_user: USER '=' QSTRING ';'
2196   kill_reason: REASON '=' QSTRING ';'
2197   {
2198    if (conf_parser_ctx.pass == 2)
2199 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2199 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2200   };
2201  
2202   /***************************************************************************
# Line 2571 | Line 2205 | kill_reason: REASON '=' QSTRING ';'
2205   deny_entry: DENY
2206   {
2207    if (conf_parser_ctx.pass == 2)
2208 <    hostbuf[0] = reasonbuf[0] = '\0';
2208 >    reset_block_state();
2209   } '{' deny_items '}' ';'
2210   {
2211 <  if (conf_parser_ctx.pass == 2)
2211 >  struct MaskItem *conf = NULL;
2212 >
2213 >  if (conf_parser_ctx.pass != 2)
2214 >    break;
2215 >
2216 >  if (!block_state.addr.buf[0])
2217 >    break;
2218 >
2219 >  if (parse_netmask(block_state.addr.buf, NULL, NULL) != HM_HOST)
2220    {
2221 <    if (hostbuf[0] && parse_netmask(hostbuf, NULL, NULL) != HM_HOST)
2222 <    {
2581 <      yy_aconf = map_to_conf(make_conf_item(DLINE_TYPE));
2582 <      DupString(yy_aconf->host, hostbuf);
2221 >    conf = conf_make(CONF_DLINE);
2222 >    conf->host = xstrdup(block_state.addr.buf);
2223  
2224 <      if (reasonbuf[0])
2225 <        DupString(yy_aconf->reason, reasonbuf);
2226 <      else
2227 <        DupString(yy_aconf->reason, "No reason");
2228 <      add_conf_by_address(CONF_DLINE, yy_aconf);
2589 <      yy_aconf = NULL;
2590 <    }
2224 >    if (block_state.rpass.buf[0])
2225 >      conf->reason = xstrdup(block_state.rpass.buf);
2226 >    else
2227 >      conf->reason = xstrdup(CONF_NOREASON);
2228 >    add_conf_by_address(CONF_DLINE, conf);
2229    }
2230   };
2231  
# Line 2597 | Line 2235 | deny_item:      deny_ip | deny_reason |
2235   deny_ip: IP '=' QSTRING ';'
2236   {
2237    if (conf_parser_ctx.pass == 2)
2238 <    strlcpy(hostbuf, yylval.string, sizeof(hostbuf));
2238 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
2239   };
2240  
2241   deny_reason: REASON '=' QSTRING ';'
2242   {
2243    if (conf_parser_ctx.pass == 2)
2244 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2244 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2245   };
2246  
2247   /***************************************************************************
# Line 2620 | Line 2258 | exempt_ip: IP '=' QSTRING ';'
2258    {
2259      if (yylval.string[0] && parse_netmask(yylval.string, NULL, NULL) != HM_HOST)
2260      {
2261 <      yy_aconf = map_to_conf(make_conf_item(EXEMPTDLINE_TYPE));
2262 <      DupString(yy_aconf->host, yylval.string);
2261 >      struct MaskItem *conf = conf_make(CONF_EXEMPT);
2262 >      conf->host = xstrdup(yylval.string);
2263  
2264 <      add_conf_by_address(CONF_EXEMPTDLINE, yy_aconf);
2627 <      yy_aconf = NULL;
2264 >      add_conf_by_address(CONF_EXEMPT, conf);
2265      }
2266    }
2267   };
# Line 2635 | Line 2272 | exempt_ip: IP '=' QSTRING ';'
2272   gecos_entry: GECOS
2273   {
2274    if (conf_parser_ctx.pass == 2)
2275 <  {
2639 <    regex_ban = 0;
2640 <    reasonbuf[0] = gecos_name[0] = '\0';
2641 <  }
2275 >    reset_block_state();
2276   } '{' gecos_items '}' ';'
2277   {
2278 <  if (conf_parser_ctx.pass == 2)
2645 <  {
2646 <    if (gecos_name[0])
2647 <    {
2648 <      if (regex_ban)
2649 <      {
2650 < #ifdef HAVE_LIBPCRE
2651 <        void *exp_p = NULL;
2652 <        const char *errptr = NULL;
2653 <
2654 <        if (!(exp_p = ircd_pcre_compile(gecos_name, &errptr)))
2655 <        {
2656 <          ilog(LOG_TYPE_IRCD, "Failed to add regular expression based X-Line: %s",
2657 <               errptr);
2658 <          break;
2659 <        }
2278 >  struct MaskItem *conf = NULL;
2279  
2280 <        yy_conf = make_conf_item(RXLINE_TYPE);
2281 <        yy_conf->regexpname = exp_p;
2663 < #else
2664 <        ilog(LOG_TYPE_IRCD, "Failed to add regular expression based X-Line: no PCRE support");
2665 <        break;
2666 < #endif
2667 <      }
2668 <      else
2669 <        yy_conf = make_conf_item(XLINE_TYPE);
2280 >  if (conf_parser_ctx.pass != 2)
2281 >    break;
2282  
2283 <      yy_match_item = map_to_conf(yy_conf);
2284 <      DupString(yy_conf->name, gecos_name);
2283 >  if (!block_state.name.buf[0])
2284 >    break;
2285  
2286 <      if (reasonbuf[0])
2287 <        DupString(yy_match_item->reason, reasonbuf);
2676 <      else
2677 <        DupString(yy_match_item->reason, "No reason");
2678 <    }
2679 <  }
2680 < };
2681 <
2682 < gecos_flags: TYPE
2683 < {
2684 < } '='  gecos_flags_items ';';
2286 >  conf = conf_make(CONF_XLINE);
2287 >  conf->name = xstrdup(block_state.name.buf);
2288  
2289 < gecos_flags_items: gecos_flags_items ',' gecos_flags_item | gecos_flags_item;
2290 < gecos_flags_item: REGEX_T
2291 < {
2292 <  if (conf_parser_ctx.pass == 2)
2690 <    regex_ban = 1;
2289 >  if (block_state.rpass.buf[0])
2290 >    conf->reason = xstrdup(block_state.rpass.buf);
2291 >  else
2292 >    conf->reason = xstrdup(CONF_NOREASON);
2293   };
2294  
2295   gecos_items: gecos_items gecos_item | gecos_item;
2296 < gecos_item:  gecos_name | gecos_reason | gecos_flags | error;
2296 > gecos_item:  gecos_name | gecos_reason | error;
2297  
2298   gecos_name: NAME '=' QSTRING ';'
2299   {
2300    if (conf_parser_ctx.pass == 2)
2301 <    strlcpy(gecos_name, yylval.string, sizeof(gecos_name));
2301 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
2302   };
2303  
2304   gecos_reason: REASON '=' QSTRING ';'
2305   {
2306    if (conf_parser_ctx.pass == 2)
2307 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2307 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2308   };
2309  
2310   /***************************************************************************
# Line 2717 | Line 2319 | general_item:       general_hide_spoof_i
2319                      general_max_nick_time | general_max_nick_changes |
2320                      general_max_accept | general_anti_spam_exit_message_time |
2321                      general_ts_warn_delta | general_ts_max_delta |
2322 <                    general_kill_chase_time_limit | general_kline_with_reason |
2323 <                    general_kline_reason | general_invisible_on_connect |
2322 >                    general_kill_chase_time_limit |
2323 >                    general_invisible_on_connect |
2324                      general_warn_no_nline | general_dots_in_ident |
2325                      general_stats_o_oper_only | general_stats_k_oper_only |
2326                      general_pace_wait | general_stats_i_oper_only |
2327                      general_pace_wait_simple | general_stats_P_oper_only |
2328                      general_short_motd | general_no_oper_flood |
2329                      general_true_no_oper_flood | general_oper_pass_resv |
2728                    general_message_locale |
2330                      general_oper_only_umodes | general_max_targets |
2331                      general_use_egd | general_egdpool_path |
2332                      general_oper_umodes | general_caller_id_wait |
2333                      general_opers_bypass_callerid | general_default_floodcount |
2334                      general_min_nonwildcard | general_min_nonwildcard_simple |
2335 <                    general_servlink_path | general_disable_remote_commands |
2735 <                    general_default_cipher_preference |
2736 <                    general_compression_level | general_client_flood |
2335 >                    general_disable_remote_commands |
2336                      general_throttle_time | general_havent_read_conf |
2337                      general_ping_cookie |
2338 <                    general_disable_auth | general_burst_away |
2339 <                    general_tkline_expire_notices | general_gline_min_cidr |
2340 <                    general_gline_min_cidr6 | general_use_whois_actually |
2341 <                    general_reject_hold_time | general_stats_e_disabled |
2338 >                    general_disable_auth |
2339 >                    general_tkline_expire_notices | general_gline_enable |
2340 >                    general_gline_duration | general_gline_request_duration |
2341 >                    general_gline_min_cidr |
2342 >                    general_gline_min_cidr6 |
2343 >                    general_stats_e_disabled |
2344                      general_max_watch | general_services_name |
2345                      error;
2346  
# Line 2749 | Line 2350 | general_max_watch: MAX_WATCH '=' NUMBER
2350    ConfigFileEntry.max_watch = $3;
2351   };
2352  
2353 < general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
2353 > general_gline_enable: GLINE_ENABLE '=' TBOOL ';'
2354   {
2355 <  ConfigFileEntry.gline_min_cidr = $3;
2355 >  if (conf_parser_ctx.pass == 2)
2356 >    ConfigFileEntry.glines = yylval.number;
2357   };
2358  
2359 < general_gline_min_cidr6: GLINE_MIN_CIDR6 '=' NUMBER ';'
2359 > general_gline_duration: GLINE_DURATION '=' timespec ';'
2360   {
2361 <  ConfigFileEntry.gline_min_cidr6 = $3;
2361 >  if (conf_parser_ctx.pass == 2)
2362 >    ConfigFileEntry.gline_time = $3;
2363   };
2364  
2365 < general_burst_away: BURST_AWAY '=' TBOOL ';'
2365 > general_gline_request_duration: GLINE_REQUEST_DURATION '=' timespec ';'
2366   {
2367 <  ConfigFileEntry.burst_away = yylval.number;
2367 >  if (conf_parser_ctx.pass == 2)
2368 >    ConfigFileEntry.gline_request_time = $3;
2369   };
2370  
2371 < general_use_whois_actually: USE_WHOIS_ACTUALLY '=' TBOOL ';'
2371 > general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
2372   {
2373 <  ConfigFileEntry.use_whois_actually = yylval.number;
2373 >  ConfigFileEntry.gline_min_cidr = $3;
2374   };
2375  
2376 < general_reject_hold_time: TREJECT_HOLD_TIME '=' timespec ';'
2376 > general_gline_min_cidr6: GLINE_MIN_CIDR6 '=' NUMBER ';'
2377   {
2378 <  GlobalSetOptions.rejecttime = yylval.number;
2378 >  ConfigFileEntry.gline_min_cidr6 = $3;
2379   };
2380  
2381   general_tkline_expire_notices: TKLINE_EXPIRE_NOTICES '=' TBOOL ';'
# Line 2851 | Line 2455 | general_havent_read_conf: HAVENT_READ_CO
2455    }
2456   };
2457  
2854 general_kline_with_reason: KLINE_WITH_REASON '=' TBOOL ';'
2855 {
2856  ConfigFileEntry.kline_with_reason = yylval.number;
2857 };
2858
2859 general_kline_reason: KLINE_REASON '=' QSTRING ';'
2860 {
2861  if (conf_parser_ctx.pass == 2)
2862  {
2863    MyFree(ConfigFileEntry.kline_reason);
2864    DupString(ConfigFileEntry.kline_reason, yylval.string);
2865  }
2866 };
2867
2458   general_invisible_on_connect: INVISIBLE_ON_CONNECT '=' TBOOL ';'
2459   {
2460    ConfigFileEntry.invisible_on_connect = yylval.number;
# Line 2946 | Line 2536 | general_oper_pass_resv: OPER_PASS_RESV '
2536    ConfigFileEntry.oper_pass_resv = yylval.number;
2537   };
2538  
2949 general_message_locale: MESSAGE_LOCALE '=' QSTRING ';'
2950 {
2951  if (conf_parser_ctx.pass == 2)
2952  {
2953    if (strlen(yylval.string) > LOCALE_LENGTH-2)
2954      yylval.string[LOCALE_LENGTH-1] = '\0';
2955
2956    set_locale(yylval.string);
2957  }
2958 };
2959
2539   general_dots_in_ident: DOTS_IN_IDENT '=' NUMBER ';'
2540   {
2541    ConfigFileEntry.dots_in_ident = $3;
# Line 2967 | Line 2546 | general_max_targets: MAX_TARGETS '=' NUM
2546    ConfigFileEntry.max_targets = $3;
2547   };
2548  
2970 general_servlink_path: SERVLINK_PATH '=' QSTRING ';'
2971 {
2972  if (conf_parser_ctx.pass == 2)
2973  {
2974    MyFree(ConfigFileEntry.servlink_path);
2975    DupString(ConfigFileEntry.servlink_path, yylval.string);
2976  }
2977 };
2978
2979 general_default_cipher_preference: DEFAULT_CIPHER_PREFERENCE '=' QSTRING ';'
2980 {
2981 #ifdef HAVE_LIBCRYPTO
2982  if (conf_parser_ctx.pass == 2)
2983  {
2984    struct EncCapability *ecap;
2985    const char *cipher_name;
2986    int found = 0;
2987
2988    ConfigFileEntry.default_cipher_preference = NULL;
2989    cipher_name = yylval.string;
2990
2991    for (ecap = CipherTable; ecap->name; ecap++)
2992    {
2993      if ((irccmp(ecap->name, cipher_name) == 0) &&
2994          (ecap->cap & CAP_ENC_MASK))
2995      {
2996        ConfigFileEntry.default_cipher_preference = ecap;
2997        found = 1;
2998        break;
2999      }
3000    }
3001
3002    if (!found)
3003      yyerror("Invalid cipher");
3004  }
3005 #else
3006  if (conf_parser_ctx.pass == 2)
3007    yyerror("Ignoring default_cipher_preference -- no OpenSSL support");
3008 #endif
3009 };
3010
3011 general_compression_level: COMPRESSION_LEVEL '=' NUMBER ';'
3012 {
3013  if (conf_parser_ctx.pass == 2)
3014  {
3015    ConfigFileEntry.compression_level = $3;
3016 #ifndef HAVE_LIBZ
3017    yyerror("Ignoring compression_level -- no zlib support");
3018 #else
3019    if ((ConfigFileEntry.compression_level < 1) ||
3020        (ConfigFileEntry.compression_level > 9))
3021    {
3022      yyerror("Ignoring invalid compression_level, using default");
3023      ConfigFileEntry.compression_level = 0;
3024    }
3025 #endif
3026  }
3027 };
3028
2549   general_use_egd: USE_EGD '=' TBOOL ';'
2550   {
2551    ConfigFileEntry.use_egd = yylval.number;
# Line 3036 | Line 2556 | general_egdpool_path: EGDPOOL_PATH '=' Q
2556    if (conf_parser_ctx.pass == 2)
2557    {
2558      MyFree(ConfigFileEntry.egdpool_path);
2559 <    DupString(ConfigFileEntry.egdpool_path, yylval.string);
2559 >    ConfigFileEntry.egdpool_path = xstrdup(yylval.string);
2560    }
2561   };
2562  
# Line 3045 | Line 2565 | general_services_name: T_SERVICES_NAME '
2565    if (conf_parser_ctx.pass == 2 && valid_servname(yylval.string))
2566    {
2567      MyFree(ConfigFileEntry.service_name);
2568 <    DupString(ConfigFileEntry.service_name, yylval.string);
2568 >    ConfigFileEntry.service_name = xstrdup(yylval.string);
2569    }
2570   };
2571  
# Line 3088 | Line 2608 | umode_oitem:     T_BOTS
2608   } | T_FULL
2609   {
2610    ConfigFileEntry.oper_umodes |= UMODE_FULL;
2611 + } | HIDDEN
2612 + {
2613 +  ConfigFileEntry.oper_umodes |= UMODE_HIDDEN;
2614   } | T_SKILL
2615   {
2616    ConfigFileEntry.oper_umodes |= UMODE_SKILL;
# Line 3127 | Line 2650 | umode_oitem:     T_BOTS
2650   } | T_LOCOPS
2651   {
2652    ConfigFileEntry.oper_umodes |= UMODE_LOCOPS;
2653 + } | T_NONONREG
2654 + {
2655 +  ConfigFileEntry.oper_umodes |= UMODE_REGONLY;
2656 + } | T_FARCONNECT
2657 + {
2658 +  ConfigFileEntry.oper_umodes |= UMODE_FARCONNECT;
2659   };
2660  
2661   general_oper_only_umodes: OPER_ONLY_UMODES
# Line 3156 | Line 2685 | umode_item:    T_BOTS
2685   } | T_SKILL
2686   {
2687    ConfigFileEntry.oper_only_umodes |= UMODE_SKILL;
2688 + } | HIDDEN
2689 + {
2690 +  ConfigFileEntry.oper_only_umodes |= UMODE_HIDDEN;
2691   } | T_NCHANGE
2692   {
2693    ConfigFileEntry.oper_only_umodes |= UMODE_NCHANGE;
# Line 3192 | Line 2724 | umode_item:    T_BOTS
2724   } | T_LOCOPS
2725   {
2726    ConfigFileEntry.oper_only_umodes |= UMODE_LOCOPS;
2727 + } | T_NONONREG
2728 + {
2729 +  ConfigFileEntry.oper_only_umodes |= UMODE_REGONLY;
2730 + } | T_FARCONNECT
2731 + {
2732 +  ConfigFileEntry.oper_only_umodes |= UMODE_FARCONNECT;
2733   };
2734  
2735   general_min_nonwildcard: MIN_NONWILDCARD '=' NUMBER ';'
# Line 3209 | Line 2747 | general_default_floodcount: DEFAULT_FLOO
2747    ConfigFileEntry.default_floodcount = $3;
2748   };
2749  
3212 general_client_flood: T_CLIENT_FLOOD '=' sizespec ';'
3213 {
3214  ConfigFileEntry.client_flood = $3;
3215 };
3216
3217
3218 /***************************************************************************
3219 *  section glines
3220 ***************************************************************************/
3221 gline_entry: GLINES
3222 {
3223  if (conf_parser_ctx.pass == 2)
3224  {
3225    yy_conf = make_conf_item(GDENY_TYPE);
3226    yy_aconf = map_to_conf(yy_conf);
3227  }
3228 } '{' gline_items '}' ';'
3229 {
3230  if (conf_parser_ctx.pass == 2)
3231  {
3232    /*
3233     * since we re-allocate yy_conf/yy_aconf after the end of action=, at the
3234     * end we will have one extra, so we should free it.
3235     */
3236    if (yy_conf->name == NULL || yy_aconf->user == NULL)
3237    {
3238      delete_conf_item(yy_conf);
3239      yy_conf = NULL;
3240      yy_aconf = NULL;
3241    }
3242  }
3243 };
3244
3245 gline_items:        gline_items gline_item | gline_item;
3246 gline_item:         gline_enable |
3247                    gline_duration |
3248                    gline_logging |
3249                    gline_user |
3250                    gline_server |
3251                    gline_action |
3252                    error;
3253
3254 gline_enable: ENABLE '=' TBOOL ';'
3255 {
3256  if (conf_parser_ctx.pass == 2)
3257    ConfigFileEntry.glines = yylval.number;
3258 };
3259
3260 gline_duration: DURATION '=' timespec ';'
3261 {
3262  if (conf_parser_ctx.pass == 2)
3263    ConfigFileEntry.gline_time = $3;
3264 };
3265
3266 gline_logging: T_LOG
3267 {
3268  if (conf_parser_ctx.pass == 2)
3269    ConfigFileEntry.gline_logging = 0;
3270 } '=' gline_logging_types ';';
3271 gline_logging_types:     gline_logging_types ',' gline_logging_type_item | gline_logging_type_item;
3272 gline_logging_type_item: T_REJECT
3273 {
3274  if (conf_parser_ctx.pass == 2)
3275    ConfigFileEntry.gline_logging |= GDENY_REJECT;
3276 } | T_BLOCK
3277 {
3278  if (conf_parser_ctx.pass == 2)
3279    ConfigFileEntry.gline_logging |= GDENY_BLOCK;
3280 };
3281
3282 gline_user: USER '=' QSTRING ';'
3283 {
3284  if (conf_parser_ctx.pass == 2)
3285  {
3286    struct split_nuh_item nuh;
3287
3288    nuh.nuhmask  = yylval.string;
3289    nuh.nickptr  = NULL;
3290    nuh.userptr  = userbuf;
3291    nuh.hostptr  = hostbuf;
3292
3293    nuh.nicksize = 0;
3294    nuh.usersize = sizeof(userbuf);
3295    nuh.hostsize = sizeof(hostbuf);
3296
3297    split_nuh(&nuh);
3298
3299    if (yy_aconf->user == NULL)
3300    {
3301      DupString(yy_aconf->user, userbuf);
3302      DupString(yy_aconf->host, hostbuf);
3303    }
3304    else
3305    {
3306      struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
3307
3308      DupString(yy_tmp->user, userbuf);
3309      DupString(yy_tmp->host, hostbuf);
3310
3311      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
3312    }
3313  }
3314 };
3315
3316 gline_server: NAME '=' QSTRING ';'
3317 {
3318  if (conf_parser_ctx.pass == 2)  
3319  {
3320    MyFree(yy_conf->name);
3321    DupString(yy_conf->name, yylval.string);
3322  }
3323 };
3324
3325 gline_action: ACTION
3326 {
3327  if (conf_parser_ctx.pass == 2)
3328    yy_aconf->flags = 0;
3329 } '=' gdeny_types ';'
3330 {
3331  if (conf_parser_ctx.pass == 2)
3332  {
3333    struct CollectItem *yy_tmp = NULL;
3334    dlink_node *ptr, *next_ptr;
3335
3336    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
3337    {
3338      struct AccessItem *new_aconf;
3339      struct ConfItem *new_conf;
3340
3341      yy_tmp = ptr->data;
3342      new_conf = make_conf_item(GDENY_TYPE);
3343      new_aconf = map_to_conf(new_conf);
3344
3345      new_aconf->flags = yy_aconf->flags;
3346
3347      if (yy_conf->name != NULL)
3348        DupString(new_conf->name, yy_conf->name);
3349      else
3350        DupString(new_conf->name, "*");
3351      if (yy_aconf->user != NULL)
3352         DupString(new_aconf->user, yy_tmp->user);
3353      else  
3354        DupString(new_aconf->user, "*");
3355      if (yy_aconf->host != NULL)
3356        DupString(new_aconf->host, yy_tmp->host);
3357      else
3358        DupString(new_aconf->host, "*");
3359
3360      dlinkDelete(&yy_tmp->node, &col_conf_list);
3361    }
3362
3363    /*
3364     * In case someone has fed us with more than one action= after user/name
3365     * which would leak memory  -Michael
3366     */
3367    if (yy_conf->name == NULL || yy_aconf->user == NULL)
3368      delete_conf_item(yy_conf);
3369
3370    yy_conf = make_conf_item(GDENY_TYPE);
3371    yy_aconf = map_to_conf(yy_conf);
3372  }
3373 };
3374
3375 gdeny_types: gdeny_types ',' gdeny_type_item | gdeny_type_item;
3376 gdeny_type_item: T_REJECT
3377 {
3378  if (conf_parser_ctx.pass == 2)
3379    yy_aconf->flags |= GDENY_REJECT;
3380 } | T_BLOCK
3381 {
3382  if (conf_parser_ctx.pass == 2)
3383    yy_aconf->flags |= GDENY_BLOCK;
3384 };
2750  
2751   /***************************************************************************
2752   *  section channel
# Line 3390 | Line 2755 | channel_entry: CHANNEL
2755    '{' channel_items '}' ';';
2756  
2757   channel_items:      channel_items channel_item | channel_item;
2758 < channel_item:       channel_disable_local_channels | channel_use_except |
2759 <                    channel_use_invex | channel_use_knock |
2760 <                    channel_max_bans | channel_knock_delay |
2761 <                    channel_knock_delay_channel | channel_max_chans_per_user |
3397 <                    channel_quiet_on_ban | channel_default_split_user_count |
2758 > channel_item:       channel_max_bans |
2759 >                    channel_knock_delay | channel_knock_delay_channel |
2760 >                    channel_max_chans_per_user | channel_max_chans_per_oper |
2761 >                    channel_default_split_user_count |
2762                      channel_default_split_server_count |
2763 <                    channel_no_create_on_split | channel_restrict_channels |
2764 <                    channel_no_join_on_split | channel_burst_topicwho |
2763 >                    channel_no_create_on_split |
2764 >                    channel_no_join_on_split |
2765                      channel_jflood_count | channel_jflood_time |
2766                      channel_disable_fake_channels | error;
2767  
# Line 3406 | Line 2770 | channel_disable_fake_channels: DISABLE_F
2770    ConfigChannel.disable_fake_channels = yylval.number;
2771   };
2772  
3409 channel_restrict_channels: RESTRICT_CHANNELS '=' TBOOL ';'
3410 {
3411  ConfigChannel.restrict_channels = yylval.number;
3412 };
3413
3414 channel_disable_local_channels: DISABLE_LOCAL_CHANNELS '=' TBOOL ';'
3415 {
3416  ConfigChannel.disable_local_channels = yylval.number;
3417 };
3418
3419 channel_use_except: USE_EXCEPT '=' TBOOL ';'
3420 {
3421  ConfigChannel.use_except = yylval.number;
3422 };
3423
3424 channel_use_invex: USE_INVEX '=' TBOOL ';'
3425 {
3426  ConfigChannel.use_invex = yylval.number;
3427 };
3428
3429 channel_use_knock: USE_KNOCK '=' TBOOL ';'
3430 {
3431  ConfigChannel.use_knock = yylval.number;
3432 };
3433
2773   channel_knock_delay: KNOCK_DELAY '=' timespec ';'
2774   {
2775    ConfigChannel.knock_delay = $3;
# Line 3446 | Line 2785 | channel_max_chans_per_user: MAX_CHANS_PE
2785    ConfigChannel.max_chans_per_user = $3;
2786   };
2787  
2788 < channel_quiet_on_ban: QUIET_ON_BAN '=' TBOOL ';'
2788 > channel_max_chans_per_oper: MAX_CHANS_PER_OPER '=' NUMBER ';'
2789   {
2790 <  ConfigChannel.quiet_on_ban = yylval.number;
2790 >  ConfigChannel.max_chans_per_oper = $3;
2791   };
2792  
2793   channel_max_bans: MAX_BANS '=' NUMBER ';'
# Line 3476 | Line 2815 | channel_no_join_on_split: NO_JOIN_ON_SPL
2815    ConfigChannel.no_join_on_split = yylval.number;
2816   };
2817  
3479 channel_burst_topicwho: BURST_TOPICWHO '=' TBOOL ';'
3480 {
3481  ConfigChannel.burst_topicwho = yylval.number;
3482 };
3483
2818   channel_jflood_count: JOIN_FLOOD_COUNT '=' NUMBER ';'
2819   {
2820    GlobalSetOptions.joinfloodcount = yylval.number;
# Line 3499 | Line 2833 | serverhide_entry: SERVERHIDE
2833  
2834   serverhide_items:   serverhide_items serverhide_item | serverhide_item;
2835   serverhide_item:    serverhide_flatten_links | serverhide_hide_servers |
2836 +                    serverhide_hide_services |
2837                      serverhide_links_delay |
3503                    serverhide_disable_hidden |
2838                      serverhide_hidden | serverhide_hidden_name |
2839                      serverhide_hide_server_ips |
2840                      error;
# Line 3517 | Line 2851 | serverhide_hide_servers: HIDE_SERVERS '=
2851      ConfigServerHide.hide_servers = yylval.number;
2852   };
2853  
2854 + serverhide_hide_services: HIDE_SERVICES '=' TBOOL ';'
2855 + {
2856 +  if (conf_parser_ctx.pass == 2)
2857 +    ConfigServerHide.hide_services = yylval.number;
2858 + };
2859 +
2860   serverhide_hidden_name: HIDDEN_NAME '=' QSTRING ';'
2861   {
2862    if (conf_parser_ctx.pass == 2)
2863    {
2864      MyFree(ConfigServerHide.hidden_name);
2865 <    DupString(ConfigServerHide.hidden_name, yylval.string);
2865 >    ConfigServerHide.hidden_name = xstrdup(yylval.string);
2866    }
2867   };
2868  
# Line 3546 | Line 2886 | serverhide_hidden: HIDDEN '=' TBOOL ';'
2886      ConfigServerHide.hidden = yylval.number;
2887   };
2888  
3549 serverhide_disable_hidden: DISABLE_HIDDEN '=' TBOOL ';'
3550 {
3551  if (conf_parser_ctx.pass == 2)
3552    ConfigServerHide.disable_hidden = yylval.number;
3553 };
3554
2889   serverhide_hide_server_ips: HIDE_SERVER_IPS '=' TBOOL ';'
2890   {
2891    if (conf_parser_ctx.pass == 2)

Diff Legend

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