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

Comparing:
ircd-hybrid-7.2/src/ircd_parser.y (file contents), Revision 136 by db, Sat Oct 15 23:39:54 2005 UTC vs.
ircd-hybrid/branches/8.0.x/src/conf_parser.y (file contents), Revision 1871 by michael, Fri Apr 26 08:53:04 2013 UTC

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

Diff Legend

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