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/trunk/src/conf_parser.y (file contents):
Revision 1592 by michael, Sat Oct 27 21:02:32 2012 UTC vs.
Revision 2185 by michael, Tue Jun 4 12:29:18 2013 UTC

# Line 33 | Line 33
33   #include "ircd.h"
34   #include "list.h"
35   #include "conf.h"
36 + #include "conf_class.h"
37   #include "event.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 47 | Line 47
47   #include "resv.h"
48   #include "numeric.h"
49   #include "s_user.h"
50 + #include "motd.h"
51  
52   #ifdef HAVE_LIBCRYPTO
53   #include <openssl/rsa.h>
# Line 55 | Line 56
56   #include <openssl/dh.h>
57   #endif
58  
59 + #include "rsa.h"
60 +
61   int yylex(void);
62  
63 < static char *class_name = NULL;
64 < static struct ConfItem *yy_conf = NULL;
65 < static struct AccessItem *yy_aconf = NULL;
66 < static struct MatchItem *yy_match_item = NULL;
67 < static struct ClassItem *yy_class = NULL;
68 < static char *yy_class_name = NULL;
69 <
70 < static dlink_list col_conf_list  = { NULL, NULL, 0 };
71 < static unsigned int listener_flags = 0;
72 < static unsigned int regex_ban = 0;
73 < static char userbuf[IRCD_BUFSIZE];
74 < static char hostbuf[IRCD_BUFSIZE];
75 < static char reasonbuf[REASONLEN + 1];
76 < static char gecos_name[REALLEN * 4];
77 < static char lfile[IRCD_BUFSIZE];
78 < static unsigned int ltype = 0;
79 < static unsigned int lsize = 0;
80 < static char *resv_reason = NULL;
81 < static char *listener_address = NULL;
82 <
83 < struct CollectItem
84 < {
85 <  dlink_node node;
86 <  char *name;
87 <  char *user;
88 <  char *host;
89 <  char *passwd;
90 <  int  port;
91 <  int  flags;
92 < #ifdef HAVE_LIBCRYPTO
93 <  char *rsa_public_key_file;
94 <  RSA *rsa_public_key;
95 < #endif
96 < };
63 > static struct
64 > {
65 >  struct {
66 >    dlink_list list;
67 >  } mask,
68 >    leaf,
69 >    hub;
70 >
71 >  struct {
72 >    char buf[IRCD_BUFSIZE];
73 >  } name,
74 >    user,
75 >    host,
76 >    addr,
77 >    bind,
78 >    file,
79 >    ciph,
80 >    rpass,
81 >    spass,
82 >    class;
83 >
84 >  struct {
85 >    unsigned int value;
86 >  } flags,
87 >    modes,
88 >    size,
89 >    type,
90 >    port,
91 >    aftype,
92 >    ping_freq,
93 >    max_perip,
94 >    con_freq,
95 >    min_idle,
96 >    max_idle,
97 >    max_total,
98 >    max_global,
99 >    max_local,
100 >    max_ident,
101 >    max_sendq,
102 >    max_recvq,
103 >    cidr_bitlen_ipv4,
104 >    cidr_bitlen_ipv6,
105 >    number_per_cidr;
106 > } block_state;
107  
108   static void
109 < free_collect_item(struct CollectItem *item)
109 > reset_block_state(void)
110   {
111 <  MyFree(item->name);
112 <  MyFree(item->user);
113 <  MyFree(item->host);
114 <  MyFree(item->passwd);
115 < #ifdef HAVE_LIBCRYPTO
116 <  MyFree(item->rsa_public_key_file);
117 < #endif
118 <  MyFree(item);
111 >  dlink_node *ptr = NULL, *ptr_next = NULL;
112 >
113 >  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.mask.list.head)
114 >  {
115 >    MyFree(ptr->data);
116 >    dlinkDelete(ptr, &block_state.mask.list);
117 >    free_dlink_node(ptr);
118 >  }
119 >
120 >  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.leaf.list.head)
121 >  {
122 >    MyFree(ptr->data);
123 >    dlinkDelete(ptr, &block_state.leaf.list);
124 >    free_dlink_node(ptr);
125 >  }
126 >
127 >  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.hub.list.head)
128 >  {
129 >    MyFree(ptr->data);
130 >    dlinkDelete(ptr, &block_state.hub.list);
131 >    free_dlink_node(ptr);
132 >  }
133 >
134 >  memset(&block_state, 0, sizeof(block_state));
135   }
136  
137   %}
# Line 122 | Line 151 | free_collect_item(struct CollectItem *it
151   %token  CALLER_ID_WAIT
152   %token  CAN_FLOOD
153   %token  CHANNEL
154 < %token  CIDR_BITLEN_IPV4
155 < %token  CIDR_BITLEN_IPV6
154 > %token  CIDR_BITLEN_IPV4
155 > %token  CIDR_BITLEN_IPV6
156   %token  CLASS
157   %token  CONNECT
158   %token  CONNECTFREQ
# Line 143 | Line 172 | free_collect_item(struct CollectItem *it
172   %token  EXCEED_LIMIT
173   %token  EXEMPT
174   %token  FAILED_OPER_NOTICE
146 %token  IRCD_FLAGS
175   %token  FLATTEN_LINKS
176   %token  GECOS
177   %token  GENERAL
# Line 151 | Line 179 | free_collect_item(struct CollectItem *it
179   %token  GLINE_DURATION
180   %token  GLINE_ENABLE
181   %token  GLINE_EXEMPT
154 %token  GLINE_REQUEST_DURATION
182   %token  GLINE_MIN_CIDR
183   %token  GLINE_MIN_CIDR6
184 + %token  GLINE_REQUEST_DURATION
185   %token  GLOBAL_KILL
158 %token  IRCD_AUTH
159 %token  NEED_IDENT
186   %token  HAVENT_READ_CONF
187   %token  HIDDEN
188 < %token  HIDDEN_NAME
188 > %token  HIDDEN_NAME
189 > %token  HIDE_IDLE_FROM_OPERS
190   %token  HIDE_SERVER_IPS
191   %token  HIDE_SERVERS
192 < %token  HIDE_SPOOF_IPS
192 > %token  HIDE_SERVICES
193 > %token  HIDE_SPOOF_IPS
194   %token  HOST
195   %token  HUB
196   %token  HUB_MASK
197   %token  IGNORE_BOGUS_TS
198   %token  INVISIBLE_ON_CONNECT
199   %token  IP
200 + %token  IRCD_AUTH
201 + %token  IRCD_FLAGS
202 + %token  IRCD_SID
203 + %token  JOIN_FLOOD_COUNT
204 + %token  JOIN_FLOOD_TIME
205   %token  KILL
206 < %token  KILL_CHASE_TIME_LIMIT
206 > %token  KILL_CHASE_TIME_LIMIT
207   %token  KLINE
208   %token  KLINE_EXEMPT
209   %token  KNOCK_DELAY
# Line 178 | Line 211 | free_collect_item(struct CollectItem *it
211   %token  LEAF_MASK
212   %token  LINKS_DELAY
213   %token  LISTEN
214 < %token  T_LOG
214 > %token  MASK
215   %token  MAX_ACCEPT
216   %token  MAX_BANS
217   %token  MAX_CHANS_PER_OPER
218   %token  MAX_CHANS_PER_USER
219   %token  MAX_GLOBAL
220   %token  MAX_IDENT
221 + %token  MAX_IDLE
222   %token  MAX_LOCAL
223   %token  MAX_NICK_CHANGES
224 + %token  MAX_NICK_LENGTH
225   %token  MAX_NICK_TIME
226   %token  MAX_NUMBER
227   %token  MAX_TARGETS
228 + %token  MAX_TOPIC_LENGTH
229   %token  MAX_WATCH
230 < %token  MESSAGE_LOCALE
230 > %token  MIN_IDLE
231   %token  MIN_NONWILDCARD
232   %token  MIN_NONWILDCARD_SIMPLE
233   %token  MODULE
234   %token  MODULES
235 + %token  MOTD
236   %token  NAME
237 + %token  NEED_IDENT
238   %token  NEED_PASSWORD
239   %token  NETWORK_DESC
240   %token  NETWORK_NAME
241   %token  NICK
204 %token  NICK_CHANGES
242   %token  NO_CREATE_ON_SPLIT
243   %token  NO_JOIN_ON_SPLIT
244   %token  NO_OPER_FLOOD
# Line 209 | Line 246 | free_collect_item(struct CollectItem *it
246   %token  NUMBER
247   %token  NUMBER_PER_CIDR
248   %token  NUMBER_PER_IP
212 %token  OPERATOR
213 %token  OPERS_BYPASS_CALLERID
249   %token  OPER_ONLY_UMODES
250   %token  OPER_PASS_RESV
216 %token  OPER_SPY_T
251   %token  OPER_UMODES
252 < %token  JOIN_FLOOD_COUNT
253 < %token  JOIN_FLOOD_TIME
252 > %token  OPERATOR
253 > %token  OPERS_BYPASS_CALLERID
254   %token  PACE_WAIT
255   %token  PACE_WAIT_SIMPLE
256   %token  PASSWORD
257   %token  PATH
258   %token  PING_COOKIE
259   %token  PING_TIME
226 %token  PING_WARNING
260   %token  PORT
261   %token  QSTRING
262 < %token  QUIET_ON_BAN
262 > %token  RANDOM_IDLE
263   %token  REASON
264   %token  REDIRPORT
265   %token  REDIRSERV
233 %token  REGEX_T
266   %token  REHASH
267   %token  REMOTE
268   %token  REMOTEBAN
237 %token  RESTRICT_CHANNELS
238 %token  RSA_PRIVATE_KEY_FILE
239 %token  RSA_PUBLIC_KEY_FILE
240 %token  SSL_CERTIFICATE_FILE
241 %token  SSL_DH_PARAM_FILE
242 %token  T_SSL_CLIENT_METHOD
243 %token  T_SSL_SERVER_METHOD
244 %token  T_SSLV3
245 %token  T_TLSV1
269   %token  RESV
270   %token  RESV_EXEMPT
271 < %token  SECONDS MINUTES HOURS DAYS WEEKS
272 < %token  SENDQ
271 > %token  RSA_PRIVATE_KEY_FILE
272 > %token  RSA_PUBLIC_KEY_FILE
273 > %token  SECONDS MINUTES HOURS DAYS WEEKS MONTHS YEARS
274   %token  SEND_PASSWORD
275 + %token  SENDQ
276   %token  SERVERHIDE
277   %token  SERVERINFO
253 %token  IRCD_SID
254 %token  TKLINE_EXPIRE_NOTICES
255 %token  T_SHARED
256 %token  T_CLUSTER
257 %token  TYPE
278   %token  SHORT_MOTD
279   %token  SPOOF
280   %token  SPOOF_NOTICE
281 + %token  SQUIT
282 + %token  SSL_CERTIFICATE_FILE
283 + %token  SSL_DH_PARAM_FILE
284   %token  STATS_E_DISABLED
285   %token  STATS_I_OPER_ONLY
286   %token  STATS_K_OPER_ONLY
287   %token  STATS_O_OPER_ONLY
288   %token  STATS_P_OPER_ONLY
266 %token  TBOOL
267 %token  TMASKED
268 %token  TS_MAX_DELTA
269 %token  TS_WARN_DELTA
270 %token  TWODOTS
289   %token  T_ALL
290   %token  T_BOTS
273 %token  T_SOFTCALLERID
291   %token  T_CALLERID
292   %token  T_CCONN
293 < %token  T_CCONN_FULL
277 < %token  T_SSL_CIPHER_LIST
293 > %token  T_CLUSTER
294   %token  T_DEAF
295   %token  T_DEBUG
296   %token  T_DLINE
297   %token  T_EXTERNAL
298 + %token  T_FARCONNECT
299 + %token  T_FILE
300   %token  T_FULL
301 + %token  T_GLOBOPS
302   %token  T_INVISIBLE
303   %token  T_IPV4
304   %token  T_IPV6
305   %token  T_LOCOPS
306 + %token  T_LOG
307   %token  T_MAX_CLIENTS
308   %token  T_NCHANGE
309 + %token  T_NONONREG
310   %token  T_OPERWALL
311   %token  T_RECVQ
312   %token  T_REJ
313 + %token  T_RESTART
314   %token  T_SERVER
315 + %token  T_SERVICE
316 + %token  T_SERVICES_NAME
317   %token  T_SERVNOTICE
318   %token  T_SET
319 + %token  T_SHARED
320 + %token  T_SIZE
321   %token  T_SKILL
322 + %token  T_SOFTCALLERID
323   %token  T_SPY
324   %token  T_SSL
325 + %token  T_SSL_CIPHER_LIST
326 + %token  T_SSL_CLIENT_METHOD
327 + %token  T_SSL_SERVER_METHOD
328 + %token  T_SSLV3
329 + %token  T_TLSV1
330   %token  T_UMODES
331   %token  T_UNAUTH
332   %token  T_UNDLINE
333   %token  T_UNLIMITED
334   %token  T_UNRESV
335   %token  T_UNXLINE
304 %token  T_GLOBOPS
336   %token  T_WALLOP
337 < %token  T_RESTART
338 < %token  T_SERVICE
339 < %token  T_SERVICES_NAME
337 > %token  T_WALLOPS
338 > %token  T_WEBIRC
339 > %token  TBOOL
340   %token  THROTTLE_TIME
341 + %token  TKLINE_EXPIRE_NOTICES
342 + %token  TMASKED
343   %token  TRUE_NO_OPER_FLOOD
344 + %token  TS_MAX_DELTA
345 + %token  TS_WARN_DELTA
346 + %token  TWODOTS
347 + %token  TYPE
348   %token  UNKLINE
312 %token  USER
349   %token  USE_EGD
350   %token  USE_LOGGING
351 + %token  USER
352   %token  VHOST
353   %token  VHOST6
317 %token  XLINE
354   %token  WARN_NO_NLINE
355 < %token  T_SIZE
320 < %token  T_FILE
355 > %token  XLINE
356  
357 < %type <string> QSTRING
358 < %type <number> NUMBER
359 < %type <number> timespec
360 < %type <number> timespec_
361 < %type <number> sizespec
362 < %type <number> sizespec_
357 > %type  <string> QSTRING
358 > %type  <number> NUMBER
359 > %type  <number> timespec
360 > %type  <number> timespec_
361 > %type  <number> sizespec
362 > %type  <number> sizespec_
363  
364   %%
365   conf:  
# Line 351 | Line 386 | conf_item:        admin_entry
386                  | general_entry
387                  | gecos_entry
388                  | modules_entry
389 +                | motd_entry
390                  | error ';'
391                  | error '}'
392          ;
# Line 381 | Line 417 | timespec:      NUMBER timespec_
417                  {
418                          $$ = $1 * 60 * 60 * 24 * 7 + $3;
419                  }
420 +                | NUMBER MONTHS timespec_
421 +                {
422 +                        $$ = $1 * 60 * 60 * 24 * 7 * 4 + $3;
423 +                }
424 +                | NUMBER YEARS timespec_
425 +                {
426 +                        $$ = $1 * 60 * 60 * 24 * 365 + $3;
427 +                }
428                  ;
429  
430   sizespec_:      { $$ = 0; } | sizespec;
# Line 419 | Line 463 | serverinfo_items:       serverinfo_items
463   serverinfo_item:        serverinfo_name | serverinfo_vhost |
464                          serverinfo_hub | serverinfo_description |
465                          serverinfo_network_name | serverinfo_network_desc |
466 <                        serverinfo_max_clients | serverinfo_ssl_dh_param_file |
466 >                        serverinfo_max_clients | serverinfo_max_nick_length |
467 >                        serverinfo_max_topic_length | serverinfo_ssl_dh_param_file |
468                          serverinfo_rsa_private_key_file | serverinfo_vhost6 |
469                          serverinfo_sid | serverinfo_ssl_certificate_file |
470                          serverinfo_ssl_client_method | serverinfo_ssl_server_method |
# Line 467 | Line 512 | serverinfo_ssl_certificate_file: SSL_CER
512    {
513      if (!ServerInfo.rsa_private_key_file)
514      {
515 <      yyerror("No rsa_private_key_file specified, SSL disabled");
515 >      conf_error_report("No rsa_private_key_file specified, SSL disabled");
516        break;
517      }
518  
# Line 476 | Line 521 | serverinfo_ssl_certificate_file: SSL_CER
521          SSL_CTX_use_certificate_file(ServerInfo.client_ctx, yylval.string,
522                                       SSL_FILETYPE_PEM) <= 0)
523      {
524 <      yyerror(ERR_lib_error_string(ERR_get_error()));
524 >      report_crypto_errors();
525 >      conf_error_report("Could not open/read certificate file");
526        break;
527      }
528  
# Line 485 | Line 531 | serverinfo_ssl_certificate_file: SSL_CER
531          SSL_CTX_use_PrivateKey_file(ServerInfo.client_ctx, ServerInfo.rsa_private_key_file,
532                                      SSL_FILETYPE_PEM) <= 0)
533      {
534 <      yyerror(ERR_lib_error_string(ERR_get_error()));
534 >      report_crypto_errors();
535 >      conf_error_report("Could not read RSA private key");
536        break;
537      }
538  
539      if (!SSL_CTX_check_private_key(ServerInfo.server_ctx) ||
540          !SSL_CTX_check_private_key(ServerInfo.client_ctx))
541      {
542 <      yyerror(ERR_lib_error_string(ERR_get_error()));
542 >      report_crypto_errors();
543 >      conf_error_report("Could not read RSA private key");
544        break;
545      }
546    }
# Line 502 | Line 550 | serverinfo_ssl_certificate_file: SSL_CER
550   serverinfo_rsa_private_key_file: RSA_PRIVATE_KEY_FILE '=' QSTRING ';'
551   {
552   #ifdef HAVE_LIBCRYPTO
553 <  if (conf_parser_ctx.pass == 1)
506 <  {
507 <    BIO *file;
553 >  BIO *file = NULL;
554  
555 <    if (ServerInfo.rsa_private_key)
556 <    {
511 <      RSA_free(ServerInfo.rsa_private_key);
512 <      ServerInfo.rsa_private_key = NULL;
513 <    }
555 >  if (conf_parser_ctx.pass != 1)
556 >    break;
557  
558 <    if (ServerInfo.rsa_private_key_file)
559 <    {
560 <      MyFree(ServerInfo.rsa_private_key_file);
561 <      ServerInfo.rsa_private_key_file = NULL;
562 <    }
558 >  if (ServerInfo.rsa_private_key)
559 >  {
560 >    RSA_free(ServerInfo.rsa_private_key);
561 >    ServerInfo.rsa_private_key = NULL;
562 >  }
563  
564 <    DupString(ServerInfo.rsa_private_key_file, yylval.string);
564 >  if (ServerInfo.rsa_private_key_file)
565 >  {
566 >    MyFree(ServerInfo.rsa_private_key_file);
567 >    ServerInfo.rsa_private_key_file = NULL;
568 >  }
569  
570 <    if ((file = BIO_new_file(yylval.string, "r")) == NULL)
524 <    {
525 <      yyerror("File open failed, ignoring");
526 <      break;
527 <    }
570 >  ServerInfo.rsa_private_key_file = xstrdup(yylval.string);
571  
572 <    ServerInfo.rsa_private_key = PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL);
572 >  if ((file = BIO_new_file(yylval.string, "r")) == NULL)
573 >  {
574 >    conf_error_report("File open failed, ignoring");
575 >    break;
576 >  }
577  
578 <    BIO_set_close(file, BIO_CLOSE);
532 <    BIO_free(file);
578 >  ServerInfo.rsa_private_key = PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL);
579  
580 <    if (ServerInfo.rsa_private_key == NULL)
581 <    {
536 <      yyerror("Couldn't extract key, ignoring");
537 <      break;
538 <    }
580 >  BIO_set_close(file, BIO_CLOSE);
581 >  BIO_free(file);
582  
583 <    if (!RSA_check_key(ServerInfo.rsa_private_key))
584 <    {
585 <      RSA_free(ServerInfo.rsa_private_key);
586 <      ServerInfo.rsa_private_key = NULL;
583 >  if (ServerInfo.rsa_private_key == NULL)
584 >  {
585 >    conf_error_report("Couldn't extract key, ignoring");
586 >    break;
587 >  }
588  
589 <      yyerror("Invalid key, ignoring");
590 <      break;
591 <    }
589 >  if (!RSA_check_key(ServerInfo.rsa_private_key))
590 >  {
591 >    RSA_free(ServerInfo.rsa_private_key);
592 >    ServerInfo.rsa_private_key = NULL;
593  
594 <    /* require 2048 bit (256 byte) key */
595 <    if (RSA_size(ServerInfo.rsa_private_key) != 256)
596 <    {
552 <      RSA_free(ServerInfo.rsa_private_key);
553 <      ServerInfo.rsa_private_key = NULL;
594 >    conf_error_report("Invalid key, ignoring");
595 >    break;
596 >  }
597  
598 <      yyerror("Not a 2048 bit key, ignoring");
599 <    }
598 >  /* require 2048 bit (256 byte) key */
599 >  if (RSA_size(ServerInfo.rsa_private_key) != 256)
600 >  {
601 >    RSA_free(ServerInfo.rsa_private_key);
602 >    ServerInfo.rsa_private_key = NULL;
603 >
604 >    conf_error_report("Not a 2048 bit key, ignoring");
605    }
606   #endif
607   };
# Line 575 | Line 623 | serverinfo_ssl_dh_param_file: SSL_DH_PAR
623        if (dh)
624        {
625          if (DH_size(dh) < 128)
626 <          ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::ssl_dh_param_file -- need at least a 1024 bit DH prime size");
626 >          conf_error_report("Ignoring serverinfo::ssl_dh_param_file -- need at least a 1024 bit DH prime size");
627          else
628            SSL_CTX_set_tmp_dh(ServerInfo.server_ctx, dh);
629  
# Line 600 | Line 648 | serverinfo_name: NAME '=' QSTRING ';'
648    if (conf_parser_ctx.pass == 2 && !ServerInfo.name)
649    {
650      if (valid_servname(yylval.string))
651 <      DupString(ServerInfo.name, yylval.string);
651 >      ServerInfo.name = xstrdup(yylval.string);
652      else
653      {
654 <      ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::name -- invalid name. Aborting.");
654 >      conf_error_report("Ignoring serverinfo::name -- invalid name. Aborting.");
655        exit(0);
656      }
657    }
# Line 615 | Line 663 | serverinfo_sid: IRCD_SID '=' QSTRING ';'
663    if (conf_parser_ctx.pass == 2 && !ServerInfo.sid)
664    {
665      if (valid_sid(yylval.string))
666 <      DupString(ServerInfo.sid, yylval.string);
666 >      ServerInfo.sid = xstrdup(yylval.string);
667      else
668      {
669 <      ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::sid -- invalid SID. Aborting.");
669 >      conf_error_report("Ignoring serverinfo::sid -- invalid SID. Aborting.");
670        exit(0);
671      }
672    }
# Line 629 | Line 677 | serverinfo_description: DESCRIPTION '='
677    if (conf_parser_ctx.pass == 2)
678    {
679      MyFree(ServerInfo.description);
680 <    DupString(ServerInfo.description,yylval.string);
680 >    ServerInfo.description = xstrdup(yylval.string);
681    }
682   };
683  
# Line 643 | Line 691 | serverinfo_network_name: NETWORK_NAME '=
691        p = '\0';
692  
693      MyFree(ServerInfo.network_name);
694 <    DupString(ServerInfo.network_name, yylval.string);
694 >    ServerInfo.network_name = xstrdup(yylval.string);
695    }
696   };
697  
698   serverinfo_network_desc: NETWORK_DESC '=' QSTRING ';'
699   {
700 <  if (conf_parser_ctx.pass == 2)
701 <  {
702 <    MyFree(ServerInfo.network_desc);
703 <    DupString(ServerInfo.network_desc, yylval.string);
704 <  }
700 >  if (conf_parser_ctx.pass != 2)
701 >    break;
702 >
703 >  MyFree(ServerInfo.network_desc);
704 >  ServerInfo.network_desc = xstrdup(yylval.string);
705   };
706  
707   serverinfo_vhost: VHOST '=' QSTRING ';'
# Line 716 | Line 764 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
764  
765   serverinfo_max_clients: T_MAX_CLIENTS '=' NUMBER ';'
766   {
767 <  if (conf_parser_ctx.pass == 2)
767 >  if (conf_parser_ctx.pass != 2)
768 >    break;
769 >
770 >  if ($3 < MAXCLIENTS_MIN)
771    {
772 <    recalc_fdlimit(NULL);
772 >    char buf[IRCD_BUFSIZE];
773  
774 <    if ($3 < MAXCLIENTS_MIN)
775 <    {
776 <      char buf[IRCD_BUFSIZE];
777 <      ircsprintf(buf, "MAXCLIENTS too low, setting to %d", MAXCLIENTS_MIN);
778 <      yyerror(buf);
779 <    }
780 <    else if ($3 > MAXCLIENTS_MAX)
781 <    {
782 <      char buf[IRCD_BUFSIZE];
783 <      ircsprintf(buf, "MAXCLIENTS too high, setting to %d", MAXCLIENTS_MAX);
784 <      yyerror(buf);
785 <    }
786 <    else
787 <      ServerInfo.max_clients = $3;
774 >    snprintf(buf, sizeof(buf), "MAXCLIENTS too low, setting to %d", MAXCLIENTS_MIN);
775 >    conf_error_report(buf);
776 >    ServerInfo.max_clients = MAXCLIENTS_MIN;
777 >  }
778 >  else if ($3 > MAXCLIENTS_MAX)
779 >  {
780 >    char buf[IRCD_BUFSIZE];
781 >
782 >    snprintf(buf, sizeof(buf), "MAXCLIENTS too high, setting to %d", MAXCLIENTS_MAX);
783 >    conf_error_report(buf);
784 >    ServerInfo.max_clients = MAXCLIENTS_MAX;
785 >  }
786 >  else
787 >    ServerInfo.max_clients = $3;
788 > };
789 >
790 > serverinfo_max_nick_length: MAX_NICK_LENGTH '=' NUMBER ';'
791 > {
792 >  if (conf_parser_ctx.pass != 2)
793 >    break;
794 >
795 >  if ($3 < 9)
796 >  {
797 >    conf_error_report("max_nick_length too low, setting to 9");
798 >    ServerInfo.max_nick_length = 9;
799 >  }
800 >  else if ($3 > NICKLEN)
801 >  {
802 >    char buf[IRCD_BUFSIZE];
803 >
804 >    snprintf(buf, sizeof(buf), "max_nick_length too high, setting to %d", NICKLEN);
805 >    conf_error_report(buf);
806 >    ServerInfo.max_nick_length = NICKLEN;
807 >  }
808 >  else
809 >    ServerInfo.max_nick_length = $3;
810 > };
811 >
812 > serverinfo_max_topic_length: MAX_TOPIC_LENGTH '=' NUMBER ';'
813 > {
814 >  if (conf_parser_ctx.pass != 2)
815 >    break;
816 >
817 >  if ($3 < 80)
818 >  {
819 >    conf_error_report("max_topic_length too low, setting to 80");
820 >    ServerInfo.max_topic_length = 80;
821 >  }
822 >  else if ($3 > TOPICLEN)
823 >  {
824 >    char buf[IRCD_BUFSIZE];
825 >
826 >    snprintf(buf, sizeof(buf), "max_topic_length too high, setting to %d", TOPICLEN);
827 >    conf_error_report(buf);
828 >    ServerInfo.max_topic_length = TOPICLEN;
829    }
830 +  else
831 +    ServerInfo.max_topic_length = $3;
832   };
833  
834   serverinfo_hub: HUB '=' TBOOL ';'
# Line 754 | Line 848 | admin_item:  admin_name | admin_descript
848  
849   admin_name: NAME '=' QSTRING ';'
850   {
851 <  if (conf_parser_ctx.pass == 2)
852 <  {
853 <    MyFree(AdminInfo.name);
854 <    DupString(AdminInfo.name, yylval.string);
855 <  }
851 >  if (conf_parser_ctx.pass != 2)
852 >    break;
853 >
854 >  MyFree(AdminInfo.name);
855 >  AdminInfo.name = xstrdup(yylval.string);
856   };
857  
858   admin_email: EMAIL '=' QSTRING ';'
859   {
860 <  if (conf_parser_ctx.pass == 2)
861 <  {
862 <    MyFree(AdminInfo.email);
863 <    DupString(AdminInfo.email, yylval.string);
864 <  }
860 >  if (conf_parser_ctx.pass != 2)
861 >    break;
862 >
863 >  MyFree(AdminInfo.email);
864 >  AdminInfo.email = xstrdup(yylval.string);
865   };
866  
867   admin_description: DESCRIPTION '=' QSTRING ';'
868   {
869 +  if (conf_parser_ctx.pass != 2)
870 +    break;
871 +
872 +  MyFree(AdminInfo.description);
873 +  AdminInfo.description = xstrdup(yylval.string);
874 + };
875 +
876 + /***************************************************************************
877 + * motd section
878 + ***************************************************************************/
879 + motd_entry: MOTD
880 + {
881    if (conf_parser_ctx.pass == 2)
882 <  {
883 <    MyFree(AdminInfo.description);
884 <    DupString(AdminInfo.description, yylval.string);
885 <  }
882 >    reset_block_state();
883 > } '{' motd_items '}' ';'
884 > {
885 >  dlink_node *ptr = NULL;
886 >
887 >  if (conf_parser_ctx.pass != 2)
888 >    break;
889 >
890 >  if (!block_state.file.buf[0])
891 >    break;
892 >
893 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
894 >    motd_add(ptr->data, block_state.file.buf);
895 > };
896 >
897 > motd_items: motd_items motd_item | motd_item;
898 > motd_item:  motd_mask | motd_file | error ';' ;
899 >
900 > motd_mask: MASK '=' QSTRING ';'
901 > {
902 >  if (conf_parser_ctx.pass == 2)
903 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
904 > };
905 >
906 > motd_file: T_FILE '=' QSTRING ';'
907 > {
908 >  if (conf_parser_ctx.pass == 2)
909 >    strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
910   };
911  
912   /***************************************************************************
# Line 796 | Line 926 | logging_use_logging: USE_LOGGING '=' TBO
926  
927   logging_file_entry:
928   {
929 <  lfile[0] = '\0';
930 <  ltype = 0;
801 <  lsize = 0;
929 >  if (conf_parser_ctx.pass == 2)
930 >    reset_block_state();
931   } T_FILE  '{' logging_file_items '}' ';'
932   {
933 <  if (conf_parser_ctx.pass == 2 && ltype > 0)
934 <    log_add_file(ltype, lsize, lfile);
933 >  if (conf_parser_ctx.pass != 2)
934 >    break;
935 >
936 >  if (block_state.type.value && block_state.file.buf[0])
937 >    log_set_file(block_state.type.value, block_state.size.value,
938 >                 block_state.file.buf);
939   };
940  
941   logging_file_items: logging_file_items logging_file_item |
# Line 813 | Line 946 | logging_file_item:  logging_file_name |
946  
947   logging_file_name: NAME '=' QSTRING ';'
948   {
949 <  strlcpy(lfile, yylval.string, sizeof(lfile));
949 >  if (conf_parser_ctx.pass != 2)
950 >    break;
951 >
952 >  strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
953   }
954  
955   logging_file_size: T_SIZE '=' sizespec ';'
956   {
957 <  lsize = $3;
957 >  block_state.size.value = $3;
958   } | T_SIZE '=' T_UNLIMITED ';'
959   {
960 <  lsize = 0;
960 >  block_state.size.value = 0;
961   };
962  
963   logging_file_type: TYPE
964   {
965    if (conf_parser_ctx.pass == 2)
966 <    ltype = 0;
966 >    block_state.type.value = 0;
967   } '='  logging_file_type_items ';' ;
968  
969   logging_file_type_items: logging_file_type_items ',' logging_file_type_item | logging_file_type_item;
970   logging_file_type_item:  USER
971   {
972    if (conf_parser_ctx.pass == 2)
973 <    ltype = LOG_TYPE_USER;
973 >    block_state.type.value = LOG_TYPE_USER;
974   } | OPERATOR
975   {
976    if (conf_parser_ctx.pass == 2)
977 <    ltype = LOG_TYPE_OPER;
977 >    block_state.type.value = LOG_TYPE_OPER;
978   } | GLINE
979   {
980    if (conf_parser_ctx.pass == 2)
981 <    ltype = LOG_TYPE_GLINE;
981 >    block_state.type.value = LOG_TYPE_GLINE;
982   } | T_DLINE
983   {
984    if (conf_parser_ctx.pass == 2)
985 <    ltype = LOG_TYPE_DLINE;
985 >    block_state.type.value = LOG_TYPE_DLINE;
986   } | KLINE
987   {
988    if (conf_parser_ctx.pass == 2)
989 <    ltype = LOG_TYPE_KLINE;
989 >    block_state.type.value = LOG_TYPE_KLINE;
990   } | KILL
991   {
992    if (conf_parser_ctx.pass == 2)
993 <    ltype = LOG_TYPE_KILL;
993 >    block_state.type.value = LOG_TYPE_KILL;
994   } | T_DEBUG
995   {
996    if (conf_parser_ctx.pass == 2)
997 <    ltype = LOG_TYPE_DEBUG;
997 >    block_state.type.value = LOG_TYPE_DEBUG;
998   };
999  
1000  
# Line 867 | Line 1003 | logging_file_type_item:  USER
1003   ***************************************************************************/
1004   oper_entry: OPERATOR
1005   {
1006 <  if (conf_parser_ctx.pass == 2)
1007 <  {
1008 <    yy_conf = make_conf_item(OPER_TYPE);
1009 <    yy_aconf = map_to_conf(yy_conf);
1010 <    SetConfEncrypted(yy_aconf); /* Yes, the default is encrypted */
875 <  }
876 <  else
877 <  {
878 <    MyFree(class_name);
879 <    class_name = NULL;
880 <  }
1006 >  if (conf_parser_ctx.pass != 2)
1007 >    break;
1008 >
1009 >  reset_block_state();
1010 >  block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1011   } '{' oper_items '}' ';'
1012   {
1013 <  if (conf_parser_ctx.pass == 2)
884 <  {
885 <    struct CollectItem *yy_tmp;
886 <    dlink_node *ptr;
887 <    dlink_node *next_ptr;
1013 >  dlink_node *ptr = NULL;
1014  
1015 <    conf_add_class_to_conf(yy_conf, class_name);
1015 >  if (conf_parser_ctx.pass != 2)
1016 >    break;
1017  
1018 <    /* Now, make sure there is a copy of the "base" given oper
1019 <     * block in each of the collected copies
1020 <     */
1018 >  if (!block_state.name.buf[0])
1019 >    break;
1020 > #ifdef HAVE_LIBCRYPTO
1021 >  if (!block_state.file.buf[0] &&
1022 >      !block_state.rpass.buf[0])
1023 >    break;
1024 > #else
1025 >  if (!block_state.rpass.buf[0])
1026 >    break;
1027 > #endif
1028  
1029 <    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
1030 <    {
1031 <      struct AccessItem *new_aconf;
1032 <      struct ConfItem *new_conf;
899 <      yy_tmp = ptr->data;
900 <
901 <      new_conf = make_conf_item(OPER_TYPE);
902 <      new_aconf = (struct AccessItem *)map_to_conf(new_conf);
903 <
904 <      new_aconf->flags = yy_aconf->flags;
905 <
906 <      if (yy_conf->name != NULL)
907 <        DupString(new_conf->name, yy_conf->name);
908 <      if (yy_tmp->user != NULL)
909 <        DupString(new_aconf->user, yy_tmp->user);
910 <      else
911 <        DupString(new_aconf->user, "*");
912 <      if (yy_tmp->host != NULL)
913 <        DupString(new_aconf->host, yy_tmp->host);
914 <      else
915 <        DupString(new_aconf->host, "*");
916 <
917 <      new_aconf->type = parse_netmask(new_aconf->host, &new_aconf->addr,
918 <                                     &new_aconf->bits);
919 <
920 <      conf_add_class_to_conf(new_conf, class_name);
921 <      if (yy_aconf->passwd != NULL)
922 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1029 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
1030 >  {
1031 >    struct MaskItem *conf = NULL;
1032 >    struct split_nuh_item nuh;
1033  
1034 <      new_aconf->port = yy_aconf->port;
1035 < #ifdef HAVE_LIBCRYPTO
1036 <      if (yy_aconf->rsa_public_key_file != NULL)
1037 <      {
1038 <        BIO *file;
1034 >    nuh.nuhmask  = ptr->data;
1035 >    nuh.nickptr  = NULL;
1036 >    nuh.userptr  = block_state.user.buf;
1037 >    nuh.hostptr  = block_state.host.buf;
1038 >    nuh.nicksize = 0;
1039 >    nuh.usersize = sizeof(block_state.user.buf);
1040 >    nuh.hostsize = sizeof(block_state.host.buf);
1041 >    split_nuh(&nuh);
1042  
1043 <        DupString(new_aconf->rsa_public_key_file,
1044 <                  yy_aconf->rsa_public_key_file);
1043 >    conf        = conf_make(CONF_OPER);
1044 >    conf->name  = xstrdup(block_state.name.buf);
1045 >    conf->user  = xstrdup(block_state.user.buf);
1046 >    conf->host  = xstrdup(block_state.host.buf);
1047 >
1048 >    if (block_state.rpass.buf[0])
1049 >      conf->passwd = xstrdup(block_state.rpass.buf);
1050 >
1051 >    conf->flags = block_state.flags.value;
1052 >    conf->modes = block_state.modes.value;
1053 >    conf->port  = block_state.port.value;
1054 >    conf->htype = parse_netmask(conf->host, &conf->addr, &conf->bits);
1055  
1056 <        file = BIO_new_file(yy_aconf->rsa_public_key_file, "r");
934 <        new_aconf->rsa_public_key = PEM_read_bio_RSA_PUBKEY(file,
935 <                                                           NULL, 0, NULL);
936 <        BIO_set_close(file, BIO_CLOSE);
937 <        BIO_free(file);
938 <      }
939 < #endif
1056 >    conf_add_class_to_conf(conf, block_state.class.buf);
1057  
1058   #ifdef HAVE_LIBCRYPTO
1059 <      if (yy_tmp->name && (yy_tmp->passwd || yy_aconf->rsa_public_key)
1060 <          && yy_tmp->host)
1061 < #else
1062 <      if (yy_tmp->name && yy_tmp->passwd && yy_tmp->host)
1063 < #endif
1059 >    if (block_state.file.buf[0])
1060 >    {
1061 >      BIO *file = NULL;
1062 >      RSA *pkey = NULL;
1063 >
1064 >      if ((file = BIO_new_file(block_state.file.buf, "r")) == NULL)
1065        {
1066 <        conf_add_class_to_conf(new_conf, class_name);
1067 <        if (yy_tmp->name != NULL)
950 <          DupString(new_conf->name, yy_tmp->name);
1066 >        conf_error_report("Ignoring rsa_public_key_file -- file doesn't exist");
1067 >        break;
1068        }
1069  
1070 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
1071 <      free_collect_item(yy_tmp);
955 <    }
956 <
957 <    yy_conf = NULL;
958 <    yy_aconf = NULL;
959 <
1070 >      if ((pkey = PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL)) == NULL)
1071 >        conf_error_report("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
1072  
1073 <    MyFree(class_name);
1074 <    class_name = NULL;
1073 >      conf->rsa_public_key = pkey;
1074 >      BIO_set_close(file, BIO_CLOSE);
1075 >      BIO_free(file);
1076 >    }
1077 > #endif /* HAVE_LIBCRYPTO */
1078    }
1079 < };
1079 > };
1080  
1081   oper_items:     oper_items oper_item | oper_item;
1082   oper_item:      oper_name | oper_user | oper_password |
# Line 971 | Line 1086 | oper_item:      oper_name | oper_user |
1086   oper_name: NAME '=' QSTRING ';'
1087   {
1088    if (conf_parser_ctx.pass == 2)
1089 <  {
975 <    MyFree(yy_conf->name);
976 <    DupString(yy_conf->name, yylval.string);
977 <  }
1089 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1090   };
1091  
1092   oper_user: USER '=' QSTRING ';'
1093   {
1094    if (conf_parser_ctx.pass == 2)
1095 <  {
984 <    struct split_nuh_item nuh;
985 <
986 <    nuh.nuhmask  = yylval.string;
987 <    nuh.nickptr  = NULL;
988 <    nuh.userptr  = userbuf;
989 <    nuh.hostptr  = hostbuf;
990 <
991 <    nuh.nicksize = 0;
992 <    nuh.usersize = sizeof(userbuf);
993 <    nuh.hostsize = sizeof(hostbuf);
994 <
995 <    split_nuh(&nuh);
996 <
997 <    if (yy_aconf->user == NULL)
998 <    {
999 <      DupString(yy_aconf->user, userbuf);
1000 <      DupString(yy_aconf->host, hostbuf);
1001 <
1002 <      yy_aconf->type = parse_netmask(yy_aconf->host, &yy_aconf->addr,
1003 <                                    &yy_aconf->bits);
1004 <    }
1005 <    else
1006 <    {
1007 <      struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
1008 <
1009 <      DupString(yy_tmp->user, userbuf);
1010 <      DupString(yy_tmp->host, hostbuf);
1011 <
1012 <      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1013 <    }
1014 <  }
1095 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1096   };
1097  
1098   oper_password: PASSWORD '=' QSTRING ';'
1099   {
1100    if (conf_parser_ctx.pass == 2)
1101 <  {
1021 <    if (yy_aconf->passwd != NULL)
1022 <      memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1023 <
1024 <    MyFree(yy_aconf->passwd);
1025 <    DupString(yy_aconf->passwd, yylval.string);
1026 <  }
1101 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1102   };
1103  
1104   oper_encrypted: ENCRYPTED '=' TBOOL ';'
1105   {
1106 <  if (conf_parser_ctx.pass == 2)
1107 <  {
1108 <    if (yylval.number)
1109 <      SetConfEncrypted(yy_aconf);
1110 <    else
1111 <      ClearConfEncrypted(yy_aconf);
1112 <  }
1106 >  if (conf_parser_ctx.pass != 2)
1107 >    break;
1108 >
1109 >  if (yylval.number)
1110 >    block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1111 >  else
1112 >    block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1113   };
1114  
1115   oper_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
1116   {
1042 #ifdef HAVE_LIBCRYPTO
1117    if (conf_parser_ctx.pass == 2)
1118 <  {
1045 <    BIO *file;
1046 <
1047 <    if (yy_aconf->rsa_public_key != NULL)
1048 <    {
1049 <      RSA_free(yy_aconf->rsa_public_key);
1050 <      yy_aconf->rsa_public_key = NULL;
1051 <    }
1052 <
1053 <    if (yy_aconf->rsa_public_key_file != NULL)
1054 <    {
1055 <      MyFree(yy_aconf->rsa_public_key_file);
1056 <      yy_aconf->rsa_public_key_file = NULL;
1057 <    }
1058 <
1059 <    DupString(yy_aconf->rsa_public_key_file, yylval.string);
1060 <    file = BIO_new_file(yylval.string, "r");
1061 <
1062 <    if (file == NULL)
1063 <    {
1064 <      yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
1065 <      break;
1066 <    }
1067 <
1068 <    yy_aconf->rsa_public_key = PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
1069 <
1070 <    if (yy_aconf->rsa_public_key == NULL)
1071 <    {
1072 <      yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
1073 <      break;
1074 <    }
1075 <
1076 <    BIO_set_close(file, BIO_CLOSE);
1077 <    BIO_free(file);
1078 <  }
1079 < #endif /* HAVE_LIBCRYPTO */
1118 >    strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
1119   };
1120  
1121   oper_class: CLASS '=' QSTRING ';'
1122   {
1123    if (conf_parser_ctx.pass == 2)
1124 <  {
1086 <    MyFree(class_name);
1087 <    DupString(class_name, yylval.string);
1088 <  }
1124 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1125   };
1126  
1127   oper_umodes: T_UMODES
1128   {
1129    if (conf_parser_ctx.pass == 2)
1130 <    yy_aconf->modes = 0;
1130 >    block_state.modes.value = 0;
1131   } '='  oper_umodes_items ';' ;
1132  
1133   oper_umodes_items: oper_umodes_items ',' oper_umodes_item | oper_umodes_item;
1134   oper_umodes_item:  T_BOTS
1135   {
1136    if (conf_parser_ctx.pass == 2)
1137 <    yy_aconf->modes |= UMODE_BOTS;
1137 >    block_state.modes.value |= UMODE_BOTS;
1138   } | T_CCONN
1139   {
1140    if (conf_parser_ctx.pass == 2)
1141 <    yy_aconf->modes |= UMODE_CCONN;
1106 < } | T_CCONN_FULL
1107 < {
1108 <  if (conf_parser_ctx.pass == 2)
1109 <    yy_aconf->modes |= UMODE_CCONN_FULL;
1141 >    block_state.modes.value |= UMODE_CCONN;
1142   } | T_DEAF
1143   {
1144    if (conf_parser_ctx.pass == 2)
1145 <    yy_aconf->modes |= UMODE_DEAF;
1145 >    block_state.modes.value |= UMODE_DEAF;
1146   } | T_DEBUG
1147   {
1148    if (conf_parser_ctx.pass == 2)
1149 <    yy_aconf->modes |= UMODE_DEBUG;
1149 >    block_state.modes.value |= UMODE_DEBUG;
1150   } | T_FULL
1151   {
1152    if (conf_parser_ctx.pass == 2)
1153 <    yy_aconf->modes |= UMODE_FULL;
1153 >    block_state.modes.value |= UMODE_FULL;
1154   } | HIDDEN
1155   {
1156    if (conf_parser_ctx.pass == 2)
1157 <    yy_aconf->modes |= UMODE_HIDDEN;
1157 >    block_state.modes.value |= UMODE_HIDDEN;
1158   } | T_SKILL
1159   {
1160    if (conf_parser_ctx.pass == 2)
1161 <    yy_aconf->modes |= UMODE_SKILL;
1161 >    block_state.modes.value |= UMODE_SKILL;
1162   } | T_NCHANGE
1163   {
1164    if (conf_parser_ctx.pass == 2)
1165 <    yy_aconf->modes |= UMODE_NCHANGE;
1165 >    block_state.modes.value |= UMODE_NCHANGE;
1166   } | T_REJ
1167   {
1168    if (conf_parser_ctx.pass == 2)
1169 <    yy_aconf->modes |= UMODE_REJ;
1169 >    block_state.modes.value |= UMODE_REJ;
1170   } | T_UNAUTH
1171   {
1172    if (conf_parser_ctx.pass == 2)
1173 <    yy_aconf->modes |= UMODE_UNAUTH;
1173 >    block_state.modes.value |= UMODE_UNAUTH;
1174   } | T_SPY
1175   {
1176    if (conf_parser_ctx.pass == 2)
1177 <    yy_aconf->modes |= UMODE_SPY;
1177 >    block_state.modes.value |= UMODE_SPY;
1178   } | T_EXTERNAL
1179   {
1180    if (conf_parser_ctx.pass == 2)
1181 <    yy_aconf->modes |= UMODE_EXTERNAL;
1181 >    block_state.modes.value |= UMODE_EXTERNAL;
1182   } | T_OPERWALL
1183   {
1184    if (conf_parser_ctx.pass == 2)
1185 <    yy_aconf->modes |= UMODE_OPERWALL;
1185 >    block_state.modes.value |= UMODE_OPERWALL;
1186   } | T_SERVNOTICE
1187   {
1188    if (conf_parser_ctx.pass == 2)
1189 <    yy_aconf->modes |= UMODE_SERVNOTICE;
1189 >    block_state.modes.value |= UMODE_SERVNOTICE;
1190   } | T_INVISIBLE
1191   {
1192    if (conf_parser_ctx.pass == 2)
1193 <    yy_aconf->modes |= UMODE_INVISIBLE;
1193 >    block_state.modes.value |= UMODE_INVISIBLE;
1194   } | T_WALLOP
1195   {
1196    if (conf_parser_ctx.pass == 2)
1197 <    yy_aconf->modes |= UMODE_WALLOP;
1197 >    block_state.modes.value |= UMODE_WALLOP;
1198   } | T_SOFTCALLERID
1199   {
1200    if (conf_parser_ctx.pass == 2)
1201 <    yy_aconf->modes |= UMODE_SOFTCALLERID;
1201 >    block_state.modes.value |= UMODE_SOFTCALLERID;
1202   } | T_CALLERID
1203   {
1204    if (conf_parser_ctx.pass == 2)
1205 <    yy_aconf->modes |= UMODE_CALLERID;
1205 >    block_state.modes.value |= UMODE_CALLERID;
1206   } | T_LOCOPS
1207   {
1208    if (conf_parser_ctx.pass == 2)
1209 <    yy_aconf->modes |= UMODE_LOCOPS;
1209 >    block_state.modes.value |= UMODE_LOCOPS;
1210 > } | T_NONONREG
1211 > {
1212 >  if (conf_parser_ctx.pass == 2)
1213 >    block_state.modes.value |= UMODE_REGONLY;
1214 > } | T_FARCONNECT
1215 > {
1216 >  if (conf_parser_ctx.pass == 2)
1217 >    block_state.modes.value |= UMODE_FARCONNECT;
1218   };
1219  
1220   oper_flags: IRCD_FLAGS
1221   {
1222    if (conf_parser_ctx.pass == 2)
1223 <    yy_aconf->port = 0;
1223 >    block_state.port.value = 0;
1224   } '='  oper_flags_items ';';
1225  
1226   oper_flags_items: oper_flags_items ',' oper_flags_item | oper_flags_item;
1227 < oper_flags_item: GLOBAL_KILL
1227 > oper_flags_item: KILL ':' REMOTE
1228 > {
1229 >  if (conf_parser_ctx.pass == 2)
1230 >    block_state.port.value |= OPER_FLAG_KILL_REMOTE;
1231 > } | KILL
1232   {
1233    if (conf_parser_ctx.pass == 2)
1234 <    yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1235 < } | REMOTE
1234 >    block_state.port.value |= OPER_FLAG_KILL;
1235 > } | CONNECT ':' REMOTE
1236   {
1237    if (conf_parser_ctx.pass == 2)
1238 <    yy_aconf->port |= OPER_FLAG_REMOTE;
1238 >    block_state.port.value |= OPER_FLAG_CONNECT_REMOTE;
1239 > } | CONNECT
1240 > {
1241 >  if (conf_parser_ctx.pass == 2)
1242 >    block_state.port.value |= OPER_FLAG_CONNECT;
1243 > } | SQUIT ':' REMOTE
1244 > {
1245 >  if (conf_parser_ctx.pass == 2)
1246 >    block_state.port.value |= OPER_FLAG_SQUIT_REMOTE;
1247 > } | SQUIT
1248 > {
1249 >  if (conf_parser_ctx.pass == 2)
1250 >    block_state.port.value |= OPER_FLAG_SQUIT;
1251   } | KLINE
1252   {
1253    if (conf_parser_ctx.pass == 2)
1254 <    yy_aconf->port |= OPER_FLAG_K;
1254 >    block_state.port.value |= OPER_FLAG_K;
1255   } | UNKLINE
1256   {
1257    if (conf_parser_ctx.pass == 2)
1258 <    yy_aconf->port |= OPER_FLAG_UNKLINE;
1258 >    block_state.port.value |= OPER_FLAG_UNKLINE;
1259   } | T_DLINE
1260   {
1261    if (conf_parser_ctx.pass == 2)
1262 <    yy_aconf->port |= OPER_FLAG_DLINE;
1262 >    block_state.port.value |= OPER_FLAG_DLINE;
1263   } | T_UNDLINE
1264   {
1265    if (conf_parser_ctx.pass == 2)
1266 <    yy_aconf->port |= OPER_FLAG_UNDLINE;
1266 >    block_state.port.value |= OPER_FLAG_UNDLINE;
1267   } | XLINE
1268   {
1269    if (conf_parser_ctx.pass == 2)
1270 <    yy_aconf->port |= OPER_FLAG_X;
1270 >    block_state.port.value |= OPER_FLAG_X;
1271   } | GLINE
1272   {
1273    if (conf_parser_ctx.pass == 2)
1274 <    yy_aconf->port |= OPER_FLAG_GLINE;
1274 >    block_state.port.value |= OPER_FLAG_GLINE;
1275   } | DIE
1276   {
1277    if (conf_parser_ctx.pass == 2)
1278 <    yy_aconf->port |= OPER_FLAG_DIE;
1278 >    block_state.port.value |= OPER_FLAG_DIE;
1279   } | T_RESTART
1280   {
1281    if (conf_parser_ctx.pass == 2)
1282 <    yy_aconf->port |= OPER_FLAG_RESTART;
1282 >    block_state.port.value |= OPER_FLAG_RESTART;
1283   } | REHASH
1284   {
1285    if (conf_parser_ctx.pass == 2)
1286 <    yy_aconf->port |= OPER_FLAG_REHASH;
1286 >    block_state.port.value |= OPER_FLAG_REHASH;
1287   } | ADMIN
1288   {
1289    if (conf_parser_ctx.pass == 2)
1290 <    yy_aconf->port |= OPER_FLAG_ADMIN;
1235 < } | NICK_CHANGES
1236 < {
1237 <  if (conf_parser_ctx.pass == 2)
1238 <    yy_aconf->port |= OPER_FLAG_N;
1290 >    block_state.port.value |= OPER_FLAG_ADMIN;
1291   } | T_OPERWALL
1292   {
1293    if (conf_parser_ctx.pass == 2)
1294 <    yy_aconf->port |= OPER_FLAG_OPERWALL;
1294 >    block_state.port.value |= OPER_FLAG_OPERWALL;
1295   } | T_GLOBOPS
1296   {
1297    if (conf_parser_ctx.pass == 2)
1298 <    yy_aconf->port |= OPER_FLAG_GLOBOPS;
1299 < } | OPER_SPY_T
1298 >    block_state.port.value |= OPER_FLAG_GLOBOPS;
1299 > } | T_WALLOPS
1300   {
1301    if (conf_parser_ctx.pass == 2)
1302 <    yy_aconf->port |= OPER_FLAG_OPER_SPY;
1302 >    block_state.port.value |= OPER_FLAG_WALLOPS;
1303 > } | T_LOCOPS
1304 > {
1305 >  if (conf_parser_ctx.pass == 2)
1306 >    block_state.port.value |= OPER_FLAG_LOCOPS;
1307   } | REMOTEBAN
1308   {
1309    if (conf_parser_ctx.pass == 2)
1310 <    yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1310 >    block_state.port.value |= OPER_FLAG_REMOTEBAN;
1311   } | T_SET
1312   {
1313    if (conf_parser_ctx.pass == 2)
1314 <    yy_aconf->port |= OPER_FLAG_SET;
1314 >    block_state.port.value |= OPER_FLAG_SET;
1315   } | MODULE
1316   {
1317    if (conf_parser_ctx.pass == 2)
1318 <    yy_aconf->port |= OPER_FLAG_MODULE;
1318 >    block_state.port.value |= OPER_FLAG_MODULE;
1319   };
1320  
1321  
# Line 1268 | Line 1324 | oper_flags_item: GLOBAL_KILL
1324   ***************************************************************************/
1325   class_entry: CLASS
1326   {
1327 <  if (conf_parser_ctx.pass == 1)
1328 <  {
1273 <    yy_conf = make_conf_item(CLASS_TYPE);
1274 <    yy_class = map_to_conf(yy_conf);
1275 <  }
1276 < } '{' class_items '}' ';'
1277 < {
1278 <  if (conf_parser_ctx.pass == 1)
1279 <  {
1280 <    struct ConfItem *cconf = NULL;
1281 <    struct ClassItem *class = NULL;
1327 >  if (conf_parser_ctx.pass != 1)
1328 >    break;
1329  
1330 <    if (yy_class_name == NULL)
1284 <      delete_conf_item(yy_conf);
1285 <    else
1286 <    {
1287 <      cconf = find_exact_name_conf(CLASS_TYPE, NULL, yy_class_name, NULL, NULL);
1288 <
1289 <      if (cconf != NULL)                /* The class existed already */
1290 <      {
1291 <        int user_count = 0;
1330 >  reset_block_state();
1331  
1332 <        rebuild_cidr_class(cconf, yy_class);
1333 <
1334 <        class = map_to_conf(cconf);
1332 >  block_state.ping_freq.value = DEFAULT_PINGFREQUENCY;
1333 >  block_state.con_freq.value  = DEFAULT_CONNECTFREQUENCY;
1334 >  block_state.max_total.value = MAXIMUM_LINKS_DEFAULT;
1335 >  block_state.max_sendq.value = DEFAULT_SENDQ;
1336 >  block_state.max_recvq.value = DEFAULT_RECVQ;
1337 > } '{' class_items '}' ';'
1338 > {
1339 >  struct ClassItem *class = NULL;
1340  
1341 <        user_count = class->curr_user_count;
1342 <        memcpy(class, yy_class, sizeof(*class));
1299 <        class->curr_user_count = user_count;
1300 <        class->active = 1;
1341 >  if (conf_parser_ctx.pass != 1)
1342 >    break;
1343  
1344 <        delete_conf_item(yy_conf);
1344 >  if (!block_state.class.buf[0])
1345 >    break;
1346  
1347 <        MyFree(cconf->name);            /* Allows case change of class name */
1348 <        cconf->name = yy_class_name;
1349 <      }
1350 <      else      /* Brand new class */
1351 <      {
1352 <        MyFree(yy_conf->name);          /* just in case it was allocated */
1353 <        yy_conf->name = yy_class_name;
1354 <        yy_class->active = 1;
1355 <      }
1356 <    }
1357 <
1358 <    yy_class_name = NULL;
1359 <  }
1347 >  if (!(class = class_find(block_state.class.buf, 0)))
1348 >    class = class_make();
1349 >
1350 >  class->active = 1;
1351 >  MyFree(class->name);
1352 >  class->name = xstrdup(block_state.class.buf);
1353 >  class->ping_freq = block_state.ping_freq.value;
1354 >  class->max_perip = block_state.max_perip.value;
1355 >  class->con_freq = block_state.con_freq.value;
1356 >  class->max_total = block_state.max_total.value;
1357 >  class->max_global = block_state.max_global.value;
1358 >  class->max_local = block_state.max_local.value;
1359 >  class->max_ident = block_state.max_ident.value;
1360 >  class->max_sendq = block_state.max_sendq.value;
1361 >  class->max_recvq = block_state.max_recvq.value;
1362 >
1363 >  if (block_state.min_idle.value > block_state.max_idle.value)
1364 >  {
1365 >    block_state.min_idle.value = 0;
1366 >    block_state.max_idle.value = 0;
1367 >    block_state.flags.value &= ~CLASS_FLAGS_FAKE_IDLE;
1368 >  }
1369 >
1370 >  class->flags = block_state.flags.value;
1371 >  class->min_idle = block_state.min_idle.value;
1372 >  class->max_idle = block_state.max_idle.value;
1373 >
1374 >  if (class->number_per_cidr && block_state.number_per_cidr.value)
1375 >    if ((class->cidr_bitlen_ipv4 && block_state.cidr_bitlen_ipv4.value) ||
1376 >        (class->cidr_bitlen_ipv6 && block_state.cidr_bitlen_ipv6.value))
1377 >      if ((class->cidr_bitlen_ipv4 != block_state.cidr_bitlen_ipv4.value) ||
1378 >          (class->cidr_bitlen_ipv6 != block_state.cidr_bitlen_ipv6.value))
1379 >        rebuild_cidr_list(class);
1380 >
1381 >  class->cidr_bitlen_ipv4 = block_state.cidr_bitlen_ipv4.value;
1382 >  class->cidr_bitlen_ipv6 = block_state.cidr_bitlen_ipv6.value;
1383 >  class->number_per_cidr = block_state.number_per_cidr.value;
1384   };
1385  
1386   class_items:    class_items class_item | class_item;
1387   class_item:     class_name |
1388                  class_cidr_bitlen_ipv4 | class_cidr_bitlen_ipv6 |
1389                  class_ping_time |
1323                class_ping_warning |
1390                  class_number_per_cidr |
1391                  class_number_per_ip |
1392                  class_connectfreq |
# Line 1329 | Line 1395 | class_item:     class_name |
1395                  class_max_local |
1396                  class_max_ident |
1397                  class_sendq | class_recvq |
1398 +                class_min_idle |
1399 +                class_max_idle |
1400 +                class_flags |
1401                  error ';' ;
1402  
1403   class_name: NAME '=' QSTRING ';'
1404   {
1405    if (conf_parser_ctx.pass == 1)
1406 <  {
1338 <    MyFree(yy_class_name);
1339 <    DupString(yy_class_name, yylval.string);
1340 <  }
1406 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1407   };
1408  
1409   class_ping_time: PING_TIME '=' timespec ';'
1410   {
1411    if (conf_parser_ctx.pass == 1)
1412 <    yy_class->ping_freq = $3;
1347 < };
1348 <
1349 < class_ping_warning: PING_WARNING '=' timespec ';'
1350 < {
1351 <  if (conf_parser_ctx.pass == 1)
1352 <    yy_class->ping_warning = $3;
1412 >    block_state.ping_freq.value = $3;
1413   };
1414  
1415   class_number_per_ip: NUMBER_PER_IP '=' NUMBER ';'
1416   {
1417    if (conf_parser_ctx.pass == 1)
1418 <    yy_class->max_perip = $3;
1418 >    block_state.max_perip.value = $3;
1419   };
1420  
1421   class_connectfreq: CONNECTFREQ '=' timespec ';'
1422   {
1423    if (conf_parser_ctx.pass == 1)
1424 <    yy_class->con_freq = $3;
1424 >    block_state.con_freq.value = $3;
1425   };
1426  
1427   class_max_number: MAX_NUMBER '=' NUMBER ';'
1428   {
1429    if (conf_parser_ctx.pass == 1)
1430 <    yy_class->max_total = $3;
1430 >    block_state.max_total.value = $3;
1431   };
1432  
1433   class_max_global: MAX_GLOBAL '=' NUMBER ';'
1434   {
1435    if (conf_parser_ctx.pass == 1)
1436 <    yy_class->max_global = $3;
1436 >    block_state.max_global.value = $3;
1437   };
1438  
1439   class_max_local: MAX_LOCAL '=' NUMBER ';'
1440   {
1441    if (conf_parser_ctx.pass == 1)
1442 <    yy_class->max_local = $3;
1442 >    block_state.max_local.value = $3;
1443   };
1444  
1445   class_max_ident: MAX_IDENT '=' NUMBER ';'
1446   {
1447    if (conf_parser_ctx.pass == 1)
1448 <    yy_class->max_ident = $3;
1448 >    block_state.max_ident.value = $3;
1449   };
1450  
1451   class_sendq: SENDQ '=' sizespec ';'
1452   {
1453    if (conf_parser_ctx.pass == 1)
1454 <    yy_class->max_sendq = $3;
1454 >    block_state.max_sendq.value = $3;
1455   };
1456  
1457   class_recvq: T_RECVQ '=' sizespec ';'
1458   {
1459    if (conf_parser_ctx.pass == 1)
1460      if ($3 >= CLIENT_FLOOD_MIN && $3 <= CLIENT_FLOOD_MAX)
1461 <      yy_class->max_recvq = $3;
1461 >      block_state.max_recvq.value = $3;
1462   };
1463  
1464   class_cidr_bitlen_ipv4: CIDR_BITLEN_IPV4 '=' NUMBER ';'
1465   {
1466    if (conf_parser_ctx.pass == 1)
1467 <    yy_class->cidr_bitlen_ipv4 = $3 > 32 ? 32 : $3;
1467 >    block_state.cidr_bitlen_ipv4.value = $3 > 32 ? 32 : $3;
1468   };
1469  
1470   class_cidr_bitlen_ipv6: CIDR_BITLEN_IPV6 '=' NUMBER ';'
1471   {
1472    if (conf_parser_ctx.pass == 1)
1473 <    yy_class->cidr_bitlen_ipv6 = $3 > 128 ? 128 : $3;
1473 >    block_state.cidr_bitlen_ipv6.value = $3 > 128 ? 128 : $3;
1474   };
1475  
1476   class_number_per_cidr: NUMBER_PER_CIDR '=' NUMBER ';'
1477   {
1478    if (conf_parser_ctx.pass == 1)
1479 <    yy_class->number_per_cidr = $3;
1479 >    block_state.number_per_cidr.value = $3;
1480 > };
1481 >
1482 > class_min_idle: MIN_IDLE '=' timespec ';'
1483 > {
1484 >  if (conf_parser_ctx.pass != 1)
1485 >    break;
1486 >
1487 >  block_state.min_idle.value = $3;
1488 >  block_state.flags.value |= CLASS_FLAGS_FAKE_IDLE;
1489 > };
1490 >
1491 > class_max_idle: MAX_IDLE '=' timespec ';'
1492 > {
1493 >  if (conf_parser_ctx.pass != 1)
1494 >    break;
1495 >
1496 >  block_state.max_idle.value = $3;
1497 >  block_state.flags.value |= CLASS_FLAGS_FAKE_IDLE;
1498 > };
1499 >
1500 > class_flags: IRCD_FLAGS
1501 > {
1502 >  if (conf_parser_ctx.pass == 1)
1503 >    block_state.flags.value &= CLASS_FLAGS_FAKE_IDLE;
1504 > } '='  class_flags_items ';';
1505 >
1506 > class_flags_items: class_flags_items ',' class_flags_item | class_flags_item;
1507 > class_flags_item: RANDOM_IDLE
1508 > {
1509 >  if (conf_parser_ctx.pass == 1)
1510 >    block_state.flags.value |= CLASS_FLAGS_RANDOM_IDLE;
1511 > } | HIDE_IDLE_FROM_OPERS
1512 > {
1513 >  if (conf_parser_ctx.pass == 1)
1514 >    block_state.flags.value |= CLASS_FLAGS_HIDE_IDLE_FROM_OPERS;
1515   };
1516  
1517 +
1518   /***************************************************************************
1519   *  section listen
1520   ***************************************************************************/
1521   listen_entry: LISTEN
1522   {
1523    if (conf_parser_ctx.pass == 2)
1524 <  {
1525 <    listener_address = NULL;
1430 <    listener_flags = 0;
1431 <  }
1432 < } '{' listen_items '}' ';'
1433 < {
1434 <  if (conf_parser_ctx.pass == 2)
1435 <  {
1436 <    MyFree(listener_address);
1437 <    listener_address = NULL;
1438 <  }
1439 < };
1524 >    reset_block_state();
1525 > } '{' listen_items '}' ';';
1526  
1527   listen_flags: IRCD_FLAGS
1528   {
1529 <  listener_flags = 0;
1529 >  block_state.flags.value = 0;
1530   } '='  listen_flags_items ';';
1531  
1532   listen_flags_items: listen_flags_items ',' listen_flags_item | listen_flags_item;
1533   listen_flags_item: T_SSL
1534   {
1535    if (conf_parser_ctx.pass == 2)
1536 <    listener_flags |= LISTENER_SSL;
1536 >    block_state.flags.value |= LISTENER_SSL;
1537   } | HIDDEN
1538   {
1539    if (conf_parser_ctx.pass == 2)
1540 <    listener_flags |= LISTENER_HIDDEN;
1540 >    block_state.flags.value |= LISTENER_HIDDEN;
1541   } | T_SERVER
1542   {
1543    if (conf_parser_ctx.pass == 2)
1544 <    listener_flags |= LISTENER_SERVER;
1544 >   block_state.flags.value |= LISTENER_SERVER;
1545   };
1546  
1461
1462
1547   listen_items:   listen_items listen_item | listen_item;
1548   listen_item:    listen_port | listen_flags | listen_address | listen_host | error ';';
1549  
1550 < listen_port: PORT '=' port_items { listener_flags = 0; } ';';
1550 > listen_port: PORT '=' port_items { block_state.flags.value = 0; } ';';
1551  
1552   port_items: port_items ',' port_item | port_item;
1553  
# Line 1471 | Line 1555 | port_item: NUMBER
1555   {
1556    if (conf_parser_ctx.pass == 2)
1557    {
1558 <    if ((listener_flags & LISTENER_SSL))
1558 >    if (block_state.flags.value & LISTENER_SSL)
1559   #ifdef HAVE_LIBCRYPTO
1560        if (!ServerInfo.server_ctx)
1561   #endif
1562        {
1563 <        yyerror("SSL not available - port closed");
1563 >        conf_error_report("SSL not available - port closed");
1564          break;
1565        }
1566 <    add_listener($1, listener_address, listener_flags);
1566 >    add_listener($1, block_state.addr.buf, block_state.flags.value);
1567    }
1568   } | NUMBER TWODOTS NUMBER
1569   {
# Line 1487 | Line 1571 | port_item: NUMBER
1571    {
1572      int i;
1573  
1574 <    if ((listener_flags & LISTENER_SSL))
1574 >    if (block_state.flags.value & LISTENER_SSL)
1575   #ifdef HAVE_LIBCRYPTO
1576        if (!ServerInfo.server_ctx)
1577   #endif
1578        {
1579 <        yyerror("SSL not available - port closed");
1579 >        conf_error_report("SSL not available - port closed");
1580          break;
1581        }
1582  
1583      for (i = $1; i <= $3; ++i)
1584 <      add_listener(i, listener_address, listener_flags);
1584 >      add_listener(i, block_state.addr.buf, block_state.flags.value);
1585    }
1586   };
1587  
1588   listen_address: IP '=' QSTRING ';'
1589   {
1590    if (conf_parser_ctx.pass == 2)
1591 <  {
1508 <    MyFree(listener_address);
1509 <    DupString(listener_address, yylval.string);
1510 <  }
1591 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
1592   };
1593  
1594   listen_host: HOST '=' QSTRING ';'
1595   {
1596    if (conf_parser_ctx.pass == 2)
1597 <  {
1517 <    MyFree(listener_address);
1518 <    DupString(listener_address, yylval.string);
1519 <  }
1597 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
1598   };
1599  
1600   /***************************************************************************
# Line 1525 | Line 1603 | listen_host: HOST '=' QSTRING ';'
1603   auth_entry: IRCD_AUTH
1604   {
1605    if (conf_parser_ctx.pass == 2)
1606 <  {
1529 <    yy_conf = make_conf_item(CLIENT_TYPE);
1530 <    yy_aconf = map_to_conf(yy_conf);
1531 <  }
1532 <  else
1533 <  {
1534 <    MyFree(class_name);
1535 <    class_name = NULL;
1536 <  }
1606 >    reset_block_state();
1607   } '{' auth_items '}' ';'
1608   {
1609 <  if (conf_parser_ctx.pass == 2)
1540 <  {
1541 <    struct CollectItem *yy_tmp = NULL;
1542 <    dlink_node *ptr = NULL, *next_ptr = NULL;
1543 <
1544 <    if (yy_aconf->user && yy_aconf->host)
1545 <    {
1546 <      conf_add_class_to_conf(yy_conf, class_name);
1547 <      add_conf_by_address(CONF_CLIENT, yy_aconf);
1548 <    }
1549 <    else
1550 <      delete_conf_item(yy_conf);
1551 <
1552 <    /* copy over settings from first struct */
1553 <    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
1554 <    {
1555 <      struct AccessItem *new_aconf;
1556 <      struct ConfItem *new_conf;
1609 >  dlink_node *ptr = NULL;
1610  
1611 <      new_conf = make_conf_item(CLIENT_TYPE);
1612 <      new_aconf = map_to_conf(new_conf);
1611 >  if (conf_parser_ctx.pass != 2)
1612 >    break;
1613  
1614 <      yy_tmp = ptr->data;
1615 <
1616 <      assert(yy_tmp->user && yy_tmp->host);
1617 <
1565 <      if (yy_aconf->passwd != NULL)
1566 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1567 <      if (yy_conf->name != NULL)
1568 <        DupString(new_conf->name, yy_conf->name);
1569 <      if (yy_aconf->passwd != NULL)
1570 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1571 <
1572 <      new_aconf->flags = yy_aconf->flags;
1573 <      new_aconf->port  = yy_aconf->port;
1614 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
1615 >  {
1616 >    struct MaskItem *conf = NULL;
1617 >    struct split_nuh_item nuh;
1618  
1619 <      DupString(new_aconf->user, yy_tmp->user);
1620 <      collapse(new_aconf->user);
1619 >    nuh.nuhmask  = ptr->data;
1620 >    nuh.nickptr  = NULL;
1621 >    nuh.userptr  = block_state.user.buf;
1622 >    nuh.hostptr  = block_state.host.buf;
1623 >    nuh.nicksize = 0;
1624 >    nuh.usersize = sizeof(block_state.user.buf);
1625 >    nuh.hostsize = sizeof(block_state.host.buf);
1626 >    split_nuh(&nuh);
1627  
1628 <      DupString(new_aconf->host, yy_tmp->host);
1629 <      collapse(new_aconf->host);
1628 >    conf        = conf_make(CONF_CLIENT);
1629 >    conf->user  = xstrdup(block_state.user.buf);
1630 >    conf->host  = xstrdup(block_state.host.buf);
1631 >
1632 >    if (block_state.rpass.buf[0])
1633 >      conf->passwd = xstrdup(block_state.rpass.buf);
1634 >    if (block_state.name.buf[0])
1635 >      conf->name = xstrdup(block_state.name.buf);
1636  
1637 <      conf_add_class_to_conf(new_conf, class_name);
1638 <      add_conf_by_address(CONF_CLIENT, new_aconf);
1583 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
1584 <      free_collect_item(yy_tmp);
1585 <    }
1637 >    conf->flags = block_state.flags.value;
1638 >    conf->port  = block_state.port.value;
1639  
1640 <    MyFree(class_name);
1641 <    class_name = NULL;
1589 <    yy_conf = NULL;
1590 <    yy_aconf = NULL;
1640 >    conf_add_class_to_conf(conf, block_state.class.buf);
1641 >    add_conf_by_address(CONF_CLIENT, conf);
1642    }
1643   };
1644  
# Line 1599 | Line 1650 | auth_item:      auth_user | auth_passwd
1650   auth_user: USER '=' QSTRING ';'
1651   {
1652    if (conf_parser_ctx.pass == 2)
1653 <  {
1603 <    struct CollectItem *yy_tmp = NULL;
1604 <    struct split_nuh_item nuh;
1605 <
1606 <    nuh.nuhmask  = yylval.string;
1607 <    nuh.nickptr  = NULL;
1608 <    nuh.userptr  = userbuf;
1609 <    nuh.hostptr  = hostbuf;
1610 <
1611 <    nuh.nicksize = 0;
1612 <    nuh.usersize = sizeof(userbuf);
1613 <    nuh.hostsize = sizeof(hostbuf);
1614 <
1615 <    split_nuh(&nuh);
1616 <
1617 <    if (yy_aconf->user == NULL)
1618 <    {
1619 <      DupString(yy_aconf->user, userbuf);
1620 <      DupString(yy_aconf->host, hostbuf);
1621 <    }
1622 <    else
1623 <    {
1624 <      yy_tmp = MyMalloc(sizeof(struct CollectItem));
1625 <
1626 <      DupString(yy_tmp->user, userbuf);
1627 <      DupString(yy_tmp->host, hostbuf);
1628 <
1629 <      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1630 <    }
1631 <  }
1653 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1654   };
1655  
1656   auth_passwd: PASSWORD '=' QSTRING ';'
1657   {
1658    if (conf_parser_ctx.pass == 2)
1659 <  {
1638 <    /* be paranoid */
1639 <    if (yy_aconf->passwd != NULL)
1640 <      memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1641 <
1642 <    MyFree(yy_aconf->passwd);
1643 <    DupString(yy_aconf->passwd, yylval.string);
1644 <  }
1659 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1660   };
1661  
1662   auth_class: CLASS '=' QSTRING ';'
1663   {
1664    if (conf_parser_ctx.pass == 2)
1665 <  {
1651 <    MyFree(class_name);
1652 <    DupString(class_name, yylval.string);
1653 <  }
1665 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1666   };
1667  
1668   auth_encrypted: ENCRYPTED '=' TBOOL ';'
# Line 1658 | Line 1670 | auth_encrypted: ENCRYPTED '=' TBOOL ';'
1670    if (conf_parser_ctx.pass == 2)
1671    {
1672      if (yylval.number)
1673 <      SetConfEncrypted(yy_aconf);
1673 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1674      else
1675 <      ClearConfEncrypted(yy_aconf);
1675 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1676    }
1677   };
1678  
1679   auth_flags: IRCD_FLAGS
1680   {
1681 +  if (conf_parser_ctx.pass == 2)
1682 +    block_state.flags.value &= (CONF_FLAGS_ENCRYPTED | CONF_FLAGS_SPOOF_IP);
1683   } '='  auth_flags_items ';';
1684  
1685   auth_flags_items: auth_flags_items ',' auth_flags_item | auth_flags_item;
1686   auth_flags_item: SPOOF_NOTICE
1687   {
1688    if (conf_parser_ctx.pass == 2)
1689 <    yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1689 >    block_state.flags.value |= CONF_FLAGS_SPOOF_NOTICE;
1690   } | EXCEED_LIMIT
1691   {
1692    if (conf_parser_ctx.pass == 2)
1693 <    yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
1693 >    block_state.flags.value |= CONF_FLAGS_NOLIMIT;
1694   } | KLINE_EXEMPT
1695   {
1696    if (conf_parser_ctx.pass == 2)
1697 <    yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
1697 >    block_state.flags.value |= CONF_FLAGS_EXEMPTKLINE;
1698   } | NEED_IDENT
1699   {
1700    if (conf_parser_ctx.pass == 2)
1701 <    yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
1701 >    block_state.flags.value |= CONF_FLAGS_NEED_IDENTD;
1702   } | CAN_FLOOD
1703   {
1704    if (conf_parser_ctx.pass == 2)
1705 <    yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
1705 >    block_state.flags.value |= CONF_FLAGS_CAN_FLOOD;
1706   } | NO_TILDE
1707   {
1708    if (conf_parser_ctx.pass == 2)
1709 <    yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
1709 >    block_state.flags.value |= CONF_FLAGS_NO_TILDE;
1710   } | GLINE_EXEMPT
1711   {
1712    if (conf_parser_ctx.pass == 2)
1713 <    yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
1713 >    block_state.flags.value |= CONF_FLAGS_EXEMPTGLINE;
1714   } | RESV_EXEMPT
1715   {
1716    if (conf_parser_ctx.pass == 2)
1717 <    yy_aconf->flags |= CONF_FLAGS_EXEMPTRESV;
1717 >    block_state.flags.value |= CONF_FLAGS_EXEMPTRESV;
1718 > } | T_WEBIRC
1719 > {
1720 >  if (conf_parser_ctx.pass == 2)
1721 >    block_state.flags.value |= CONF_FLAGS_WEBIRC;
1722   } | NEED_PASSWORD
1723   {
1724    if (conf_parser_ctx.pass == 2)
1725 <    yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
1725 >    block_state.flags.value |= CONF_FLAGS_NEED_PASSWORD;
1726   };
1727  
1728   auth_spoof: SPOOF '=' QSTRING ';'
1729   {
1730 <  if (conf_parser_ctx.pass == 2)
1731 <  {
1714 <    MyFree(yy_conf->name);
1730 >  if (conf_parser_ctx.pass != 2)
1731 >    break;
1732  
1733 <    if (strlen(yylval.string) <= HOSTLEN && valid_hostname(yylval.string))
1734 <    {    
1735 <      DupString(yy_conf->name, yylval.string);
1736 <      yy_aconf->flags |= CONF_FLAGS_SPOOF_IP;
1720 <    }
1721 <    else
1722 <    {
1723 <      ilog(LOG_TYPE_IRCD, "Spoof either is too long or contains invalid characters. Ignoring it.");
1724 <      yy_conf->name = NULL;
1725 <    }
1733 >  if (strlen(yylval.string) <= HOSTLEN && valid_hostname(yylval.string))
1734 >  {
1735 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1736 >    block_state.flags.value |= CONF_FLAGS_SPOOF_IP;
1737    }
1738 +  else
1739 +    ilog(LOG_TYPE_IRCD, "Spoof either is too long or contains invalid characters. Ignoring it.");
1740   };
1741  
1742   auth_redir_serv: REDIRSERV '=' QSTRING ';'
1743   {
1744 <  if (conf_parser_ctx.pass == 2)
1745 <  {
1746 <    yy_aconf->flags |= CONF_FLAGS_REDIR;
1747 <    MyFree(yy_conf->name);
1748 <    DupString(yy_conf->name, yylval.string);
1736 <  }
1744 >  if (conf_parser_ctx.pass != 2)
1745 >    break;
1746 >
1747 >  strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1748 >  block_state.flags.value |= CONF_FLAGS_REDIR;
1749   };
1750  
1751   auth_redir_port: REDIRPORT '=' NUMBER ';'
1752   {
1753 <  if (conf_parser_ctx.pass == 2)
1754 <  {
1755 <    yy_aconf->flags |= CONF_FLAGS_REDIR;
1756 <    yy_aconf->port = $3;
1757 <  }
1753 >  if (conf_parser_ctx.pass != 2)
1754 >    break;
1755 >
1756 >  block_state.flags.value |= CONF_FLAGS_REDIR;
1757 >  block_state.port.value = $3;
1758   };
1759  
1760  
# Line 1751 | Line 1763 | auth_redir_port: REDIRPORT '=' NUMBER ';
1763   ***************************************************************************/
1764   resv_entry: RESV
1765   {
1766 <  if (conf_parser_ctx.pass == 2)
1767 <  {
1768 <    MyFree(resv_reason);
1769 <    resv_reason = NULL;
1770 <  }
1766 >  if (conf_parser_ctx.pass != 2)
1767 >    break;
1768 >
1769 >  reset_block_state();
1770 >  strlcpy(block_state.rpass.buf, CONF_NOREASON, sizeof(block_state.rpass.buf));
1771   } '{' resv_items '}' ';'
1772   {
1773 <  if (conf_parser_ctx.pass == 2)
1774 <  {
1775 <    MyFree(resv_reason);
1776 <    resv_reason = NULL;
1765 <  }
1773 >  if (conf_parser_ctx.pass != 2)
1774 >    break;
1775 >
1776 >  create_resv(block_state.name.buf, block_state.rpass.buf, &block_state.mask.list);
1777   };
1778  
1779   resv_items:     resv_items resv_item | resv_item;
1780 < resv_item:      resv_creason | resv_channel | resv_nick | error ';' ;
1780 > resv_item:      resv_mask | resv_reason | resv_exempt | error ';' ;
1781  
1782 < resv_creason: REASON '=' QSTRING ';'
1782 > resv_mask: MASK '=' QSTRING ';'
1783   {
1784    if (conf_parser_ctx.pass == 2)
1785 <  {
1775 <    MyFree(resv_reason);
1776 <    DupString(resv_reason, yylval.string);
1777 <  }
1785 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1786   };
1787  
1788 < resv_channel: CHANNEL '=' QSTRING ';'
1788 > resv_reason: REASON '=' QSTRING ';'
1789   {
1790    if (conf_parser_ctx.pass == 2)
1791 <  {
1784 <    if (IsChanPrefix(*yylval.string))
1785 <    {
1786 <      char def_reason[] = "No reason";
1787 <
1788 <      create_channel_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
1789 <    }
1790 <  }
1791 <  /* ignore it for now.. but we really should make a warning if
1792 <   * its an erroneous name --fl_ */
1791 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1792   };
1793  
1794 < resv_nick: NICK '=' QSTRING ';'
1794 > resv_exempt: EXEMPT '=' QSTRING ';'
1795   {
1796    if (conf_parser_ctx.pass == 2)
1797 <  {
1799 <    char def_reason[] = "No reason";
1800 <
1801 <    create_nick_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
1802 <  }
1797 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1798   };
1799  
1800 +
1801   /***************************************************************************
1802   *  section service
1803   ***************************************************************************/
# Line 1812 | Line 1808 | service_item:      service_name | error;
1808  
1809   service_name: NAME '=' QSTRING ';'
1810   {
1811 <  if (conf_parser_ctx.pass == 2)
1811 >  if (conf_parser_ctx.pass != 2)
1812 >    break;
1813 >
1814 >  if (valid_servname(yylval.string))
1815    {
1816 <    if (valid_servname(yylval.string))
1817 <    {
1819 <      yy_conf = make_conf_item(SERVICE_TYPE);
1820 <      DupString(yy_conf->name, yylval.string);
1821 <    }
1816 >    struct MaskItem *conf = conf_make(CONF_SERVICE);
1817 >    conf->name = xstrdup(yylval.string);
1818    }
1819   };
1820  
# Line 1827 | Line 1823 | service_name: NAME '=' QSTRING ';'
1823   ***************************************************************************/
1824   shared_entry: T_SHARED
1825   {
1826 <  if (conf_parser_ctx.pass == 2)
1827 <  {
1828 <    yy_conf = make_conf_item(ULINE_TYPE);
1829 <    yy_match_item = map_to_conf(yy_conf);
1830 <    yy_match_item->action = SHARED_ALL;
1831 <  }
1826 >  if (conf_parser_ctx.pass != 2)
1827 >    break;
1828 >
1829 >  reset_block_state();
1830 >
1831 >  strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1832 >  strlcpy(block_state.user.buf, "*", sizeof(block_state.user.buf));
1833 >  strlcpy(block_state.host.buf, "*", sizeof(block_state.host.buf));
1834 >  block_state.flags.value = SHARED_ALL;
1835   } '{' shared_items '}' ';'
1836   {
1837 <  if (conf_parser_ctx.pass == 2)
1838 <  {
1839 <    yy_conf = NULL;
1840 <  }
1837 >  struct MaskItem *conf = NULL;
1838 >
1839 >  if (conf_parser_ctx.pass != 2)
1840 >    break;
1841 >
1842 >  conf = conf_make(CONF_ULINE);
1843 >  conf->flags = block_state.flags.value;
1844 >  conf->name = xstrdup(block_state.name.buf);
1845 >  conf->user = xstrdup(block_state.user.buf);
1846 >  conf->host = xstrdup(block_state.host.buf);
1847   };
1848  
1849   shared_items: shared_items shared_item | shared_item;
# Line 1847 | Line 1852 | shared_item:  shared_name | shared_user
1852   shared_name: NAME '=' QSTRING ';'
1853   {
1854    if (conf_parser_ctx.pass == 2)
1855 <  {
1851 <    MyFree(yy_conf->name);
1852 <    DupString(yy_conf->name, yylval.string);
1853 <  }
1855 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1856   };
1857  
1858   shared_user: USER '=' QSTRING ';'
# Line 1861 | Line 1863 | shared_user: USER '=' QSTRING ';'
1863  
1864      nuh.nuhmask  = yylval.string;
1865      nuh.nickptr  = NULL;
1866 <    nuh.userptr  = userbuf;
1867 <    nuh.hostptr  = hostbuf;
1866 >    nuh.userptr  = block_state.user.buf;
1867 >    nuh.hostptr  = block_state.host.buf;
1868  
1869      nuh.nicksize = 0;
1870 <    nuh.usersize = sizeof(userbuf);
1871 <    nuh.hostsize = sizeof(hostbuf);
1870 >    nuh.usersize = sizeof(block_state.user.buf);
1871 >    nuh.hostsize = sizeof(block_state.host.buf);
1872  
1873      split_nuh(&nuh);
1872
1873    DupString(yy_match_item->user, userbuf);
1874    DupString(yy_match_item->host, hostbuf);
1874    }
1875   };
1876  
1877   shared_type: TYPE
1878   {
1879    if (conf_parser_ctx.pass == 2)
1880 <    yy_match_item->action = 0;
1880 >    block_state.flags.value = 0;
1881   } '=' shared_types ';' ;
1882  
1883   shared_types: shared_types ',' shared_type_item | shared_type_item;
1884   shared_type_item: KLINE
1885   {
1886    if (conf_parser_ctx.pass == 2)
1887 <    yy_match_item->action |= SHARED_KLINE;
1887 >    block_state.flags.value |= SHARED_KLINE;
1888   } | UNKLINE
1889   {
1890    if (conf_parser_ctx.pass == 2)
1891 <    yy_match_item->action |= SHARED_UNKLINE;
1891 >    block_state.flags.value |= SHARED_UNKLINE;
1892   } | T_DLINE
1893   {
1894    if (conf_parser_ctx.pass == 2)
1895 <    yy_match_item->action |= SHARED_DLINE;
1895 >    block_state.flags.value |= SHARED_DLINE;
1896   } | T_UNDLINE
1897   {
1898    if (conf_parser_ctx.pass == 2)
1899 <    yy_match_item->action |= SHARED_UNDLINE;
1899 >    block_state.flags.value |= SHARED_UNDLINE;
1900   } | XLINE
1901   {
1902    if (conf_parser_ctx.pass == 2)
1903 <    yy_match_item->action |= SHARED_XLINE;
1903 >    block_state.flags.value |= SHARED_XLINE;
1904   } | T_UNXLINE
1905   {
1906    if (conf_parser_ctx.pass == 2)
1907 <    yy_match_item->action |= SHARED_UNXLINE;
1907 >    block_state.flags.value |= SHARED_UNXLINE;
1908   } | RESV
1909   {
1910    if (conf_parser_ctx.pass == 2)
1911 <    yy_match_item->action |= SHARED_RESV;
1911 >    block_state.flags.value |= SHARED_RESV;
1912   } | T_UNRESV
1913   {
1914    if (conf_parser_ctx.pass == 2)
1915 <    yy_match_item->action |= SHARED_UNRESV;
1915 >    block_state.flags.value |= SHARED_UNRESV;
1916   } | T_LOCOPS
1917   {
1918    if (conf_parser_ctx.pass == 2)
1919 <    yy_match_item->action |= SHARED_LOCOPS;
1919 >    block_state.flags.value |= SHARED_LOCOPS;
1920   } | T_ALL
1921   {
1922    if (conf_parser_ctx.pass == 2)
1923 <    yy_match_item->action = SHARED_ALL;
1923 >    block_state.flags.value = SHARED_ALL;
1924   };
1925  
1926   /***************************************************************************
# Line 1929 | Line 1928 | shared_type_item: KLINE
1928   ***************************************************************************/
1929   cluster_entry: T_CLUSTER
1930   {
1931 <  if (conf_parser_ctx.pass == 2)
1932 <  {
1933 <    yy_conf = make_conf_item(CLUSTER_TYPE);
1934 <    yy_conf->flags = SHARED_ALL;
1935 <  }
1931 >  if (conf_parser_ctx.pass != 2)
1932 >    break;
1933 >
1934 >  reset_block_state();
1935 >
1936 >  strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1937 >  block_state.flags.value = SHARED_ALL;
1938   } '{' cluster_items '}' ';'
1939   {
1940 <  if (conf_parser_ctx.pass == 2)
1941 <  {
1942 <    if (yy_conf->name == NULL)
1943 <      DupString(yy_conf->name, "*");
1944 <    yy_conf = NULL;
1945 <  }
1940 >  struct MaskItem *conf = NULL;
1941 >
1942 >  if (conf_parser_ctx.pass != 2)
1943 >    break;
1944 >
1945 >  conf = conf_make(CONF_CLUSTER);
1946 >  conf->flags = block_state.flags.value;
1947 >  conf->name = xstrdup(block_state.name.buf);
1948   };
1949  
1950   cluster_items:  cluster_items cluster_item | cluster_item;
# Line 1950 | Line 1953 | cluster_item:  cluster_name | cluster_typ
1953   cluster_name: NAME '=' QSTRING ';'
1954   {
1955    if (conf_parser_ctx.pass == 2)
1956 <    DupString(yy_conf->name, yylval.string);
1956 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1957   };
1958  
1959   cluster_type: TYPE
1960   {
1961    if (conf_parser_ctx.pass == 2)
1962 <    yy_conf->flags = 0;
1962 >    block_state.flags.value = 0;
1963   } '=' cluster_types ';' ;
1964  
1965   cluster_types:  cluster_types ',' cluster_type_item | cluster_type_item;
1966   cluster_type_item: KLINE
1967   {
1968    if (conf_parser_ctx.pass == 2)
1969 <    yy_conf->flags |= SHARED_KLINE;
1969 >    block_state.flags.value |= SHARED_KLINE;
1970   } | UNKLINE
1971   {
1972    if (conf_parser_ctx.pass == 2)
1973 <    yy_conf->flags |= SHARED_UNKLINE;
1973 >    block_state.flags.value |= SHARED_UNKLINE;
1974   } | T_DLINE
1975   {
1976    if (conf_parser_ctx.pass == 2)
1977 <    yy_conf->flags |= SHARED_DLINE;
1977 >    block_state.flags.value |= SHARED_DLINE;
1978   } | T_UNDLINE
1979   {
1980    if (conf_parser_ctx.pass == 2)
1981 <    yy_conf->flags |= SHARED_UNDLINE;
1981 >    block_state.flags.value |= SHARED_UNDLINE;
1982   } | XLINE
1983   {
1984    if (conf_parser_ctx.pass == 2)
1985 <    yy_conf->flags |= SHARED_XLINE;
1985 >    block_state.flags.value |= SHARED_XLINE;
1986   } | T_UNXLINE
1987   {
1988    if (conf_parser_ctx.pass == 2)
1989 <    yy_conf->flags |= SHARED_UNXLINE;
1989 >    block_state.flags.value |= SHARED_UNXLINE;
1990   } | RESV
1991   {
1992    if (conf_parser_ctx.pass == 2)
1993 <    yy_conf->flags |= SHARED_RESV;
1993 >    block_state.flags.value |= SHARED_RESV;
1994   } | T_UNRESV
1995   {
1996    if (conf_parser_ctx.pass == 2)
1997 <    yy_conf->flags |= SHARED_UNRESV;
1997 >    block_state.flags.value |= SHARED_UNRESV;
1998   } | T_LOCOPS
1999   {
2000    if (conf_parser_ctx.pass == 2)
2001 <    yy_conf->flags |= SHARED_LOCOPS;
2001 >    block_state.flags.value |= SHARED_LOCOPS;
2002   } | T_ALL
2003   {
2004    if (conf_parser_ctx.pass == 2)
2005 <    yy_conf->flags = SHARED_ALL;
2005 >    block_state.flags.value = SHARED_ALL;
2006   };
2007  
2008   /***************************************************************************
# Line 2007 | Line 2010 | cluster_type_item: KLINE
2010   ***************************************************************************/
2011   connect_entry: CONNECT  
2012   {
2010  if (conf_parser_ctx.pass == 2)
2011  {
2012    yy_conf = make_conf_item(SERVER_TYPE);
2013    yy_aconf = map_to_conf(yy_conf);
2013  
2014 <    /* defaults */
2015 <    yy_aconf->port = PORTNUM;
2016 <  }
2017 <  else
2018 <  {
2020 <    MyFree(class_name);
2021 <    class_name = NULL;
2022 <  }
2014 >  if (conf_parser_ctx.pass != 2)
2015 >    break;
2016 >
2017 >  reset_block_state();
2018 >  block_state.port.value = PORTNUM;
2019   } '{' connect_items '}' ';'
2020   {
2021 <  if (conf_parser_ctx.pass == 2)
2021 >  struct MaskItem *conf = NULL;
2022 >  struct addrinfo hints, *res;
2023 >
2024 >  if (conf_parser_ctx.pass != 2)
2025 >    break;
2026 >
2027 >  if (!block_state.name.buf[0] ||
2028 >      !block_state.host.buf[0])
2029 >    break;
2030 >
2031 >  if (!block_state.rpass.buf[0] ||
2032 >      !block_state.spass.buf[0])
2033 >    break;
2034 >
2035 >  if (has_wildcards(block_state.name.buf) ||
2036 >      has_wildcards(block_state.host.buf))
2037 >    break;
2038 >
2039 >  conf = conf_make(CONF_SERVER);
2040 >  conf->port = block_state.port.value;
2041 >  conf->flags = block_state.flags.value;
2042 >  conf->aftype = block_state.aftype.value;
2043 >  conf->host = xstrdup(block_state.host.buf);
2044 >  conf->name = xstrdup(block_state.name.buf);
2045 >  conf->passwd = xstrdup(block_state.rpass.buf);
2046 >  conf->spasswd = xstrdup(block_state.spass.buf);
2047 >  conf->cipher_list = xstrdup(block_state.ciph.buf);
2048 >
2049 >  dlinkMoveList(&block_state.leaf.list, &conf->leaf_list);
2050 >  dlinkMoveList(&block_state.hub.list, &conf->hub_list);
2051 >
2052 >  if (block_state.bind.buf[0])
2053    {
2054 <    if (yy_aconf->host && yy_aconf->passwd && yy_aconf->spasswd)
2055 <    {
2056 <      if (conf_add_server(yy_conf, class_name) == -1)
2057 <        delete_conf_item(yy_conf);
2058 <    }
2054 >    memset(&hints, 0, sizeof(hints));
2055 >
2056 >    hints.ai_family   = AF_UNSPEC;
2057 >    hints.ai_socktype = SOCK_STREAM;
2058 >    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
2059 >
2060 >    if (getaddrinfo(block_state.bind.buf, NULL, &hints, &res))
2061 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", block_state.bind.buf);
2062      else
2063      {
2064 <      if (yy_conf->name != NULL)
2035 <      {
2036 <        if (yy_aconf->host == NULL)
2037 <          yyerror("Ignoring connect block -- missing host");
2038 <        else if (!yy_aconf->passwd || !yy_aconf->spasswd)
2039 <          yyerror("Ignoring connect block -- missing password");
2040 <      }
2064 >      assert(res != NULL);
2065  
2066 <      /* XXX
2067 <       * This fixes a try_connections() core (caused by invalid class_ptr
2068 <       * pointers) reported by metalrock. That's an ugly fix, but there
2069 <       * is currently no better way. The entire config subsystem needs an
2046 <       * rewrite ASAP. make_conf_item() shouldn't really add things onto
2047 <       * a doubly linked list immediately without any sanity checks!  -Michael
2048 <       */
2049 <      delete_conf_item(yy_conf);
2066 >      memcpy(&conf->bind, res->ai_addr, res->ai_addrlen);
2067 >      conf->bind.ss.ss_family = res->ai_family;
2068 >      conf->bind.ss_len = res->ai_addrlen;
2069 >      freeaddrinfo(res);
2070      }
2051
2052    MyFree(class_name);
2053    class_name = NULL;
2054    yy_conf = NULL;
2055    yy_aconf = NULL;
2071    }
2072 +
2073 +  conf_add_class_to_conf(conf, block_state.class.buf);
2074 +  lookup_confhost(conf);
2075   };
2076  
2077   connect_items:  connect_items connect_item | connect_item;
# Line 2067 | Line 2085 | connect_item:   connect_name | connect_h
2085   connect_name: NAME '=' QSTRING ';'
2086   {
2087    if (conf_parser_ctx.pass == 2)
2088 <  {
2071 <    MyFree(yy_conf->name);
2072 <    DupString(yy_conf->name, yylval.string);
2073 <  }
2088 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
2089   };
2090  
2091   connect_host: HOST '=' QSTRING ';'
2092   {
2093    if (conf_parser_ctx.pass == 2)
2094 <  {
2080 <    MyFree(yy_aconf->host);
2081 <    DupString(yy_aconf->host, yylval.string);
2082 <  }
2094 >    strlcpy(block_state.host.buf, yylval.string, sizeof(block_state.host.buf));
2095   };
2096  
2097   connect_vhost: VHOST '=' QSTRING ';'
2098   {
2099    if (conf_parser_ctx.pass == 2)
2100 <  {
2089 <    struct addrinfo hints, *res;
2090 <
2091 <    memset(&hints, 0, sizeof(hints));
2092 <
2093 <    hints.ai_family   = AF_UNSPEC;
2094 <    hints.ai_socktype = SOCK_STREAM;
2095 <    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
2096 <
2097 <    if (getaddrinfo(yylval.string, NULL, &hints, &res))
2098 <      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", yylval.string);
2099 <    else
2100 <    {
2101 <      assert(res != NULL);
2102 <
2103 <      memcpy(&yy_aconf->bind, res->ai_addr, res->ai_addrlen);
2104 <      yy_aconf->bind.ss.ss_family = res->ai_family;
2105 <      yy_aconf->bind.ss_len = res->ai_addrlen;
2106 <      freeaddrinfo(res);
2107 <    }
2108 <  }
2100 >    strlcpy(block_state.bind.buf, yylval.string, sizeof(block_state.bind.buf));
2101   };
2102  
2103   connect_send_password: SEND_PASSWORD '=' QSTRING ';'
2104   {
2105 <  if (conf_parser_ctx.pass == 2)
2106 <  {
2115 <    if ($3[0] == ':')
2116 <      yyerror("Server passwords cannot begin with a colon");
2117 <    else if (strchr($3, ' ') != NULL)
2118 <      yyerror("Server passwords cannot contain spaces");
2119 <    else {
2120 <      if (yy_aconf->spasswd != NULL)
2121 <        memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd));
2105 >  if (conf_parser_ctx.pass != 2)
2106 >    break;
2107  
2108 <      MyFree(yy_aconf->spasswd);
2109 <      DupString(yy_aconf->spasswd, yylval.string);
2110 <    }
2111 <  }
2108 >  if ($3[0] == ':')
2109 >    conf_error_report("Server passwords cannot begin with a colon");
2110 >  else if (strchr($3, ' ') != NULL)
2111 >    conf_error_report("Server passwords cannot contain spaces");
2112 >  else
2113 >    strlcpy(block_state.spass.buf, yylval.string, sizeof(block_state.spass.buf));
2114   };
2115  
2116   connect_accept_password: ACCEPT_PASSWORD '=' QSTRING ';'
2117   {
2118 <  if (conf_parser_ctx.pass == 2)
2119 <  {
2133 <    if ($3[0] == ':')
2134 <      yyerror("Server passwords cannot begin with a colon");
2135 <    else if (strchr($3, ' ') != NULL)
2136 <      yyerror("Server passwords cannot contain spaces");
2137 <    else {
2138 <      if (yy_aconf->passwd != NULL)
2139 <        memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
2118 >  if (conf_parser_ctx.pass != 2)
2119 >    break;
2120  
2121 <      MyFree(yy_aconf->passwd);
2122 <      DupString(yy_aconf->passwd, yylval.string);
2123 <    }
2124 <  }
2121 >  if ($3[0] == ':')
2122 >    conf_error_report("Server passwords cannot begin with a colon");
2123 >  else if (strchr($3, ' ') != NULL)
2124 >    conf_error_report("Server passwords cannot contain spaces");
2125 >  else
2126 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2127   };
2128  
2129   connect_port: PORT '=' NUMBER ';'
2130   {
2131    if (conf_parser_ctx.pass == 2)
2132 <    yy_aconf->port = $3;
2132 >    block_state.port.value = $3;
2133   };
2134  
2135   connect_aftype: AFTYPE '=' T_IPV4 ';'
2136   {
2137    if (conf_parser_ctx.pass == 2)
2138 <    yy_aconf->aftype = AF_INET;
2138 >    block_state.aftype.value = AF_INET;
2139   } | AFTYPE '=' T_IPV6 ';'
2140   {
2141   #ifdef IPV6
2142    if (conf_parser_ctx.pass == 2)
2143 <    yy_aconf->aftype = AF_INET6;
2143 >    block_state.aftype.value = AF_INET6;
2144   #endif
2145   };
2146  
2147   connect_flags: IRCD_FLAGS
2148   {
2149 +  block_state.flags.value &= CONF_FLAGS_ENCRYPTED;
2150   } '='  connect_flags_items ';';
2151  
2152   connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;
2153   connect_flags_item: AUTOCONN
2154   {
2155    if (conf_parser_ctx.pass == 2)
2156 <    SetConfAllowAutoConn(yy_aconf);
2156 >    block_state.flags.value |= CONF_FLAGS_ALLOW_AUTO_CONN;
2157   } | T_SSL
2158   {
2159    if (conf_parser_ctx.pass == 2)
2160 <    SetConfSSL(yy_aconf);
2160 >    block_state.flags.value |= CONF_FLAGS_SSL;
2161   };
2162  
2163   connect_encrypted: ENCRYPTED '=' TBOOL ';'
# Line 2182 | Line 2165 | connect_encrypted: ENCRYPTED '=' TBOOL '
2165    if (conf_parser_ctx.pass == 2)
2166    {
2167      if (yylval.number)
2168 <      yy_aconf->flags |= CONF_FLAGS_ENCRYPTED;
2168 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
2169      else
2170 <      yy_aconf->flags &= ~CONF_FLAGS_ENCRYPTED;
2170 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
2171    }
2172   };
2173  
2174   connect_hub_mask: HUB_MASK '=' QSTRING ';'
2175   {
2176    if (conf_parser_ctx.pass == 2)
2177 <  {
2195 <    char *mask;
2196 <
2197 <    DupString(mask, yylval.string);
2198 <    dlinkAdd(mask, make_dlink_node(), &yy_aconf->hub_list);
2199 <  }
2177 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.hub.list);
2178   };
2179  
2180   connect_leaf_mask: LEAF_MASK '=' QSTRING ';'
2181   {
2182    if (conf_parser_ctx.pass == 2)
2183 <  {
2206 <    char *mask;
2207 <
2208 <    DupString(mask, yylval.string);
2209 <    dlinkAdd(mask, make_dlink_node(), &yy_aconf->leaf_list);
2210 <  }
2183 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.leaf.list);
2184   };
2185  
2186   connect_class: CLASS '=' QSTRING ';'
2187   {
2188    if (conf_parser_ctx.pass == 2)
2189 <  {
2217 <    MyFree(class_name);
2218 <    DupString(class_name, yylval.string);
2219 <  }
2189 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
2190   };
2191  
2192   connect_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
2193   {
2194   #ifdef HAVE_LIBCRYPTO
2195    if (conf_parser_ctx.pass == 2)
2196 <  {
2227 <    MyFree(yy_aconf->cipher_list);
2228 <    DupString(yy_aconf->cipher_list, yylval.string);
2229 <  }
2196 >    strlcpy(block_state.ciph.buf, yylval.string, sizeof(block_state.ciph.buf));
2197   #else
2198    if (conf_parser_ctx.pass == 2)
2199 <    yyerror("Ignoring connect::ciphers -- no OpenSSL support");
2199 >    conf_error_report("Ignoring connect::ciphers -- no OpenSSL support");
2200   #endif
2201   };
2202  
# Line 2240 | Line 2207 | connect_ssl_cipher_list: T_SSL_CIPHER_LI
2207   kill_entry: KILL
2208   {
2209    if (conf_parser_ctx.pass == 2)
2210 <  {
2244 <    userbuf[0] = hostbuf[0] = reasonbuf[0] = '\0';
2245 <    regex_ban = 0;
2246 <  }
2210 >    reset_block_state();
2211   } '{' kill_items '}' ';'
2212   {
2213 <  if (conf_parser_ctx.pass == 2)
2250 <  {
2251 <    if (userbuf[0] && hostbuf[0])
2252 <    {
2253 <      if (regex_ban)
2254 <      {
2255 < #ifdef HAVE_LIBPCRE
2256 <        void *exp_user = NULL;
2257 <        void *exp_host = NULL;
2258 <        const char *errptr = NULL;
2259 <
2260 <        if (!(exp_user = ircd_pcre_compile(userbuf, &errptr)) ||
2261 <            !(exp_host = ircd_pcre_compile(hostbuf, &errptr)))
2262 <        {
2263 <          ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: %s",
2264 <               errptr);
2265 <          break;
2266 <        }
2267 <
2268 <        yy_aconf = map_to_conf(make_conf_item(RKLINE_TYPE));
2269 <        yy_aconf->regexuser = exp_user;
2270 <        yy_aconf->regexhost = exp_host;
2213 >  struct MaskItem *conf = NULL;
2214  
2215 <        DupString(yy_aconf->user, userbuf);
2216 <        DupString(yy_aconf->host, hostbuf);
2215 >  if (conf_parser_ctx.pass != 2)
2216 >    break;
2217  
2218 <        if (reasonbuf[0])
2219 <          DupString(yy_aconf->reason, reasonbuf);
2220 <        else
2278 <          DupString(yy_aconf->reason, "No reason");
2279 < #else
2280 <        ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: no PCRE support");
2281 <        break;
2282 < #endif
2283 <      }
2284 <      else
2285 <      {
2286 <        find_and_delete_temporary(userbuf, hostbuf, CONF_KLINE);
2287 <
2288 <        yy_aconf = map_to_conf(make_conf_item(KLINE_TYPE));
2218 >  if (!block_state.user.buf[0] ||
2219 >      !block_state.host.buf[0])
2220 >    break;
2221  
2222 <        DupString(yy_aconf->user, userbuf);
2223 <        DupString(yy_aconf->host, hostbuf);
2222 >  conf = conf_make(CONF_KLINE);
2223 >  conf->user = xstrdup(block_state.user.buf);
2224 >  conf->host = xstrdup(block_state.host.buf);
2225  
2226 <        if (reasonbuf[0])
2227 <          DupString(yy_aconf->reason, reasonbuf);
2228 <        else
2229 <          DupString(yy_aconf->reason, "No reason");
2230 <        add_conf_by_address(CONF_KLINE, yy_aconf);
2298 <      }
2299 <    }
2300 <
2301 <    yy_aconf = NULL;
2302 <  }
2226 >  if (block_state.rpass.buf[0])
2227 >    conf->reason = xstrdup(block_state.rpass.buf);
2228 >  else
2229 >    conf->reason = xstrdup(CONF_NOREASON);
2230 >  add_conf_by_address(CONF_KLINE, conf);
2231   };
2232  
2305 kill_type: TYPE
2306 {
2307 } '='  kill_type_items ';';
2308
2309 kill_type_items: kill_type_items ',' kill_type_item | kill_type_item;
2310 kill_type_item: REGEX_T
2311 {
2312  if (conf_parser_ctx.pass == 2)
2313    regex_ban = 1;
2314 };
2315
2233   kill_items:     kill_items kill_item | kill_item;
2234 < kill_item:      kill_user | kill_reason | kill_type | error;
2234 > kill_item:      kill_user | kill_reason | error;
2235  
2236   kill_user: USER '=' QSTRING ';'
2237   {
2238 +
2239    if (conf_parser_ctx.pass == 2)
2240    {
2241      struct split_nuh_item nuh;
2242  
2243      nuh.nuhmask  = yylval.string;
2244      nuh.nickptr  = NULL;
2245 <    nuh.userptr  = userbuf;
2246 <    nuh.hostptr  = hostbuf;
2245 >    nuh.userptr  = block_state.user.buf;
2246 >    nuh.hostptr  = block_state.host.buf;
2247  
2248      nuh.nicksize = 0;
2249 <    nuh.usersize = sizeof(userbuf);
2250 <    nuh.hostsize = sizeof(hostbuf);
2249 >    nuh.usersize = sizeof(block_state.user.buf);
2250 >    nuh.hostsize = sizeof(block_state.host.buf);
2251  
2252      split_nuh(&nuh);
2253    }
# Line 2338 | Line 2256 | kill_user: USER '=' QSTRING ';'
2256   kill_reason: REASON '=' QSTRING ';'
2257   {
2258    if (conf_parser_ctx.pass == 2)
2259 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2259 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2260   };
2261  
2262   /***************************************************************************
# Line 2347 | Line 2265 | kill_reason: REASON '=' QSTRING ';'
2265   deny_entry: DENY
2266   {
2267    if (conf_parser_ctx.pass == 2)
2268 <    hostbuf[0] = reasonbuf[0] = '\0';
2268 >    reset_block_state();
2269   } '{' deny_items '}' ';'
2270   {
2271 <  if (conf_parser_ctx.pass == 2)
2354 <  {
2355 <    if (hostbuf[0] && parse_netmask(hostbuf, NULL, NULL) != HM_HOST)
2356 <    {
2357 <      find_and_delete_temporary(NULL, hostbuf, CONF_DLINE);
2271 >  struct MaskItem *conf = NULL;
2272  
2273 <      yy_aconf = map_to_conf(make_conf_item(DLINE_TYPE));
2274 <      DupString(yy_aconf->host, hostbuf);
2273 >  if (conf_parser_ctx.pass != 2)
2274 >    break;
2275  
2276 <      if (reasonbuf[0])
2277 <        DupString(yy_aconf->reason, reasonbuf);
2278 <      else
2279 <        DupString(yy_aconf->reason, "No reason");
2280 <      add_conf_by_address(CONF_DLINE, yy_aconf);
2281 <      yy_aconf = NULL;
2282 <    }
2276 >  if (!block_state.addr.buf[0])
2277 >    break;
2278 >
2279 >  if (parse_netmask(block_state.addr.buf, NULL, NULL) != HM_HOST)
2280 >  {
2281 >    conf = conf_make(CONF_DLINE);
2282 >    conf->host = xstrdup(block_state.addr.buf);
2283 >
2284 >    if (block_state.rpass.buf[0])
2285 >      conf->reason = xstrdup(block_state.rpass.buf);
2286 >    else
2287 >      conf->reason = xstrdup(CONF_NOREASON);
2288 >    add_conf_by_address(CONF_DLINE, conf);
2289    }
2290   };
2291  
# Line 2375 | Line 2295 | deny_item:      deny_ip | deny_reason |
2295   deny_ip: IP '=' QSTRING ';'
2296   {
2297    if (conf_parser_ctx.pass == 2)
2298 <    strlcpy(hostbuf, yylval.string, sizeof(hostbuf));
2298 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
2299   };
2300  
2301   deny_reason: REASON '=' QSTRING ';'
2302   {
2303    if (conf_parser_ctx.pass == 2)
2304 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2304 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2305   };
2306  
2307   /***************************************************************************
# Line 2398 | Line 2318 | exempt_ip: IP '=' QSTRING ';'
2318    {
2319      if (yylval.string[0] && parse_netmask(yylval.string, NULL, NULL) != HM_HOST)
2320      {
2321 <      yy_aconf = map_to_conf(make_conf_item(EXEMPTDLINE_TYPE));
2322 <      DupString(yy_aconf->host, yylval.string);
2321 >      struct MaskItem *conf = conf_make(CONF_EXEMPT);
2322 >      conf->host = xstrdup(yylval.string);
2323  
2324 <      add_conf_by_address(CONF_EXEMPTDLINE, yy_aconf);
2405 <      yy_aconf = NULL;
2324 >      add_conf_by_address(CONF_EXEMPT, conf);
2325      }
2326    }
2327   };
# Line 2413 | Line 2332 | exempt_ip: IP '=' QSTRING ';'
2332   gecos_entry: GECOS
2333   {
2334    if (conf_parser_ctx.pass == 2)
2335 <  {
2417 <    regex_ban = 0;
2418 <    reasonbuf[0] = gecos_name[0] = '\0';
2419 <  }
2335 >    reset_block_state();
2336   } '{' gecos_items '}' ';'
2337   {
2338 <  if (conf_parser_ctx.pass == 2)
2423 <  {
2424 <    if (gecos_name[0])
2425 <    {
2426 <      if (regex_ban)
2427 <      {
2428 < #ifdef HAVE_LIBPCRE
2429 <        void *exp_p = NULL;
2430 <        const char *errptr = NULL;
2431 <
2432 <        if (!(exp_p = ircd_pcre_compile(gecos_name, &errptr)))
2433 <        {
2434 <          ilog(LOG_TYPE_IRCD, "Failed to add regular expression based X-Line: %s",
2435 <               errptr);
2436 <          break;
2437 <        }
2338 >  struct MaskItem *conf = NULL;
2339  
2340 <        yy_conf = make_conf_item(RXLINE_TYPE);
2341 <        yy_conf->regexpname = exp_p;
2441 < #else
2442 <        ilog(LOG_TYPE_IRCD, "Failed to add regular expression based X-Line: no PCRE support");
2443 <        break;
2444 < #endif
2445 <      }
2446 <      else
2447 <        yy_conf = make_conf_item(XLINE_TYPE);
2340 >  if (conf_parser_ctx.pass != 2)
2341 >    break;
2342  
2343 <      yy_match_item = map_to_conf(yy_conf);
2344 <      DupString(yy_conf->name, gecos_name);
2343 >  if (!block_state.name.buf[0])
2344 >    break;
2345  
2346 <      if (reasonbuf[0])
2347 <        DupString(yy_match_item->reason, reasonbuf);
2454 <      else
2455 <        DupString(yy_match_item->reason, "No reason");
2456 <    }
2457 <  }
2458 < };
2346 >  conf = conf_make(CONF_XLINE);
2347 >  conf->name = xstrdup(block_state.name.buf);
2348  
2349 < gecos_flags: TYPE
2350 < {
2351 < } '='  gecos_flags_items ';';
2352 <
2464 < gecos_flags_items: gecos_flags_items ',' gecos_flags_item | gecos_flags_item;
2465 < gecos_flags_item: REGEX_T
2466 < {
2467 <  if (conf_parser_ctx.pass == 2)
2468 <    regex_ban = 1;
2349 >  if (block_state.rpass.buf[0])
2350 >    conf->reason = xstrdup(block_state.rpass.buf);
2351 >  else
2352 >    conf->reason = xstrdup(CONF_NOREASON);
2353   };
2354  
2355   gecos_items: gecos_items gecos_item | gecos_item;
2356 < gecos_item:  gecos_name | gecos_reason | gecos_flags | error;
2356 > gecos_item:  gecos_name | gecos_reason | error;
2357  
2358   gecos_name: NAME '=' QSTRING ';'
2359   {
2360    if (conf_parser_ctx.pass == 2)
2361 <    strlcpy(gecos_name, yylval.string, sizeof(gecos_name));
2361 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
2362   };
2363  
2364   gecos_reason: REASON '=' QSTRING ';'
2365   {
2366    if (conf_parser_ctx.pass == 2)
2367 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2367 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2368   };
2369  
2370   /***************************************************************************
# Line 2503 | Line 2387 | general_item:       general_hide_spoof_i
2387                      general_pace_wait_simple | general_stats_P_oper_only |
2388                      general_short_motd | general_no_oper_flood |
2389                      general_true_no_oper_flood | general_oper_pass_resv |
2506                    general_message_locale |
2390                      general_oper_only_umodes | general_max_targets |
2391                      general_use_egd | general_egdpool_path |
2392                      general_oper_umodes | general_caller_id_wait |
# Line 2713 | Line 2596 | general_oper_pass_resv: OPER_PASS_RESV '
2596    ConfigFileEntry.oper_pass_resv = yylval.number;
2597   };
2598  
2716 general_message_locale: MESSAGE_LOCALE '=' QSTRING ';'
2717 {
2718  if (conf_parser_ctx.pass == 2)
2719  {
2720    if (strlen(yylval.string) > LOCALE_LENGTH-2)
2721      yylval.string[LOCALE_LENGTH-1] = '\0';
2722
2723    set_locale(yylval.string);
2724  }
2725 };
2726
2599   general_dots_in_ident: DOTS_IN_IDENT '=' NUMBER ';'
2600   {
2601    ConfigFileEntry.dots_in_ident = $3;
# Line 2744 | Line 2616 | general_egdpool_path: EGDPOOL_PATH '=' Q
2616    if (conf_parser_ctx.pass == 2)
2617    {
2618      MyFree(ConfigFileEntry.egdpool_path);
2619 <    DupString(ConfigFileEntry.egdpool_path, yylval.string);
2619 >    ConfigFileEntry.egdpool_path = xstrdup(yylval.string);
2620    }
2621   };
2622  
# Line 2753 | Line 2625 | general_services_name: T_SERVICES_NAME '
2625    if (conf_parser_ctx.pass == 2 && valid_servname(yylval.string))
2626    {
2627      MyFree(ConfigFileEntry.service_name);
2628 <    DupString(ConfigFileEntry.service_name, yylval.string);
2628 >    ConfigFileEntry.service_name = xstrdup(yylval.string);
2629    }
2630   };
2631  
# Line 2784 | Line 2656 | umode_oitem:     T_BOTS
2656   } | T_CCONN
2657   {
2658    ConfigFileEntry.oper_umodes |= UMODE_CCONN;
2787 } | T_CCONN_FULL
2788 {
2789  ConfigFileEntry.oper_umodes |= UMODE_CCONN_FULL;
2659   } | T_DEAF
2660   {
2661    ConfigFileEntry.oper_umodes |= UMODE_DEAF;
# Line 2838 | Line 2707 | umode_oitem:     T_BOTS
2707   } | T_LOCOPS
2708   {
2709    ConfigFileEntry.oper_umodes |= UMODE_LOCOPS;
2710 + } | T_NONONREG
2711 + {
2712 +  ConfigFileEntry.oper_umodes |= UMODE_REGONLY;
2713 + } | T_FARCONNECT
2714 + {
2715 +  ConfigFileEntry.oper_umodes |= UMODE_FARCONNECT;
2716   };
2717  
2718   general_oper_only_umodes: OPER_ONLY_UMODES
# Line 2852 | Line 2727 | umode_item:    T_BOTS
2727   } | T_CCONN
2728   {
2729    ConfigFileEntry.oper_only_umodes |= UMODE_CCONN;
2855 } | T_CCONN_FULL
2856 {
2857  ConfigFileEntry.oper_only_umodes |= UMODE_CCONN_FULL;
2730   } | T_DEAF
2731   {
2732    ConfigFileEntry.oper_only_umodes |= UMODE_DEAF;
# Line 2906 | Line 2778 | umode_item:    T_BOTS
2778   } | T_LOCOPS
2779   {
2780    ConfigFileEntry.oper_only_umodes |= UMODE_LOCOPS;
2781 + } | T_NONONREG
2782 + {
2783 +  ConfigFileEntry.oper_only_umodes |= UMODE_REGONLY;
2784 + } | T_FARCONNECT
2785 + {
2786 +  ConfigFileEntry.oper_only_umodes |= UMODE_FARCONNECT;
2787   };
2788  
2789   general_min_nonwildcard: MIN_NONWILDCARD '=' NUMBER ';'
# Line 2934 | Line 2812 | channel_items:      channel_items channe
2812   channel_item:       channel_max_bans |
2813                      channel_knock_delay | channel_knock_delay_channel |
2814                      channel_max_chans_per_user | channel_max_chans_per_oper |
2815 <                    channel_quiet_on_ban | channel_default_split_user_count |
2815 >                    channel_default_split_user_count |
2816                      channel_default_split_server_count |
2817 <                    channel_no_create_on_split | channel_restrict_channels |
2817 >                    channel_no_create_on_split |
2818                      channel_no_join_on_split |
2819                      channel_jflood_count | channel_jflood_time |
2820                      channel_disable_fake_channels | error;
# Line 2946 | Line 2824 | channel_disable_fake_channels: DISABLE_F
2824    ConfigChannel.disable_fake_channels = yylval.number;
2825   };
2826  
2949 channel_restrict_channels: RESTRICT_CHANNELS '=' TBOOL ';'
2950 {
2951  ConfigChannel.restrict_channels = yylval.number;
2952 };
2953
2827   channel_knock_delay: KNOCK_DELAY '=' timespec ';'
2828   {
2829    ConfigChannel.knock_delay = $3;
# Line 2971 | Line 2844 | channel_max_chans_per_oper: MAX_CHANS_PE
2844    ConfigChannel.max_chans_per_oper = $3;
2845   };
2846  
2974 channel_quiet_on_ban: QUIET_ON_BAN '=' TBOOL ';'
2975 {
2976  ConfigChannel.quiet_on_ban = yylval.number;
2977 };
2978
2847   channel_max_bans: MAX_BANS '=' NUMBER ';'
2848   {
2849    ConfigChannel.max_bans = $3;
# Line 3019 | Line 2887 | serverhide_entry: SERVERHIDE
2887  
2888   serverhide_items:   serverhide_items serverhide_item | serverhide_item;
2889   serverhide_item:    serverhide_flatten_links | serverhide_hide_servers |
2890 +                    serverhide_hide_services |
2891                      serverhide_links_delay |
2892                      serverhide_hidden | serverhide_hidden_name |
2893                      serverhide_hide_server_ips |
# Line 3036 | Line 2905 | serverhide_hide_servers: HIDE_SERVERS '=
2905      ConfigServerHide.hide_servers = yylval.number;
2906   };
2907  
2908 + serverhide_hide_services: HIDE_SERVICES '=' TBOOL ';'
2909 + {
2910 +  if (conf_parser_ctx.pass == 2)
2911 +    ConfigServerHide.hide_services = yylval.number;
2912 + };
2913 +
2914   serverhide_hidden_name: HIDDEN_NAME '=' QSTRING ';'
2915   {
2916    if (conf_parser_ctx.pass == 2)
2917    {
2918      MyFree(ConfigServerHide.hidden_name);
2919 <    DupString(ConfigServerHide.hidden_name, yylval.string);
2919 >    ConfigServerHide.hidden_name = xstrdup(yylval.string);
2920    }
2921   };
2922  

Diff Legend

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