ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_parser.y
(Generate patch)

Comparing:
ircd-hybrid-8/src/conf_parser.y (file contents), Revision 1547 by michael, Sun Sep 30 17:50:03 2012 UTC vs.
ircd-hybrid/trunk/src/conf_parser.y (file contents), Revision 3435 by michael, Thu May 1 13:57:39 2014 UTC

# Line 1 | Line 1
1   /*
2 < *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  conf_parser.y: Parses the ircd configuration file.
2 > *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3   *
4 < *  Copyright (C) 2005 by the past and present ircd coders, and others.
4 > *  Copyright (c) 2000-2014 ircd-hybrid development team
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 18 | Line 17
17   *  along with this program; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   *  USA
21 *
22 *  $Id$
20   */
21  
22 + /*! \file conf_parser.y
23 + * \brief Parses the ircd configuration file.
24 + * \version $Id$
25 + */
26 +
27 +
28   %{
29  
30   #define YY_NO_UNPUT
# Line 33 | Line 36
36   #include "ircd.h"
37   #include "list.h"
38   #include "conf.h"
39 + #include "conf_class.h"
40   #include "event.h"
41   #include "log.h"
42   #include "client.h"     /* for UMODE_ALL only */
43   #include "irc_string.h"
40 #include "sprintf_irc.h"
44   #include "memory.h"
45   #include "modules.h"
46 < #include "s_serv.h"
46 > #include "server.h"
47   #include "hostmask.h"
48   #include "send.h"
49   #include "listener.h"
50   #include "resv.h"
51   #include "numeric.h"
52 < #include "s_user.h"
52 > #include "user.h"
53 > #include "motd.h"
54  
55   #ifdef HAVE_LIBCRYPTO
56   #include <openssl/rsa.h>
# Line 55 | Line 59
59   #include <openssl/dh.h>
60   #endif
61  
62 + #include "rsa.h"
63 +
64   int yylex(void);
65  
66 < static char *class_name = NULL;
67 < static struct ConfItem *yy_conf = NULL;
68 < static struct AccessItem *yy_aconf = NULL;
69 < static struct MatchItem *yy_match_item = NULL;
70 < static struct ClassItem *yy_class = NULL;
71 < static char *yy_class_name = NULL;
72 <
73 < static dlink_list col_conf_list  = { NULL, NULL, 0 };
74 < static unsigned int listener_flags = 0;
75 < static unsigned int regex_ban = 0;
76 < static char userbuf[IRCD_BUFSIZE];
77 < static char hostbuf[IRCD_BUFSIZE];
78 < static char reasonbuf[REASONLEN + 1];
79 < static char gecos_name[REALLEN * 4];
80 < static char lfile[IRCD_BUFSIZE];
81 < static unsigned int ltype = 0;
82 < static unsigned int lsize = 0;
83 < static char *resv_reason = NULL;
84 < static char *listener_address = NULL;
85 <
86 < struct CollectItem
87 < {
88 <  dlink_node node;
89 <  char *name;
90 <  char *user;
91 <  char *host;
92 <  char *passwd;
93 <  int  port;
94 <  int  flags;
95 < #ifdef HAVE_LIBCRYPTO
96 <  char *rsa_public_key_file;
97 <  RSA *rsa_public_key;
98 < #endif
99 < };
66 > static struct
67 > {
68 >  struct {
69 >    dlink_list list;
70 >  } mask,
71 >    leaf,
72 >    hub;
73 >
74 >  struct {
75 >    char buf[IRCD_BUFSIZE];
76 >  } name,
77 >    user,
78 >    host,
79 >    addr,
80 >    bind,
81 >    file,
82 >    ciph,
83 >    cert,
84 >    rpass,
85 >    spass,
86 >    class;
87 >
88 >  struct {
89 >    unsigned int value;
90 >  } flags,
91 >    modes,
92 >    size,
93 >    type,
94 >    port,
95 >    aftype,
96 >    ping_freq,
97 >    max_perip,
98 >    con_freq,
99 >    min_idle,
100 >    max_idle,
101 >    max_total,
102 >    max_global,
103 >    max_local,
104 >    max_ident,
105 >    max_sendq,
106 >    max_recvq,
107 >    cidr_bitlen_ipv4,
108 >    cidr_bitlen_ipv6,
109 >    number_per_cidr;
110 > } block_state;
111  
112   static void
113 < free_collect_item(struct CollectItem *item)
113 > reset_block_state(void)
114   {
115 <  MyFree(item->name);
116 <  MyFree(item->user);
117 <  MyFree(item->host);
118 <  MyFree(item->passwd);
119 < #ifdef HAVE_LIBCRYPTO
120 <  MyFree(item->rsa_public_key_file);
121 < #endif
122 <  MyFree(item);
115 >  dlink_node *ptr = NULL, *ptr_next = NULL;
116 >
117 >  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.mask.list.head)
118 >  {
119 >    MyFree(ptr->data);
120 >    dlinkDelete(ptr, &block_state.mask.list);
121 >    free_dlink_node(ptr);
122 >  }
123 >
124 >  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.leaf.list.head)
125 >  {
126 >    MyFree(ptr->data);
127 >    dlinkDelete(ptr, &block_state.leaf.list);
128 >    free_dlink_node(ptr);
129 >  }
130 >
131 >  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.hub.list.head)
132 >  {
133 >    MyFree(ptr->data);
134 >    dlinkDelete(ptr, &block_state.hub.list);
135 >    free_dlink_node(ptr);
136 >  }
137 >
138 >  memset(&block_state, 0, sizeof(block_state));
139   }
140  
141   %}
# Line 122 | Line 155 | free_collect_item(struct CollectItem *it
155   %token  CALLER_ID_WAIT
156   %token  CAN_FLOOD
157   %token  CHANNEL
158 < %token  CIDR_BITLEN_IPV4
159 < %token  CIDR_BITLEN_IPV6
158 > %token  CIDR_BITLEN_IPV4
159 > %token  CIDR_BITLEN_IPV6
160   %token  CLASS
161   %token  CONNECT
162   %token  CONNECTFREQ
163 + %token  CYCLE_ON_HOST_CHANGE
164   %token  DEFAULT_FLOODCOUNT
165   %token  DEFAULT_SPLIT_SERVER_COUNT
166   %token  DEFAULT_SPLIT_USER_COUNT
# Line 143 | Line 177 | free_collect_item(struct CollectItem *it
177   %token  EXCEED_LIMIT
178   %token  EXEMPT
179   %token  FAILED_OPER_NOTICE
146 %token  IRCD_FLAGS
180   %token  FLATTEN_LINKS
181   %token  GECOS
182   %token  GENERAL
# Line 151 | Line 184 | free_collect_item(struct CollectItem *it
184   %token  GLINE_DURATION
185   %token  GLINE_ENABLE
186   %token  GLINE_EXEMPT
154 %token  GLINE_REQUEST_DURATION
187   %token  GLINE_MIN_CIDR
188   %token  GLINE_MIN_CIDR6
189 + %token  GLINE_REQUEST_DURATION
190   %token  GLOBAL_KILL
158 %token  IRCD_AUTH
159 %token  NEED_IDENT
191   %token  HAVENT_READ_CONF
192   %token  HIDDEN
193 < %token  HIDDEN_NAME
193 > %token  HIDDEN_NAME
194 > %token  HIDE_IDLE_FROM_OPERS
195   %token  HIDE_SERVER_IPS
196   %token  HIDE_SERVERS
197 < %token  HIDE_SPOOF_IPS
197 > %token  HIDE_SERVICES
198 > %token  HIDE_SPOOF_IPS
199   %token  HOST
200   %token  HUB
201   %token  HUB_MASK
202   %token  IGNORE_BOGUS_TS
203   %token  INVISIBLE_ON_CONNECT
204   %token  IP
205 + %token  IRCD_AUTH
206 + %token  IRCD_FLAGS
207 + %token  IRCD_SID
208 + %token  JOIN_FLOOD_COUNT
209 + %token  JOIN_FLOOD_TIME
210   %token  KILL
211 < %token  KILL_CHASE_TIME_LIMIT
211 > %token  KILL_CHASE_TIME_LIMIT
212   %token  KLINE
213   %token  KLINE_EXEMPT
176 %token  KLINE_REASON
177 %token  KLINE_WITH_REASON
214   %token  KNOCK_DELAY
215   %token  KNOCK_DELAY_CHANNEL
216   %token  LEAF_MASK
217   %token  LINKS_DELAY
218   %token  LISTEN
219 < %token  T_LOG
219 > %token  MASK
220   %token  MAX_ACCEPT
221   %token  MAX_BANS
222   %token  MAX_CHANS_PER_OPER
223   %token  MAX_CHANS_PER_USER
224   %token  MAX_GLOBAL
225   %token  MAX_IDENT
226 + %token  MAX_IDLE
227   %token  MAX_LOCAL
228   %token  MAX_NICK_CHANGES
229 + %token  MAX_NICK_LENGTH
230   %token  MAX_NICK_TIME
231   %token  MAX_NUMBER
232   %token  MAX_TARGETS
233 + %token  MAX_TOPIC_LENGTH
234   %token  MAX_WATCH
235 < %token  MESSAGE_LOCALE
235 > %token  MIN_IDLE
236   %token  MIN_NONWILDCARD
237   %token  MIN_NONWILDCARD_SIMPLE
238   %token  MODULE
239   %token  MODULES
240 + %token  MOTD
241   %token  NAME
242 + %token  NEED_IDENT
243   %token  NEED_PASSWORD
244   %token  NETWORK_DESC
245   %token  NETWORK_NAME
246   %token  NICK
206 %token  NICK_CHANGES
247   %token  NO_CREATE_ON_SPLIT
248   %token  NO_JOIN_ON_SPLIT
249   %token  NO_OPER_FLOOD
# Line 211 | Line 251 | free_collect_item(struct CollectItem *it
251   %token  NUMBER
252   %token  NUMBER_PER_CIDR
253   %token  NUMBER_PER_IP
214 %token  OPERATOR
215 %token  OPERS_BYPASS_CALLERID
254   %token  OPER_ONLY_UMODES
255   %token  OPER_PASS_RESV
218 %token  OPER_SPY_T
256   %token  OPER_UMODES
257 < %token  JOIN_FLOOD_COUNT
258 < %token  JOIN_FLOOD_TIME
257 > %token  OPERATOR
258 > %token  OPERS_BYPASS_CALLERID
259   %token  PACE_WAIT
260   %token  PACE_WAIT_SIMPLE
261   %token  PASSWORD
262   %token  PATH
263   %token  PING_COOKIE
264   %token  PING_TIME
228 %token  PING_WARNING
265   %token  PORT
266   %token  QSTRING
267 < %token  QUIET_ON_BAN
267 > %token  RANDOM_IDLE
268   %token  REASON
269   %token  REDIRPORT
270   %token  REDIRSERV
235 %token  REGEX_T
271   %token  REHASH
237 %token  TREJECT_HOLD_TIME
272   %token  REMOTE
273   %token  REMOTEBAN
240 %token  RESTRICT_CHANNELS
241 %token  RSA_PRIVATE_KEY_FILE
242 %token  RSA_PUBLIC_KEY_FILE
243 %token  SSL_CERTIFICATE_FILE
244 %token  SSL_DH_PARAM_FILE
245 %token  T_SSL_CLIENT_METHOD
246 %token  T_SSL_SERVER_METHOD
247 %token  T_SSLV3
248 %token  T_TLSV1
274   %token  RESV
275   %token  RESV_EXEMPT
276 < %token  SECONDS MINUTES HOURS DAYS WEEKS
277 < %token  SENDQ
276 > %token  RSA_PRIVATE_KEY_FILE
277 > %token  RSA_PUBLIC_KEY_FILE
278 > %token  SECONDS MINUTES HOURS DAYS WEEKS MONTHS YEARS
279   %token  SEND_PASSWORD
280 + %token  SENDQ
281   %token  SERVERHIDE
282   %token  SERVERINFO
256 %token  IRCD_SID
257 %token  TKLINE_EXPIRE_NOTICES
258 %token  T_SHARED
259 %token  T_CLUSTER
260 %token  TYPE
283   %token  SHORT_MOTD
284   %token  SPOOF
285   %token  SPOOF_NOTICE
286 + %token  SQUIT
287 + %token  SSL_CERTIFICATE_FILE
288 + %token  SSL_CERTIFICATE_FINGERPRINT
289 + %token  SSL_CONNECTION_REQUIRED
290 + %token  SSL_DH_PARAM_FILE
291   %token  STATS_E_DISABLED
292   %token  STATS_I_OPER_ONLY
293   %token  STATS_K_OPER_ONLY
294   %token  STATS_O_OPER_ONLY
295   %token  STATS_P_OPER_ONLY
296 < %token  TBOOL
270 < %token  TMASKED
271 < %token  TS_MAX_DELTA
272 < %token  TS_WARN_DELTA
273 < %token  TWODOTS
296 > %token  STATS_U_OPER_ONLY
297   %token  T_ALL
298   %token  T_BOTS
276 %token  T_SOFTCALLERID
299   %token  T_CALLERID
300   %token  T_CCONN
301 < %token  T_CCONN_FULL
280 < %token  T_SSL_CIPHER_LIST
301 > %token  T_CLUSTER
302   %token  T_DEAF
303   %token  T_DEBUG
304   %token  T_DLINE
305   %token  T_EXTERNAL
306 + %token  T_FARCONNECT
307 + %token  T_FILE
308   %token  T_FULL
309 + %token  T_GLOBOPS
310   %token  T_INVISIBLE
311   %token  T_IPV4
312   %token  T_IPV6
313   %token  T_LOCOPS
314 + %token  T_LOG
315   %token  T_MAX_CLIENTS
316   %token  T_NCHANGE
317 + %token  T_NONONREG
318   %token  T_OPERWALL
319   %token  T_RECVQ
320   %token  T_REJ
321 + %token  T_RESTART
322   %token  T_SERVER
323 + %token  T_SERVICE
324 + %token  T_SERVICES_NAME
325   %token  T_SERVNOTICE
326   %token  T_SET
327 + %token  T_SHARED
328 + %token  T_SIZE
329   %token  T_SKILL
330 + %token  T_SOFTCALLERID
331   %token  T_SPY
332   %token  T_SSL
333 + %token  T_SSL_CIPHER_LIST
334 + %token  T_SSL_CLIENT_METHOD
335 + %token  T_SSL_SERVER_METHOD
336 + %token  T_SSLV3
337 + %token  T_TLSV1
338   %token  T_UMODES
339   %token  T_UNAUTH
340   %token  T_UNDLINE
341   %token  T_UNLIMITED
342   %token  T_UNRESV
343   %token  T_UNXLINE
307 %token  T_GLOBOPS
344   %token  T_WALLOP
345 < %token  T_RESTART
346 < %token  T_SERVICE
347 < %token  T_SERVICES_NAME
345 > %token  T_WALLOPS
346 > %token  T_WEBIRC
347 > %token  TBOOL
348   %token  THROTTLE_TIME
349 + %token  TKLINE_EXPIRE_NOTICES
350 + %token  TMASKED
351   %token  TRUE_NO_OPER_FLOOD
352 + %token  TS_MAX_DELTA
353 + %token  TS_WARN_DELTA
354 + %token  TWODOTS
355 + %token  TYPE
356   %token  UNKLINE
315 %token  USER
357   %token  USE_EGD
358   %token  USE_LOGGING
359 + %token  USER
360   %token  VHOST
361   %token  VHOST6
320 %token  XLINE
362   %token  WARN_NO_NLINE
363 < %token  T_SIZE
323 < %token  T_FILE
363 > %token  XLINE
364  
365 < %type <string> QSTRING
366 < %type <number> NUMBER
367 < %type <number> timespec
368 < %type <number> timespec_
369 < %type <number> sizespec
370 < %type <number> sizespec_
365 > %type  <string> QSTRING
366 > %type  <number> NUMBER
367 > %type  <number> timespec
368 > %type  <number> timespec_
369 > %type  <number> sizespec
370 > %type  <number> sizespec_
371  
372   %%
373 < conf:  
373 > conf:
374          | conf conf_item
375          ;
376  
# Line 338 | Line 378 | conf_item:        admin_entry
378                  | logging_entry
379                  | oper_entry
380                  | channel_entry
381 <                | class_entry
381 >                | class_entry
382                  | listen_entry
383                  | auth_entry
384                  | serverinfo_entry
# Line 354 | Line 394 | conf_item:        admin_entry
394                  | general_entry
395                  | gecos_entry
396                  | modules_entry
397 +                | motd_entry
398                  | error ';'
399                  | error '}'
400          ;
# Line 384 | Line 425 | timespec:      NUMBER timespec_
425                  {
426                          $$ = $1 * 60 * 60 * 24 * 7 + $3;
427                  }
428 +                | NUMBER MONTHS timespec_
429 +                {
430 +                        $$ = $1 * 60 * 60 * 24 * 7 * 4 + $3;
431 +                }
432 +                | NUMBER YEARS timespec_
433 +                {
434 +                        $$ = $1 * 60 * 60 * 24 * 365 + $3;
435 +                }
436                  ;
437  
438   sizespec_:      { $$ = 0; } | sizespec;
# Line 422 | Line 471 | serverinfo_items:       serverinfo_items
471   serverinfo_item:        serverinfo_name | serverinfo_vhost |
472                          serverinfo_hub | serverinfo_description |
473                          serverinfo_network_name | serverinfo_network_desc |
474 <                        serverinfo_max_clients | serverinfo_ssl_dh_param_file |
474 >                        serverinfo_max_clients | serverinfo_max_nick_length |
475 >                        serverinfo_max_topic_length | serverinfo_ssl_dh_param_file |
476                          serverinfo_rsa_private_key_file | serverinfo_vhost6 |
477                          serverinfo_sid | serverinfo_ssl_certificate_file |
478                          serverinfo_ssl_client_method | serverinfo_ssl_server_method |
# Line 466 | Line 516 | server_method_type_item: T_SSLV3
516   serverinfo_ssl_certificate_file: SSL_CERTIFICATE_FILE '=' QSTRING ';'
517   {
518   #ifdef HAVE_LIBCRYPTO
519 <  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
519 >  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
520    {
521      if (!ServerInfo.rsa_private_key_file)
522      {
523 <      yyerror("No rsa_private_key_file specified, SSL disabled");
523 >      conf_error_report("No rsa_private_key_file specified, SSL disabled");
524        break;
525      }
526  
# Line 479 | Line 529 | serverinfo_ssl_certificate_file: SSL_CER
529          SSL_CTX_use_certificate_file(ServerInfo.client_ctx, yylval.string,
530                                       SSL_FILETYPE_PEM) <= 0)
531      {
532 <      yyerror(ERR_lib_error_string(ERR_get_error()));
532 >      report_crypto_errors();
533 >      conf_error_report("Could not open/read certificate file");
534        break;
535      }
536  
# Line 488 | Line 539 | serverinfo_ssl_certificate_file: SSL_CER
539          SSL_CTX_use_PrivateKey_file(ServerInfo.client_ctx, ServerInfo.rsa_private_key_file,
540                                      SSL_FILETYPE_PEM) <= 0)
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  
547      if (!SSL_CTX_check_private_key(ServerInfo.server_ctx) ||
548          !SSL_CTX_check_private_key(ServerInfo.client_ctx))
549      {
550 <      yyerror(ERR_lib_error_string(ERR_get_error()));
550 >      report_crypto_errors();
551 >      conf_error_report("Could not read RSA private key");
552        break;
553      }
554    }
# Line 505 | Line 558 | serverinfo_ssl_certificate_file: SSL_CER
558   serverinfo_rsa_private_key_file: RSA_PRIVATE_KEY_FILE '=' QSTRING ';'
559   {
560   #ifdef HAVE_LIBCRYPTO
561 <  if (conf_parser_ctx.pass == 1)
509 <  {
510 <    BIO *file;
561 >  BIO *file = NULL;
562  
563 <    if (ServerInfo.rsa_private_key)
564 <    {
514 <      RSA_free(ServerInfo.rsa_private_key);
515 <      ServerInfo.rsa_private_key = NULL;
516 <    }
563 >  if (conf_parser_ctx.pass != 1)
564 >    break;
565  
566 <    if (ServerInfo.rsa_private_key_file)
567 <    {
568 <      MyFree(ServerInfo.rsa_private_key_file);
569 <      ServerInfo.rsa_private_key_file = NULL;
570 <    }
566 >  if (ServerInfo.rsa_private_key)
567 >  {
568 >    RSA_free(ServerInfo.rsa_private_key);
569 >    ServerInfo.rsa_private_key = NULL;
570 >  }
571  
572 <    DupString(ServerInfo.rsa_private_key_file, yylval.string);
572 >  if (ServerInfo.rsa_private_key_file)
573 >  {
574 >    MyFree(ServerInfo.rsa_private_key_file);
575 >    ServerInfo.rsa_private_key_file = NULL;
576 >  }
577  
578 <    if ((file = BIO_new_file(yylval.string, "r")) == NULL)
527 <    {
528 <      yyerror("File open failed, ignoring");
529 <      break;
530 <    }
578 >  ServerInfo.rsa_private_key_file = xstrdup(yylval.string);
579  
580 <    ServerInfo.rsa_private_key = PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL);
580 >  if ((file = BIO_new_file(yylval.string, "r")) == NULL)
581 >  {
582 >    conf_error_report("File open failed, ignoring");
583 >    break;
584 >  }
585  
586 <    BIO_set_close(file, BIO_CLOSE);
535 <    BIO_free(file);
586 >  ServerInfo.rsa_private_key = PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL);
587  
588 <    if (ServerInfo.rsa_private_key == NULL)
589 <    {
539 <      yyerror("Couldn't extract key, ignoring");
540 <      break;
541 <    }
588 >  BIO_set_close(file, BIO_CLOSE);
589 >  BIO_free(file);
590  
591 <    if (!RSA_check_key(ServerInfo.rsa_private_key))
592 <    {
593 <      RSA_free(ServerInfo.rsa_private_key);
594 <      ServerInfo.rsa_private_key = NULL;
591 >  if (ServerInfo.rsa_private_key == NULL)
592 >  {
593 >    conf_error_report("Couldn't extract key, ignoring");
594 >    break;
595 >  }
596  
597 <      yyerror("Invalid key, ignoring");
598 <      break;
599 <    }
597 >  if (!RSA_check_key(ServerInfo.rsa_private_key))
598 >  {
599 >    RSA_free(ServerInfo.rsa_private_key);
600 >    ServerInfo.rsa_private_key = NULL;
601  
602 <    /* require 2048 bit (256 byte) key */
603 <    if (RSA_size(ServerInfo.rsa_private_key) != 256)
604 <    {
555 <      RSA_free(ServerInfo.rsa_private_key);
556 <      ServerInfo.rsa_private_key = NULL;
602 >    conf_error_report("Invalid key, ignoring");
603 >    break;
604 >  }
605  
606 <      yyerror("Not a 2048 bit key, ignoring");
607 <    }
606 >  if (RSA_size(ServerInfo.rsa_private_key) < 128)
607 >  {
608 >    RSA_free(ServerInfo.rsa_private_key);
609 >    ServerInfo.rsa_private_key = NULL;
610 >
611 >    conf_error_report("Ignoring serverinfo::rsa_private_key_file -- need at least a 1024 bit key size");
612    }
613   #endif
614   };
# Line 578 | Line 630 | serverinfo_ssl_dh_param_file: SSL_DH_PAR
630        if (dh)
631        {
632          if (DH_size(dh) < 128)
633 <          ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::ssl_dh_param_file -- need at least a 1024 bit DH prime size");
633 >          conf_error_report("Ignoring serverinfo::ssl_dh_param_file -- need at least a 1024 bit DH prime size");
634          else
635            SSL_CTX_set_tmp_dh(ServerInfo.server_ctx, dh);
636  
# Line 597 | Line 649 | serverinfo_ssl_cipher_list: T_SSL_CIPHER
649   #endif
650   };
651  
652 < serverinfo_name: NAME '=' QSTRING ';'
652 > serverinfo_name: NAME '=' QSTRING ';'
653   {
654    /* this isn't rehashable */
655    if (conf_parser_ctx.pass == 2 && !ServerInfo.name)
656    {
657      if (valid_servname(yylval.string))
658 <      DupString(ServerInfo.name, yylval.string);
658 >      ServerInfo.name = xstrdup(yylval.string);
659      else
660      {
661 <      ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::name -- invalid name. Aborting.");
661 >      conf_error_report("Ignoring serverinfo::name -- invalid name. Aborting.");
662        exit(0);
663      }
664    }
665   };
666  
667 < serverinfo_sid: IRCD_SID '=' QSTRING ';'
667 > serverinfo_sid: IRCD_SID '=' QSTRING ';'
668   {
669    /* this isn't rehashable */
670    if (conf_parser_ctx.pass == 2 && !ServerInfo.sid)
671    {
672      if (valid_sid(yylval.string))
673 <      DupString(ServerInfo.sid, yylval.string);
673 >      ServerInfo.sid = xstrdup(yylval.string);
674      else
675      {
676 <      ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::sid -- invalid SID. Aborting.");
676 >      conf_error_report("Ignoring serverinfo::sid -- invalid SID. Aborting.");
677        exit(0);
678      }
679    }
# Line 632 | Line 684 | serverinfo_description: DESCRIPTION '='
684    if (conf_parser_ctx.pass == 2)
685    {
686      MyFree(ServerInfo.description);
687 <    DupString(ServerInfo.description,yylval.string);
687 >    ServerInfo.description = xstrdup(yylval.string);
688    }
689   };
690  
# Line 646 | Line 698 | serverinfo_network_name: NETWORK_NAME '=
698        p = '\0';
699  
700      MyFree(ServerInfo.network_name);
701 <    DupString(ServerInfo.network_name, yylval.string);
701 >    ServerInfo.network_name = xstrdup(yylval.string);
702    }
703   };
704  
705   serverinfo_network_desc: NETWORK_DESC '=' QSTRING ';'
706   {
707 <  if (conf_parser_ctx.pass == 2)
708 <  {
709 <    MyFree(ServerInfo.network_desc);
710 <    DupString(ServerInfo.network_desc, yylval.string);
711 <  }
707 >  if (conf_parser_ctx.pass != 2)
708 >    break;
709 >
710 >  MyFree(ServerInfo.network_desc);
711 >  ServerInfo.network_desc = xstrdup(yylval.string);
712   };
713  
714   serverinfo_vhost: VHOST '=' QSTRING ';'
# Line 719 | Line 771 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
771  
772   serverinfo_max_clients: T_MAX_CLIENTS '=' NUMBER ';'
773   {
774 <  if (conf_parser_ctx.pass == 2)
774 >  if (conf_parser_ctx.pass != 2)
775 >    break;
776 >
777 >  if ($3 < MAXCLIENTS_MIN)
778    {
779 <    recalc_fdlimit(NULL);
779 >    char buf[IRCD_BUFSIZE];
780  
781 <    if ($3 < MAXCLIENTS_MIN)
782 <    {
783 <      char buf[IRCD_BUFSIZE];
729 <      ircsprintf(buf, "MAXCLIENTS too low, setting to %d", MAXCLIENTS_MIN);
730 <      yyerror(buf);
731 <    }
732 <    else if ($3 > MAXCLIENTS_MAX)
733 <    {
734 <      char buf[IRCD_BUFSIZE];
735 <      ircsprintf(buf, "MAXCLIENTS too high, setting to %d", MAXCLIENTS_MAX);
736 <      yyerror(buf);
737 <    }
738 <    else
739 <      ServerInfo.max_clients = $3;
781 >    snprintf(buf, sizeof(buf), "MAXCLIENTS too low, setting to %d", MAXCLIENTS_MIN);
782 >    conf_error_report(buf);
783 >    ServerInfo.max_clients = MAXCLIENTS_MIN;
784    }
785 +  else if ($3 > MAXCLIENTS_MAX)
786 +  {
787 +    char buf[IRCD_BUFSIZE];
788 +
789 +    snprintf(buf, sizeof(buf), "MAXCLIENTS too high, setting to %d", MAXCLIENTS_MAX);
790 +    conf_error_report(buf);
791 +    ServerInfo.max_clients = MAXCLIENTS_MAX;
792 +  }
793 +  else
794 +    ServerInfo.max_clients = $3;
795   };
796  
797 < serverinfo_hub: HUB '=' TBOOL ';'
797 > serverinfo_max_nick_length: MAX_NICK_LENGTH '=' NUMBER ';'
798 > {
799 >  if (conf_parser_ctx.pass != 2)
800 >    break;
801 >
802 >  if ($3 < 9)
803 >  {
804 >    conf_error_report("max_nick_length too low, setting to 9");
805 >    ServerInfo.max_nick_length = 9;
806 >  }
807 >  else if ($3 > NICKLEN)
808 >  {
809 >    char buf[IRCD_BUFSIZE];
810 >
811 >    snprintf(buf, sizeof(buf), "max_nick_length too high, setting to %d", NICKLEN);
812 >    conf_error_report(buf);
813 >    ServerInfo.max_nick_length = NICKLEN;
814 >  }
815 >  else
816 >    ServerInfo.max_nick_length = $3;
817 > };
818 >
819 > serverinfo_max_topic_length: MAX_TOPIC_LENGTH '=' NUMBER ';'
820 > {
821 >  if (conf_parser_ctx.pass != 2)
822 >    break;
823 >
824 >  if ($3 < 80)
825 >  {
826 >    conf_error_report("max_topic_length too low, setting to 80");
827 >    ServerInfo.max_topic_length = 80;
828 >  }
829 >  else if ($3 > TOPICLEN)
830 >  {
831 >    char buf[IRCD_BUFSIZE];
832 >
833 >    snprintf(buf, sizeof(buf), "max_topic_length too high, setting to %d", TOPICLEN);
834 >    conf_error_report(buf);
835 >    ServerInfo.max_topic_length = TOPICLEN;
836 >  }
837 >  else
838 >    ServerInfo.max_topic_length = $3;
839 > };
840 >
841 > serverinfo_hub: HUB '=' TBOOL ';'
842   {
843    if (conf_parser_ctx.pass == 2)
844      ServerInfo.hub = yylval.number;
# Line 755 | Line 853 | admin_items: admin_items admin_item | ad
853   admin_item:  admin_name | admin_description |
854               admin_email | error ';' ;
855  
856 < admin_name: NAME '=' QSTRING ';'
856 > admin_name: NAME '=' QSTRING ';'
857   {
858 <  if (conf_parser_ctx.pass == 2)
859 <  {
860 <    MyFree(AdminInfo.name);
861 <    DupString(AdminInfo.name, yylval.string);
862 <  }
858 >  if (conf_parser_ctx.pass != 2)
859 >    break;
860 >
861 >  MyFree(AdminInfo.name);
862 >  AdminInfo.name = xstrdup(yylval.string);
863   };
864  
865   admin_email: EMAIL '=' QSTRING ';'
866   {
867 <  if (conf_parser_ctx.pass == 2)
868 <  {
869 <    MyFree(AdminInfo.email);
870 <    DupString(AdminInfo.email, yylval.string);
871 <  }
867 >  if (conf_parser_ctx.pass != 2)
868 >    break;
869 >
870 >  MyFree(AdminInfo.email);
871 >  AdminInfo.email = xstrdup(yylval.string);
872   };
873  
874   admin_description: DESCRIPTION '=' QSTRING ';'
875   {
876 +  if (conf_parser_ctx.pass != 2)
877 +    break;
878 +
879 +  MyFree(AdminInfo.description);
880 +  AdminInfo.description = xstrdup(yylval.string);
881 + };
882 +
883 + /***************************************************************************
884 + * motd section
885 + ***************************************************************************/
886 + motd_entry: MOTD
887 + {
888    if (conf_parser_ctx.pass == 2)
889 <  {
890 <    MyFree(AdminInfo.description);
891 <    DupString(AdminInfo.description, yylval.string);
892 <  }
889 >    reset_block_state();
890 > } '{' motd_items '}' ';'
891 > {
892 >  dlink_node *ptr = NULL;
893 >
894 >  if (conf_parser_ctx.pass != 2)
895 >    break;
896 >
897 >  if (!block_state.file.buf[0])
898 >    break;
899 >
900 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
901 >    motd_add(ptr->data, block_state.file.buf);
902 > };
903 >
904 > motd_items: motd_items motd_item | motd_item;
905 > motd_item:  motd_mask | motd_file | error ';' ;
906 >
907 > motd_mask: MASK '=' QSTRING ';'
908 > {
909 >  if (conf_parser_ctx.pass == 2)
910 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
911 > };
912 >
913 > motd_file: T_FILE '=' QSTRING ';'
914 > {
915 >  if (conf_parser_ctx.pass == 2)
916 >    strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
917   };
918  
919   /***************************************************************************
# Line 799 | Line 933 | logging_use_logging: USE_LOGGING '=' TBO
933  
934   logging_file_entry:
935   {
936 <  lfile[0] = '\0';
937 <  ltype = 0;
804 <  lsize = 0;
936 >  if (conf_parser_ctx.pass == 2)
937 >    reset_block_state();
938   } T_FILE  '{' logging_file_items '}' ';'
939   {
940 <  if (conf_parser_ctx.pass == 2 && ltype > 0)
941 <    log_add_file(ltype, lsize, lfile);
940 >  if (conf_parser_ctx.pass != 2)
941 >    break;
942 >
943 >  if (block_state.type.value && block_state.file.buf[0])
944 >    log_set_file(block_state.type.value, block_state.size.value,
945 >                 block_state.file.buf);
946   };
947  
948   logging_file_items: logging_file_items logging_file_item |
# Line 816 | Line 953 | logging_file_item:  logging_file_name |
953  
954   logging_file_name: NAME '=' QSTRING ';'
955   {
956 <  strlcpy(lfile, yylval.string, sizeof(lfile));
956 >  if (conf_parser_ctx.pass != 2)
957 >    break;
958 >
959 >  strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
960   }
961  
962   logging_file_size: T_SIZE '=' sizespec ';'
963   {
964 <  lsize = $3;
964 >  block_state.size.value = $3;
965   } | T_SIZE '=' T_UNLIMITED ';'
966   {
967 <  lsize = 0;
967 >  block_state.size.value = 0;
968   };
969  
970   logging_file_type: TYPE
971   {
972    if (conf_parser_ctx.pass == 2)
973 <    ltype = 0;
973 >    block_state.type.value = 0;
974   } '='  logging_file_type_items ';' ;
975  
976   logging_file_type_items: logging_file_type_items ',' logging_file_type_item | logging_file_type_item;
977   logging_file_type_item:  USER
978   {
979    if (conf_parser_ctx.pass == 2)
980 <    ltype = LOG_TYPE_USER;
980 >    block_state.type.value = LOG_TYPE_USER;
981   } | OPERATOR
982   {
983    if (conf_parser_ctx.pass == 2)
984 <    ltype = LOG_TYPE_OPER;
984 >    block_state.type.value = LOG_TYPE_OPER;
985   } | GLINE
986   {
987    if (conf_parser_ctx.pass == 2)
988 <    ltype = LOG_TYPE_GLINE;
988 >    block_state.type.value = LOG_TYPE_GLINE;
989 > } | XLINE
990 > {
991 >  if (conf_parser_ctx.pass == 2)
992 >    block_state.type.value = LOG_TYPE_XLINE;
993 > } | RESV
994 > {
995 >  if (conf_parser_ctx.pass == 2)
996 >    block_state.type.value = LOG_TYPE_RESV;
997   } | T_DLINE
998   {
999    if (conf_parser_ctx.pass == 2)
1000 <    ltype = LOG_TYPE_DLINE;
1000 >    block_state.type.value = LOG_TYPE_DLINE;
1001   } | KLINE
1002   {
1003    if (conf_parser_ctx.pass == 2)
1004 <    ltype = LOG_TYPE_KLINE;
1004 >    block_state.type.value = LOG_TYPE_KLINE;
1005   } | KILL
1006   {
1007    if (conf_parser_ctx.pass == 2)
1008 <    ltype = LOG_TYPE_KILL;
1008 >    block_state.type.value = LOG_TYPE_KILL;
1009   } | T_DEBUG
1010   {
1011    if (conf_parser_ctx.pass == 2)
1012 <    ltype = LOG_TYPE_DEBUG;
1012 >    block_state.type.value = LOG_TYPE_DEBUG;
1013   };
1014  
1015  
1016   /***************************************************************************
1017   * section oper
1018   ***************************************************************************/
1019 < oper_entry: OPERATOR
1019 > oper_entry: OPERATOR
1020   {
1021 <  if (conf_parser_ctx.pass == 2)
1022 <  {
1023 <    yy_conf = make_conf_item(OPER_TYPE);
1024 <    yy_aconf = map_to_conf(yy_conf);
1025 <    SetConfEncrypted(yy_aconf); /* Yes, the default is encrypted */
878 <  }
879 <  else
880 <  {
881 <    MyFree(class_name);
882 <    class_name = NULL;
883 <  }
1021 >  if (conf_parser_ctx.pass != 2)
1022 >    break;
1023 >
1024 >  reset_block_state();
1025 >  block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1026   } '{' oper_items '}' ';'
1027   {
1028 <  if (conf_parser_ctx.pass == 2)
887 <  {
888 <    struct CollectItem *yy_tmp;
889 <    dlink_node *ptr;
890 <    dlink_node *next_ptr;
1028 >  dlink_node *ptr = NULL;
1029  
1030 <    conf_add_class_to_conf(yy_conf, class_name);
1030 >  if (conf_parser_ctx.pass != 2)
1031 >    break;
1032  
1033 <    /* Now, make sure there is a copy of the "base" given oper
1034 <     * block in each of the collected copies
1035 <     */
1033 >  if (!block_state.name.buf[0])
1034 >    break;
1035 > #ifdef HAVE_LIBCRYPTO
1036 >  if (!block_state.file.buf[0] &&
1037 >      !block_state.rpass.buf[0])
1038 >    break;
1039 > #else
1040 >  if (!block_state.rpass.buf[0])
1041 >    break;
1042 > #endif
1043  
1044 <    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
1045 <    {
1046 <      struct AccessItem *new_aconf;
1047 <      struct ConfItem *new_conf;
902 <      yy_tmp = ptr->data;
903 <
904 <      new_conf = make_conf_item(OPER_TYPE);
905 <      new_aconf = (struct AccessItem *)map_to_conf(new_conf);
906 <
907 <      new_aconf->flags = yy_aconf->flags;
908 <
909 <      if (yy_conf->name != NULL)
910 <        DupString(new_conf->name, yy_conf->name);
911 <      if (yy_tmp->user != NULL)
912 <        DupString(new_aconf->user, yy_tmp->user);
913 <      else
914 <        DupString(new_aconf->user, "*");
915 <      if (yy_tmp->host != NULL)
916 <        DupString(new_aconf->host, yy_tmp->host);
917 <      else
918 <        DupString(new_aconf->host, "*");
919 <
920 <      new_aconf->type = parse_netmask(new_aconf->host, &new_aconf->addr,
921 <                                     &new_aconf->bits);
922 <
923 <      conf_add_class_to_conf(new_conf, class_name);
924 <      if (yy_aconf->passwd != NULL)
925 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1044 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
1045 >  {
1046 >    struct MaskItem *conf = NULL;
1047 >    struct split_nuh_item nuh;
1048  
1049 <      new_aconf->port = yy_aconf->port;
1050 < #ifdef HAVE_LIBCRYPTO
1051 <      if (yy_aconf->rsa_public_key_file != NULL)
1052 <      {
1053 <        BIO *file;
1049 >    nuh.nuhmask  = ptr->data;
1050 >    nuh.nickptr  = NULL;
1051 >    nuh.userptr  = block_state.user.buf;
1052 >    nuh.hostptr  = block_state.host.buf;
1053 >    nuh.nicksize = 0;
1054 >    nuh.usersize = sizeof(block_state.user.buf);
1055 >    nuh.hostsize = sizeof(block_state.host.buf);
1056 >    split_nuh(&nuh);
1057  
1058 <        DupString(new_aconf->rsa_public_key_file,
1059 <                  yy_aconf->rsa_public_key_file);
1058 >    conf         = conf_make(CONF_OPER);
1059 >    conf->name   = xstrdup(block_state.name.buf);
1060 >    conf->user   = xstrdup(block_state.user.buf);
1061 >    conf->host   = xstrdup(block_state.host.buf);
1062 >
1063 >    if (block_state.cert.buf[0])
1064 >      conf->certfp = xstrdup(block_state.cert.buf);
1065 >
1066 >    if (block_state.rpass.buf[0])
1067 >      conf->passwd = xstrdup(block_state.rpass.buf);
1068 >
1069 >    conf->flags = block_state.flags.value;
1070 >    conf->modes = block_state.modes.value;
1071 >    conf->port  = block_state.port.value;
1072 >    conf->htype = parse_netmask(conf->host, &conf->addr, &conf->bits);
1073  
1074 <        file = BIO_new_file(yy_aconf->rsa_public_key_file, "r");
937 <        new_aconf->rsa_public_key = PEM_read_bio_RSA_PUBKEY(file,
938 <                                                           NULL, 0, NULL);
939 <        BIO_set_close(file, BIO_CLOSE);
940 <        BIO_free(file);
941 <      }
942 < #endif
1074 >    conf_add_class_to_conf(conf, block_state.class.buf);
1075  
1076   #ifdef HAVE_LIBCRYPTO
1077 <      if (yy_tmp->name && (yy_tmp->passwd || yy_aconf->rsa_public_key)
1078 <          && yy_tmp->host)
1079 < #else
1080 <      if (yy_tmp->name && yy_tmp->passwd && yy_tmp->host)
1081 < #endif
1077 >    if (block_state.file.buf[0])
1078 >    {
1079 >      BIO *file = NULL;
1080 >      RSA *pkey = NULL;
1081 >
1082 >      if ((file = BIO_new_file(block_state.file.buf, "r")) == NULL)
1083        {
1084 <        conf_add_class_to_conf(new_conf, class_name);
1085 <        if (yy_tmp->name != NULL)
953 <          DupString(new_conf->name, yy_tmp->name);
1084 >        conf_error_report("Ignoring rsa_public_key_file -- file doesn't exist");
1085 >        break;
1086        }
1087  
1088 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
1089 <      free_collect_item(yy_tmp);
958 <    }
959 <
960 <    yy_conf = NULL;
961 <    yy_aconf = NULL;
1088 >      if ((pkey = PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL)) == NULL)
1089 >        conf_error_report("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
1090  
1091 <
1092 <    MyFree(class_name);
1093 <    class_name = NULL;
1091 >      conf->rsa_public_key = pkey;
1092 >      BIO_set_close(file, BIO_CLOSE);
1093 >      BIO_free(file);
1094 >    }
1095 > #endif /* HAVE_LIBCRYPTO */
1096    }
1097 < };
1097 > };
1098  
1099   oper_items:     oper_items oper_item | oper_item;
1100   oper_item:      oper_name | oper_user | oper_password |
1101                  oper_umodes | oper_class | oper_encrypted |
1102 <                oper_rsa_public_key_file | oper_flags | error ';' ;
1102 >                oper_rsa_public_key_file | oper_ssl_certificate_fingerprint |
1103 >                oper_ssl_connection_required |
1104 >                oper_flags | error ';' ;
1105  
1106   oper_name: NAME '=' QSTRING ';'
1107   {
1108    if (conf_parser_ctx.pass == 2)
1109 <  {
978 <    MyFree(yy_conf->name);
979 <    DupString(yy_conf->name, yylval.string);
980 <  }
1109 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1110   };
1111  
1112   oper_user: USER '=' QSTRING ';'
1113   {
1114    if (conf_parser_ctx.pass == 2)
1115 <  {
987 <    struct split_nuh_item nuh;
988 <
989 <    nuh.nuhmask  = yylval.string;
990 <    nuh.nickptr  = NULL;
991 <    nuh.userptr  = userbuf;
992 <    nuh.hostptr  = hostbuf;
993 <
994 <    nuh.nicksize = 0;
995 <    nuh.usersize = sizeof(userbuf);
996 <    nuh.hostsize = sizeof(hostbuf);
997 <
998 <    split_nuh(&nuh);
999 <
1000 <    if (yy_aconf->user == NULL)
1001 <    {
1002 <      DupString(yy_aconf->user, userbuf);
1003 <      DupString(yy_aconf->host, hostbuf);
1004 <
1005 <      yy_aconf->type = parse_netmask(yy_aconf->host, &yy_aconf->addr,
1006 <                                    &yy_aconf->bits);
1007 <    }
1008 <    else
1009 <    {
1010 <      struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
1011 <
1012 <      DupString(yy_tmp->user, userbuf);
1013 <      DupString(yy_tmp->host, hostbuf);
1014 <
1015 <      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1016 <    }
1017 <  }
1115 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1116   };
1117  
1118   oper_password: PASSWORD '=' QSTRING ';'
1119   {
1120    if (conf_parser_ctx.pass == 2)
1121 <  {
1024 <    if (yy_aconf->passwd != NULL)
1025 <      memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1026 <
1027 <    MyFree(yy_aconf->passwd);
1028 <    DupString(yy_aconf->passwd, yylval.string);
1029 <  }
1121 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1122   };
1123  
1124   oper_encrypted: ENCRYPTED '=' TBOOL ';'
1125   {
1126 <  if (conf_parser_ctx.pass == 2)
1127 <  {
1128 <    if (yylval.number)
1129 <      SetConfEncrypted(yy_aconf);
1130 <    else
1131 <      ClearConfEncrypted(yy_aconf);
1132 <  }
1126 >  if (conf_parser_ctx.pass != 2)
1127 >    break;
1128 >
1129 >  if (yylval.number)
1130 >    block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1131 >  else
1132 >    block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1133   };
1134  
1135   oper_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
1136   {
1045 #ifdef HAVE_LIBCRYPTO
1137    if (conf_parser_ctx.pass == 2)
1138 <  {
1139 <    BIO *file;
1049 <
1050 <    if (yy_aconf->rsa_public_key != NULL)
1051 <    {
1052 <      RSA_free(yy_aconf->rsa_public_key);
1053 <      yy_aconf->rsa_public_key = NULL;
1054 <    }
1055 <
1056 <    if (yy_aconf->rsa_public_key_file != NULL)
1057 <    {
1058 <      MyFree(yy_aconf->rsa_public_key_file);
1059 <      yy_aconf->rsa_public_key_file = NULL;
1060 <    }
1061 <
1062 <    DupString(yy_aconf->rsa_public_key_file, yylval.string);
1063 <    file = BIO_new_file(yylval.string, "r");
1064 <
1065 <    if (file == NULL)
1066 <    {
1067 <      yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
1068 <      break;
1069 <    }
1138 >    strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
1139 > };
1140  
1141 <    yy_aconf->rsa_public_key = PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
1141 > oper_ssl_certificate_fingerprint: SSL_CERTIFICATE_FINGERPRINT '=' QSTRING ';'
1142 > {
1143 >  if (conf_parser_ctx.pass == 2)
1144 >    strlcpy(block_state.cert.buf, yylval.string, sizeof(block_state.cert.buf));
1145 > };
1146  
1147 <    if (yy_aconf->rsa_public_key == NULL)
1148 <    {
1149 <      yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
1150 <      break;
1077 <    }
1147 > oper_ssl_connection_required: SSL_CONNECTION_REQUIRED '=' TBOOL ';'
1148 > {
1149 >  if (conf_parser_ctx.pass != 2)
1150 >    break;
1151  
1152 <    BIO_set_close(file, BIO_CLOSE);
1153 <    BIO_free(file);
1154 <  }
1155 < #endif /* HAVE_LIBCRYPTO */
1152 >  if (yylval.number)
1153 >    block_state.flags.value |= CONF_FLAGS_SSL;
1154 >  else
1155 >    block_state.flags.value &= ~CONF_FLAGS_SSL;
1156   };
1157  
1158   oper_class: CLASS '=' QSTRING ';'
1159   {
1160    if (conf_parser_ctx.pass == 2)
1161 <  {
1089 <    MyFree(class_name);
1090 <    DupString(class_name, yylval.string);
1091 <  }
1161 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1162   };
1163  
1164   oper_umodes: T_UMODES
1165   {
1166    if (conf_parser_ctx.pass == 2)
1167 <    yy_aconf->modes = 0;
1167 >    block_state.modes.value = 0;
1168   } '='  oper_umodes_items ';' ;
1169  
1170   oper_umodes_items: oper_umodes_items ',' oper_umodes_item | oper_umodes_item;
1171   oper_umodes_item:  T_BOTS
1172   {
1173    if (conf_parser_ctx.pass == 2)
1174 <    yy_aconf->modes |= UMODE_BOTS;
1174 >    block_state.modes.value |= UMODE_BOTS;
1175   } | T_CCONN
1176   {
1177    if (conf_parser_ctx.pass == 2)
1178 <    yy_aconf->modes |= UMODE_CCONN;
1109 < } | T_CCONN_FULL
1110 < {
1111 <  if (conf_parser_ctx.pass == 2)
1112 <    yy_aconf->modes |= UMODE_CCONN_FULL;
1178 >    block_state.modes.value |= UMODE_CCONN;
1179   } | T_DEAF
1180   {
1181    if (conf_parser_ctx.pass == 2)
1182 <    yy_aconf->modes |= UMODE_DEAF;
1182 >    block_state.modes.value |= UMODE_DEAF;
1183   } | T_DEBUG
1184   {
1185    if (conf_parser_ctx.pass == 2)
1186 <    yy_aconf->modes |= UMODE_DEBUG;
1186 >    block_state.modes.value |= UMODE_DEBUG;
1187   } | T_FULL
1188   {
1189    if (conf_parser_ctx.pass == 2)
1190 <    yy_aconf->modes |= UMODE_FULL;
1190 >    block_state.modes.value |= UMODE_FULL;
1191   } | HIDDEN
1192   {
1193    if (conf_parser_ctx.pass == 2)
1194 <    yy_aconf->modes |= UMODE_HIDDEN;
1194 >    block_state.modes.value |= UMODE_HIDDEN;
1195   } | T_SKILL
1196   {
1197    if (conf_parser_ctx.pass == 2)
1198 <    yy_aconf->modes |= UMODE_SKILL;
1198 >    block_state.modes.value |= UMODE_SKILL;
1199   } | T_NCHANGE
1200   {
1201    if (conf_parser_ctx.pass == 2)
1202 <    yy_aconf->modes |= UMODE_NCHANGE;
1202 >    block_state.modes.value |= UMODE_NCHANGE;
1203   } | T_REJ
1204   {
1205    if (conf_parser_ctx.pass == 2)
1206 <    yy_aconf->modes |= UMODE_REJ;
1206 >    block_state.modes.value |= UMODE_REJ;
1207   } | T_UNAUTH
1208   {
1209    if (conf_parser_ctx.pass == 2)
1210 <    yy_aconf->modes |= UMODE_UNAUTH;
1210 >    block_state.modes.value |= UMODE_UNAUTH;
1211   } | T_SPY
1212   {
1213    if (conf_parser_ctx.pass == 2)
1214 <    yy_aconf->modes |= UMODE_SPY;
1214 >    block_state.modes.value |= UMODE_SPY;
1215   } | T_EXTERNAL
1216   {
1217    if (conf_parser_ctx.pass == 2)
1218 <    yy_aconf->modes |= UMODE_EXTERNAL;
1218 >    block_state.modes.value |= UMODE_EXTERNAL;
1219   } | T_OPERWALL
1220   {
1221    if (conf_parser_ctx.pass == 2)
1222 <    yy_aconf->modes |= UMODE_OPERWALL;
1222 >    block_state.modes.value |= UMODE_OPERWALL;
1223   } | T_SERVNOTICE
1224   {
1225    if (conf_parser_ctx.pass == 2)
1226 <    yy_aconf->modes |= UMODE_SERVNOTICE;
1226 >    block_state.modes.value |= UMODE_SERVNOTICE;
1227   } | T_INVISIBLE
1228   {
1229    if (conf_parser_ctx.pass == 2)
1230 <    yy_aconf->modes |= UMODE_INVISIBLE;
1230 >    block_state.modes.value |= UMODE_INVISIBLE;
1231   } | T_WALLOP
1232   {
1233    if (conf_parser_ctx.pass == 2)
1234 <    yy_aconf->modes |= UMODE_WALLOP;
1234 >    block_state.modes.value |= UMODE_WALLOP;
1235   } | T_SOFTCALLERID
1236   {
1237    if (conf_parser_ctx.pass == 2)
1238 <    yy_aconf->modes |= UMODE_SOFTCALLERID;
1238 >    block_state.modes.value |= UMODE_SOFTCALLERID;
1239   } | T_CALLERID
1240   {
1241    if (conf_parser_ctx.pass == 2)
1242 <    yy_aconf->modes |= UMODE_CALLERID;
1242 >    block_state.modes.value |= UMODE_CALLERID;
1243   } | T_LOCOPS
1244   {
1245    if (conf_parser_ctx.pass == 2)
1246 <    yy_aconf->modes |= UMODE_LOCOPS;
1246 >    block_state.modes.value |= UMODE_LOCOPS;
1247 > } | T_NONONREG
1248 > {
1249 >  if (conf_parser_ctx.pass == 2)
1250 >    block_state.modes.value |= UMODE_REGONLY;
1251 > } | T_FARCONNECT
1252 > {
1253 >  if (conf_parser_ctx.pass == 2)
1254 >    block_state.modes.value |= UMODE_FARCONNECT;
1255   };
1256  
1257   oper_flags: IRCD_FLAGS
1258   {
1259    if (conf_parser_ctx.pass == 2)
1260 <    yy_aconf->port = 0;
1260 >    block_state.port.value = 0;
1261   } '='  oper_flags_items ';';
1262  
1263   oper_flags_items: oper_flags_items ',' oper_flags_item | oper_flags_item;
1264 < oper_flags_item: GLOBAL_KILL
1264 > oper_flags_item: KILL ':' REMOTE
1265   {
1266    if (conf_parser_ctx.pass == 2)
1267 <    yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1268 < } | REMOTE
1267 >    block_state.port.value |= OPER_FLAG_KILL_REMOTE;
1268 > } | KILL
1269   {
1270    if (conf_parser_ctx.pass == 2)
1271 <    yy_aconf->port |= OPER_FLAG_REMOTE;
1271 >    block_state.port.value |= OPER_FLAG_KILL;
1272 > } | CONNECT ':' REMOTE
1273 > {
1274 >  if (conf_parser_ctx.pass == 2)
1275 >    block_state.port.value |= OPER_FLAG_CONNECT_REMOTE;
1276 > } | CONNECT
1277 > {
1278 >  if (conf_parser_ctx.pass == 2)
1279 >    block_state.port.value |= OPER_FLAG_CONNECT;
1280 > } | SQUIT ':' REMOTE
1281 > {
1282 >  if (conf_parser_ctx.pass == 2)
1283 >    block_state.port.value |= OPER_FLAG_SQUIT_REMOTE;
1284 > } | SQUIT
1285 > {
1286 >  if (conf_parser_ctx.pass == 2)
1287 >    block_state.port.value |= OPER_FLAG_SQUIT;
1288   } | KLINE
1289   {
1290    if (conf_parser_ctx.pass == 2)
1291 <    yy_aconf->port |= OPER_FLAG_K;
1291 >    block_state.port.value |= OPER_FLAG_K;
1292   } | UNKLINE
1293   {
1294    if (conf_parser_ctx.pass == 2)
1295 <    yy_aconf->port |= OPER_FLAG_UNKLINE;
1295 >    block_state.port.value |= OPER_FLAG_UNKLINE;
1296   } | T_DLINE
1297   {
1298    if (conf_parser_ctx.pass == 2)
1299 <    yy_aconf->port |= OPER_FLAG_DLINE;
1299 >    block_state.port.value |= OPER_FLAG_DLINE;
1300   } | T_UNDLINE
1301   {
1302    if (conf_parser_ctx.pass == 2)
1303 <    yy_aconf->port |= OPER_FLAG_UNDLINE;
1303 >    block_state.port.value |= OPER_FLAG_UNDLINE;
1304   } | XLINE
1305   {
1306    if (conf_parser_ctx.pass == 2)
1307 <    yy_aconf->port |= OPER_FLAG_X;
1307 >    block_state.port.value |= OPER_FLAG_XLINE;
1308 > } | T_UNXLINE
1309 > {
1310 >  if (conf_parser_ctx.pass == 2)
1311 >    block_state.port.value |= OPER_FLAG_UNXLINE;
1312   } | GLINE
1313   {
1314    if (conf_parser_ctx.pass == 2)
1315 <    yy_aconf->port |= OPER_FLAG_GLINE;
1315 >    block_state.port.value |= OPER_FLAG_GLINE;
1316   } | DIE
1317   {
1318    if (conf_parser_ctx.pass == 2)
1319 <    yy_aconf->port |= OPER_FLAG_DIE;
1319 >    block_state.port.value |= OPER_FLAG_DIE;
1320   } | T_RESTART
1321   {
1322    if (conf_parser_ctx.pass == 2)
1323 <    yy_aconf->port |= OPER_FLAG_RESTART;
1323 >    block_state.port.value |= OPER_FLAG_RESTART;
1324   } | REHASH
1325   {
1326    if (conf_parser_ctx.pass == 2)
1327 <    yy_aconf->port |= OPER_FLAG_REHASH;
1327 >    block_state.port.value |= OPER_FLAG_REHASH;
1328   } | ADMIN
1329   {
1330    if (conf_parser_ctx.pass == 2)
1331 <    yy_aconf->port |= OPER_FLAG_ADMIN;
1238 < } | NICK_CHANGES
1239 < {
1240 <  if (conf_parser_ctx.pass == 2)
1241 <    yy_aconf->port |= OPER_FLAG_N;
1331 >    block_state.port.value |= OPER_FLAG_ADMIN;
1332   } | T_OPERWALL
1333   {
1334    if (conf_parser_ctx.pass == 2)
1335 <    yy_aconf->port |= OPER_FLAG_OPERWALL;
1335 >    block_state.port.value |= OPER_FLAG_OPERWALL;
1336   } | T_GLOBOPS
1337   {
1338    if (conf_parser_ctx.pass == 2)
1339 <    yy_aconf->port |= OPER_FLAG_GLOBOPS;
1340 < } | OPER_SPY_T
1339 >    block_state.port.value |= OPER_FLAG_GLOBOPS;
1340 > } | T_WALLOPS
1341   {
1342    if (conf_parser_ctx.pass == 2)
1343 <    yy_aconf->port |= OPER_FLAG_OPER_SPY;
1343 >    block_state.port.value |= OPER_FLAG_WALLOPS;
1344 > } | T_LOCOPS
1345 > {
1346 >  if (conf_parser_ctx.pass == 2)
1347 >    block_state.port.value |= OPER_FLAG_LOCOPS;
1348   } | REMOTEBAN
1349   {
1350    if (conf_parser_ctx.pass == 2)
1351 <    yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1351 >    block_state.port.value |= OPER_FLAG_REMOTEBAN;
1352   } | T_SET
1353   {
1354    if (conf_parser_ctx.pass == 2)
1355 <    yy_aconf->port |= OPER_FLAG_SET;
1355 >    block_state.port.value |= OPER_FLAG_SET;
1356   } | MODULE
1357   {
1358    if (conf_parser_ctx.pass == 2)
1359 <    yy_aconf->port |= OPER_FLAG_MODULE;
1359 >    block_state.port.value |= OPER_FLAG_MODULE;
1360   };
1361  
1362  
# Line 1271 | Line 1365 | oper_flags_item: GLOBAL_KILL
1365   ***************************************************************************/
1366   class_entry: CLASS
1367   {
1368 <  if (conf_parser_ctx.pass == 1)
1369 <  {
1276 <    yy_conf = make_conf_item(CLASS_TYPE);
1277 <    yy_class = map_to_conf(yy_conf);
1278 <  }
1279 < } '{' class_items '}' ';'
1280 < {
1281 <  if (conf_parser_ctx.pass == 1)
1282 <  {
1283 <    struct ConfItem *cconf = NULL;
1284 <    struct ClassItem *class = NULL;
1368 >  if (conf_parser_ctx.pass != 1)
1369 >    break;
1370  
1371 <    if (yy_class_name == NULL)
1287 <      delete_conf_item(yy_conf);
1288 <    else
1289 <    {
1290 <      cconf = find_exact_name_conf(CLASS_TYPE, NULL, yy_class_name, NULL, NULL);
1291 <
1292 <      if (cconf != NULL)                /* The class existed already */
1293 <      {
1294 <        int user_count = 0;
1295 <
1296 <        rebuild_cidr_class(cconf, yy_class);
1371 >  reset_block_state();
1372  
1373 <        class = map_to_conf(cconf);
1374 <
1375 <        user_count = class->curr_user_count;
1376 <        memcpy(class, yy_class, sizeof(*class));
1377 <        class->curr_user_count = user_count;
1378 <        class->active = 1;
1373 >  block_state.ping_freq.value = DEFAULT_PINGFREQUENCY;
1374 >  block_state.con_freq.value  = DEFAULT_CONNECTFREQUENCY;
1375 >  block_state.max_total.value = MAXIMUM_LINKS_DEFAULT;
1376 >  block_state.max_sendq.value = DEFAULT_SENDQ;
1377 >  block_state.max_recvq.value = DEFAULT_RECVQ;
1378 > } '{' class_items '}' ';'
1379 > {
1380 >  struct ClassItem *class = NULL;
1381  
1382 <        delete_conf_item(yy_conf);
1382 >  if (conf_parser_ctx.pass != 1)
1383 >    break;
1384  
1385 <        MyFree(cconf->name);            /* Allows case change of class name */
1386 <        cconf->name = yy_class_name;
1309 <      }
1310 <      else      /* Brand new class */
1311 <      {
1312 <        MyFree(yy_conf->name);          /* just in case it was allocated */
1313 <        yy_conf->name = yy_class_name;
1314 <        yy_class->active = 1;
1315 <      }
1316 <    }
1385 >  if (!block_state.class.buf[0])
1386 >    break;
1387  
1388 <    yy_class_name = NULL;
1389 <  }
1388 >  if (!(class = class_find(block_state.class.buf, 0)))
1389 >    class = class_make();
1390 >
1391 >  class->active = 1;
1392 >  MyFree(class->name);
1393 >  class->name = xstrdup(block_state.class.buf);
1394 >  class->ping_freq = block_state.ping_freq.value;
1395 >  class->max_perip = block_state.max_perip.value;
1396 >  class->con_freq = block_state.con_freq.value;
1397 >  class->max_total = block_state.max_total.value;
1398 >  class->max_global = block_state.max_global.value;
1399 >  class->max_local = block_state.max_local.value;
1400 >  class->max_ident = block_state.max_ident.value;
1401 >  class->max_sendq = block_state.max_sendq.value;
1402 >  class->max_recvq = block_state.max_recvq.value;
1403 >
1404 >  if (block_state.min_idle.value > block_state.max_idle.value)
1405 >  {
1406 >    block_state.min_idle.value = 0;
1407 >    block_state.max_idle.value = 0;
1408 >    block_state.flags.value &= ~CLASS_FLAGS_FAKE_IDLE;
1409 >  }
1410 >
1411 >  class->flags = block_state.flags.value;
1412 >  class->min_idle = block_state.min_idle.value;
1413 >  class->max_idle = block_state.max_idle.value;
1414 >
1415 >  if (class->number_per_cidr && block_state.number_per_cidr.value)
1416 >    if ((class->cidr_bitlen_ipv4 && block_state.cidr_bitlen_ipv4.value) ||
1417 >        (class->cidr_bitlen_ipv6 && block_state.cidr_bitlen_ipv6.value))
1418 >      if ((class->cidr_bitlen_ipv4 != block_state.cidr_bitlen_ipv4.value) ||
1419 >          (class->cidr_bitlen_ipv6 != block_state.cidr_bitlen_ipv6.value))
1420 >        rebuild_cidr_list(class);
1421 >
1422 >  class->cidr_bitlen_ipv4 = block_state.cidr_bitlen_ipv4.value;
1423 >  class->cidr_bitlen_ipv6 = block_state.cidr_bitlen_ipv6.value;
1424 >  class->number_per_cidr = block_state.number_per_cidr.value;
1425   };
1426  
1427   class_items:    class_items class_item | class_item;
1428   class_item:     class_name |
1429                  class_cidr_bitlen_ipv4 | class_cidr_bitlen_ipv6 |
1430                  class_ping_time |
1326                class_ping_warning |
1431                  class_number_per_cidr |
1432                  class_number_per_ip |
1433                  class_connectfreq |
# Line 1332 | Line 1436 | class_item:     class_name |
1436                  class_max_local |
1437                  class_max_ident |
1438                  class_sendq | class_recvq |
1439 +                class_min_idle |
1440 +                class_max_idle |
1441 +                class_flags |
1442                  error ';' ;
1443  
1444 < class_name: NAME '=' QSTRING ';'
1444 > class_name: NAME '=' QSTRING ';'
1445   {
1446    if (conf_parser_ctx.pass == 1)
1447 <  {
1341 <    MyFree(yy_class_name);
1342 <    DupString(yy_class_name, yylval.string);
1343 <  }
1447 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1448   };
1449  
1450   class_ping_time: PING_TIME '=' timespec ';'
1451   {
1452    if (conf_parser_ctx.pass == 1)
1453 <    yy_class->ping_freq = $3;
1350 < };
1351 <
1352 < class_ping_warning: PING_WARNING '=' timespec ';'
1353 < {
1354 <  if (conf_parser_ctx.pass == 1)
1355 <    yy_class->ping_warning = $3;
1453 >    block_state.ping_freq.value = $3;
1454   };
1455  
1456   class_number_per_ip: NUMBER_PER_IP '=' NUMBER ';'
1457   {
1458    if (conf_parser_ctx.pass == 1)
1459 <    yy_class->max_perip = $3;
1459 >    block_state.max_perip.value = $3;
1460   };
1461  
1462   class_connectfreq: CONNECTFREQ '=' timespec ';'
1463   {
1464    if (conf_parser_ctx.pass == 1)
1465 <    yy_class->con_freq = $3;
1465 >    block_state.con_freq.value = $3;
1466   };
1467  
1468   class_max_number: MAX_NUMBER '=' NUMBER ';'
1469   {
1470    if (conf_parser_ctx.pass == 1)
1471 <    yy_class->max_total = $3;
1471 >    block_state.max_total.value = $3;
1472   };
1473  
1474   class_max_global: MAX_GLOBAL '=' NUMBER ';'
1475   {
1476    if (conf_parser_ctx.pass == 1)
1477 <    yy_class->max_global = $3;
1477 >    block_state.max_global.value = $3;
1478   };
1479  
1480   class_max_local: MAX_LOCAL '=' NUMBER ';'
1481   {
1482    if (conf_parser_ctx.pass == 1)
1483 <    yy_class->max_local = $3;
1483 >    block_state.max_local.value = $3;
1484   };
1485  
1486   class_max_ident: MAX_IDENT '=' NUMBER ';'
1487   {
1488    if (conf_parser_ctx.pass == 1)
1489 <    yy_class->max_ident = $3;
1489 >    block_state.max_ident.value = $3;
1490   };
1491  
1492   class_sendq: SENDQ '=' sizespec ';'
1493   {
1494    if (conf_parser_ctx.pass == 1)
1495 <    yy_class->max_sendq = $3;
1495 >    block_state.max_sendq.value = $3;
1496   };
1497  
1498   class_recvq: T_RECVQ '=' sizespec ';'
1499   {
1500    if (conf_parser_ctx.pass == 1)
1501      if ($3 >= CLIENT_FLOOD_MIN && $3 <= CLIENT_FLOOD_MAX)
1502 <      yy_class->max_recvq = $3;
1502 >      block_state.max_recvq.value = $3;
1503   };
1504  
1505   class_cidr_bitlen_ipv4: CIDR_BITLEN_IPV4 '=' NUMBER ';'
1506   {
1507    if (conf_parser_ctx.pass == 1)
1508 <    yy_class->cidr_bitlen_ipv4 = $3 > 32 ? 32 : $3;
1508 >    block_state.cidr_bitlen_ipv4.value = $3 > 32 ? 32 : $3;
1509   };
1510  
1511   class_cidr_bitlen_ipv6: CIDR_BITLEN_IPV6 '=' NUMBER ';'
1512   {
1513    if (conf_parser_ctx.pass == 1)
1514 <    yy_class->cidr_bitlen_ipv6 = $3 > 128 ? 128 : $3;
1514 >    block_state.cidr_bitlen_ipv6.value = $3 > 128 ? 128 : $3;
1515   };
1516  
1517   class_number_per_cidr: NUMBER_PER_CIDR '=' NUMBER ';'
1518   {
1519    if (conf_parser_ctx.pass == 1)
1520 <    yy_class->number_per_cidr = $3;
1520 >    block_state.number_per_cidr.value = $3;
1521 > };
1522 >
1523 > class_min_idle: MIN_IDLE '=' timespec ';'
1524 > {
1525 >  if (conf_parser_ctx.pass != 1)
1526 >    break;
1527 >
1528 >  block_state.min_idle.value = $3;
1529 >  block_state.flags.value |= CLASS_FLAGS_FAKE_IDLE;
1530 > };
1531 >
1532 > class_max_idle: MAX_IDLE '=' timespec ';'
1533 > {
1534 >  if (conf_parser_ctx.pass != 1)
1535 >    break;
1536 >
1537 >  block_state.max_idle.value = $3;
1538 >  block_state.flags.value |= CLASS_FLAGS_FAKE_IDLE;
1539 > };
1540 >
1541 > class_flags: IRCD_FLAGS
1542 > {
1543 >  if (conf_parser_ctx.pass == 1)
1544 >    block_state.flags.value &= CLASS_FLAGS_FAKE_IDLE;
1545 > } '='  class_flags_items ';';
1546 >
1547 > class_flags_items: class_flags_items ',' class_flags_item | class_flags_item;
1548 > class_flags_item: RANDOM_IDLE
1549 > {
1550 >  if (conf_parser_ctx.pass == 1)
1551 >    block_state.flags.value |= CLASS_FLAGS_RANDOM_IDLE;
1552 > } | HIDE_IDLE_FROM_OPERS
1553 > {
1554 >  if (conf_parser_ctx.pass == 1)
1555 >    block_state.flags.value |= CLASS_FLAGS_HIDE_IDLE_FROM_OPERS;
1556   };
1557  
1558 +
1559   /***************************************************************************
1560   *  section listen
1561   ***************************************************************************/
1562   listen_entry: LISTEN
1563   {
1564    if (conf_parser_ctx.pass == 2)
1565 <  {
1566 <    listener_address = NULL;
1433 <    listener_flags = 0;
1434 <  }
1435 < } '{' listen_items '}' ';'
1436 < {
1437 <  if (conf_parser_ctx.pass == 2)
1438 <  {
1439 <    MyFree(listener_address);
1440 <    listener_address = NULL;
1441 <  }
1442 < };
1565 >    reset_block_state();
1566 > } '{' listen_items '}' ';';
1567  
1568   listen_flags: IRCD_FLAGS
1569   {
1570 <  listener_flags = 0;
1570 >  block_state.flags.value = 0;
1571   } '='  listen_flags_items ';';
1572  
1573   listen_flags_items: listen_flags_items ',' listen_flags_item | listen_flags_item;
1574   listen_flags_item: T_SSL
1575   {
1576    if (conf_parser_ctx.pass == 2)
1577 <    listener_flags |= LISTENER_SSL;
1577 >    block_state.flags.value |= LISTENER_SSL;
1578   } | HIDDEN
1579   {
1580    if (conf_parser_ctx.pass == 2)
1581 <    listener_flags |= LISTENER_HIDDEN;
1581 >    block_state.flags.value |= LISTENER_HIDDEN;
1582   } | T_SERVER
1583   {
1584    if (conf_parser_ctx.pass == 2)
1585 <    listener_flags |= LISTENER_SERVER;
1585 >   block_state.flags.value |= LISTENER_SERVER;
1586   };
1587  
1464
1465
1588   listen_items:   listen_items listen_item | listen_item;
1589   listen_item:    listen_port | listen_flags | listen_address | listen_host | error ';';
1590  
1591 < listen_port: PORT '=' port_items { listener_flags = 0; } ';';
1591 > listen_port: PORT '=' port_items { block_state.flags.value = 0; } ';';
1592  
1593   port_items: port_items ',' port_item | port_item;
1594  
# Line 1474 | Line 1596 | port_item: NUMBER
1596   {
1597    if (conf_parser_ctx.pass == 2)
1598    {
1599 <    if ((listener_flags & LISTENER_SSL))
1599 >    if (block_state.flags.value & LISTENER_SSL)
1600   #ifdef HAVE_LIBCRYPTO
1601        if (!ServerInfo.server_ctx)
1602   #endif
1603        {
1604 <        yyerror("SSL not available - port closed");
1604 >        conf_error_report("SSL not available - port closed");
1605          break;
1606        }
1607 <    add_listener($1, listener_address, listener_flags);
1607 >    add_listener($1, block_state.addr.buf, block_state.flags.value);
1608    }
1609   } | NUMBER TWODOTS NUMBER
1610   {
# Line 1490 | Line 1612 | port_item: NUMBER
1612    {
1613      int i;
1614  
1615 <    if ((listener_flags & LISTENER_SSL))
1615 >    if (block_state.flags.value & LISTENER_SSL)
1616   #ifdef HAVE_LIBCRYPTO
1617        if (!ServerInfo.server_ctx)
1618   #endif
1619        {
1620 <        yyerror("SSL not available - port closed");
1620 >        conf_error_report("SSL not available - port closed");
1621          break;
1622        }
1623  
1624      for (i = $1; i <= $3; ++i)
1625 <      add_listener(i, listener_address, listener_flags);
1625 >      add_listener(i, block_state.addr.buf, block_state.flags.value);
1626    }
1627   };
1628  
1629   listen_address: IP '=' QSTRING ';'
1630   {
1631    if (conf_parser_ctx.pass == 2)
1632 <  {
1511 <    MyFree(listener_address);
1512 <    DupString(listener_address, yylval.string);
1513 <  }
1632 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
1633   };
1634  
1635   listen_host: HOST '=' QSTRING ';'
1636   {
1637    if (conf_parser_ctx.pass == 2)
1638 <  {
1520 <    MyFree(listener_address);
1521 <    DupString(listener_address, yylval.string);
1522 <  }
1638 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
1639   };
1640  
1641   /***************************************************************************
# Line 1528 | Line 1644 | listen_host: HOST '=' QSTRING ';'
1644   auth_entry: IRCD_AUTH
1645   {
1646    if (conf_parser_ctx.pass == 2)
1647 <  {
1532 <    yy_conf = make_conf_item(CLIENT_TYPE);
1533 <    yy_aconf = map_to_conf(yy_conf);
1534 <  }
1535 <  else
1536 <  {
1537 <    MyFree(class_name);
1538 <    class_name = NULL;
1539 <  }
1647 >    reset_block_state();
1648   } '{' auth_items '}' ';'
1649   {
1650 <  if (conf_parser_ctx.pass == 2)
1543 <  {
1544 <    struct CollectItem *yy_tmp = NULL;
1545 <    dlink_node *ptr = NULL, *next_ptr = NULL;
1546 <
1547 <    if (yy_aconf->user && yy_aconf->host)
1548 <    {
1549 <      conf_add_class_to_conf(yy_conf, class_name);
1550 <      add_conf_by_address(CONF_CLIENT, yy_aconf);
1551 <    }
1552 <    else
1553 <      delete_conf_item(yy_conf);
1554 <
1555 <    /* copy over settings from first struct */
1556 <    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
1557 <    {
1558 <      struct AccessItem *new_aconf;
1559 <      struct ConfItem *new_conf;
1650 >  dlink_node *ptr = NULL;
1651  
1652 <      new_conf = make_conf_item(CLIENT_TYPE);
1653 <      new_aconf = map_to_conf(new_conf);
1652 >  if (conf_parser_ctx.pass != 2)
1653 >    break;
1654  
1655 <      yy_tmp = ptr->data;
1656 <
1657 <      assert(yy_tmp->user && yy_tmp->host);
1658 <
1568 <      if (yy_aconf->passwd != NULL)
1569 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1570 <      if (yy_conf->name != NULL)
1571 <        DupString(new_conf->name, yy_conf->name);
1572 <      if (yy_aconf->passwd != NULL)
1573 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1574 <
1575 <      new_aconf->flags = yy_aconf->flags;
1576 <      new_aconf->port  = yy_aconf->port;
1655 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
1656 >  {
1657 >    struct MaskItem *conf = NULL;
1658 >    struct split_nuh_item nuh;
1659  
1660 <      DupString(new_aconf->user, yy_tmp->user);
1661 <      collapse(new_aconf->user);
1660 >    nuh.nuhmask  = ptr->data;
1661 >    nuh.nickptr  = NULL;
1662 >    nuh.userptr  = block_state.user.buf;
1663 >    nuh.hostptr  = block_state.host.buf;
1664 >    nuh.nicksize = 0;
1665 >    nuh.usersize = sizeof(block_state.user.buf);
1666 >    nuh.hostsize = sizeof(block_state.host.buf);
1667 >    split_nuh(&nuh);
1668  
1669 <      DupString(new_aconf->host, yy_tmp->host);
1670 <      collapse(new_aconf->host);
1669 >    conf        = conf_make(CONF_CLIENT);
1670 >    conf->user  = xstrdup(block_state.user.buf);
1671 >    conf->host  = xstrdup(block_state.host.buf);
1672 >
1673 >    if (block_state.rpass.buf[0])
1674 >      conf->passwd = xstrdup(block_state.rpass.buf);
1675 >    if (block_state.name.buf[0])
1676 >      conf->name = xstrdup(block_state.name.buf);
1677  
1678 <      conf_add_class_to_conf(new_conf, class_name);
1679 <      add_conf_by_address(CONF_CLIENT, new_aconf);
1586 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
1587 <      free_collect_item(yy_tmp);
1588 <    }
1678 >    conf->flags = block_state.flags.value;
1679 >    conf->port  = block_state.port.value;
1680  
1681 <    MyFree(class_name);
1682 <    class_name = NULL;
1592 <    yy_conf = NULL;
1593 <    yy_aconf = NULL;
1681 >    conf_add_class_to_conf(conf, block_state.class.buf);
1682 >    add_conf_by_address(CONF_CLIENT, conf);
1683    }
1684 < };
1684 > };
1685  
1686   auth_items:     auth_items auth_item | auth_item;
1687   auth_item:      auth_user | auth_passwd | auth_class | auth_flags |
# Line 1602 | Line 1691 | auth_item:      auth_user | auth_passwd
1691   auth_user: USER '=' QSTRING ';'
1692   {
1693    if (conf_parser_ctx.pass == 2)
1694 <  {
1606 <    struct CollectItem *yy_tmp = NULL;
1607 <    struct split_nuh_item nuh;
1608 <
1609 <    nuh.nuhmask  = yylval.string;
1610 <    nuh.nickptr  = NULL;
1611 <    nuh.userptr  = userbuf;
1612 <    nuh.hostptr  = hostbuf;
1613 <
1614 <    nuh.nicksize = 0;
1615 <    nuh.usersize = sizeof(userbuf);
1616 <    nuh.hostsize = sizeof(hostbuf);
1617 <
1618 <    split_nuh(&nuh);
1619 <
1620 <    if (yy_aconf->user == NULL)
1621 <    {
1622 <      DupString(yy_aconf->user, userbuf);
1623 <      DupString(yy_aconf->host, hostbuf);
1624 <    }
1625 <    else
1626 <    {
1627 <      yy_tmp = MyMalloc(sizeof(struct CollectItem));
1628 <
1629 <      DupString(yy_tmp->user, userbuf);
1630 <      DupString(yy_tmp->host, hostbuf);
1631 <
1632 <      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1633 <    }
1634 <  }
1694 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1695   };
1696  
1697   auth_passwd: PASSWORD '=' QSTRING ';'
1698   {
1699    if (conf_parser_ctx.pass == 2)
1700 <  {
1641 <    /* be paranoid */
1642 <    if (yy_aconf->passwd != NULL)
1643 <      memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1644 <
1645 <    MyFree(yy_aconf->passwd);
1646 <    DupString(yy_aconf->passwd, yylval.string);
1647 <  }
1700 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1701   };
1702  
1703   auth_class: CLASS '=' QSTRING ';'
1704   {
1705    if (conf_parser_ctx.pass == 2)
1706 <  {
1654 <    MyFree(class_name);
1655 <    DupString(class_name, yylval.string);
1656 <  }
1706 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1707   };
1708  
1709   auth_encrypted: ENCRYPTED '=' TBOOL ';'
# Line 1661 | Line 1711 | auth_encrypted: ENCRYPTED '=' TBOOL ';'
1711    if (conf_parser_ctx.pass == 2)
1712    {
1713      if (yylval.number)
1714 <      SetConfEncrypted(yy_aconf);
1714 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1715      else
1716 <      ClearConfEncrypted(yy_aconf);
1716 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1717    }
1718   };
1719  
1720   auth_flags: IRCD_FLAGS
1721   {
1722 +  if (conf_parser_ctx.pass == 2)
1723 +    block_state.flags.value &= (CONF_FLAGS_ENCRYPTED | CONF_FLAGS_SPOOF_IP);
1724   } '='  auth_flags_items ';';
1725  
1726   auth_flags_items: auth_flags_items ',' auth_flags_item | auth_flags_item;
1727   auth_flags_item: SPOOF_NOTICE
1728   {
1729    if (conf_parser_ctx.pass == 2)
1730 <    yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1730 >    block_state.flags.value |= CONF_FLAGS_SPOOF_NOTICE;
1731   } | EXCEED_LIMIT
1732   {
1733    if (conf_parser_ctx.pass == 2)
1734 <    yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
1734 >    block_state.flags.value |= CONF_FLAGS_NOLIMIT;
1735   } | KLINE_EXEMPT
1736   {
1737    if (conf_parser_ctx.pass == 2)
1738 <    yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
1738 >    block_state.flags.value |= CONF_FLAGS_EXEMPTKLINE;
1739   } | NEED_IDENT
1740   {
1741    if (conf_parser_ctx.pass == 2)
1742 <    yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
1742 >    block_state.flags.value |= CONF_FLAGS_NEED_IDENTD;
1743   } | CAN_FLOOD
1744   {
1745    if (conf_parser_ctx.pass == 2)
1746 <    yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
1746 >    block_state.flags.value |= CONF_FLAGS_CAN_FLOOD;
1747   } | NO_TILDE
1748   {
1749    if (conf_parser_ctx.pass == 2)
1750 <    yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
1750 >    block_state.flags.value |= CONF_FLAGS_NO_TILDE;
1751   } | GLINE_EXEMPT
1752   {
1753    if (conf_parser_ctx.pass == 2)
1754 <    yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
1754 >    block_state.flags.value |= CONF_FLAGS_EXEMPTGLINE;
1755   } | RESV_EXEMPT
1756   {
1757    if (conf_parser_ctx.pass == 2)
1758 <    yy_aconf->flags |= CONF_FLAGS_EXEMPTRESV;
1758 >    block_state.flags.value |= CONF_FLAGS_EXEMPTRESV;
1759 > } | T_WEBIRC
1760 > {
1761 >  if (conf_parser_ctx.pass == 2)
1762 >    block_state.flags.value |= CONF_FLAGS_WEBIRC;
1763   } | NEED_PASSWORD
1764   {
1765    if (conf_parser_ctx.pass == 2)
1766 <    yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
1766 >    block_state.flags.value |= CONF_FLAGS_NEED_PASSWORD;
1767   };
1768  
1769 < auth_spoof: SPOOF '=' QSTRING ';'
1769 > auth_spoof: SPOOF '=' QSTRING ';'
1770   {
1771 <  if (conf_parser_ctx.pass == 2)
1772 <  {
1717 <    MyFree(yy_conf->name);
1771 >  if (conf_parser_ctx.pass != 2)
1772 >    break;
1773  
1774 <    if (strlen(yylval.string) <= HOSTLEN && valid_hostname(yylval.string))
1775 <    {    
1776 <      DupString(yy_conf->name, yylval.string);
1777 <      yy_aconf->flags |= CONF_FLAGS_SPOOF_IP;
1723 <    }
1724 <    else
1725 <    {
1726 <      ilog(LOG_TYPE_IRCD, "Spoof either is too long or contains invalid characters. Ignoring it.");
1727 <      yy_conf->name = NULL;
1728 <    }
1774 >  if (strlen(yylval.string) <= HOSTLEN && valid_hostname(yylval.string))
1775 >  {
1776 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1777 >    block_state.flags.value |= CONF_FLAGS_SPOOF_IP;
1778    }
1779 +  else
1780 +    ilog(LOG_TYPE_IRCD, "Spoof either is too long or contains invalid characters. Ignoring it.");
1781   };
1782  
1783   auth_redir_serv: REDIRSERV '=' QSTRING ';'
1784   {
1785 <  if (conf_parser_ctx.pass == 2)
1786 <  {
1787 <    yy_aconf->flags |= CONF_FLAGS_REDIR;
1788 <    MyFree(yy_conf->name);
1789 <    DupString(yy_conf->name, yylval.string);
1739 <  }
1785 >  if (conf_parser_ctx.pass != 2)
1786 >    break;
1787 >
1788 >  strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1789 >  block_state.flags.value |= CONF_FLAGS_REDIR;
1790   };
1791  
1792   auth_redir_port: REDIRPORT '=' NUMBER ';'
1793   {
1794 <  if (conf_parser_ctx.pass == 2)
1795 <  {
1796 <    yy_aconf->flags |= CONF_FLAGS_REDIR;
1797 <    yy_aconf->port = $3;
1798 <  }
1794 >  if (conf_parser_ctx.pass != 2)
1795 >    break;
1796 >
1797 >  block_state.flags.value |= CONF_FLAGS_REDIR;
1798 >  block_state.port.value = $3;
1799   };
1800  
1801  
# Line 1754 | Line 1804 | auth_redir_port: REDIRPORT '=' NUMBER ';
1804   ***************************************************************************/
1805   resv_entry: RESV
1806   {
1807 <  if (conf_parser_ctx.pass == 2)
1808 <  {
1809 <    MyFree(resv_reason);
1810 <    resv_reason = NULL;
1811 <  }
1807 >  if (conf_parser_ctx.pass != 2)
1808 >    break;
1809 >
1810 >  reset_block_state();
1811 >  strlcpy(block_state.rpass.buf, CONF_NOREASON, sizeof(block_state.rpass.buf));
1812   } '{' resv_items '}' ';'
1813   {
1814 <  if (conf_parser_ctx.pass == 2)
1815 <  {
1816 <    MyFree(resv_reason);
1817 <    resv_reason = NULL;
1768 <  }
1814 >  if (conf_parser_ctx.pass != 2)
1815 >    break;
1816 >
1817 >  create_resv(block_state.name.buf, block_state.rpass.buf, &block_state.mask.list);
1818   };
1819  
1820   resv_items:     resv_items resv_item | resv_item;
1821 < resv_item:      resv_creason | resv_channel | resv_nick | error ';' ;
1821 > resv_item:      resv_mask | resv_reason | resv_exempt | error ';' ;
1822  
1823 < resv_creason: REASON '=' QSTRING ';'
1823 > resv_mask: MASK '=' QSTRING ';'
1824   {
1825    if (conf_parser_ctx.pass == 2)
1826 <  {
1778 <    MyFree(resv_reason);
1779 <    DupString(resv_reason, yylval.string);
1780 <  }
1826 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1827   };
1828  
1829 < resv_channel: CHANNEL '=' QSTRING ';'
1829 > resv_reason: REASON '=' QSTRING ';'
1830   {
1831    if (conf_parser_ctx.pass == 2)
1832 <  {
1787 <    if (IsChanPrefix(*yylval.string))
1788 <    {
1789 <      char def_reason[] = "No reason";
1790 <
1791 <      create_channel_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
1792 <    }
1793 <  }
1794 <  /* ignore it for now.. but we really should make a warning if
1795 <   * its an erroneous name --fl_ */
1832 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1833   };
1834  
1835 < resv_nick: NICK '=' QSTRING ';'
1835 > resv_exempt: EXEMPT '=' QSTRING ';'
1836   {
1837    if (conf_parser_ctx.pass == 2)
1838 <  {
1802 <    char def_reason[] = "No reason";
1803 <
1804 <    create_nick_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
1805 <  }
1838 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1839   };
1840  
1841 +
1842   /***************************************************************************
1843   *  section service
1844   ***************************************************************************/
# Line 1815 | Line 1849 | service_item:      service_name | error;
1849  
1850   service_name: NAME '=' QSTRING ';'
1851   {
1852 <  if (conf_parser_ctx.pass == 2)
1852 >  if (conf_parser_ctx.pass != 2)
1853 >    break;
1854 >
1855 >  if (valid_servname(yylval.string))
1856    {
1857 <    if (valid_servname(yylval.string))
1858 <    {
1822 <      yy_conf = make_conf_item(SERVICE_TYPE);
1823 <      DupString(yy_conf->name, yylval.string);
1824 <    }
1857 >    struct MaskItem *conf = conf_make(CONF_SERVICE);
1858 >    conf->name = xstrdup(yylval.string);
1859    }
1860   };
1861  
# Line 1830 | Line 1864 | service_name: NAME '=' QSTRING ';'
1864   ***************************************************************************/
1865   shared_entry: T_SHARED
1866   {
1867 <  if (conf_parser_ctx.pass == 2)
1868 <  {
1869 <    yy_conf = make_conf_item(ULINE_TYPE);
1870 <    yy_match_item = map_to_conf(yy_conf);
1871 <    yy_match_item->action = SHARED_ALL;
1872 <  }
1867 >  if (conf_parser_ctx.pass != 2)
1868 >    break;
1869 >
1870 >  reset_block_state();
1871 >
1872 >  strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1873 >  strlcpy(block_state.user.buf, "*", sizeof(block_state.user.buf));
1874 >  strlcpy(block_state.host.buf, "*", sizeof(block_state.host.buf));
1875 >  block_state.flags.value = SHARED_ALL;
1876   } '{' shared_items '}' ';'
1877   {
1878 <  if (conf_parser_ctx.pass == 2)
1879 <  {
1880 <    yy_conf = NULL;
1881 <  }
1878 >  struct MaskItem *conf = NULL;
1879 >
1880 >  if (conf_parser_ctx.pass != 2)
1881 >    break;
1882 >
1883 >  conf = conf_make(CONF_ULINE);
1884 >  conf->flags = block_state.flags.value;
1885 >  conf->name = xstrdup(block_state.name.buf);
1886 >  conf->user = xstrdup(block_state.user.buf);
1887 >  conf->host = xstrdup(block_state.host.buf);
1888   };
1889  
1890   shared_items: shared_items shared_item | shared_item;
# Line 1850 | Line 1893 | shared_item:  shared_name | shared_user
1893   shared_name: NAME '=' QSTRING ';'
1894   {
1895    if (conf_parser_ctx.pass == 2)
1896 <  {
1854 <    MyFree(yy_conf->name);
1855 <    DupString(yy_conf->name, yylval.string);
1856 <  }
1896 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1897   };
1898  
1899   shared_user: USER '=' QSTRING ';'
# Line 1864 | Line 1904 | shared_user: USER '=' QSTRING ';'
1904  
1905      nuh.nuhmask  = yylval.string;
1906      nuh.nickptr  = NULL;
1907 <    nuh.userptr  = userbuf;
1908 <    nuh.hostptr  = hostbuf;
1907 >    nuh.userptr  = block_state.user.buf;
1908 >    nuh.hostptr  = block_state.host.buf;
1909  
1910      nuh.nicksize = 0;
1911 <    nuh.usersize = sizeof(userbuf);
1912 <    nuh.hostsize = sizeof(hostbuf);
1911 >    nuh.usersize = sizeof(block_state.user.buf);
1912 >    nuh.hostsize = sizeof(block_state.host.buf);
1913  
1914      split_nuh(&nuh);
1875
1876    DupString(yy_match_item->user, userbuf);
1877    DupString(yy_match_item->host, hostbuf);
1915    }
1916   };
1917  
1918   shared_type: TYPE
1919   {
1920    if (conf_parser_ctx.pass == 2)
1921 <    yy_match_item->action = 0;
1921 >    block_state.flags.value = 0;
1922   } '=' shared_types ';' ;
1923  
1924   shared_types: shared_types ',' shared_type_item | shared_type_item;
1925   shared_type_item: KLINE
1926   {
1927    if (conf_parser_ctx.pass == 2)
1928 <    yy_match_item->action |= SHARED_KLINE;
1928 >    block_state.flags.value |= SHARED_KLINE;
1929   } | UNKLINE
1930   {
1931    if (conf_parser_ctx.pass == 2)
1932 <    yy_match_item->action |= SHARED_UNKLINE;
1932 >    block_state.flags.value |= SHARED_UNKLINE;
1933   } | T_DLINE
1934   {
1935    if (conf_parser_ctx.pass == 2)
1936 <    yy_match_item->action |= SHARED_DLINE;
1936 >    block_state.flags.value |= SHARED_DLINE;
1937   } | T_UNDLINE
1938   {
1939    if (conf_parser_ctx.pass == 2)
1940 <    yy_match_item->action |= SHARED_UNDLINE;
1940 >    block_state.flags.value |= SHARED_UNDLINE;
1941   } | XLINE
1942   {
1943    if (conf_parser_ctx.pass == 2)
1944 <    yy_match_item->action |= SHARED_XLINE;
1944 >    block_state.flags.value |= SHARED_XLINE;
1945   } | T_UNXLINE
1946   {
1947    if (conf_parser_ctx.pass == 2)
1948 <    yy_match_item->action |= SHARED_UNXLINE;
1948 >    block_state.flags.value |= SHARED_UNXLINE;
1949   } | RESV
1950   {
1951    if (conf_parser_ctx.pass == 2)
1952 <    yy_match_item->action |= SHARED_RESV;
1952 >    block_state.flags.value |= SHARED_RESV;
1953   } | T_UNRESV
1954   {
1955    if (conf_parser_ctx.pass == 2)
1956 <    yy_match_item->action |= SHARED_UNRESV;
1956 >    block_state.flags.value |= SHARED_UNRESV;
1957   } | T_LOCOPS
1958   {
1959    if (conf_parser_ctx.pass == 2)
1960 <    yy_match_item->action |= SHARED_LOCOPS;
1960 >    block_state.flags.value |= SHARED_LOCOPS;
1961   } | T_ALL
1962   {
1963    if (conf_parser_ctx.pass == 2)
1964 <    yy_match_item->action = SHARED_ALL;
1964 >    block_state.flags.value = SHARED_ALL;
1965   };
1966  
1967   /***************************************************************************
# Line 1932 | Line 1969 | shared_type_item: KLINE
1969   ***************************************************************************/
1970   cluster_entry: T_CLUSTER
1971   {
1972 <  if (conf_parser_ctx.pass == 2)
1973 <  {
1974 <    yy_conf = make_conf_item(CLUSTER_TYPE);
1975 <    yy_conf->flags = SHARED_ALL;
1976 <  }
1972 >  if (conf_parser_ctx.pass != 2)
1973 >    break;
1974 >
1975 >  reset_block_state();
1976 >
1977 >  strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1978 >  block_state.flags.value = SHARED_ALL;
1979   } '{' cluster_items '}' ';'
1980   {
1981 <  if (conf_parser_ctx.pass == 2)
1982 <  {
1983 <    if (yy_conf->name == NULL)
1984 <      DupString(yy_conf->name, "*");
1985 <    yy_conf = NULL;
1986 <  }
1981 >  struct MaskItem *conf = NULL;
1982 >
1983 >  if (conf_parser_ctx.pass != 2)
1984 >    break;
1985 >
1986 >  conf = conf_make(CONF_CLUSTER);
1987 >  conf->flags = block_state.flags.value;
1988 >  conf->name = xstrdup(block_state.name.buf);
1989   };
1990  
1991   cluster_items:  cluster_items cluster_item | cluster_item;
# Line 1953 | Line 1994 | cluster_item:  cluster_name | cluster_typ
1994   cluster_name: NAME '=' QSTRING ';'
1995   {
1996    if (conf_parser_ctx.pass == 2)
1997 <    DupString(yy_conf->name, yylval.string);
1997 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1998   };
1999  
2000   cluster_type: TYPE
2001   {
2002    if (conf_parser_ctx.pass == 2)
2003 <    yy_conf->flags = 0;
2003 >    block_state.flags.value = 0;
2004   } '=' cluster_types ';' ;
2005  
2006   cluster_types:  cluster_types ',' cluster_type_item | cluster_type_item;
2007   cluster_type_item: KLINE
2008   {
2009    if (conf_parser_ctx.pass == 2)
2010 <    yy_conf->flags |= SHARED_KLINE;
2010 >    block_state.flags.value |= SHARED_KLINE;
2011   } | UNKLINE
2012   {
2013    if (conf_parser_ctx.pass == 2)
2014 <    yy_conf->flags |= SHARED_UNKLINE;
2014 >    block_state.flags.value |= SHARED_UNKLINE;
2015   } | T_DLINE
2016   {
2017    if (conf_parser_ctx.pass == 2)
2018 <    yy_conf->flags |= SHARED_DLINE;
2018 >    block_state.flags.value |= SHARED_DLINE;
2019   } | T_UNDLINE
2020   {
2021    if (conf_parser_ctx.pass == 2)
2022 <    yy_conf->flags |= SHARED_UNDLINE;
2022 >    block_state.flags.value |= SHARED_UNDLINE;
2023   } | XLINE
2024   {
2025    if (conf_parser_ctx.pass == 2)
2026 <    yy_conf->flags |= SHARED_XLINE;
2026 >    block_state.flags.value |= SHARED_XLINE;
2027   } | T_UNXLINE
2028   {
2029    if (conf_parser_ctx.pass == 2)
2030 <    yy_conf->flags |= SHARED_UNXLINE;
2030 >    block_state.flags.value |= SHARED_UNXLINE;
2031   } | RESV
2032   {
2033    if (conf_parser_ctx.pass == 2)
2034 <    yy_conf->flags |= SHARED_RESV;
2034 >    block_state.flags.value |= SHARED_RESV;
2035   } | T_UNRESV
2036   {
2037    if (conf_parser_ctx.pass == 2)
2038 <    yy_conf->flags |= SHARED_UNRESV;
2038 >    block_state.flags.value |= SHARED_UNRESV;
2039   } | T_LOCOPS
2040   {
2041    if (conf_parser_ctx.pass == 2)
2042 <    yy_conf->flags |= SHARED_LOCOPS;
2042 >    block_state.flags.value |= SHARED_LOCOPS;
2043   } | T_ALL
2044   {
2045    if (conf_parser_ctx.pass == 2)
2046 <    yy_conf->flags = SHARED_ALL;
2046 >    block_state.flags.value = SHARED_ALL;
2047   };
2048  
2049   /***************************************************************************
2050   *  section connect
2051   ***************************************************************************/
2052 < connect_entry: CONNECT  
2052 > connect_entry: CONNECT
2053   {
2013  if (conf_parser_ctx.pass == 2)
2014  {
2015    yy_conf = make_conf_item(SERVER_TYPE);
2016    yy_aconf = map_to_conf(yy_conf);
2054  
2055 <    /* defaults */
2056 <    yy_aconf->port = PORTNUM;
2057 <  }
2058 <  else
2059 <  {
2060 <    MyFree(class_name);
2024 <    class_name = NULL;
2025 <  }
2055 >  if (conf_parser_ctx.pass != 2)
2056 >    break;
2057 >
2058 >  reset_block_state();
2059 >  block_state.aftype.value = AF_INET;
2060 >  block_state.port.value = PORTNUM;
2061   } '{' connect_items '}' ';'
2062   {
2063 <  if (conf_parser_ctx.pass == 2)
2063 >  struct MaskItem *conf = NULL;
2064 >  struct addrinfo hints, *res;
2065 >
2066 >  if (conf_parser_ctx.pass != 2)
2067 >    break;
2068 >
2069 >  if (!block_state.name.buf[0] ||
2070 >      !block_state.host.buf[0])
2071 >    break;
2072 >
2073 >  if (!block_state.rpass.buf[0] ||
2074 >      !block_state.spass.buf[0])
2075 >    break;
2076 >
2077 >  if (has_wildcards(block_state.name.buf) ||
2078 >      has_wildcards(block_state.host.buf))
2079 >    break;
2080 >
2081 >  conf = conf_make(CONF_SERVER);
2082 >  conf->port = block_state.port.value;
2083 >  conf->flags = block_state.flags.value;
2084 >  conf->aftype = block_state.aftype.value;
2085 >  conf->host = xstrdup(block_state.host.buf);
2086 >  conf->name = xstrdup(block_state.name.buf);
2087 >  conf->passwd = xstrdup(block_state.rpass.buf);
2088 >  conf->spasswd = xstrdup(block_state.spass.buf);
2089 >
2090 >  if (block_state.cert.buf[0])
2091 >    conf->certfp = xstrdup(block_state.cert.buf);
2092 >
2093 >  if (block_state.ciph.buf[0])
2094 >    conf->cipher_list = xstrdup(block_state.ciph.buf);
2095 >
2096 >  dlinkMoveList(&block_state.leaf.list, &conf->leaf_list);
2097 >  dlinkMoveList(&block_state.hub.list, &conf->hub_list);
2098 >
2099 >  if (block_state.bind.buf[0])
2100    {
2101 <    if (yy_aconf->host && yy_aconf->passwd && yy_aconf->spasswd)
2102 <    {
2103 <      if (conf_add_server(yy_conf, class_name) == -1)
2104 <        delete_conf_item(yy_conf);
2105 <    }
2101 >    memset(&hints, 0, sizeof(hints));
2102 >
2103 >    hints.ai_family   = AF_UNSPEC;
2104 >    hints.ai_socktype = SOCK_STREAM;
2105 >    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
2106 >
2107 >    if (getaddrinfo(block_state.bind.buf, NULL, &hints, &res))
2108 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", block_state.bind.buf);
2109      else
2110      {
2111 <      if (yy_conf->name != NULL)
2038 <      {
2039 <        if (yy_aconf->host == NULL)
2040 <          yyerror("Ignoring connect block -- missing host");
2041 <        else if (!yy_aconf->passwd || !yy_aconf->spasswd)
2042 <          yyerror("Ignoring connect block -- missing password");
2043 <      }
2111 >      assert(res != NULL);
2112  
2113 <      /* XXX
2114 <       * This fixes a try_connections() core (caused by invalid class_ptr
2115 <       * pointers) reported by metalrock. That's an ugly fix, but there
2116 <       * is currently no better way. The entire config subsystem needs an
2049 <       * rewrite ASAP. make_conf_item() shouldn't really add things onto
2050 <       * a doubly linked list immediately without any sanity checks!  -Michael
2051 <       */
2052 <      delete_conf_item(yy_conf);
2113 >      memcpy(&conf->bind, res->ai_addr, res->ai_addrlen);
2114 >      conf->bind.ss.ss_family = res->ai_family;
2115 >      conf->bind.ss_len = res->ai_addrlen;
2116 >      freeaddrinfo(res);
2117      }
2054
2055    MyFree(class_name);
2056    class_name = NULL;
2057    yy_conf = NULL;
2058    yy_aconf = NULL;
2118    }
2119 +
2120 +  conf_add_class_to_conf(conf, block_state.class.buf);
2121 +  lookup_confhost(conf);
2122   };
2123  
2124   connect_items:  connect_items connect_item | connect_item;
2125   connect_item:   connect_name | connect_host | connect_vhost |
2126                  connect_send_password | connect_accept_password |
2127 +                connect_ssl_certificate_fingerprint |
2128                  connect_aftype | connect_port | connect_ssl_cipher_list |
2129                  connect_flags | connect_hub_mask | connect_leaf_mask |
2130 <                connect_class | connect_encrypted |
2130 >                connect_class | connect_encrypted |
2131                  error ';' ;
2132  
2133   connect_name: NAME '=' QSTRING ';'
2134   {
2135    if (conf_parser_ctx.pass == 2)
2136 <  {
2074 <    MyFree(yy_conf->name);
2075 <    DupString(yy_conf->name, yylval.string);
2076 <  }
2136 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
2137   };
2138  
2139 < connect_host: HOST '=' QSTRING ';'
2139 > connect_host: HOST '=' QSTRING ';'
2140   {
2141    if (conf_parser_ctx.pass == 2)
2142 <  {
2083 <    MyFree(yy_aconf->host);
2084 <    DupString(yy_aconf->host, yylval.string);
2085 <  }
2142 >    strlcpy(block_state.host.buf, yylval.string, sizeof(block_state.host.buf));
2143   };
2144  
2145 < connect_vhost: VHOST '=' QSTRING ';'
2145 > connect_vhost: VHOST '=' QSTRING ';'
2146   {
2147    if (conf_parser_ctx.pass == 2)
2148 <  {
2092 <    struct addrinfo hints, *res;
2093 <
2094 <    memset(&hints, 0, sizeof(hints));
2095 <
2096 <    hints.ai_family   = AF_UNSPEC;
2097 <    hints.ai_socktype = SOCK_STREAM;
2098 <    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
2099 <
2100 <    if (getaddrinfo(yylval.string, NULL, &hints, &res))
2101 <      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", yylval.string);
2102 <    else
2103 <    {
2104 <      assert(res != NULL);
2105 <
2106 <      memcpy(&yy_aconf->bind, res->ai_addr, res->ai_addrlen);
2107 <      yy_aconf->bind.ss.ss_family = res->ai_family;
2108 <      yy_aconf->bind.ss_len = res->ai_addrlen;
2109 <      freeaddrinfo(res);
2110 <    }
2111 <  }
2148 >    strlcpy(block_state.bind.buf, yylval.string, sizeof(block_state.bind.buf));
2149   };
2150 <
2150 >
2151   connect_send_password: SEND_PASSWORD '=' QSTRING ';'
2152   {
2153 <  if (conf_parser_ctx.pass == 2)
2154 <  {
2118 <    if ($3[0] == ':')
2119 <      yyerror("Server passwords cannot begin with a colon");
2120 <    else if (strchr($3, ' ') != NULL)
2121 <      yyerror("Server passwords cannot contain spaces");
2122 <    else {
2123 <      if (yy_aconf->spasswd != NULL)
2124 <        memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd));
2153 >  if (conf_parser_ctx.pass != 2)
2154 >    break;
2155  
2156 <      MyFree(yy_aconf->spasswd);
2157 <      DupString(yy_aconf->spasswd, yylval.string);
2158 <    }
2159 <  }
2156 >  if ($3[0] == ':')
2157 >    conf_error_report("Server passwords cannot begin with a colon");
2158 >  else if (strchr($3, ' ') != NULL)
2159 >    conf_error_report("Server passwords cannot contain spaces");
2160 >  else
2161 >    strlcpy(block_state.spass.buf, yylval.string, sizeof(block_state.spass.buf));
2162   };
2163  
2164   connect_accept_password: ACCEPT_PASSWORD '=' QSTRING ';'
2165   {
2166 <  if (conf_parser_ctx.pass == 2)
2167 <  {
2136 <    if ($3[0] == ':')
2137 <      yyerror("Server passwords cannot begin with a colon");
2138 <    else if (strchr($3, ' ') != NULL)
2139 <      yyerror("Server passwords cannot contain spaces");
2140 <    else {
2141 <      if (yy_aconf->passwd != NULL)
2142 <        memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
2166 >  if (conf_parser_ctx.pass != 2)
2167 >    break;
2168  
2169 <      MyFree(yy_aconf->passwd);
2170 <      DupString(yy_aconf->passwd, yylval.string);
2171 <    }
2172 <  }
2169 >  if ($3[0] == ':')
2170 >    conf_error_report("Server passwords cannot begin with a colon");
2171 >  else if (strchr($3, ' ') != NULL)
2172 >    conf_error_report("Server passwords cannot contain spaces");
2173 >  else
2174 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2175 > };
2176 >
2177 > connect_ssl_certificate_fingerprint: SSL_CERTIFICATE_FINGERPRINT '=' QSTRING ';'
2178 > {
2179 >  if (conf_parser_ctx.pass == 2)
2180 >    strlcpy(block_state.cert.buf, yylval.string, sizeof(block_state.cert.buf));
2181   };
2182  
2183   connect_port: PORT '=' NUMBER ';'
2184   {
2185    if (conf_parser_ctx.pass == 2)
2186 <    yy_aconf->port = $3;
2186 >    block_state.port.value = $3;
2187   };
2188  
2189   connect_aftype: AFTYPE '=' T_IPV4 ';'
2190   {
2191    if (conf_parser_ctx.pass == 2)
2192 <    yy_aconf->aftype = AF_INET;
2192 >    block_state.aftype.value = AF_INET;
2193   } | AFTYPE '=' T_IPV6 ';'
2194   {
2195   #ifdef IPV6
2196    if (conf_parser_ctx.pass == 2)
2197 <    yy_aconf->aftype = AF_INET6;
2197 >    block_state.aftype.value = AF_INET6;
2198   #endif
2199   };
2200  
2201   connect_flags: IRCD_FLAGS
2202   {
2203 +  block_state.flags.value &= CONF_FLAGS_ENCRYPTED;
2204   } '='  connect_flags_items ';';
2205  
2206   connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;
2207   connect_flags_item: AUTOCONN
2208   {
2209    if (conf_parser_ctx.pass == 2)
2210 <    SetConfAllowAutoConn(yy_aconf);
2210 >    block_state.flags.value |= CONF_FLAGS_ALLOW_AUTO_CONN;
2211   } | T_SSL
2212   {
2213    if (conf_parser_ctx.pass == 2)
2214 <    SetConfSSL(yy_aconf);
2214 >    block_state.flags.value |= CONF_FLAGS_SSL;
2215   };
2216  
2217   connect_encrypted: ENCRYPTED '=' TBOOL ';'
# Line 2185 | Line 2219 | connect_encrypted: ENCRYPTED '=' TBOOL '
2219    if (conf_parser_ctx.pass == 2)
2220    {
2221      if (yylval.number)
2222 <      yy_aconf->flags |= CONF_FLAGS_ENCRYPTED;
2222 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
2223      else
2224 <      yy_aconf->flags &= ~CONF_FLAGS_ENCRYPTED;
2224 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
2225    }
2226   };
2227  
2228 < connect_hub_mask: HUB_MASK '=' QSTRING ';'
2228 > connect_hub_mask: HUB_MASK '=' QSTRING ';'
2229   {
2230    if (conf_parser_ctx.pass == 2)
2231 <  {
2198 <    char *mask;
2199 <
2200 <    DupString(mask, yylval.string);
2201 <    dlinkAdd(mask, make_dlink_node(), &yy_aconf->hub_list);
2202 <  }
2231 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.hub.list);
2232   };
2233  
2234 < connect_leaf_mask: LEAF_MASK '=' QSTRING ';'
2234 > connect_leaf_mask: LEAF_MASK '=' QSTRING ';'
2235   {
2236    if (conf_parser_ctx.pass == 2)
2237 <  {
2209 <    char *mask;
2210 <
2211 <    DupString(mask, yylval.string);
2212 <    dlinkAdd(mask, make_dlink_node(), &yy_aconf->leaf_list);
2213 <  }
2237 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.leaf.list);
2238   };
2239  
2240   connect_class: CLASS '=' QSTRING ';'
2241   {
2242    if (conf_parser_ctx.pass == 2)
2243 <  {
2220 <    MyFree(class_name);
2221 <    DupString(class_name, yylval.string);
2222 <  }
2243 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
2244   };
2245  
2246   connect_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
2247   {
2248   #ifdef HAVE_LIBCRYPTO
2249    if (conf_parser_ctx.pass == 2)
2250 <  {
2230 <    MyFree(yy_aconf->cipher_list);
2231 <    DupString(yy_aconf->cipher_list, yylval.string);
2232 <  }
2250 >    strlcpy(block_state.ciph.buf, yylval.string, sizeof(block_state.ciph.buf));
2251   #else
2252    if (conf_parser_ctx.pass == 2)
2253 <    yyerror("Ignoring connect::ciphers -- no OpenSSL support");
2253 >    conf_error_report("Ignoring connect::ciphers -- no OpenSSL support");
2254   #endif
2255   };
2256  
# Line 2243 | Line 2261 | connect_ssl_cipher_list: T_SSL_CIPHER_LI
2261   kill_entry: KILL
2262   {
2263    if (conf_parser_ctx.pass == 2)
2264 <  {
2247 <    userbuf[0] = hostbuf[0] = reasonbuf[0] = '\0';
2248 <    regex_ban = 0;
2249 <  }
2264 >    reset_block_state();
2265   } '{' kill_items '}' ';'
2266   {
2267 <  if (conf_parser_ctx.pass == 2)
2253 <  {
2254 <    if (userbuf[0] && hostbuf[0])
2255 <    {
2256 <      if (regex_ban)
2257 <      {
2258 < #ifdef HAVE_LIBPCRE
2259 <        void *exp_user = NULL;
2260 <        void *exp_host = NULL;
2261 <        const char *errptr = NULL;
2262 <
2263 <        if (!(exp_user = ircd_pcre_compile(userbuf, &errptr)) ||
2264 <            !(exp_host = ircd_pcre_compile(hostbuf, &errptr)))
2265 <        {
2266 <          ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: %s",
2267 <               errptr);
2268 <          break;
2269 <        }
2270 <
2271 <        yy_aconf = map_to_conf(make_conf_item(RKLINE_TYPE));
2272 <        yy_aconf->regexuser = exp_user;
2273 <        yy_aconf->regexhost = exp_host;
2274 <
2275 <        DupString(yy_aconf->user, userbuf);
2276 <        DupString(yy_aconf->host, hostbuf);
2277 <
2278 <        if (reasonbuf[0])
2279 <          DupString(yy_aconf->reason, reasonbuf);
2280 <        else
2281 <          DupString(yy_aconf->reason, "No reason");
2282 < #else
2283 <        ilog(LOG_TYPE_IRCD, "Failed to add regular expression based K-Line: no PCRE support");
2284 <        break;
2285 < #endif
2286 <      }
2287 <      else
2288 <      {
2289 <        find_and_delete_temporary(userbuf, hostbuf, CONF_KLINE);
2290 <
2291 <        yy_aconf = map_to_conf(make_conf_item(KLINE_TYPE));
2292 <
2293 <        DupString(yy_aconf->user, userbuf);
2294 <        DupString(yy_aconf->host, hostbuf);
2267 >  struct MaskItem *conf = NULL;
2268  
2269 <        if (reasonbuf[0])
2270 <          DupString(yy_aconf->reason, reasonbuf);
2298 <        else
2299 <          DupString(yy_aconf->reason, "No reason");
2300 <        add_conf_by_address(CONF_KLINE, yy_aconf);
2301 <      }
2302 <    }
2269 >  if (conf_parser_ctx.pass != 2)
2270 >    break;
2271  
2272 <    yy_aconf = NULL;
2273 <  }
2274 < };
2272 >  if (!block_state.user.buf[0] ||
2273 >      !block_state.host.buf[0])
2274 >    break;
2275  
2276 < kill_type: TYPE
2277 < {
2278 < } '='  kill_type_items ';';
2276 >  conf = conf_make(CONF_KLINE);
2277 >  conf->user = xstrdup(block_state.user.buf);
2278 >  conf->host = xstrdup(block_state.host.buf);
2279  
2280 < kill_type_items: kill_type_items ',' kill_type_item | kill_type_item;
2281 < kill_type_item: REGEX_T
2282 < {
2283 <  if (conf_parser_ctx.pass == 2)
2284 <    regex_ban = 1;
2280 >  if (block_state.rpass.buf[0])
2281 >    conf->reason = xstrdup(block_state.rpass.buf);
2282 >  else
2283 >    conf->reason = xstrdup(CONF_NOREASON);
2284 >  add_conf_by_address(CONF_KLINE, conf);
2285   };
2286  
2287   kill_items:     kill_items kill_item | kill_item;
2288 < kill_item:      kill_user | kill_reason | kill_type | error;
2288 > kill_item:      kill_user | kill_reason | error;
2289  
2290   kill_user: USER '=' QSTRING ';'
2291   {
2292 +
2293    if (conf_parser_ctx.pass == 2)
2294    {
2295      struct split_nuh_item nuh;
2296  
2297      nuh.nuhmask  = yylval.string;
2298      nuh.nickptr  = NULL;
2299 <    nuh.userptr  = userbuf;
2300 <    nuh.hostptr  = hostbuf;
2299 >    nuh.userptr  = block_state.user.buf;
2300 >    nuh.hostptr  = block_state.host.buf;
2301  
2302      nuh.nicksize = 0;
2303 <    nuh.usersize = sizeof(userbuf);
2304 <    nuh.hostsize = sizeof(hostbuf);
2303 >    nuh.usersize = sizeof(block_state.user.buf);
2304 >    nuh.hostsize = sizeof(block_state.host.buf);
2305  
2306      split_nuh(&nuh);
2307    }
2308   };
2309  
2310 < kill_reason: REASON '=' QSTRING ';'
2310 > kill_reason: REASON '=' QSTRING ';'
2311   {
2312    if (conf_parser_ctx.pass == 2)
2313 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2313 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2314   };
2315  
2316   /***************************************************************************
2317   *  section deny
2318   ***************************************************************************/
2319 < deny_entry: DENY
2319 > deny_entry: DENY
2320   {
2321    if (conf_parser_ctx.pass == 2)
2322 <    hostbuf[0] = reasonbuf[0] = '\0';
2322 >    reset_block_state();
2323   } '{' deny_items '}' ';'
2324   {
2325 <  if (conf_parser_ctx.pass == 2)
2357 <  {
2358 <    if (hostbuf[0] && parse_netmask(hostbuf, NULL, NULL) != HM_HOST)
2359 <    {
2360 <      find_and_delete_temporary(NULL, hostbuf, CONF_DLINE);
2325 >  struct MaskItem *conf = NULL;
2326  
2327 <      yy_aconf = map_to_conf(make_conf_item(DLINE_TYPE));
2328 <      DupString(yy_aconf->host, hostbuf);
2327 >  if (conf_parser_ctx.pass != 2)
2328 >    break;
2329  
2330 <      if (reasonbuf[0])
2331 <        DupString(yy_aconf->reason, reasonbuf);
2332 <      else
2333 <        DupString(yy_aconf->reason, "No reason");
2334 <      add_conf_by_address(CONF_DLINE, yy_aconf);
2335 <      yy_aconf = NULL;
2336 <    }
2330 >  if (!block_state.addr.buf[0])
2331 >    break;
2332 >
2333 >  if (parse_netmask(block_state.addr.buf, NULL, NULL) != HM_HOST)
2334 >  {
2335 >    conf = conf_make(CONF_DLINE);
2336 >    conf->host = xstrdup(block_state.addr.buf);
2337 >
2338 >    if (block_state.rpass.buf[0])
2339 >      conf->reason = xstrdup(block_state.rpass.buf);
2340 >    else
2341 >      conf->reason = xstrdup(CONF_NOREASON);
2342 >    add_conf_by_address(CONF_DLINE, conf);
2343    }
2344 < };
2344 > };
2345  
2346   deny_items:     deny_items deny_item | deny_item;
2347   deny_item:      deny_ip | deny_reason | error;
# Line 2378 | Line 2349 | deny_item:      deny_ip | deny_reason |
2349   deny_ip: IP '=' QSTRING ';'
2350   {
2351    if (conf_parser_ctx.pass == 2)
2352 <    strlcpy(hostbuf, yylval.string, sizeof(hostbuf));
2352 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
2353   };
2354  
2355 < deny_reason: REASON '=' QSTRING ';'
2355 > deny_reason: REASON '=' QSTRING ';'
2356   {
2357    if (conf_parser_ctx.pass == 2)
2358 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2358 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2359   };
2360  
2361   /***************************************************************************
# Line 2401 | Line 2372 | exempt_ip: IP '=' QSTRING ';'
2372    {
2373      if (yylval.string[0] && parse_netmask(yylval.string, NULL, NULL) != HM_HOST)
2374      {
2375 <      yy_aconf = map_to_conf(make_conf_item(EXEMPTDLINE_TYPE));
2376 <      DupString(yy_aconf->host, yylval.string);
2375 >      struct MaskItem *conf = conf_make(CONF_EXEMPT);
2376 >      conf->host = xstrdup(yylval.string);
2377  
2378 <      add_conf_by_address(CONF_EXEMPTDLINE, yy_aconf);
2408 <      yy_aconf = NULL;
2378 >      add_conf_by_address(CONF_EXEMPT, conf);
2379      }
2380    }
2381   };
# Line 2416 | Line 2386 | exempt_ip: IP '=' QSTRING ';'
2386   gecos_entry: GECOS
2387   {
2388    if (conf_parser_ctx.pass == 2)
2389 <  {
2420 <    regex_ban = 0;
2421 <    reasonbuf[0] = gecos_name[0] = '\0';
2422 <  }
2389 >    reset_block_state();
2390   } '{' gecos_items '}' ';'
2391   {
2392 <  if (conf_parser_ctx.pass == 2)
2426 <  {
2427 <    if (gecos_name[0])
2428 <    {
2429 <      if (regex_ban)
2430 <      {
2431 < #ifdef HAVE_LIBPCRE
2432 <        void *exp_p = NULL;
2433 <        const char *errptr = NULL;
2434 <
2435 <        if (!(exp_p = ircd_pcre_compile(gecos_name, &errptr)))
2436 <        {
2437 <          ilog(LOG_TYPE_IRCD, "Failed to add regular expression based X-Line: %s",
2438 <               errptr);
2439 <          break;
2440 <        }
2392 >  struct MaskItem *conf = NULL;
2393  
2394 <        yy_conf = make_conf_item(RXLINE_TYPE);
2395 <        yy_conf->regexpname = exp_p;
2444 < #else
2445 <        ilog(LOG_TYPE_IRCD, "Failed to add regular expression based X-Line: no PCRE support");
2446 <        break;
2447 < #endif
2448 <      }
2449 <      else
2450 <        yy_conf = make_conf_item(XLINE_TYPE);
2451 <
2452 <      yy_match_item = map_to_conf(yy_conf);
2453 <      DupString(yy_conf->name, gecos_name);
2394 >  if (conf_parser_ctx.pass != 2)
2395 >    break;
2396  
2397 <      if (reasonbuf[0])
2398 <        DupString(yy_match_item->reason, reasonbuf);
2457 <      else
2458 <        DupString(yy_match_item->reason, "No reason");
2459 <    }
2460 <  }
2461 < };
2397 >  if (!block_state.name.buf[0])
2398 >    break;
2399  
2400 < gecos_flags: TYPE
2401 < {
2465 < } '='  gecos_flags_items ';';
2400 >  conf = conf_make(CONF_XLINE);
2401 >  conf->name = xstrdup(block_state.name.buf);
2402  
2403 < gecos_flags_items: gecos_flags_items ',' gecos_flags_item | gecos_flags_item;
2404 < gecos_flags_item: REGEX_T
2405 < {
2406 <  if (conf_parser_ctx.pass == 2)
2471 <    regex_ban = 1;
2403 >  if (block_state.rpass.buf[0])
2404 >    conf->reason = xstrdup(block_state.rpass.buf);
2405 >  else
2406 >    conf->reason = xstrdup(CONF_NOREASON);
2407   };
2408  
2409   gecos_items: gecos_items gecos_item | gecos_item;
2410 < gecos_item:  gecos_name | gecos_reason | gecos_flags | error;
2410 > gecos_item:  gecos_name | gecos_reason | error;
2411  
2412 < gecos_name: NAME '=' QSTRING ';'
2412 > gecos_name: NAME '=' QSTRING ';'
2413   {
2414    if (conf_parser_ctx.pass == 2)
2415 <    strlcpy(gecos_name, yylval.string, sizeof(gecos_name));
2415 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
2416   };
2417  
2418 < gecos_reason: REASON '=' QSTRING ';'
2418 > gecos_reason: REASON '=' QSTRING ';'
2419   {
2420    if (conf_parser_ctx.pass == 2)
2421 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2421 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2422   };
2423  
2424   /***************************************************************************
# Line 2498 | Line 2433 | general_item:       general_hide_spoof_i
2433                      general_max_nick_time | general_max_nick_changes |
2434                      general_max_accept | general_anti_spam_exit_message_time |
2435                      general_ts_warn_delta | general_ts_max_delta |
2436 <                    general_kill_chase_time_limit | general_kline_with_reason |
2437 <                    general_kline_reason | general_invisible_on_connect |
2436 >                    general_kill_chase_time_limit |
2437 >                    general_invisible_on_connect |
2438                      general_warn_no_nline | general_dots_in_ident |
2439                      general_stats_o_oper_only | general_stats_k_oper_only |
2440                      general_pace_wait | general_stats_i_oper_only |
2441                      general_pace_wait_simple | general_stats_P_oper_only |
2442 +                    general_stats_u_oper_only |
2443                      general_short_motd | general_no_oper_flood |
2444                      general_true_no_oper_flood | general_oper_pass_resv |
2509                    general_message_locale |
2445                      general_oper_only_umodes | general_max_targets |
2446                      general_use_egd | general_egdpool_path |
2447                      general_oper_umodes | general_caller_id_wait |
2448                      general_opers_bypass_callerid | general_default_floodcount |
2449                      general_min_nonwildcard | general_min_nonwildcard_simple |
2515                    general_disable_remote_commands |
2450                      general_throttle_time | general_havent_read_conf |
2451                      general_ping_cookie |
2452 <                    general_disable_auth |
2452 >                    general_disable_auth |
2453                      general_tkline_expire_notices | general_gline_enable |
2454                      general_gline_duration | general_gline_request_duration |
2455                      general_gline_min_cidr |
2456                      general_gline_min_cidr6 |
2457 <                    general_reject_hold_time | general_stats_e_disabled |
2457 >                    general_stats_e_disabled |
2458                      general_max_watch | general_services_name |
2459 +                    general_cycle_on_host_change |
2460                      error;
2461  
2462  
# Line 2530 | Line 2465 | general_max_watch: MAX_WATCH '=' NUMBER
2465    ConfigFileEntry.max_watch = $3;
2466   };
2467  
2468 + general_cycle_on_host_change: CYCLE_ON_HOST_CHANGE '=' TBOOL ';'
2469 + {
2470 +  if (conf_parser_ctx.pass == 2)
2471 +    ConfigFileEntry.cycle_on_host_change = yylval.number;
2472 + };
2473 +
2474   general_gline_enable: GLINE_ENABLE '=' TBOOL ';'
2475   {
2476    if (conf_parser_ctx.pass == 2)
# Line 2558 | Line 2499 | general_gline_min_cidr6: GLINE_MIN_CIDR6
2499    ConfigFileEntry.gline_min_cidr6 = $3;
2500   };
2501  
2561 general_reject_hold_time: TREJECT_HOLD_TIME '=' timespec ';'
2562 {
2563  GlobalSetOptions.rejecttime = yylval.number;
2564 };
2565
2502   general_tkline_expire_notices: TKLINE_EXPIRE_NOTICES '=' TBOOL ';'
2503   {
2504    ConfigFileEntry.tkline_expire_notices = yylval.number;
# Line 2583 | Line 2519 | general_ignore_bogus_ts: IGNORE_BOGUS_TS
2519    ConfigFileEntry.ignore_bogus_ts = yylval.number;
2520   };
2521  
2586 general_disable_remote_commands: DISABLE_REMOTE_COMMANDS '=' TBOOL ';'
2587 {
2588  ConfigFileEntry.disable_remote = yylval.number;
2589 };
2590
2522   general_failed_oper_notice: FAILED_OPER_NOTICE '=' TBOOL ';'
2523   {
2524    ConfigFileEntry.failed_oper_notice = yylval.number;
# Line 2600 | Line 2531 | general_anti_nick_flood: ANTI_NICK_FLOOD
2531  
2532   general_max_nick_time: MAX_NICK_TIME '=' timespec ';'
2533   {
2534 <  ConfigFileEntry.max_nick_time = $3;
2534 >  ConfigFileEntry.max_nick_time = $3;
2535   };
2536  
2537   general_max_nick_changes: MAX_NICK_CHANGES '=' NUMBER ';'
# Line 2640 | Line 2571 | general_havent_read_conf: HAVENT_READ_CO
2571    }
2572   };
2573  
2643 general_kline_with_reason: KLINE_WITH_REASON '=' TBOOL ';'
2644 {
2645  ConfigFileEntry.kline_with_reason = yylval.number;
2646 };
2647
2648 general_kline_reason: KLINE_REASON '=' QSTRING ';'
2649 {
2650  if (conf_parser_ctx.pass == 2)
2651  {
2652    MyFree(ConfigFileEntry.kline_reason);
2653    DupString(ConfigFileEntry.kline_reason, yylval.string);
2654  }
2655 };
2656
2574   general_invisible_on_connect: INVISIBLE_ON_CONNECT '=' TBOOL ';'
2575   {
2576    ConfigFileEntry.invisible_on_connect = yylval.number;
# Line 2679 | Line 2596 | general_stats_P_oper_only: STATS_P_OPER_
2596    ConfigFileEntry.stats_P_oper_only = yylval.number;
2597   };
2598  
2599 + general_stats_u_oper_only: STATS_U_OPER_ONLY '=' TBOOL ';'
2600 + {
2601 +  ConfigFileEntry.stats_u_oper_only = yylval.number;
2602 + };
2603 +
2604   general_stats_k_oper_only: STATS_K_OPER_ONLY '=' TBOOL ';'
2605   {
2606    ConfigFileEntry.stats_k_oper_only = 2 * yylval.number;
# Line 2719 | Line 2641 | general_short_motd: SHORT_MOTD '=' TBOOL
2641   {
2642    ConfigFileEntry.short_motd = yylval.number;
2643   };
2644 <  
2644 >
2645   general_no_oper_flood: NO_OPER_FLOOD '=' TBOOL ';'
2646   {
2647    ConfigFileEntry.no_oper_flood = yylval.number;
# Line 2735 | Line 2657 | general_oper_pass_resv: OPER_PASS_RESV '
2657    ConfigFileEntry.oper_pass_resv = yylval.number;
2658   };
2659  
2738 general_message_locale: MESSAGE_LOCALE '=' QSTRING ';'
2739 {
2740  if (conf_parser_ctx.pass == 2)
2741  {
2742    if (strlen(yylval.string) > LOCALE_LENGTH-2)
2743      yylval.string[LOCALE_LENGTH-1] = '\0';
2744
2745    set_locale(yylval.string);
2746  }
2747 };
2748
2660   general_dots_in_ident: DOTS_IN_IDENT '=' NUMBER ';'
2661   {
2662    ConfigFileEntry.dots_in_ident = $3;
# Line 2766 | Line 2677 | general_egdpool_path: EGDPOOL_PATH '=' Q
2677    if (conf_parser_ctx.pass == 2)
2678    {
2679      MyFree(ConfigFileEntry.egdpool_path);
2680 <    DupString(ConfigFileEntry.egdpool_path, yylval.string);
2680 >    ConfigFileEntry.egdpool_path = xstrdup(yylval.string);
2681    }
2682   };
2683  
# Line 2775 | Line 2686 | general_services_name: T_SERVICES_NAME '
2686    if (conf_parser_ctx.pass == 2 && valid_servname(yylval.string))
2687    {
2688      MyFree(ConfigFileEntry.service_name);
2689 <    DupString(ConfigFileEntry.service_name, yylval.string);
2689 >    ConfigFileEntry.service_name = xstrdup(yylval.string);
2690    }
2691   };
2692  
# Line 2791 | Line 2702 | general_disable_auth: DISABLE_AUTH '=' T
2702  
2703   general_throttle_time: THROTTLE_TIME '=' timespec ';'
2704   {
2705 <  ConfigFileEntry.throttle_time = yylval.number;
2705 >  ConfigFileEntry.throttle_time = $3;
2706   };
2707  
2708   general_oper_umodes: OPER_UMODES
# Line 2806 | Line 2717 | umode_oitem:     T_BOTS
2717   } | T_CCONN
2718   {
2719    ConfigFileEntry.oper_umodes |= UMODE_CCONN;
2809 } | T_CCONN_FULL
2810 {
2811  ConfigFileEntry.oper_umodes |= UMODE_CCONN_FULL;
2720   } | T_DEAF
2721   {
2722    ConfigFileEntry.oper_umodes |= UMODE_DEAF;
# Line 2860 | Line 2768 | umode_oitem:     T_BOTS
2768   } | T_LOCOPS
2769   {
2770    ConfigFileEntry.oper_umodes |= UMODE_LOCOPS;
2771 + } | T_NONONREG
2772 + {
2773 +  ConfigFileEntry.oper_umodes |= UMODE_REGONLY;
2774 + } | T_FARCONNECT
2775 + {
2776 +  ConfigFileEntry.oper_umodes |= UMODE_FARCONNECT;
2777   };
2778  
2779 < general_oper_only_umodes: OPER_ONLY_UMODES
2779 > general_oper_only_umodes: OPER_ONLY_UMODES
2780   {
2781    ConfigFileEntry.oper_only_umodes = 0;
2782   } '='  umode_items ';' ;
2783  
2784   umode_items:    umode_items ',' umode_item | umode_item;
2785 < umode_item:     T_BOTS
2785 > umode_item:     T_BOTS
2786   {
2787    ConfigFileEntry.oper_only_umodes |= UMODE_BOTS;
2788   } | T_CCONN
2789   {
2790    ConfigFileEntry.oper_only_umodes |= UMODE_CCONN;
2877 } | T_CCONN_FULL
2878 {
2879  ConfigFileEntry.oper_only_umodes |= UMODE_CCONN_FULL;
2791   } | T_DEAF
2792   {
2793    ConfigFileEntry.oper_only_umodes |= UMODE_DEAF;
# Line 2884 | Line 2795 | umode_item:    T_BOTS
2795   {
2796    ConfigFileEntry.oper_only_umodes |= UMODE_DEBUG;
2797   } | T_FULL
2798 < {
2798 > {
2799    ConfigFileEntry.oper_only_umodes |= UMODE_FULL;
2800   } | T_SKILL
2801   {
# Line 2928 | Line 2839 | umode_item:    T_BOTS
2839   } | T_LOCOPS
2840   {
2841    ConfigFileEntry.oper_only_umodes |= UMODE_LOCOPS;
2842 + } | T_NONONREG
2843 + {
2844 +  ConfigFileEntry.oper_only_umodes |= UMODE_REGONLY;
2845 + } | T_FARCONNECT
2846 + {
2847 +  ConfigFileEntry.oper_only_umodes |= UMODE_FARCONNECT;
2848   };
2849  
2850   general_min_nonwildcard: MIN_NONWILDCARD '=' NUMBER ';'
# Line 2956 | Line 2873 | channel_items:      channel_items channe
2873   channel_item:       channel_max_bans |
2874                      channel_knock_delay | channel_knock_delay_channel |
2875                      channel_max_chans_per_user | channel_max_chans_per_oper |
2876 <                    channel_quiet_on_ban | channel_default_split_user_count |
2876 >                    channel_default_split_user_count |
2877                      channel_default_split_server_count |
2878 <                    channel_no_create_on_split | channel_restrict_channels |
2878 >                    channel_no_create_on_split |
2879                      channel_no_join_on_split |
2880                      channel_jflood_count | channel_jflood_time |
2881                      channel_disable_fake_channels | error;
# Line 2968 | Line 2885 | channel_disable_fake_channels: DISABLE_F
2885    ConfigChannel.disable_fake_channels = yylval.number;
2886   };
2887  
2971 channel_restrict_channels: RESTRICT_CHANNELS '=' TBOOL ';'
2972 {
2973  ConfigChannel.restrict_channels = yylval.number;
2974 };
2975
2888   channel_knock_delay: KNOCK_DELAY '=' timespec ';'
2889   {
2890    ConfigChannel.knock_delay = $3;
# Line 2993 | Line 2905 | channel_max_chans_per_oper: MAX_CHANS_PE
2905    ConfigChannel.max_chans_per_oper = $3;
2906   };
2907  
2996 channel_quiet_on_ban: QUIET_ON_BAN '=' TBOOL ';'
2997 {
2998  ConfigChannel.quiet_on_ban = yylval.number;
2999 };
3000
2908   channel_max_bans: MAX_BANS '=' NUMBER ';'
2909   {
2910    ConfigChannel.max_bans = $3;
# Line 3030 | Line 2937 | channel_jflood_count: JOIN_FLOOD_COUNT '
2937  
2938   channel_jflood_time: JOIN_FLOOD_TIME '=' timespec ';'
2939   {
2940 <  GlobalSetOptions.joinfloodtime = yylval.number;
2940 >  GlobalSetOptions.joinfloodtime = $3;
2941   };
2942  
2943   /***************************************************************************
# Line 3040 | Line 2947 | serverhide_entry: SERVERHIDE
2947    '{' serverhide_items '}' ';';
2948  
2949   serverhide_items:   serverhide_items serverhide_item | serverhide_item;
2950 < serverhide_item:    serverhide_flatten_links | serverhide_hide_servers |
2950 > serverhide_item:    serverhide_flatten_links | serverhide_disable_remote_commands |
2951 >                    serverhide_hide_servers |
2952 >                    serverhide_hide_services |
2953                      serverhide_links_delay |
2954                      serverhide_hidden | serverhide_hidden_name |
2955                      serverhide_hide_server_ips |
# Line 3052 | Line 2961 | serverhide_flatten_links: FLATTEN_LINKS
2961      ConfigServerHide.flatten_links = yylval.number;
2962   };
2963  
2964 + serverhide_disable_remote_commands: DISABLE_REMOTE_COMMANDS '=' TBOOL ';'
2965 + {
2966 +  if (conf_parser_ctx.pass == 2)
2967 +    ConfigServerHide.disable_remote_commands = yylval.number;
2968 + };
2969 +
2970   serverhide_hide_servers: HIDE_SERVERS '=' TBOOL ';'
2971   {
2972    if (conf_parser_ctx.pass == 2)
2973      ConfigServerHide.hide_servers = yylval.number;
2974   };
2975  
2976 + serverhide_hide_services: HIDE_SERVICES '=' TBOOL ';'
2977 + {
2978 +  if (conf_parser_ctx.pass == 2)
2979 +    ConfigServerHide.hide_services = yylval.number;
2980 + };
2981 +
2982   serverhide_hidden_name: HIDDEN_NAME '=' QSTRING ';'
2983   {
2984    if (conf_parser_ctx.pass == 2)
2985    {
2986      MyFree(ConfigServerHide.hidden_name);
2987 <    DupString(ConfigServerHide.hidden_name, yylval.string);
2987 >    ConfigServerHide.hidden_name = xstrdup(yylval.string);
2988    }
2989   };
2990  

Diff Legend

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