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

Comparing:
ircd-hybrid-7.2/src/ircd_parser.y (file contents), Revision 967 by michael, Sun Aug 2 18:05:28 2009 UTC vs.
ircd-hybrid/trunk/src/conf_parser.y (file contents), Revision 2185 by michael, Tue Jun 4 12:29:18 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 28 | Line 28
28   #include <sys/types.h>
29   #include <string.h>
30  
31 + #include "config.h"
32   #include "stdinc.h"
33   #include "ircd.h"
33 #include "tools.h"
34   #include "list.h"
35 < #include "s_conf.h"
35 > #include "conf.h"
36 > #include "conf_class.h"
37   #include "event.h"
38 < #include "s_log.h"
38 > #include "log.h"
39   #include "client.h"     /* for UMODE_ALL only */
39 #include "pcre.h"
40   #include "irc_string.h"
41 #include "irc_getaddrinfo.h"
42 #include "sprintf_irc.h"
41   #include "memory.h"
42   #include "modules.h"
43   #include "s_serv.h"
# Line 49 | Line 47
47   #include "resv.h"
48   #include "numeric.h"
49   #include "s_user.h"
50 + #include "motd.h"
51  
52   #ifdef HAVE_LIBCRYPTO
53   #include <openssl/rsa.h>
54   #include <openssl/bio.h>
55   #include <openssl/pem.h>
56 + #include <openssl/dh.h>
57   #endif
58  
59 < static char *class_name = NULL;
60 < static struct ConfItem *yy_conf = NULL;
61 < static struct AccessItem *yy_aconf = NULL;
62 < static struct MatchItem *yy_match_item = NULL;
63 < static struct ClassItem *yy_class = NULL;
64 < static char *yy_class_name = NULL;
65 <
66 < static dlink_list col_conf_list  = { NULL, NULL, 0 };
67 < static dlink_list hub_conf_list  = { NULL, NULL, 0 };
68 < static dlink_list leaf_conf_list = { NULL, NULL, 0 };
69 < static unsigned int listener_flags = 0;
70 < static unsigned int regex_ban = 0;
71 < static char userbuf[IRCD_BUFSIZE];
72 < static char hostbuf[IRCD_BUFSIZE];
73 < static char reasonbuf[REASONLEN + 1];
74 < static char gecos_name[REALLEN * 4];
75 <
76 < extern dlink_list gdeny_items; /* XXX */
77 <
78 < static char *resv_reason = NULL;
79 < static char *listener_address = NULL;
80 < static int not_atom = 0;
81 <
82 < struct CollectItem
83 < {
84 <  dlink_node node;
85 <  char *name;
86 <  char *user;
87 <  char *host;
88 <  char *passwd;
89 <  int  port;
90 <  int  flags;
91 < #ifdef HAVE_LIBCRYPTO
92 <  char *rsa_public_key_file;
93 <  RSA *rsa_public_key;
94 < #endif
95 < };
59 > #include "rsa.h"
60  
61 < static void
62 < free_collect_item(struct CollectItem *item)
61 > int yylex(void);
62 >
63 > static struct
64   {
65 <  MyFree(item->name);
66 <  MyFree(item->user);
67 <  MyFree(item->host);
68 <  MyFree(item->passwd);
69 < #ifdef HAVE_LIBCRYPTO
70 <  MyFree(item->rsa_public_key_file);
71 < #endif
72 <  MyFree(item);
73 < }
65 >  struct {
66 >    dlink_list list;
67 >  } mask,
68 >    leaf,
69 >    hub;
70 >
71 >  struct {
72 >    char buf[IRCD_BUFSIZE];
73 >  } name,
74 >    user,
75 >    host,
76 >    addr,
77 >    bind,
78 >    file,
79 >    ciph,
80 >    rpass,
81 >    spass,
82 >    class;
83 >
84 >  struct {
85 >    unsigned int value;
86 >  } flags,
87 >    modes,
88 >    size,
89 >    type,
90 >    port,
91 >    aftype,
92 >    ping_freq,
93 >    max_perip,
94 >    con_freq,
95 >    min_idle,
96 >    max_idle,
97 >    max_total,
98 >    max_global,
99 >    max_local,
100 >    max_ident,
101 >    max_sendq,
102 >    max_recvq,
103 >    cidr_bitlen_ipv4,
104 >    cidr_bitlen_ipv6,
105 >    number_per_cidr;
106 > } block_state;
107  
108   static void
109 < unhook_hub_leaf_confs(void)
109 > reset_block_state(void)
110   {
111 <  dlink_node *ptr;
112 <  dlink_node *next_ptr;
113 <  struct CollectItem *yy_hconf;
114 <  struct CollectItem *yy_lconf;
111 >  dlink_node *ptr = NULL, *ptr_next = NULL;
112 >
113 >  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.mask.list.head)
114 >  {
115 >    MyFree(ptr->data);
116 >    dlinkDelete(ptr, &block_state.mask.list);
117 >    free_dlink_node(ptr);
118 >  }
119  
120 <  DLINK_FOREACH_SAFE(ptr, next_ptr, hub_conf_list.head)
120 >  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.leaf.list.head)
121    {
122 <    yy_hconf = ptr->data;
123 <    dlinkDelete(&yy_hconf->node, &hub_conf_list);
124 <    free_collect_item(yy_hconf);
122 >    MyFree(ptr->data);
123 >    dlinkDelete(ptr, &block_state.leaf.list);
124 >    free_dlink_node(ptr);
125    }
126  
127 <  DLINK_FOREACH_SAFE(ptr, next_ptr, leaf_conf_list.head)
127 >  DLINK_FOREACH_SAFE(ptr, ptr_next, block_state.hub.list.head)
128    {
129 <    yy_lconf = ptr->data;
130 <    dlinkDelete(&yy_lconf->node, &leaf_conf_list);
131 <    free_collect_item(yy_lconf);
129 >    MyFree(ptr->data);
130 >    dlinkDelete(ptr, &block_state.hub.list);
131 >    free_dlink_node(ptr);
132    }
133 +
134 +  memset(&block_state, 0, sizeof(block_state));
135   }
136  
137   %}
# Line 138 | Line 142 | unhook_hub_leaf_confs(void)
142   }
143  
144   %token  ACCEPT_PASSWORD
141 %token  ACTION
145   %token  ADMIN
146   %token  AFTYPE
144 %token  T_ALLOW
147   %token  ANTI_NICK_FLOOD
148   %token  ANTI_SPAM_EXIT_MESSAGE_TIME
149   %token  AUTOCONN
150 < %token  T_BLOCK
149 < %token  BURST_AWAY
150 < %token  BURST_TOPICWHO
151 < %token  BYTES KBYTES MBYTES GBYTES TBYTES
150 > %token  BYTES KBYTES MBYTES
151   %token  CALLER_ID_WAIT
152   %token  CAN_FLOOD
154 %token  CAN_IDLE
153   %token  CHANNEL
154 < %token  CIDR_BITLEN_IPV4
155 < %token  CIDR_BITLEN_IPV6
158 < %token  CIPHER_PREFERENCE
154 > %token  CIDR_BITLEN_IPV4
155 > %token  CIDR_BITLEN_IPV6
156   %token  CLASS
160 %token  COMPRESSED
161 %token  COMPRESSION_LEVEL
157   %token  CONNECT
158   %token  CONNECTFREQ
164 %token  CRYPTLINK
165 %token  DEFAULT_CIPHER_PREFERENCE
159   %token  DEFAULT_FLOODCOUNT
160   %token  DEFAULT_SPLIT_SERVER_COUNT
161   %token  DEFAULT_SPLIT_USER_COUNT
# Line 171 | Line 164 | unhook_hub_leaf_confs(void)
164   %token  DIE
165   %token  DISABLE_AUTH
166   %token  DISABLE_FAKE_CHANNELS
174 %token  DISABLE_HIDDEN
175 %token  DISABLE_LOCAL_CHANNELS
167   %token  DISABLE_REMOTE_COMMANDS
177 %token  DOT_IN_IP6_ADDR
168   %token  DOTS_IN_IDENT
179 %token  DURATION
169   %token  EGDPOOL_PATH
170   %token  EMAIL
182 %token  ENABLE
171   %token  ENCRYPTED
172   %token  EXCEED_LIMIT
173   %token  EXEMPT
174   %token  FAILED_OPER_NOTICE
187 %token  FAKENAME
188 %token  IRCD_FLAGS
175   %token  FLATTEN_LINKS
190 %token  FFAILED_OPERLOG
191 %token  FKILLLOG
192 %token  FKLINELOG
193 %token  FGLINELOG
194 %token  FIOERRLOG
195 %token  FOPERLOG
196 %token  FOPERSPYLOG
197 %token  FUSERLOG
176   %token  GECOS
177   %token  GENERAL
178   %token  GLINE
179 < %token  GLINES
179 > %token  GLINE_DURATION
180 > %token  GLINE_ENABLE
181   %token  GLINE_EXEMPT
203 %token  GLINE_LOG
204 %token  GLINE_TIME
182   %token  GLINE_MIN_CIDR
183   %token  GLINE_MIN_CIDR6
184 + %token  GLINE_REQUEST_DURATION
185   %token  GLOBAL_KILL
208 %token  IRCD_AUTH
209 %token  NEED_IDENT
186   %token  HAVENT_READ_CONF
187   %token  HIDDEN
188 < %token  HIDDEN_ADMIN
189 < %token  HIDDEN_NAME
214 < %token  HIDDEN_OPER
188 > %token  HIDDEN_NAME
189 > %token  HIDE_IDLE_FROM_OPERS
190   %token  HIDE_SERVER_IPS
191   %token  HIDE_SERVERS
192 < %token  HIDE_SPOOF_IPS
192 > %token  HIDE_SERVICES
193 > %token  HIDE_SPOOF_IPS
194   %token  HOST
195   %token  HUB
196   %token  HUB_MASK
221 %token  IDLETIME
197   %token  IGNORE_BOGUS_TS
198   %token  INVISIBLE_ON_CONNECT
199   %token  IP
200 + %token  IRCD_AUTH
201 + %token  IRCD_FLAGS
202 + %token  IRCD_SID
203 + %token  JOIN_FLOOD_COUNT
204 + %token  JOIN_FLOOD_TIME
205   %token  KILL
206 < %token  KILL_CHASE_TIME_LIMIT
206 > %token  KILL_CHASE_TIME_LIMIT
207   %token  KLINE
208   %token  KLINE_EXEMPT
229 %token  KLINE_REASON
230 %token  KLINE_WITH_REASON
209   %token  KNOCK_DELAY
210   %token  KNOCK_DELAY_CHANNEL
211   %token  LEAF_MASK
212   %token  LINKS_DELAY
213   %token  LISTEN
214 < %token  T_LOG
237 < %token  LOGGING
238 < %token  LOG_LEVEL
214 > %token  MASK
215   %token  MAX_ACCEPT
216   %token  MAX_BANS
217 + %token  MAX_CHANS_PER_OPER
218   %token  MAX_CHANS_PER_USER
219   %token  MAX_GLOBAL
220   %token  MAX_IDENT
221 + %token  MAX_IDLE
222   %token  MAX_LOCAL
223   %token  MAX_NICK_CHANGES
224 + %token  MAX_NICK_LENGTH
225   %token  MAX_NICK_TIME
226   %token  MAX_NUMBER
227   %token  MAX_TARGETS
228 + %token  MAX_TOPIC_LENGTH
229   %token  MAX_WATCH
230 < %token  MESSAGE_LOCALE
230 > %token  MIN_IDLE
231   %token  MIN_NONWILDCARD
232   %token  MIN_NONWILDCARD_SIMPLE
233   %token  MODULE
234   %token  MODULES
235 + %token  MOTD
236   %token  NAME
237 + %token  NEED_IDENT
238   %token  NEED_PASSWORD
239   %token  NETWORK_DESC
240   %token  NETWORK_NAME
241   %token  NICK
260 %token  NICK_CHANGES
242   %token  NO_CREATE_ON_SPLIT
243   %token  NO_JOIN_ON_SPLIT
244   %token  NO_OPER_FLOOD
245   %token  NO_TILDE
265 %token  NOT
246   %token  NUMBER
267 %token  NUMBER_PER_IDENT
247   %token  NUMBER_PER_CIDR
248   %token  NUMBER_PER_IP
270 %token  NUMBER_PER_IP_GLOBAL
271 %token  OPERATOR
272 %token  OPERS_BYPASS_CALLERID
273 %token  OPER_LOG
249   %token  OPER_ONLY_UMODES
250   %token  OPER_PASS_RESV
276 %token  OPER_SPY_T
251   %token  OPER_UMODES
252 < %token  JOIN_FLOOD_COUNT
253 < %token  JOIN_FLOOD_TIME
252 > %token  OPERATOR
253 > %token  OPERS_BYPASS_CALLERID
254   %token  PACE_WAIT
255   %token  PACE_WAIT_SIMPLE
256   %token  PASSWORD
257   %token  PATH
258   %token  PING_COOKIE
259   %token  PING_TIME
286 %token  PING_WARNING
260   %token  PORT
261   %token  QSTRING
262 < %token  QUIET_ON_BAN
262 > %token  RANDOM_IDLE
263   %token  REASON
264   %token  REDIRPORT
265   %token  REDIRSERV
293 %token  REGEX_T
266   %token  REHASH
295 %token  TREJECT_HOLD_TIME
267   %token  REMOTE
268   %token  REMOTEBAN
298 %token  RESTRICT_CHANNELS
299 %token  RESTRICTED
300 %token  RSA_PRIVATE_KEY_FILE
301 %token  RSA_PUBLIC_KEY_FILE
302 %token  SSL_CERTIFICATE_FILE
303 %token  T_SSL_CONNECTION_METHOD
304 %token  T_SSLV3
305 %token  T_TLSV1
269   %token  RESV
270   %token  RESV_EXEMPT
271 < %token  SECONDS MINUTES HOURS DAYS WEEKS
272 < %token  SENDQ
271 > %token  RSA_PRIVATE_KEY_FILE
272 > %token  RSA_PUBLIC_KEY_FILE
273 > %token  SECONDS MINUTES HOURS DAYS WEEKS MONTHS YEARS
274   %token  SEND_PASSWORD
275 + %token  SENDQ
276   %token  SERVERHIDE
277   %token  SERVERINFO
313 %token  SERVLINK_PATH
314 %token  IRCD_SID
315 %token  TKLINE_EXPIRE_NOTICES
316 %token  T_SHARED
317 %token  T_CLUSTER
318 %token  TYPE
278   %token  SHORT_MOTD
320 %token  SILENT
279   %token  SPOOF
280   %token  SPOOF_NOTICE
281 + %token  SQUIT
282 + %token  SSL_CERTIFICATE_FILE
283 + %token  SSL_DH_PARAM_FILE
284   %token  STATS_E_DISABLED
285   %token  STATS_I_OPER_ONLY
286   %token  STATS_K_OPER_ONLY
287   %token  STATS_O_OPER_ONLY
288   %token  STATS_P_OPER_ONLY
328 %token  TBOOL
329 %token  TMASKED
330 %token  T_REJECT
331 %token  TS_MAX_DELTA
332 %token  TS_WARN_DELTA
333 %token  TWODOTS
289   %token  T_ALL
290   %token  T_BOTS
336 %token  T_SOFTCALLERID
291   %token  T_CALLERID
292   %token  T_CCONN
293 < %token  T_CCONN_FULL
340 < %token  T_CLIENT_FLOOD
293 > %token  T_CLUSTER
294   %token  T_DEAF
295   %token  T_DEBUG
296 < %token  T_DRONE
296 > %token  T_DLINE
297   %token  T_EXTERNAL
298 + %token  T_FARCONNECT
299 + %token  T_FILE
300   %token  T_FULL
301 + %token  T_GLOBOPS
302   %token  T_INVISIBLE
303   %token  T_IPV4
304   %token  T_IPV6
305   %token  T_LOCOPS
306 < %token  T_LOGPATH
351 < %token  T_L_CRIT
352 < %token  T_L_DEBUG
353 < %token  T_L_ERROR
354 < %token  T_L_INFO
355 < %token  T_L_NOTICE
356 < %token  T_L_TRACE
357 < %token  T_L_WARN
306 > %token  T_LOG
307   %token  T_MAX_CLIENTS
308   %token  T_NCHANGE
309 + %token  T_NONONREG
310   %token  T_OPERWALL
311 + %token  T_RECVQ
312   %token  T_REJ
313 + %token  T_RESTART
314   %token  T_SERVER
315 + %token  T_SERVICE
316 + %token  T_SERVICES_NAME
317   %token  T_SERVNOTICE
318 + %token  T_SET
319 + %token  T_SHARED
320 + %token  T_SIZE
321   %token  T_SKILL
322 + %token  T_SOFTCALLERID
323   %token  T_SPY
324   %token  T_SSL
325 + %token  T_SSL_CIPHER_LIST
326 + %token  T_SSL_CLIENT_METHOD
327 + %token  T_SSL_SERVER_METHOD
328 + %token  T_SSLV3
329 + %token  T_TLSV1
330   %token  T_UMODES
331   %token  T_UNAUTH
332 + %token  T_UNDLINE
333 + %token  T_UNLIMITED
334   %token  T_UNRESV
335   %token  T_UNXLINE
336   %token  T_WALLOP
337 + %token  T_WALLOPS
338 + %token  T_WEBIRC
339 + %token  TBOOL
340   %token  THROTTLE_TIME
341 < %token  TOPICBURST
341 > %token  TKLINE_EXPIRE_NOTICES
342 > %token  TMASKED
343   %token  TRUE_NO_OPER_FLOOD
344 < %token  TKLINE
345 < %token  TXLINE
346 < %token  TRESV
344 > %token  TS_MAX_DELTA
345 > %token  TS_WARN_DELTA
346 > %token  TWODOTS
347 > %token  TYPE
348   %token  UNKLINE
379 %token  USER
349   %token  USE_EGD
381 %token  USE_EXCEPT
382 %token  USE_INVEX
383 %token  USE_KNOCK
350   %token  USE_LOGGING
351 < %token  USE_WHOIS_ACTUALLY
351 > %token  USER
352   %token  VHOST
353   %token  VHOST6
388 %token  XLINE
389 %token  WARN
354   %token  WARN_NO_NLINE
355 + %token  XLINE
356  
357 < %type <string> QSTRING
358 < %type <number> NUMBER
359 < %type <number> timespec
360 < %type <number> timespec_
361 < %type <number> sizespec
362 < %type <number> sizespec_
357 > %type  <string> QSTRING
358 > %type  <number> NUMBER
359 > %type  <number> timespec
360 > %type  <number> timespec_
361 > %type  <number> sizespec
362 > %type  <number> sizespec_
363  
364   %%
365   conf:  
# Line 411 | Line 376 | conf_item:        admin_entry
376                  | serverinfo_entry
377                  | serverhide_entry
378                  | resv_entry
379 +                | service_entry
380                  | shared_entry
381                  | cluster_entry
382                  | connect_entry
# Line 418 | Line 384 | conf_item:        admin_entry
384                  | deny_entry
385                  | exempt_entry
386                  | general_entry
421                | gline_entry
387                  | gecos_entry
388                  | modules_entry
389 +                | motd_entry
390                  | error ';'
391                  | error '}'
392          ;
# Line 451 | Line 417 | timespec:      NUMBER timespec_
417                  {
418                          $$ = $1 * 60 * 60 * 24 * 7 + $3;
419                  }
420 +                | NUMBER MONTHS timespec_
421 +                {
422 +                        $$ = $1 * 60 * 60 * 24 * 7 * 4 + $3;
423 +                }
424 +                | NUMBER YEARS timespec_
425 +                {
426 +                        $$ = $1 * 60 * 60 * 24 * 365 + $3;
427 +                }
428                  ;
429  
430   sizespec_:      { $$ = 0; } | sizespec;
# Line 472 | Line 446 | modules_item:   modules_module | modules
446  
447   modules_module: MODULE '=' QSTRING ';'
448   {
475 #ifndef STATIC_MODULES /* NOOP in the static case */
449    if (conf_parser_ctx.pass == 2)
450 <  {
478 <    char *m_bn;
479 <
480 <    m_bn = basename(yylval.string);
481 <
482 <    /* I suppose we should just ignore it if it is already loaded(since
483 <     * otherwise we would flood the opers on rehash) -A1kmm.
484 <     */
485 <    add_conf_module(yylval.string);
486 <  }
487 < #endif
450 >    add_conf_module(libio_basename(yylval.string));
451   };
452  
453   modules_path: PATH '=' QSTRING ';'
454   {
492 #ifndef STATIC_MODULES
455    if (conf_parser_ctx.pass == 2)
456      mod_add_path(yylval.string);
495 #endif
457   };
458  
459  
# Line 502 | Line 463 | serverinfo_items:       serverinfo_items
463   serverinfo_item:        serverinfo_name | serverinfo_vhost |
464                          serverinfo_hub | serverinfo_description |
465                          serverinfo_network_name | serverinfo_network_desc |
466 <                        serverinfo_max_clients |
466 >                        serverinfo_max_clients | serverinfo_max_nick_length |
467 >                        serverinfo_max_topic_length | serverinfo_ssl_dh_param_file |
468                          serverinfo_rsa_private_key_file | serverinfo_vhost6 |
469                          serverinfo_sid | serverinfo_ssl_certificate_file |
470 <                        serverinfo_ssl_connection_method |
470 >                        serverinfo_ssl_client_method | serverinfo_ssl_server_method |
471 >                        serverinfo_ssl_cipher_list |
472                          error ';' ;
473  
474  
475 < serverinfo_ssl_connection_method: T_SSL_CONNECTION_METHOD
475 > serverinfo_ssl_client_method: T_SSL_CLIENT_METHOD '=' client_method_types ';' ;
476 > serverinfo_ssl_server_method: T_SSL_SERVER_METHOD '=' server_method_types ';' ;
477 >
478 > client_method_types: client_method_types ',' client_method_type_item | client_method_type_item;
479 > client_method_type_item: T_SSLV3
480   {
481 <  if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
482 <    ServerInfo.tls_version = 0;
483 < } '=' method_types ';'
481 > #ifdef HAVE_LIBCRYPTO
482 >  if (conf_parser_ctx.pass == 2 && ServerInfo.client_ctx)
483 >    SSL_CTX_clear_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv3);
484 > #endif
485 > } | T_TLSV1
486   {
487 <  if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
488 <  {
489 <    if (!(ServerInfo.tls_version & CONF_SERVER_INFO_TLS_VERSION_SSLV3))
490 <      SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv3);
522 <    if (!(ServerInfo.tls_version & CONF_SERVER_INFO_TLS_VERSION_TLSV1))
523 <      SSL_CTX_set_options(ServerInfo.server_ctx, SSL_OP_NO_TLSv1);
524 <  }
487 > #ifdef HAVE_LIBCRYPTO
488 >  if (conf_parser_ctx.pass == 2 && ServerInfo.client_ctx)
489 >    SSL_CTX_clear_options(ServerInfo.client_ctx, SSL_OP_NO_TLSv1);
490 > #endif
491   };
492  
493 < method_types: method_types ',' method_type_item | method_type_item;
494 < method_type_item: T_SSLV3
493 > server_method_types: server_method_types ',' server_method_type_item | server_method_type_item;
494 > server_method_type_item: T_SSLV3
495   {
496 <  if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
497 <    ServerInfo.tls_version |= CONF_SERVER_INFO_TLS_VERSION_SSLV3;
496 > #ifdef HAVE_LIBCRYPTO
497 >  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
498 >    SSL_CTX_clear_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv3);
499 > #endif
500   } | T_TLSV1
501   {
502 <  if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
503 <    ServerInfo.tls_version |= CONF_SERVER_INFO_TLS_VERSION_TLSV1;
502 > #ifdef HAVE_LIBCRYPTO
503 >  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
504 >    SSL_CTX_clear_options(ServerInfo.server_ctx, SSL_OP_NO_TLSv1);
505 > #endif
506   };
507  
508   serverinfo_ssl_certificate_file: SSL_CERTIFICATE_FILE '=' QSTRING ';'
# Line 542 | Line 512 | serverinfo_ssl_certificate_file: SSL_CER
512    {
513      if (!ServerInfo.rsa_private_key_file)
514      {
515 <      yyerror("No rsa_private_key_file specified, SSL disabled");
515 >      conf_error_report("No rsa_private_key_file specified, SSL disabled");
516        break;
517      }
518  
519      if (SSL_CTX_use_certificate_file(ServerInfo.server_ctx, yylval.string,
520 +                                     SSL_FILETYPE_PEM) <= 0 ||
521 +        SSL_CTX_use_certificate_file(ServerInfo.client_ctx, yylval.string,
522                                       SSL_FILETYPE_PEM) <= 0)
523      {
524 <      yyerror(ERR_lib_error_string(ERR_get_error()));
524 >      report_crypto_errors();
525 >      conf_error_report("Could not open/read certificate file");
526        break;
527      }
528  
529      if (SSL_CTX_use_PrivateKey_file(ServerInfo.server_ctx, ServerInfo.rsa_private_key_file,
530 +                                    SSL_FILETYPE_PEM) <= 0 ||
531 +        SSL_CTX_use_PrivateKey_file(ServerInfo.client_ctx, ServerInfo.rsa_private_key_file,
532                                      SSL_FILETYPE_PEM) <= 0)
533      {
534 <      yyerror(ERR_lib_error_string(ERR_get_error()));
534 >      report_crypto_errors();
535 >      conf_error_report("Could not read RSA private key");
536        break;
537      }
538  
539 <    if (!SSL_CTX_check_private_key(ServerInfo.server_ctx))
539 >    if (!SSL_CTX_check_private_key(ServerInfo.server_ctx) ||
540 >        !SSL_CTX_check_private_key(ServerInfo.client_ctx))
541      {
542 <      yyerror(ERR_lib_error_string(ERR_get_error()));
542 >      report_crypto_errors();
543 >      conf_error_report("Could not read RSA private key");
544        break;
545      }
546    }
# Line 572 | Line 550 | serverinfo_ssl_certificate_file: SSL_CER
550   serverinfo_rsa_private_key_file: RSA_PRIVATE_KEY_FILE '=' QSTRING ';'
551   {
552   #ifdef HAVE_LIBCRYPTO
553 <  if (conf_parser_ctx.pass == 1)
553 >  BIO *file = NULL;
554 >
555 >  if (conf_parser_ctx.pass != 1)
556 >    break;
557 >
558 >  if (ServerInfo.rsa_private_key)
559    {
560 <    BIO *file;
560 >    RSA_free(ServerInfo.rsa_private_key);
561 >    ServerInfo.rsa_private_key = NULL;
562 >  }
563  
564 <    if (ServerInfo.rsa_private_key)
565 <    {
566 <      RSA_free(ServerInfo.rsa_private_key);
567 <      ServerInfo.rsa_private_key = NULL;
568 <    }
564 >  if (ServerInfo.rsa_private_key_file)
565 >  {
566 >    MyFree(ServerInfo.rsa_private_key_file);
567 >    ServerInfo.rsa_private_key_file = NULL;
568 >  }
569  
570 <    if (ServerInfo.rsa_private_key_file)
586 <    {
587 <      MyFree(ServerInfo.rsa_private_key_file);
588 <      ServerInfo.rsa_private_key_file = NULL;
589 <    }
570 >  ServerInfo.rsa_private_key_file = xstrdup(yylval.string);
571  
572 <    DupString(ServerInfo.rsa_private_key_file, yylval.string);
572 >  if ((file = BIO_new_file(yylval.string, "r")) == NULL)
573 >  {
574 >    conf_error_report("File open failed, ignoring");
575 >    break;
576 >  }
577  
578 <    if ((file = BIO_new_file(yylval.string, "r")) == NULL)
594 <    {
595 <      yyerror("File open failed, ignoring");
596 <      break;
597 <    }
578 >  ServerInfo.rsa_private_key = PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL);
579  
580 <    ServerInfo.rsa_private_key = (RSA *)PEM_read_bio_RSAPrivateKey(file, NULL,
581 <      0, NULL);
580 >  BIO_set_close(file, BIO_CLOSE);
581 >  BIO_free(file);
582  
583 <    BIO_set_close(file, BIO_CLOSE);
584 <    BIO_free(file);
583 >  if (ServerInfo.rsa_private_key == NULL)
584 >  {
585 >    conf_error_report("Couldn't extract key, ignoring");
586 >    break;
587 >  }
588  
589 <    if (ServerInfo.rsa_private_key == NULL)
590 <    {
591 <      yyerror("Couldn't extract key, ignoring");
592 <      break;
609 <    }
589 >  if (!RSA_check_key(ServerInfo.rsa_private_key))
590 >  {
591 >    RSA_free(ServerInfo.rsa_private_key);
592 >    ServerInfo.rsa_private_key = NULL;
593  
594 <    if (!RSA_check_key(ServerInfo.rsa_private_key))
595 <    {
596 <      RSA_free(ServerInfo.rsa_private_key);
614 <      ServerInfo.rsa_private_key = NULL;
594 >    conf_error_report("Invalid key, ignoring");
595 >    break;
596 >  }
597  
598 <      yyerror("Invalid key, ignoring");
599 <      break;
600 <    }
598 >  /* require 2048 bit (256 byte) key */
599 >  if (RSA_size(ServerInfo.rsa_private_key) != 256)
600 >  {
601 >    RSA_free(ServerInfo.rsa_private_key);
602 >    ServerInfo.rsa_private_key = NULL;
603  
604 <    /* require 2048 bit (256 byte) key */
605 <    if (RSA_size(ServerInfo.rsa_private_key) != 256)
604 >    conf_error_report("Not a 2048 bit key, ignoring");
605 >  }
606 > #endif
607 > };
608 >
609 > serverinfo_ssl_dh_param_file: SSL_DH_PARAM_FILE '=' QSTRING ';'
610 > {
611 > /* TBD - XXX: error reporting */
612 > #ifdef HAVE_LIBCRYPTO
613 >  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
614 >  {
615 >    BIO *file = BIO_new_file(yylval.string, "r");
616 >
617 >    if (file)
618      {
619 <      RSA_free(ServerInfo.rsa_private_key);
620 <      ServerInfo.rsa_private_key = NULL;
619 >      DH *dh = PEM_read_bio_DHparams(file, NULL, NULL, NULL);
620 >
621 >      BIO_free(file);
622  
623 <      yyerror("Not a 2048 bit key, ignoring");
623 >      if (dh)
624 >      {
625 >        if (DH_size(dh) < 128)
626 >          conf_error_report("Ignoring serverinfo::ssl_dh_param_file -- need at least a 1024 bit DH prime size");
627 >        else
628 >          SSL_CTX_set_tmp_dh(ServerInfo.server_ctx, dh);
629 >
630 >        DH_free(dh);
631 >      }
632      }
633    }
634   #endif
635   };
636  
637 + serverinfo_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
638 + {
639 + #ifdef HAVE_LIBCRYPTO
640 +  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
641 +    SSL_CTX_set_cipher_list(ServerInfo.server_ctx, yylval.string);
642 + #endif
643 + };
644 +
645   serverinfo_name: NAME '=' QSTRING ';'
646   {
647    /* this isn't rehashable */
648 <  if (conf_parser_ctx.pass == 2)
648 >  if (conf_parser_ctx.pass == 2 && !ServerInfo.name)
649    {
650 <    if (ServerInfo.name == NULL)
650 >    if (valid_servname(yylval.string))
651 >      ServerInfo.name = xstrdup(yylval.string);
652 >    else
653      {
654 <      /* the ircd will exit() in main() if we dont set one */
655 <      if (strlen(yylval.string) <= HOSTLEN)
641 <        DupString(ServerInfo.name, yylval.string);
654 >      conf_error_report("Ignoring serverinfo::name -- invalid name. Aborting.");
655 >      exit(0);
656      }
657    }
658   };
# Line 649 | Line 663 | serverinfo_sid: IRCD_SID '=' QSTRING ';'
663    if (conf_parser_ctx.pass == 2 && !ServerInfo.sid)
664    {
665      if (valid_sid(yylval.string))
666 <      DupString(ServerInfo.sid, yylval.string);
666 >      ServerInfo.sid = xstrdup(yylval.string);
667      else
668      {
669 <      ilog(L_ERROR, "Ignoring config file entry SID -- invalid SID. Aborting.");
669 >      conf_error_report("Ignoring serverinfo::sid -- invalid SID. Aborting.");
670        exit(0);
671      }
672    }
# Line 663 | Line 677 | serverinfo_description: DESCRIPTION '='
677    if (conf_parser_ctx.pass == 2)
678    {
679      MyFree(ServerInfo.description);
680 <    DupString(ServerInfo.description,yylval.string);
680 >    ServerInfo.description = xstrdup(yylval.string);
681    }
682   };
683  
# Line 677 | Line 691 | serverinfo_network_name: NETWORK_NAME '=
691        p = '\0';
692  
693      MyFree(ServerInfo.network_name);
694 <    DupString(ServerInfo.network_name, yylval.string);
694 >    ServerInfo.network_name = xstrdup(yylval.string);
695    }
696   };
697  
698   serverinfo_network_desc: NETWORK_DESC '=' QSTRING ';'
699   {
700 <  if (conf_parser_ctx.pass == 2)
701 <  {
702 <    MyFree(ServerInfo.network_desc);
703 <    DupString(ServerInfo.network_desc, yylval.string);
704 <  }
700 >  if (conf_parser_ctx.pass != 2)
701 >    break;
702 >
703 >  MyFree(ServerInfo.network_desc);
704 >  ServerInfo.network_desc = xstrdup(yylval.string);
705   };
706  
707   serverinfo_vhost: VHOST '=' QSTRING ';'
# Line 702 | Line 716 | serverinfo_vhost: VHOST '=' QSTRING ';'
716      hints.ai_socktype = SOCK_STREAM;
717      hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
718  
719 <    if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
720 <      ilog(L_ERROR, "Invalid netmask for server vhost(%s)", yylval.string);
719 >    if (getaddrinfo(yylval.string, NULL, &hints, &res))
720 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", yylval.string);
721      else
722      {
723        assert(res != NULL);
# Line 711 | Line 725 | serverinfo_vhost: VHOST '=' QSTRING ';'
725        memcpy(&ServerInfo.ip, res->ai_addr, res->ai_addrlen);
726        ServerInfo.ip.ss.ss_family = res->ai_family;
727        ServerInfo.ip.ss_len = res->ai_addrlen;
728 <      irc_freeaddrinfo(res);
728 >      freeaddrinfo(res);
729  
730        ServerInfo.specific_ipv4_vhost = 1;
731      }
# Line 731 | Line 745 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
745      hints.ai_socktype = SOCK_STREAM;
746      hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
747  
748 <    if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
749 <      ilog(L_ERROR, "Invalid netmask for server vhost6(%s)", yylval.string);
748 >    if (getaddrinfo(yylval.string, NULL, &hints, &res))
749 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost6(%s)", yylval.string);
750      else
751      {
752        assert(res != NULL);
# Line 740 | Line 754 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
754        memcpy(&ServerInfo.ip6, res->ai_addr, res->ai_addrlen);
755        ServerInfo.ip6.ss.ss_family = res->ai_family;
756        ServerInfo.ip6.ss_len = res->ai_addrlen;
757 <      irc_freeaddrinfo(res);
757 >      freeaddrinfo(res);
758  
759        ServerInfo.specific_ipv6_vhost = 1;
760      }
# Line 750 | Line 764 | serverinfo_vhost6: VHOST6 '=' QSTRING ';
764  
765   serverinfo_max_clients: T_MAX_CLIENTS '=' NUMBER ';'
766   {
767 <  if (conf_parser_ctx.pass == 2)
767 >  if (conf_parser_ctx.pass != 2)
768 >    break;
769 >
770 >  if ($3 < MAXCLIENTS_MIN)
771    {
772 <    recalc_fdlimit(NULL);
772 >    char buf[IRCD_BUFSIZE];
773  
774 <    if ($3 < MAXCLIENTS_MIN)
775 <    {
776 <      char buf[IRCD_BUFSIZE];
777 <      ircsprintf(buf, "MAXCLIENTS too low, setting to %d", MAXCLIENTS_MIN);
778 <      yyerror(buf);
779 <    }
780 <    else if ($3 > MAXCLIENTS_MAX)
781 <    {
782 <      char buf[IRCD_BUFSIZE];
783 <      ircsprintf(buf, "MAXCLIENTS too high, setting to %d", MAXCLIENTS_MAX);
784 <      yyerror(buf);
768 <    }
769 <    else
770 <      ServerInfo.max_clients = $3;
774 >    snprintf(buf, sizeof(buf), "MAXCLIENTS too low, setting to %d", MAXCLIENTS_MIN);
775 >    conf_error_report(buf);
776 >    ServerInfo.max_clients = MAXCLIENTS_MIN;
777 >  }
778 >  else if ($3 > MAXCLIENTS_MAX)
779 >  {
780 >    char buf[IRCD_BUFSIZE];
781 >
782 >    snprintf(buf, sizeof(buf), "MAXCLIENTS too high, setting to %d", MAXCLIENTS_MAX);
783 >    conf_error_report(buf);
784 >    ServerInfo.max_clients = MAXCLIENTS_MAX;
785    }
786 +  else
787 +    ServerInfo.max_clients = $3;
788   };
789  
790 < serverinfo_hub: HUB '=' TBOOL ';'
790 > serverinfo_max_nick_length: MAX_NICK_LENGTH '=' NUMBER ';'
791   {
792 <  if (conf_parser_ctx.pass == 2)
792 >  if (conf_parser_ctx.pass != 2)
793 >    break;
794 >
795 >  if ($3 < 9)
796    {
797 <    if (yylval.number)
798 <    {
799 <      ServerInfo.hub = 1;
800 <      delete_capability("HUB");
801 <      add_capability("HUB", CAP_HUB, 1);
802 <    }
784 <    else if (ServerInfo.hub)
785 <    {
797 >    conf_error_report("max_nick_length too low, setting to 9");
798 >    ServerInfo.max_nick_length = 9;
799 >  }
800 >  else if ($3 > NICKLEN)
801 >  {
802 >    char buf[IRCD_BUFSIZE];
803  
804 <      ServerInfo.hub = 0;
805 <      delete_capability("HUB");
806 <    }
804 >    snprintf(buf, sizeof(buf), "max_nick_length too high, setting to %d", NICKLEN);
805 >    conf_error_report(buf);
806 >    ServerInfo.max_nick_length = NICKLEN;
807 >  }
808 >  else
809 >    ServerInfo.max_nick_length = $3;
810 > };
811 >
812 > serverinfo_max_topic_length: MAX_TOPIC_LENGTH '=' NUMBER ';'
813 > {
814 >  if (conf_parser_ctx.pass != 2)
815 >    break;
816 >
817 >  if ($3 < 80)
818 >  {
819 >    conf_error_report("max_topic_length too low, setting to 80");
820 >    ServerInfo.max_topic_length = 80;
821    }
822 +  else if ($3 > TOPICLEN)
823 +  {
824 +    char buf[IRCD_BUFSIZE];
825 +
826 +    snprintf(buf, sizeof(buf), "max_topic_length too high, setting to %d", TOPICLEN);
827 +    conf_error_report(buf);
828 +    ServerInfo.max_topic_length = TOPICLEN;
829 +  }
830 +  else
831 +    ServerInfo.max_topic_length = $3;
832 + };
833 +
834 + serverinfo_hub: HUB '=' TBOOL ';'
835 + {
836 +  if (conf_parser_ctx.pass == 2)
837 +    ServerInfo.hub = yylval.number;
838   };
839  
840   /***************************************************************************
# Line 801 | Line 848 | admin_item:  admin_name | admin_descript
848  
849   admin_name: NAME '=' QSTRING ';'
850   {
851 <  if (conf_parser_ctx.pass == 2)
852 <  {
853 <    MyFree(AdminInfo.name);
854 <    DupString(AdminInfo.name, yylval.string);
855 <  }
851 >  if (conf_parser_ctx.pass != 2)
852 >    break;
853 >
854 >  MyFree(AdminInfo.name);
855 >  AdminInfo.name = xstrdup(yylval.string);
856   };
857  
858   admin_email: EMAIL '=' QSTRING ';'
859   {
860 <  if (conf_parser_ctx.pass == 2)
861 <  {
862 <    MyFree(AdminInfo.email);
863 <    DupString(AdminInfo.email, yylval.string);
864 <  }
860 >  if (conf_parser_ctx.pass != 2)
861 >    break;
862 >
863 >  MyFree(AdminInfo.email);
864 >  AdminInfo.email = xstrdup(yylval.string);
865   };
866  
867   admin_description: DESCRIPTION '=' QSTRING ';'
868   {
869 <  if (conf_parser_ctx.pass == 2)
870 <  {
871 <    MyFree(AdminInfo.description);
872 <    DupString(AdminInfo.description, yylval.string);
873 <  }
869 >  if (conf_parser_ctx.pass != 2)
870 >    break;
871 >
872 >  MyFree(AdminInfo.description);
873 >  AdminInfo.description = xstrdup(yylval.string);
874   };
875  
876   /***************************************************************************
877 < *  section logging
877 > * motd section
878   ***************************************************************************/
879 < /* XXX */
880 < logging_entry:          LOGGING  '{' logging_items '}' ';' ;
879 > motd_entry: MOTD
880 > {
881 >  if (conf_parser_ctx.pass == 2)
882 >    reset_block_state();
883 > } '{' motd_items '}' ';'
884 > {
885 >  dlink_node *ptr = NULL;
886  
887 < logging_items:          logging_items logging_item |
888 <                        logging_item ;
887 >  if (conf_parser_ctx.pass != 2)
888 >    break;
889  
890 < logging_item:           logging_path | logging_oper_log |
891 <                        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 |
845 <                        error ';' ;
890 >  if (!block_state.file.buf[0])
891 >    break;
892  
893 < logging_path:           T_LOGPATH '=' QSTRING ';'
894 <                        {
895 <                        };
893 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
894 >    motd_add(ptr->data, block_state.file.buf);
895 > };
896  
897 < logging_oper_log:       OPER_LOG '=' QSTRING ';'
898 <                        {
853 <                        };
897 > motd_items: motd_items motd_item | motd_item;
898 > motd_item:  motd_mask | motd_file | error ';' ;
899  
900 < logging_fuserlog: FUSERLOG '=' QSTRING ';'
900 > motd_mask: MASK '=' QSTRING ';'
901   {
902    if (conf_parser_ctx.pass == 2)
903 <    strlcpy(ConfigLoggingEntry.userlog, yylval.string,
859 <            sizeof(ConfigLoggingEntry.userlog));
903 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
904   };
905  
906 < logging_ffailed_operlog: FFAILED_OPERLOG '=' QSTRING ';'
906 > motd_file: T_FILE '=' QSTRING ';'
907   {
908    if (conf_parser_ctx.pass == 2)
909 <    strlcpy(ConfigLoggingEntry.failed_operlog, yylval.string,
866 <            sizeof(ConfigLoggingEntry.failed_operlog));
909 >    strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
910   };
911  
912 < logging_foperlog: FOPERLOG '=' QSTRING ';'
913 < {
914 <  if (conf_parser_ctx.pass == 2)
915 <    strlcpy(ConfigLoggingEntry.operlog, yylval.string,
916 <            sizeof(ConfigLoggingEntry.operlog));
917 < };
912 > /***************************************************************************
913 > *  section logging
914 > ***************************************************************************/
915 > logging_entry:          T_LOG  '{' logging_items '}' ';' ;
916 > logging_items:          logging_items logging_item | logging_item ;
917 >
918 > logging_item:           logging_use_logging | logging_file_entry |
919 >                        error ';' ;
920  
921 < logging_foperspylog: FOPERSPYLOG '=' QSTRING ';'
921 > logging_use_logging: USE_LOGGING '=' TBOOL ';'
922   {
923    if (conf_parser_ctx.pass == 2)
924 <    strlcpy(ConfigLoggingEntry.operspylog, yylval.string,
880 <            sizeof(ConfigLoggingEntry.operspylog));
924 >    ConfigLoggingEntry.use_logging = yylval.number;
925   };
926  
927 < logging_fglinelog: FGLINELOG '=' QSTRING ';'
927 > logging_file_entry:
928   {
929    if (conf_parser_ctx.pass == 2)
930 <    strlcpy(ConfigLoggingEntry.glinelog, yylval.string,
931 <            sizeof(ConfigLoggingEntry.glinelog));
930 >    reset_block_state();
931 > } T_FILE  '{' logging_file_items '}' ';'
932 > {
933 >  if (conf_parser_ctx.pass != 2)
934 >    break;
935 >
936 >  if (block_state.type.value && block_state.file.buf[0])
937 >    log_set_file(block_state.type.value, block_state.size.value,
938 >                 block_state.file.buf);
939   };
940  
941 < logging_fklinelog: FKLINELOG '=' QSTRING ';'
941 > logging_file_items: logging_file_items logging_file_item |
942 >                    logging_file_item ;
943 >
944 > logging_file_item:  logging_file_name | logging_file_type |
945 >                    logging_file_size | error ';' ;
946 >
947 > logging_file_name: NAME '=' QSTRING ';'
948   {
949 <  if (conf_parser_ctx.pass == 2)
950 <    strlcpy(ConfigLoggingEntry.klinelog, yylval.string,
951 <            sizeof(ConfigLoggingEntry.klinelog));
952 < };
949 >  if (conf_parser_ctx.pass != 2)
950 >    break;
951 >
952 >  strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
953 > }
954  
955 < logging_ioerrlog: FIOERRLOG '=' QSTRING ';'
955 > logging_file_size: T_SIZE '=' sizespec ';'
956   {
957 <  if (conf_parser_ctx.pass == 2)
958 <    strlcpy(ConfigLoggingEntry.ioerrlog, yylval.string,
959 <            sizeof(ConfigLoggingEntry.ioerrlog));
957 >  block_state.size.value = $3;
958 > } | T_SIZE '=' T_UNLIMITED ';'
959 > {
960 >  block_state.size.value = 0;
961   };
962  
963 < logging_killlog: FKILLLOG '=' QSTRING ';'
963 > logging_file_type: TYPE
964   {
965    if (conf_parser_ctx.pass == 2)
966 <    strlcpy(ConfigLoggingEntry.killlog, yylval.string,
967 <            sizeof(ConfigLoggingEntry.killlog));
909 < };
966 >    block_state.type.value = 0;
967 > } '='  logging_file_type_items ';' ;
968  
969 < logging_log_level: LOG_LEVEL '=' T_L_CRIT ';'
970 < {
913 <  if (conf_parser_ctx.pass == 2)
914 <    set_log_level(L_CRIT);
915 < } | LOG_LEVEL '=' T_L_ERROR ';'
969 > logging_file_type_items: logging_file_type_items ',' logging_file_type_item | logging_file_type_item;
970 > logging_file_type_item:  USER
971   {
972    if (conf_parser_ctx.pass == 2)
973 <    set_log_level(L_ERROR);
974 < } | LOG_LEVEL '=' T_L_WARN ';'
973 >    block_state.type.value = LOG_TYPE_USER;
974 > } | OPERATOR
975   {
976    if (conf_parser_ctx.pass == 2)
977 <    set_log_level(L_WARN);
978 < } | LOG_LEVEL '=' T_L_NOTICE ';'
977 >    block_state.type.value = LOG_TYPE_OPER;
978 > } | GLINE
979   {
980    if (conf_parser_ctx.pass == 2)
981 <    set_log_level(L_NOTICE);
982 < } | LOG_LEVEL '=' T_L_TRACE ';'
981 >    block_state.type.value = LOG_TYPE_GLINE;
982 > } | T_DLINE
983   {
984    if (conf_parser_ctx.pass == 2)
985 <    set_log_level(L_TRACE);
986 < } | LOG_LEVEL '=' T_L_INFO ';'
985 >    block_state.type.value = LOG_TYPE_DLINE;
986 > } | KLINE
987   {
988    if (conf_parser_ctx.pass == 2)
989 <    set_log_level(L_INFO);
990 < } | LOG_LEVEL '=' T_L_DEBUG ';'
989 >    block_state.type.value = LOG_TYPE_KLINE;
990 > } | KILL
991   {
992    if (conf_parser_ctx.pass == 2)
993 <    set_log_level(L_DEBUG);
994 < };
940 <
941 < logging_use_logging: USE_LOGGING '=' TBOOL ';'
993 >    block_state.type.value = LOG_TYPE_KILL;
994 > } | T_DEBUG
995   {
996    if (conf_parser_ctx.pass == 2)
997 <    ConfigLoggingEntry.use_logging = yylval.number;
997 >    block_state.type.value = LOG_TYPE_DEBUG;
998   };
999  
1000 +
1001   /***************************************************************************
1002   * section oper
1003   ***************************************************************************/
1004   oper_entry: OPERATOR
1005   {
1006 <  if (conf_parser_ctx.pass == 2)
1007 <  {
1008 <    yy_conf = make_conf_item(OPER_TYPE);
1009 <    yy_aconf = map_to_conf(yy_conf);
1010 <    SetConfEncrypted(yy_aconf); /* Yes, the default is encrypted */
1011 <  }
958 <  else
959 <  {
960 <    MyFree(class_name);
961 <    class_name = NULL;
962 <  }
963 < } oper_name_b '{' oper_items '}' ';'
1006 >  if (conf_parser_ctx.pass != 2)
1007 >    break;
1008 >
1009 >  reset_block_state();
1010 >  block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1011 > } '{' oper_items '}' ';'
1012   {
1013 <  if (conf_parser_ctx.pass == 2)
966 <  {
967 <    struct CollectItem *yy_tmp;
968 <    dlink_node *ptr;
969 <    dlink_node *next_ptr;
1013 >  dlink_node *ptr = NULL;
1014  
1015 <    conf_add_class_to_conf(yy_conf, class_name);
1015 >  if (conf_parser_ctx.pass != 2)
1016 >    break;
1017  
1018 <    /* Now, make sure there is a copy of the "base" given oper
1019 <     * block in each of the collected copies
1020 <     */
1018 >  if (!block_state.name.buf[0])
1019 >    break;
1020 > #ifdef HAVE_LIBCRYPTO
1021 >  if (!block_state.file.buf[0] &&
1022 >      !block_state.rpass.buf[0])
1023 >    break;
1024 > #else
1025 >  if (!block_state.rpass.buf[0])
1026 >    break;
1027 > #endif
1028  
1029 <    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
1030 <    {
1031 <      struct AccessItem *new_aconf;
1032 <      struct ConfItem *new_conf;
981 <      yy_tmp = ptr->data;
982 <
983 <      new_conf = make_conf_item(OPER_TYPE);
984 <      new_aconf = (struct AccessItem *)map_to_conf(new_conf);
985 <
986 <      new_aconf->flags = yy_aconf->flags;
987 <
988 <      if (yy_conf->name != NULL)
989 <        DupString(new_conf->name, yy_conf->name);
990 <      if (yy_tmp->user != NULL)
991 <        DupString(new_aconf->user, yy_tmp->user);
992 <      else
993 <        DupString(new_aconf->user, "*");
994 <      if (yy_tmp->host != NULL)
995 <        DupString(new_aconf->host, yy_tmp->host);
996 <      else
997 <        DupString(new_aconf->host, "*");
998 <      conf_add_class_to_conf(new_conf, class_name);
999 <      if (yy_aconf->passwd != NULL)
1000 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1029 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
1030 >  {
1031 >    struct MaskItem *conf = NULL;
1032 >    struct split_nuh_item nuh;
1033  
1034 <      new_aconf->port = yy_aconf->port;
1035 < #ifdef HAVE_LIBCRYPTO
1036 <      if (yy_aconf->rsa_public_key_file != NULL)
1037 <      {
1038 <        BIO *file;
1034 >    nuh.nuhmask  = ptr->data;
1035 >    nuh.nickptr  = NULL;
1036 >    nuh.userptr  = block_state.user.buf;
1037 >    nuh.hostptr  = block_state.host.buf;
1038 >    nuh.nicksize = 0;
1039 >    nuh.usersize = sizeof(block_state.user.buf);
1040 >    nuh.hostsize = sizeof(block_state.host.buf);
1041 >    split_nuh(&nuh);
1042  
1043 <        DupString(new_aconf->rsa_public_key_file,
1044 <                  yy_aconf->rsa_public_key_file);
1043 >    conf        = conf_make(CONF_OPER);
1044 >    conf->name  = xstrdup(block_state.name.buf);
1045 >    conf->user  = xstrdup(block_state.user.buf);
1046 >    conf->host  = xstrdup(block_state.host.buf);
1047 >
1048 >    if (block_state.rpass.buf[0])
1049 >      conf->passwd = xstrdup(block_state.rpass.buf);
1050 >
1051 >    conf->flags = block_state.flags.value;
1052 >    conf->modes = block_state.modes.value;
1053 >    conf->port  = block_state.port.value;
1054 >    conf->htype = parse_netmask(conf->host, &conf->addr, &conf->bits);
1055  
1056 <        file = BIO_new_file(yy_aconf->rsa_public_key_file, "r");
1012 <        new_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file,
1013 <                                                           NULL, 0, NULL);
1014 <        BIO_set_close(file, BIO_CLOSE);
1015 <        BIO_free(file);
1016 <      }
1017 < #endif
1056 >    conf_add_class_to_conf(conf, block_state.class.buf);
1057  
1058   #ifdef HAVE_LIBCRYPTO
1059 <      if (yy_tmp->name && (yy_tmp->passwd || yy_aconf->rsa_public_key)
1060 <          && yy_tmp->host)
1061 < #else
1062 <      if (yy_tmp->name && yy_tmp->passwd && yy_tmp->host)
1063 < #endif
1059 >    if (block_state.file.buf[0])
1060 >    {
1061 >      BIO *file = NULL;
1062 >      RSA *pkey = NULL;
1063 >
1064 >      if ((file = BIO_new_file(block_state.file.buf, "r")) == NULL)
1065        {
1066 <        conf_add_class_to_conf(new_conf, class_name);
1067 <        if (yy_tmp->name != NULL)
1028 <          DupString(new_conf->name, yy_tmp->name);
1066 >        conf_error_report("Ignoring rsa_public_key_file -- file doesn't exist");
1067 >        break;
1068        }
1069  
1070 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
1071 <      free_collect_item(yy_tmp);
1033 <    }
1070 >      if ((pkey = PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL)) == NULL)
1071 >        conf_error_report("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
1072  
1073 <    yy_conf = NULL;
1074 <    yy_aconf = NULL;
1075 <
1076 <
1077 <    MyFree(class_name);
1040 <    class_name = NULL;
1073 >      conf->rsa_public_key = pkey;
1074 >      BIO_set_close(file, BIO_CLOSE);
1075 >      BIO_free(file);
1076 >    }
1077 > #endif /* HAVE_LIBCRYPTO */
1078    }
1079 < };
1079 > };
1080  
1044 oper_name_b: | oper_name_t;
1081   oper_items:     oper_items oper_item | oper_item;
1082 < oper_item:      oper_name | oper_user | oper_password | oper_hidden_admin |
1083 <                oper_hidden_oper | oper_umodes |
1084 <                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 ';' ;
1082 > oper_item:      oper_name | oper_user | oper_password |
1083 >                oper_umodes | oper_class | oper_encrypted |
1084 >                oper_rsa_public_key_file | oper_flags | error ';' ;
1085  
1086   oper_name: NAME '=' QSTRING ';'
1087   {
1088    if (conf_parser_ctx.pass == 2)
1089 <  {
1059 <    if (strlen(yylval.string) > OPERNICKLEN)
1060 <      yylval.string[OPERNICKLEN] = '\0';
1061 <
1062 <    MyFree(yy_conf->name);
1063 <    DupString(yy_conf->name, yylval.string);
1064 <  }
1065 < };
1066 <
1067 < oper_name_t: QSTRING
1068 < {
1069 <  if (conf_parser_ctx.pass == 2)
1070 <  {
1071 <    if (strlen(yylval.string) > OPERNICKLEN)
1072 <      yylval.string[OPERNICKLEN] = '\0';
1073 <
1074 <    MyFree(yy_conf->name);
1075 <    DupString(yy_conf->name, yylval.string);
1076 <  }
1089 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1090   };
1091  
1092   oper_user: USER '=' QSTRING ';'
1093   {
1094    if (conf_parser_ctx.pass == 2)
1095 <  {
1083 <    struct split_nuh_item nuh;
1084 <
1085 <    nuh.nuhmask  = yylval.string;
1086 <    nuh.nickptr  = NULL;
1087 <    nuh.userptr  = userbuf;
1088 <    nuh.hostptr  = hostbuf;
1089 <
1090 <    nuh.nicksize = 0;
1091 <    nuh.usersize = sizeof(userbuf);
1092 <    nuh.hostsize = sizeof(hostbuf);
1093 <
1094 <    split_nuh(&nuh);
1095 <
1096 <    if (yy_aconf->user == NULL)
1097 <    {
1098 <      DupString(yy_aconf->user, userbuf);
1099 <      DupString(yy_aconf->host, hostbuf);
1100 <    }
1101 <    else
1102 <    {
1103 <      struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
1104 <
1105 <      DupString(yy_tmp->user, userbuf);
1106 <      DupString(yy_tmp->host, hostbuf);
1107 <
1108 <      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1109 <    }
1110 <  }
1095 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1096   };
1097  
1098   oper_password: PASSWORD '=' QSTRING ';'
1099   {
1100    if (conf_parser_ctx.pass == 2)
1101 <  {
1117 <    if (yy_aconf->passwd != NULL)
1118 <      memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1119 <
1120 <    MyFree(yy_aconf->passwd);
1121 <    DupString(yy_aconf->passwd, yylval.string);
1122 <  }
1101 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1102   };
1103  
1104   oper_encrypted: ENCRYPTED '=' TBOOL ';'
1105   {
1106 <  if (conf_parser_ctx.pass == 2)
1107 <  {
1108 <    if (yylval.number)
1109 <      SetConfEncrypted(yy_aconf);
1110 <    else
1111 <      ClearConfEncrypted(yy_aconf);
1112 <  }
1106 >  if (conf_parser_ctx.pass != 2)
1107 >    break;
1108 >
1109 >  if (yylval.number)
1110 >    block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1111 >  else
1112 >    block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1113   };
1114  
1115   oper_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
1116   {
1138 #ifdef HAVE_LIBCRYPTO
1117    if (conf_parser_ctx.pass == 2)
1118 <  {
1141 <    BIO *file;
1142 <
1143 <    if (yy_aconf->rsa_public_key != NULL)
1144 <    {
1145 <      RSA_free(yy_aconf->rsa_public_key);
1146 <      yy_aconf->rsa_public_key = NULL;
1147 <    }
1148 <
1149 <    if (yy_aconf->rsa_public_key_file != NULL)
1150 <    {
1151 <      MyFree(yy_aconf->rsa_public_key_file);
1152 <      yy_aconf->rsa_public_key_file = NULL;
1153 <    }
1154 <
1155 <    DupString(yy_aconf->rsa_public_key_file, yylval.string);
1156 <    file = BIO_new_file(yylval.string, "r");
1157 <
1158 <    if (file == NULL)
1159 <    {
1160 <      yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
1161 <      break;
1162 <    }
1163 <
1164 <    yy_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
1165 <
1166 <    if (yy_aconf->rsa_public_key == NULL)
1167 <    {
1168 <      yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
1169 <      break;
1170 <    }
1171 <
1172 <    BIO_set_close(file, BIO_CLOSE);
1173 <    BIO_free(file);
1174 <  }
1175 < #endif /* HAVE_LIBCRYPTO */
1118 >    strlcpy(block_state.file.buf, yylval.string, sizeof(block_state.file.buf));
1119   };
1120  
1121   oper_class: CLASS '=' QSTRING ';'
1122   {
1123    if (conf_parser_ctx.pass == 2)
1124 <  {
1182 <    MyFree(class_name);
1183 <    DupString(class_name, yylval.string);
1184 <  }
1124 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1125   };
1126  
1127   oper_umodes: T_UMODES
1128   {
1129    if (conf_parser_ctx.pass == 2)
1130 <    yy_aconf->modes = 0;
1130 >    block_state.modes.value = 0;
1131   } '='  oper_umodes_items ';' ;
1132  
1133   oper_umodes_items: oper_umodes_items ',' oper_umodes_item | oper_umodes_item;
1134   oper_umodes_item:  T_BOTS
1135   {
1136    if (conf_parser_ctx.pass == 2)
1137 <    yy_aconf->modes |= UMODE_BOTS;
1137 >    block_state.modes.value |= UMODE_BOTS;
1138   } | T_CCONN
1139   {
1140    if (conf_parser_ctx.pass == 2)
1141 <    yy_aconf->modes |= UMODE_CCONN;
1202 < } | T_CCONN_FULL
1203 < {
1204 <  if (conf_parser_ctx.pass == 2)
1205 <    yy_aconf->modes |= UMODE_CCONN_FULL;
1141 >    block_state.modes.value |= UMODE_CCONN;
1142   } | T_DEAF
1143   {
1144    if (conf_parser_ctx.pass == 2)
1145 <    yy_aconf->modes |= UMODE_DEAF;
1145 >    block_state.modes.value |= UMODE_DEAF;
1146   } | T_DEBUG
1147   {
1148    if (conf_parser_ctx.pass == 2)
1149 <    yy_aconf->modes |= UMODE_DEBUG;
1149 >    block_state.modes.value |= UMODE_DEBUG;
1150   } | T_FULL
1151   {
1152    if (conf_parser_ctx.pass == 2)
1153 <    yy_aconf->modes |= UMODE_FULL;
1153 >    block_state.modes.value |= UMODE_FULL;
1154 > } | HIDDEN
1155 > {
1156 >  if (conf_parser_ctx.pass == 2)
1157 >    block_state.modes.value |= UMODE_HIDDEN;
1158   } | T_SKILL
1159   {
1160    if (conf_parser_ctx.pass == 2)
1161 <    yy_aconf->modes |= UMODE_SKILL;
1161 >    block_state.modes.value |= UMODE_SKILL;
1162   } | T_NCHANGE
1163   {
1164    if (conf_parser_ctx.pass == 2)
1165 <    yy_aconf->modes |= UMODE_NCHANGE;
1165 >    block_state.modes.value |= UMODE_NCHANGE;
1166   } | T_REJ
1167   {
1168    if (conf_parser_ctx.pass == 2)
1169 <    yy_aconf->modes |= UMODE_REJ;
1169 >    block_state.modes.value |= UMODE_REJ;
1170   } | T_UNAUTH
1171   {
1172    if (conf_parser_ctx.pass == 2)
1173 <    yy_aconf->modes |= UMODE_UNAUTH;
1173 >    block_state.modes.value |= UMODE_UNAUTH;
1174   } | T_SPY
1175   {
1176    if (conf_parser_ctx.pass == 2)
1177 <    yy_aconf->modes |= UMODE_SPY;
1177 >    block_state.modes.value |= UMODE_SPY;
1178   } | T_EXTERNAL
1179   {
1180    if (conf_parser_ctx.pass == 2)
1181 <    yy_aconf->modes |= UMODE_EXTERNAL;
1181 >    block_state.modes.value |= UMODE_EXTERNAL;
1182   } | T_OPERWALL
1183   {
1184    if (conf_parser_ctx.pass == 2)
1185 <    yy_aconf->modes |= UMODE_OPERWALL;
1185 >    block_state.modes.value |= UMODE_OPERWALL;
1186   } | T_SERVNOTICE
1187   {
1188    if (conf_parser_ctx.pass == 2)
1189 <    yy_aconf->modes |= UMODE_SERVNOTICE;
1189 >    block_state.modes.value |= UMODE_SERVNOTICE;
1190   } | T_INVISIBLE
1191   {
1192    if (conf_parser_ctx.pass == 2)
1193 <    yy_aconf->modes |= UMODE_INVISIBLE;
1193 >    block_state.modes.value |= UMODE_INVISIBLE;
1194   } | T_WALLOP
1195   {
1196    if (conf_parser_ctx.pass == 2)
1197 <    yy_aconf->modes |= UMODE_WALLOP;
1197 >    block_state.modes.value |= UMODE_WALLOP;
1198   } | T_SOFTCALLERID
1199   {
1200    if (conf_parser_ctx.pass == 2)
1201 <    yy_aconf->modes |= UMODE_SOFTCALLERID;
1201 >    block_state.modes.value |= UMODE_SOFTCALLERID;
1202   } | T_CALLERID
1203   {
1204    if (conf_parser_ctx.pass == 2)
1205 <    yy_aconf->modes |= UMODE_CALLERID;
1205 >    block_state.modes.value |= UMODE_CALLERID;
1206   } | T_LOCOPS
1207   {
1208    if (conf_parser_ctx.pass == 2)
1209 <    yy_aconf->modes |= UMODE_LOCOPS;
1210 < };
1271 <
1272 < oper_global_kill: GLOBAL_KILL '=' TBOOL ';'
1273 < {
1274 <  if (conf_parser_ctx.pass == 2)
1275 <  {
1276 <    if (yylval.number)
1277 <      yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1278 <    else
1279 <      yy_aconf->port &= ~OPER_FLAG_GLOBAL_KILL;
1280 <  }
1281 < };
1282 <
1283 < oper_remote: REMOTE '=' TBOOL ';'
1284 < {
1285 <  if (conf_parser_ctx.pass == 2)
1286 <  {
1287 <    if (yylval.number)
1288 <      yy_aconf->port |= OPER_FLAG_REMOTE;
1289 <    else
1290 <      yy_aconf->port &= ~OPER_FLAG_REMOTE;
1291 <  }
1292 < };
1293 <
1294 < oper_remoteban: REMOTEBAN '=' TBOOL ';'
1295 < {
1296 <  if (conf_parser_ctx.pass == 2)
1297 <  {
1298 <    if (yylval.number)
1299 <      yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1300 <    else
1301 <      yy_aconf->port &= ~OPER_FLAG_REMOTEBAN;
1302 <  }
1303 < };
1304 <
1305 < oper_kline: KLINE '=' TBOOL ';'
1209 >    block_state.modes.value |= UMODE_LOCOPS;
1210 > } | T_NONONREG
1211   {
1212    if (conf_parser_ctx.pass == 2)
1213 <  {
1214 <    if (yylval.number)
1310 <      yy_aconf->port |= OPER_FLAG_K;
1311 <    else
1312 <      yy_aconf->port &= ~OPER_FLAG_K;
1313 <  }
1314 < };
1315 <
1316 < oper_xline: XLINE '=' TBOOL ';'
1213 >    block_state.modes.value |= UMODE_REGONLY;
1214 > } | T_FARCONNECT
1215   {
1216    if (conf_parser_ctx.pass == 2)
1217 <  {
1320 <    if (yylval.number)
1321 <      yy_aconf->port |= OPER_FLAG_X;
1322 <    else
1323 <      yy_aconf->port &= ~OPER_FLAG_X;
1324 <  }
1217 >    block_state.modes.value |= UMODE_FARCONNECT;
1218   };
1219  
1220 < oper_unkline: UNKLINE '=' TBOOL ';'
1328 < {
1329 <  if (conf_parser_ctx.pass == 2)
1330 <  {
1331 <    if (yylval.number)
1332 <      yy_aconf->port |= OPER_FLAG_UNKLINE;
1333 <    else
1334 <      yy_aconf->port &= ~OPER_FLAG_UNKLINE;
1335 <  }
1336 < };
1337 <
1338 < oper_gline: GLINE '=' TBOOL ';'
1220 > oper_flags: IRCD_FLAGS
1221   {
1222    if (conf_parser_ctx.pass == 2)
1223 <  {
1224 <    if (yylval.number)
1343 <      yy_aconf->port |= OPER_FLAG_GLINE;
1344 <    else
1345 <      yy_aconf->port &= ~OPER_FLAG_GLINE;
1346 <  }
1347 < };
1223 >    block_state.port.value = 0;
1224 > } '='  oper_flags_items ';';
1225  
1226 < oper_nick_changes: NICK_CHANGES '=' TBOOL ';'
1226 > oper_flags_items: oper_flags_items ',' oper_flags_item | oper_flags_item;
1227 > oper_flags_item: KILL ':' REMOTE
1228   {
1229    if (conf_parser_ctx.pass == 2)
1230 <  {
1231 <    if (yylval.number)
1354 <      yy_aconf->port |= OPER_FLAG_N;
1355 <    else
1356 <      yy_aconf->port &= ~OPER_FLAG_N;
1357 <  }
1358 < };
1359 <
1360 < oper_die: DIE '=' TBOOL ';'
1230 >    block_state.port.value |= OPER_FLAG_KILL_REMOTE;
1231 > } | KILL
1232   {
1233    if (conf_parser_ctx.pass == 2)
1234 <  {
1235 <    if (yylval.number)
1365 <      yy_aconf->port |= OPER_FLAG_DIE;
1366 <    else
1367 <      yy_aconf->port &= ~OPER_FLAG_DIE;
1368 <  }
1369 < };
1370 <
1371 < oper_rehash: REHASH '=' TBOOL ';'
1234 >    block_state.port.value |= OPER_FLAG_KILL;
1235 > } | CONNECT ':' REMOTE
1236   {
1237    if (conf_parser_ctx.pass == 2)
1238 <  {
1239 <    if (yylval.number)
1376 <      yy_aconf->port |= OPER_FLAG_REHASH;
1377 <    else
1378 <      yy_aconf->port &= ~OPER_FLAG_REHASH;
1379 <  }
1380 < };
1381 <
1382 < oper_admin: ADMIN '=' TBOOL ';'
1238 >    block_state.port.value |= OPER_FLAG_CONNECT_REMOTE;
1239 > } | CONNECT
1240   {
1241    if (conf_parser_ctx.pass == 2)
1242 <  {
1243 <    if (yylval.number)
1387 <      yy_aconf->port |= OPER_FLAG_ADMIN;
1388 <    else
1389 <      yy_aconf->port &= ~OPER_FLAG_ADMIN;
1390 <  }
1391 < };
1392 <
1393 < oper_hidden_admin: HIDDEN_ADMIN '=' TBOOL ';'
1394 < {
1395 <  if (conf_parser_ctx.pass == 2)
1396 <  {
1397 <    if (yylval.number)
1398 <      yy_aconf->port |= OPER_FLAG_HIDDEN_ADMIN;
1399 <    else
1400 <      yy_aconf->port &= ~OPER_FLAG_HIDDEN_ADMIN;
1401 <  }
1402 < };
1403 <
1404 < oper_hidden_oper: HIDDEN_OPER '=' TBOOL ';'
1242 >    block_state.port.value |= OPER_FLAG_CONNECT;
1243 > } | SQUIT ':' REMOTE
1244   {
1245    if (conf_parser_ctx.pass == 2)
1246 <  {
1247 <    if (yylval.number)
1409 <      yy_aconf->port |= OPER_FLAG_HIDDEN_OPER;
1410 <    else
1411 <      yy_aconf->port &= ~OPER_FLAG_HIDDEN_OPER;
1412 <  }
1413 < };
1414 <
1415 < oper_operwall: T_OPERWALL '=' TBOOL ';'
1246 >    block_state.port.value |= OPER_FLAG_SQUIT_REMOTE;
1247 > } | SQUIT
1248   {
1249    if (conf_parser_ctx.pass == 2)
1250 <  {
1251 <    if (yylval.number)
1420 <      yy_aconf->port |= OPER_FLAG_OPERWALL;
1421 <    else
1422 <      yy_aconf->port &= ~OPER_FLAG_OPERWALL;
1423 <  }
1424 < };
1425 <
1426 < oper_flags: IRCD_FLAGS
1427 < {
1428 < } '='  oper_flags_items ';';
1429 <
1430 < oper_flags_items: oper_flags_items ',' oper_flags_item | oper_flags_item;
1431 < oper_flags_item: NOT { not_atom = 1; } oper_flags_item_atom
1432 <                | { not_atom = 0; } oper_flags_item_atom;
1433 <
1434 < oper_flags_item_atom: GLOBAL_KILL
1250 >    block_state.port.value |= OPER_FLAG_SQUIT;
1251 > } | KLINE
1252   {
1253    if (conf_parser_ctx.pass == 2)
1254 <  {
1255 <    if (not_atom)yy_aconf->port &= ~OPER_FLAG_GLOBAL_KILL;
1439 <    else yy_aconf->port |= OPER_FLAG_GLOBAL_KILL;
1440 <  }
1441 < } | REMOTE
1254 >    block_state.port.value |= OPER_FLAG_K;
1255 > } | UNKLINE
1256   {
1257    if (conf_parser_ctx.pass == 2)
1258 <  {
1259 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_REMOTE;
1446 <    else yy_aconf->port |= OPER_FLAG_REMOTE;
1447 <  }
1448 < } | KLINE
1258 >    block_state.port.value |= OPER_FLAG_UNKLINE;
1259 > } | T_DLINE
1260   {
1261    if (conf_parser_ctx.pass == 2)
1262 <  {
1263 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_K;
1453 <    else yy_aconf->port |= OPER_FLAG_K;
1454 <  }
1455 < } | UNKLINE
1262 >    block_state.port.value |= OPER_FLAG_DLINE;
1263 > } | T_UNDLINE
1264   {
1265    if (conf_parser_ctx.pass == 2)
1266 <  {
1459 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_UNKLINE;
1460 <    else yy_aconf->port |= OPER_FLAG_UNKLINE;
1461 <  }
1266 >    block_state.port.value |= OPER_FLAG_UNDLINE;
1267   } | XLINE
1268   {
1269    if (conf_parser_ctx.pass == 2)
1270 <  {
1466 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_X;
1467 <    else yy_aconf->port |= OPER_FLAG_X;
1468 <  }
1270 >    block_state.port.value |= OPER_FLAG_X;
1271   } | GLINE
1272   {
1273    if (conf_parser_ctx.pass == 2)
1274 <  {
1473 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_GLINE;
1474 <    else yy_aconf->port |= OPER_FLAG_GLINE;
1475 <  }
1274 >    block_state.port.value |= OPER_FLAG_GLINE;
1275   } | DIE
1276   {
1277    if (conf_parser_ctx.pass == 2)
1278 <  {
1279 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_DIE;
1280 <    else yy_aconf->port |= OPER_FLAG_DIE;
1281 <  }
1278 >    block_state.port.value |= OPER_FLAG_DIE;
1279 > } | T_RESTART
1280 > {
1281 >  if (conf_parser_ctx.pass == 2)
1282 >    block_state.port.value |= OPER_FLAG_RESTART;
1283   } | REHASH
1284   {
1285    if (conf_parser_ctx.pass == 2)
1286 <  {
1487 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_REHASH;
1488 <    else yy_aconf->port |= OPER_FLAG_REHASH;
1489 <  }
1286 >    block_state.port.value |= OPER_FLAG_REHASH;
1287   } | ADMIN
1288   {
1289    if (conf_parser_ctx.pass == 2)
1290 <  {
1291 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_ADMIN;
1495 <    else yy_aconf->port |= OPER_FLAG_ADMIN;
1496 <  }
1497 < } | HIDDEN_ADMIN
1290 >    block_state.port.value |= OPER_FLAG_ADMIN;
1291 > } | T_OPERWALL
1292   {
1293    if (conf_parser_ctx.pass == 2)
1294 <  {
1295 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_HIDDEN_ADMIN;
1502 <    else yy_aconf->port |= OPER_FLAG_HIDDEN_ADMIN;
1503 <  }
1504 < } | NICK_CHANGES
1294 >    block_state.port.value |= OPER_FLAG_OPERWALL;
1295 > } | T_GLOBOPS
1296   {
1297    if (conf_parser_ctx.pass == 2)
1298 <  {
1299 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_N;
1509 <    else yy_aconf->port |= OPER_FLAG_N;
1510 <  }
1511 < } | T_OPERWALL
1298 >    block_state.port.value |= OPER_FLAG_GLOBOPS;
1299 > } | T_WALLOPS
1300   {
1301    if (conf_parser_ctx.pass == 2)
1302 <  {
1303 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_OPERWALL;
1516 <    else yy_aconf->port |= OPER_FLAG_OPERWALL;
1517 <  }
1518 < } | OPER_SPY_T
1302 >    block_state.port.value |= OPER_FLAG_WALLOPS;
1303 > } | T_LOCOPS
1304   {
1305    if (conf_parser_ctx.pass == 2)
1306 <  {
1307 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_OPER_SPY;
1523 <    else yy_aconf->port |= OPER_FLAG_OPER_SPY;
1524 <  }
1525 < } | HIDDEN_OPER
1306 >    block_state.port.value |= OPER_FLAG_LOCOPS;
1307 > } | REMOTEBAN
1308   {
1309    if (conf_parser_ctx.pass == 2)
1310 <  {
1311 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_HIDDEN_OPER;
1530 <    else yy_aconf->port |= OPER_FLAG_HIDDEN_OPER;
1531 <  }
1532 < } | REMOTEBAN
1310 >    block_state.port.value |= OPER_FLAG_REMOTEBAN;
1311 > } | T_SET
1312   {
1313    if (conf_parser_ctx.pass == 2)
1314 <  {
1315 <    if (not_atom) yy_aconf->port &= ~OPER_FLAG_REMOTEBAN;
1537 <    else yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1538 <  }
1539 < } | ENCRYPTED
1314 >    block_state.port.value |= OPER_FLAG_SET;
1315 > } | MODULE
1316   {
1317    if (conf_parser_ctx.pass == 2)
1318 <  {
1543 <    if (not_atom) ClearConfEncrypted(yy_aconf);
1544 <    else SetConfEncrypted(yy_aconf);
1545 <  }
1318 >    block_state.port.value |= OPER_FLAG_MODULE;
1319   };
1320  
1321  
# Line 1551 | Line 1324 | oper_flags_item_atom: GLOBAL_KILL
1324   ***************************************************************************/
1325   class_entry: CLASS
1326   {
1327 <  if (conf_parser_ctx.pass == 1)
1328 <  {
1556 <    yy_conf = make_conf_item(CLASS_TYPE);
1557 <    yy_class = map_to_conf(yy_conf);
1558 <  }
1559 < } class_name_b '{' class_items '}' ';'
1560 < {
1561 <  if (conf_parser_ctx.pass == 1)
1562 <  {
1563 <    struct ConfItem *cconf = NULL;
1564 <    struct ClassItem *class = NULL;
1565 <
1566 <    if (yy_class_name == NULL)
1567 <      delete_conf_item(yy_conf);
1568 <    else
1569 <    {
1570 <      cconf = find_exact_name_conf(CLASS_TYPE, yy_class_name, NULL, NULL);
1571 <
1572 <      if (cconf != NULL)                /* The class existed already */
1573 <      {
1574 <        int user_count = 0;
1327 >  if (conf_parser_ctx.pass != 1)
1328 >    break;
1329  
1330 <        rebuild_cidr_class(cconf, yy_class);
1330 >  reset_block_state();
1331  
1332 <        class = map_to_conf(cconf);
1333 <
1334 <        user_count = class->curr_user_count;
1335 <        memcpy(class, yy_class, sizeof(*class));
1336 <        class->curr_user_count = user_count;
1337 <        class->active = 1;
1338 <
1339 <        delete_conf_item(yy_conf);
1340 <
1341 <        MyFree(cconf->name);            /* Allows case change of class name */
1342 <        cconf->name = yy_class_name;
1343 <      }
1344 <      else      /* Brand new class */
1345 <      {
1346 <        MyFree(yy_conf->name);          /* just in case it was allocated */
1347 <        yy_conf->name = yy_class_name;
1348 <        yy_class->active = 1;
1349 <      }
1350 <    }
1351 <
1352 <    yy_class_name = NULL;
1353 <  }
1332 >  block_state.ping_freq.value = DEFAULT_PINGFREQUENCY;
1333 >  block_state.con_freq.value  = DEFAULT_CONNECTFREQUENCY;
1334 >  block_state.max_total.value = MAXIMUM_LINKS_DEFAULT;
1335 >  block_state.max_sendq.value = DEFAULT_SENDQ;
1336 >  block_state.max_recvq.value = DEFAULT_RECVQ;
1337 > } '{' class_items '}' ';'
1338 > {
1339 >  struct ClassItem *class = NULL;
1340 >
1341 >  if (conf_parser_ctx.pass != 1)
1342 >    break;
1343 >
1344 >  if (!block_state.class.buf[0])
1345 >    break;
1346 >
1347 >  if (!(class = class_find(block_state.class.buf, 0)))
1348 >    class = class_make();
1349 >
1350 >  class->active = 1;
1351 >  MyFree(class->name);
1352 >  class->name = xstrdup(block_state.class.buf);
1353 >  class->ping_freq = block_state.ping_freq.value;
1354 >  class->max_perip = block_state.max_perip.value;
1355 >  class->con_freq = block_state.con_freq.value;
1356 >  class->max_total = block_state.max_total.value;
1357 >  class->max_global = block_state.max_global.value;
1358 >  class->max_local = block_state.max_local.value;
1359 >  class->max_ident = block_state.max_ident.value;
1360 >  class->max_sendq = block_state.max_sendq.value;
1361 >  class->max_recvq = block_state.max_recvq.value;
1362 >
1363 >  if (block_state.min_idle.value > block_state.max_idle.value)
1364 >  {
1365 >    block_state.min_idle.value = 0;
1366 >    block_state.max_idle.value = 0;
1367 >    block_state.flags.value &= ~CLASS_FLAGS_FAKE_IDLE;
1368 >  }
1369 >
1370 >  class->flags = block_state.flags.value;
1371 >  class->min_idle = block_state.min_idle.value;
1372 >  class->max_idle = block_state.max_idle.value;
1373 >
1374 >  if (class->number_per_cidr && block_state.number_per_cidr.value)
1375 >    if ((class->cidr_bitlen_ipv4 && block_state.cidr_bitlen_ipv4.value) ||
1376 >        (class->cidr_bitlen_ipv6 && block_state.cidr_bitlen_ipv6.value))
1377 >      if ((class->cidr_bitlen_ipv4 != block_state.cidr_bitlen_ipv4.value) ||
1378 >          (class->cidr_bitlen_ipv6 != block_state.cidr_bitlen_ipv6.value))
1379 >        rebuild_cidr_list(class);
1380 >
1381 >  class->cidr_bitlen_ipv4 = block_state.cidr_bitlen_ipv4.value;
1382 >  class->cidr_bitlen_ipv6 = block_state.cidr_bitlen_ipv6.value;
1383 >  class->number_per_cidr = block_state.number_per_cidr.value;
1384   };
1385  
1602 class_name_b: | class_name_t;
1603
1386   class_items:    class_items class_item | class_item;
1387   class_item:     class_name |
1388                  class_cidr_bitlen_ipv4 | class_cidr_bitlen_ipv6 |
1389                  class_ping_time |
1608                class_ping_warning |
1390                  class_number_per_cidr |
1391                  class_number_per_ip |
1392                  class_connectfreq |
# Line 1613 | Line 1394 | class_item:     class_name |
1394                  class_max_global |
1395                  class_max_local |
1396                  class_max_ident |
1397 <                class_sendq |
1397 >                class_sendq | class_recvq |
1398 >                class_min_idle |
1399 >                class_max_idle |
1400 >                class_flags |
1401                  error ';' ;
1402  
1403   class_name: NAME '=' QSTRING ';'
1404   {
1405    if (conf_parser_ctx.pass == 1)
1406 <  {
1623 <    MyFree(yy_class_name);
1624 <    DupString(yy_class_name, yylval.string);
1625 <  }
1626 < };
1627 <
1628 < class_name_t: QSTRING
1629 < {
1630 <  if (conf_parser_ctx.pass == 1)
1631 <  {
1632 <    MyFree(yy_class_name);
1633 <    DupString(yy_class_name, yylval.string);
1634 <  }
1406 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1407   };
1408  
1409   class_ping_time: PING_TIME '=' timespec ';'
1410   {
1411    if (conf_parser_ctx.pass == 1)
1412 <    PingFreq(yy_class) = $3;
1641 < };
1642 <
1643 < class_ping_warning: PING_WARNING '=' timespec ';'
1644 < {
1645 <  if (conf_parser_ctx.pass == 1)
1646 <    PingWarning(yy_class) = $3;
1412 >    block_state.ping_freq.value = $3;
1413   };
1414  
1415   class_number_per_ip: NUMBER_PER_IP '=' NUMBER ';'
1416   {
1417    if (conf_parser_ctx.pass == 1)
1418 <    MaxPerIp(yy_class) = $3;
1418 >    block_state.max_perip.value = $3;
1419   };
1420  
1421   class_connectfreq: CONNECTFREQ '=' timespec ';'
1422   {
1423    if (conf_parser_ctx.pass == 1)
1424 <    ConFreq(yy_class) = $3;
1424 >    block_state.con_freq.value = $3;
1425   };
1426  
1427   class_max_number: MAX_NUMBER '=' NUMBER ';'
1428   {
1429    if (conf_parser_ctx.pass == 1)
1430 <    MaxTotal(yy_class) = $3;
1430 >    block_state.max_total.value = $3;
1431   };
1432  
1433   class_max_global: MAX_GLOBAL '=' NUMBER ';'
1434   {
1435    if (conf_parser_ctx.pass == 1)
1436 <    MaxGlobal(yy_class) = $3;
1436 >    block_state.max_global.value = $3;
1437   };
1438  
1439   class_max_local: MAX_LOCAL '=' NUMBER ';'
1440   {
1441    if (conf_parser_ctx.pass == 1)
1442 <    MaxLocal(yy_class) = $3;
1442 >    block_state.max_local.value = $3;
1443   };
1444  
1445   class_max_ident: MAX_IDENT '=' NUMBER ';'
1446   {
1447    if (conf_parser_ctx.pass == 1)
1448 <    MaxIdent(yy_class) = $3;
1448 >    block_state.max_ident.value = $3;
1449   };
1450  
1451   class_sendq: SENDQ '=' sizespec ';'
1452   {
1453    if (conf_parser_ctx.pass == 1)
1454 <    MaxSendq(yy_class) = $3;
1454 >    block_state.max_sendq.value = $3;
1455 > };
1456 >
1457 > class_recvq: T_RECVQ '=' sizespec ';'
1458 > {
1459 >  if (conf_parser_ctx.pass == 1)
1460 >    if ($3 >= CLIENT_FLOOD_MIN && $3 <= CLIENT_FLOOD_MAX)
1461 >      block_state.max_recvq.value = $3;
1462   };
1463  
1464   class_cidr_bitlen_ipv4: CIDR_BITLEN_IPV4 '=' NUMBER ';'
1465   {
1466    if (conf_parser_ctx.pass == 1)
1467 <    CidrBitlenIPV4(yy_class) = $3;
1467 >    block_state.cidr_bitlen_ipv4.value = $3 > 32 ? 32 : $3;
1468   };
1469  
1470   class_cidr_bitlen_ipv6: CIDR_BITLEN_IPV6 '=' NUMBER ';'
1471   {
1472    if (conf_parser_ctx.pass == 1)
1473 <    CidrBitlenIPV6(yy_class) = $3;
1473 >    block_state.cidr_bitlen_ipv6.value = $3 > 128 ? 128 : $3;
1474   };
1475  
1476   class_number_per_cidr: NUMBER_PER_CIDR '=' NUMBER ';'
1477   {
1478    if (conf_parser_ctx.pass == 1)
1479 <    NumberPerCidr(yy_class) = $3;
1479 >    block_state.number_per_cidr.value = $3;
1480   };
1481  
1482 + class_min_idle: MIN_IDLE '=' timespec ';'
1483 + {
1484 +  if (conf_parser_ctx.pass != 1)
1485 +    break;
1486 +
1487 +  block_state.min_idle.value = $3;
1488 +  block_state.flags.value |= CLASS_FLAGS_FAKE_IDLE;
1489 + };
1490 +
1491 + class_max_idle: MAX_IDLE '=' timespec ';'
1492 + {
1493 +  if (conf_parser_ctx.pass != 1)
1494 +    break;
1495 +
1496 +  block_state.max_idle.value = $3;
1497 +  block_state.flags.value |= CLASS_FLAGS_FAKE_IDLE;
1498 + };
1499 +
1500 + class_flags: IRCD_FLAGS
1501 + {
1502 +  if (conf_parser_ctx.pass == 1)
1503 +    block_state.flags.value &= CLASS_FLAGS_FAKE_IDLE;
1504 + } '='  class_flags_items ';';
1505 +
1506 + class_flags_items: class_flags_items ',' class_flags_item | class_flags_item;
1507 + class_flags_item: RANDOM_IDLE
1508 + {
1509 +  if (conf_parser_ctx.pass == 1)
1510 +    block_state.flags.value |= CLASS_FLAGS_RANDOM_IDLE;
1511 + } | HIDE_IDLE_FROM_OPERS
1512 + {
1513 +  if (conf_parser_ctx.pass == 1)
1514 +    block_state.flags.value |= CLASS_FLAGS_HIDE_IDLE_FROM_OPERS;
1515 + };
1516 +
1517 +
1518   /***************************************************************************
1519   *  section listen
1520   ***************************************************************************/
1521   listen_entry: LISTEN
1522   {
1523    if (conf_parser_ctx.pass == 2)
1524 <  {
1525 <    listener_address = NULL;
1717 <    listener_flags = 0;
1718 <  }
1719 < } '{' listen_items '}' ';'
1720 < {
1721 <  if (conf_parser_ctx.pass == 2)
1722 <  {
1723 <    MyFree(listener_address);
1724 <    listener_address = NULL;
1725 <  }
1726 < };
1524 >    reset_block_state();
1525 > } '{' listen_items '}' ';';
1526  
1527   listen_flags: IRCD_FLAGS
1528   {
1529 <  listener_flags = 0;
1529 >  block_state.flags.value = 0;
1530   } '='  listen_flags_items ';';
1531  
1532   listen_flags_items: listen_flags_items ',' listen_flags_item | listen_flags_item;
1533   listen_flags_item: T_SSL
1534   {
1535    if (conf_parser_ctx.pass == 2)
1536 <    listener_flags |= LISTENER_SSL;
1536 >    block_state.flags.value |= LISTENER_SSL;
1537   } | HIDDEN
1538   {
1539    if (conf_parser_ctx.pass == 2)
1540 <    listener_flags |= LISTENER_HIDDEN;
1540 >    block_state.flags.value |= LISTENER_HIDDEN;
1541   } | T_SERVER
1542   {
1543    if (conf_parser_ctx.pass == 2)
1544 <    listener_flags |= LISTENER_SERVER;
1544 >   block_state.flags.value |= LISTENER_SERVER;
1545   };
1546  
1748
1749
1547   listen_items:   listen_items listen_item | listen_item;
1548   listen_item:    listen_port | listen_flags | listen_address | listen_host | error ';';
1549  
1550 < listen_port: PORT '=' port_items { listener_flags = 0; } ';';
1550 > listen_port: PORT '=' port_items { block_state.flags.value = 0; } ';';
1551  
1552   port_items: port_items ',' port_item | port_item;
1553  
# Line 1758 | Line 1555 | port_item: NUMBER
1555   {
1556    if (conf_parser_ctx.pass == 2)
1557    {
1558 <    if ((listener_flags & LISTENER_SSL))
1558 >    if (block_state.flags.value & LISTENER_SSL)
1559   #ifdef HAVE_LIBCRYPTO
1560        if (!ServerInfo.server_ctx)
1561   #endif
1562        {
1563 <        yyerror("SSL not available - port closed");
1563 >        conf_error_report("SSL not available - port closed");
1564          break;
1565        }
1566 <    add_listener($1, listener_address, listener_flags);
1566 >    add_listener($1, block_state.addr.buf, block_state.flags.value);
1567    }
1568   } | NUMBER TWODOTS NUMBER
1569   {
# Line 1774 | Line 1571 | port_item: NUMBER
1571    {
1572      int i;
1573  
1574 <    if ((listener_flags & LISTENER_SSL))
1574 >    if (block_state.flags.value & LISTENER_SSL)
1575   #ifdef HAVE_LIBCRYPTO
1576        if (!ServerInfo.server_ctx)
1577   #endif
1578        {
1579 <        yyerror("SSL not available - port closed");
1579 >        conf_error_report("SSL not available - port closed");
1580          break;
1581        }
1582  
1583      for (i = $1; i <= $3; ++i)
1584 <      add_listener(i, listener_address, listener_flags);
1584 >      add_listener(i, block_state.addr.buf, block_state.flags.value);
1585    }
1586   };
1587  
1588   listen_address: IP '=' QSTRING ';'
1589   {
1590    if (conf_parser_ctx.pass == 2)
1591 <  {
1795 <    MyFree(listener_address);
1796 <    DupString(listener_address, yylval.string);
1797 <  }
1591 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
1592   };
1593  
1594   listen_host: HOST '=' QSTRING ';'
1595   {
1596    if (conf_parser_ctx.pass == 2)
1597 <  {
1804 <    MyFree(listener_address);
1805 <    DupString(listener_address, yylval.string);
1806 <  }
1597 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
1598   };
1599  
1600   /***************************************************************************
# Line 1812 | Line 1603 | listen_host: HOST '=' QSTRING ';'
1603   auth_entry: IRCD_AUTH
1604   {
1605    if (conf_parser_ctx.pass == 2)
1606 <  {
1816 <    yy_conf = make_conf_item(CLIENT_TYPE);
1817 <    yy_aconf = map_to_conf(yy_conf);
1818 <  }
1819 <  else
1820 <  {
1821 <    MyFree(class_name);
1822 <    class_name = NULL;
1823 <  }
1606 >    reset_block_state();
1607   } '{' auth_items '}' ';'
1608   {
1609 <  if (conf_parser_ctx.pass == 2)
1827 <  {
1828 <    struct CollectItem *yy_tmp = NULL;
1829 <    dlink_node *ptr = NULL, *next_ptr = NULL;
1830 <
1831 <    if (yy_aconf->user && yy_aconf->host)
1832 <    {
1833 <      conf_add_class_to_conf(yy_conf, class_name);
1834 <      add_conf_by_address(CONF_CLIENT, yy_aconf);
1835 <    }
1836 <    else
1837 <      delete_conf_item(yy_conf);
1838 <
1839 <    /* copy over settings from first struct */
1840 <    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
1841 <    {
1842 <      struct AccessItem *new_aconf;
1843 <      struct ConfItem *new_conf;
1844 <
1845 <      new_conf = make_conf_item(CLIENT_TYPE);
1846 <      new_aconf = map_to_conf(new_conf);
1847 <
1848 <      yy_tmp = ptr->data;
1609 >  dlink_node *ptr = NULL;
1610  
1611 <      assert(yy_tmp->user && yy_tmp->host);
1612 <
1852 <      if (yy_aconf->passwd != NULL)
1853 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1854 <      if (yy_conf->name != NULL)
1855 <        DupString(new_conf->name, yy_conf->name);
1856 <      if (yy_aconf->passwd != NULL)
1857 <        DupString(new_aconf->passwd, yy_aconf->passwd);
1858 <
1859 <      new_aconf->flags = yy_aconf->flags;
1860 <      new_aconf->port  = yy_aconf->port;
1861 <
1862 <      DupString(new_aconf->user, yy_tmp->user);
1863 <      collapse(new_aconf->user);
1864 <
1865 <      DupString(new_aconf->host, yy_tmp->host);
1866 <      collapse(new_aconf->host);
1867 <
1868 <      conf_add_class_to_conf(new_conf, class_name);
1869 <      add_conf_by_address(CONF_CLIENT, new_aconf);
1870 <      dlinkDelete(&yy_tmp->node, &col_conf_list);
1871 <      free_collect_item(yy_tmp);
1872 <    }
1873 <
1874 <    MyFree(class_name);
1875 <    class_name = NULL;
1876 <    yy_conf = NULL;
1877 <    yy_aconf = NULL;
1878 <  }
1879 < };
1611 >  if (conf_parser_ctx.pass != 2)
1612 >    break;
1613  
1614 < auth_items:     auth_items auth_item | auth_item;
1882 < auth_item:      auth_user | auth_passwd | auth_class | auth_flags |
1883 <                auth_kline_exempt | auth_need_ident |
1884 <                auth_exceed_limit | auth_no_tilde | auth_gline_exempt |
1885 <                auth_spoof | auth_spoof_notice |
1886 <                auth_redir_serv | auth_redir_port | auth_can_flood |
1887 <                auth_need_password | auth_encrypted | error ';' ;
1888 <
1889 < auth_user: USER '=' QSTRING ';'
1890 < {
1891 <  if (conf_parser_ctx.pass == 2)
1614 >  DLINK_FOREACH(ptr, block_state.mask.list.head)
1615    {
1616 <    struct CollectItem *yy_tmp = NULL;
1616 >    struct MaskItem *conf = NULL;
1617      struct split_nuh_item nuh;
1618  
1619 <    nuh.nuhmask  = yylval.string;
1619 >    nuh.nuhmask  = ptr->data;
1620      nuh.nickptr  = NULL;
1621 <    nuh.userptr  = userbuf;
1622 <    nuh.hostptr  = hostbuf;
1900 <
1621 >    nuh.userptr  = block_state.user.buf;
1622 >    nuh.hostptr  = block_state.host.buf;
1623      nuh.nicksize = 0;
1624 <    nuh.usersize = sizeof(userbuf);
1625 <    nuh.hostsize = sizeof(hostbuf);
1904 <
1624 >    nuh.usersize = sizeof(block_state.user.buf);
1625 >    nuh.hostsize = sizeof(block_state.host.buf);
1626      split_nuh(&nuh);
1627  
1628 <    if (yy_aconf->user == NULL)
1629 <    {
1630 <      DupString(yy_aconf->user, userbuf);
1631 <      DupString(yy_aconf->host, hostbuf);
1632 <    }
1633 <    else
1634 <    {
1635 <      yy_tmp = MyMalloc(sizeof(struct CollectItem));
1628 >    conf        = conf_make(CONF_CLIENT);
1629 >    conf->user  = xstrdup(block_state.user.buf);
1630 >    conf->host  = xstrdup(block_state.host.buf);
1631 >
1632 >    if (block_state.rpass.buf[0])
1633 >      conf->passwd = xstrdup(block_state.rpass.buf);
1634 >    if (block_state.name.buf[0])
1635 >      conf->name = xstrdup(block_state.name.buf);
1636  
1637 <      DupString(yy_tmp->user, userbuf);
1638 <      DupString(yy_tmp->host, hostbuf);
1637 >    conf->flags = block_state.flags.value;
1638 >    conf->port  = block_state.port.value;
1639  
1640 <      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
1641 <    }
1640 >    conf_add_class_to_conf(conf, block_state.class.buf);
1641 >    add_conf_by_address(CONF_CLIENT, conf);
1642    }
1643 < };
1643 > };
1644  
1645 < /* XXX - IP/IPV6 tags don't exist anymore - put IP/IPV6 into user. */
1645 > auth_items:     auth_items auth_item | auth_item;
1646 > auth_item:      auth_user | auth_passwd | auth_class | auth_flags |
1647 >                auth_spoof | auth_redir_serv | auth_redir_port |
1648 >                auth_encrypted | error ';' ;
1649  
1650 < auth_passwd: PASSWORD '=' QSTRING ';'
1650 > auth_user: USER '=' QSTRING ';'
1651   {
1652    if (conf_parser_ctx.pass == 2)
1653 <  {
1930 <    /* be paranoid */
1931 <    if (yy_aconf->passwd != NULL)
1932 <      memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
1933 <
1934 <    MyFree(yy_aconf->passwd);
1935 <    DupString(yy_aconf->passwd, yylval.string);
1936 <  }
1653 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1654   };
1655  
1656 < auth_spoof_notice: SPOOF_NOTICE '=' TBOOL ';'
1656 > auth_passwd: PASSWORD '=' QSTRING ';'
1657   {
1658    if (conf_parser_ctx.pass == 2)
1659 <  {
1943 <    if (yylval.number)
1944 <      yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1945 <    else
1946 <      yy_aconf->flags &= ~CONF_FLAGS_SPOOF_NOTICE;
1947 <  }
1659 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1660   };
1661  
1662   auth_class: CLASS '=' QSTRING ';'
1663   {
1664    if (conf_parser_ctx.pass == 2)
1665 <  {
1954 <    MyFree(class_name);
1955 <    DupString(class_name, yylval.string);
1956 <  }
1665 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
1666   };
1667  
1668   auth_encrypted: ENCRYPTED '=' TBOOL ';'
# Line 1961 | Line 1670 | auth_encrypted: ENCRYPTED '=' TBOOL ';'
1670    if (conf_parser_ctx.pass == 2)
1671    {
1672      if (yylval.number)
1673 <      SetConfEncrypted(yy_aconf);
1673 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
1674      else
1675 <      ClearConfEncrypted(yy_aconf);
1675 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
1676    }
1677   };
1678  
1679   auth_flags: IRCD_FLAGS
1680   {
1681 +  if (conf_parser_ctx.pass == 2)
1682 +    block_state.flags.value &= (CONF_FLAGS_ENCRYPTED | CONF_FLAGS_SPOOF_IP);
1683   } '='  auth_flags_items ';';
1684  
1685   auth_flags_items: auth_flags_items ',' auth_flags_item | auth_flags_item;
1686 < auth_flags_item: NOT { not_atom = 1; } auth_flags_item_atom
1976 <                | { not_atom = 0; } auth_flags_item_atom;
1977 <
1978 < auth_flags_item_atom: SPOOF_NOTICE
1686 > auth_flags_item: SPOOF_NOTICE
1687   {
1688    if (conf_parser_ctx.pass == 2)
1689 <  {
1982 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_SPOOF_NOTICE;
1983 <    else yy_aconf->flags |= CONF_FLAGS_SPOOF_NOTICE;
1984 <  }
1985 <
1689 >    block_state.flags.value |= CONF_FLAGS_SPOOF_NOTICE;
1690   } | EXCEED_LIMIT
1691   {
1692    if (conf_parser_ctx.pass == 2)
1693 <  {
1990 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NOLIMIT;
1991 <    else yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
1992 <  }
1693 >    block_state.flags.value |= CONF_FLAGS_NOLIMIT;
1694   } | KLINE_EXEMPT
1695   {
1696    if (conf_parser_ctx.pass == 2)
1697 <  {
1997 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTKLINE;
1998 <    else yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
1999 <  }
1697 >    block_state.flags.value |= CONF_FLAGS_EXEMPTKLINE;
1698   } | NEED_IDENT
1699   {
1700    if (conf_parser_ctx.pass == 2)
1701 <  {
2004 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NEED_IDENTD;
2005 <    else yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
2006 <  }
1701 >    block_state.flags.value |= CONF_FLAGS_NEED_IDENTD;
1702   } | CAN_FLOOD
1703   {
1704    if (conf_parser_ctx.pass == 2)
1705 <  {
2011 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_CAN_FLOOD;
2012 <    else yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
2013 <  }
2014 < } | CAN_IDLE
2015 < {
2016 <  if (conf_parser_ctx.pass == 2)
2017 <  {
2018 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_IDLE_LINED;
2019 <    else yy_aconf->flags |= CONF_FLAGS_IDLE_LINED;
2020 <  }
1705 >    block_state.flags.value |= CONF_FLAGS_CAN_FLOOD;
1706   } | NO_TILDE
1707   {
1708    if (conf_parser_ctx.pass == 2)
1709 <  {
2025 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NO_TILDE;
2026 <    else yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
2027 <  }
1709 >    block_state.flags.value |= CONF_FLAGS_NO_TILDE;
1710   } | GLINE_EXEMPT
1711   {
1712    if (conf_parser_ctx.pass == 2)
1713 <  {
2032 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTGLINE;
2033 <    else yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
2034 <  }
1713 >    block_state.flags.value |= CONF_FLAGS_EXEMPTGLINE;
1714   } | RESV_EXEMPT
1715   {
1716    if (conf_parser_ctx.pass == 2)
1717 <  {
1718 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_EXEMPTRESV;
2040 <    else yy_aconf->flags |= CONF_FLAGS_EXEMPTRESV;
2041 <  }
2042 < } | NEED_PASSWORD
2043 < {
2044 <  if (conf_parser_ctx.pass == 2)
2045 <  {
2046 <    if (not_atom) yy_aconf->flags &= ~CONF_FLAGS_NEED_PASSWORD;
2047 <    else yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
2048 <  }
2049 < };
2050 <
2051 < auth_kline_exempt: KLINE_EXEMPT '=' TBOOL ';'
2052 < {
2053 <  if (conf_parser_ctx.pass == 2)
2054 <  {
2055 <    if (yylval.number)
2056 <      yy_aconf->flags |= CONF_FLAGS_EXEMPTKLINE;
2057 <    else
2058 <      yy_aconf->flags &= ~CONF_FLAGS_EXEMPTKLINE;
2059 <  }
2060 < };
2061 <
2062 < auth_need_ident: NEED_IDENT '=' TBOOL ';'
2063 < {
2064 <  if (conf_parser_ctx.pass == 2)
2065 <  {
2066 <    if (yylval.number)
2067 <      yy_aconf->flags |= CONF_FLAGS_NEED_IDENTD;
2068 <    else
2069 <      yy_aconf->flags &= ~CONF_FLAGS_NEED_IDENTD;
2070 <  }
2071 < };
2072 <
2073 < auth_exceed_limit: EXCEED_LIMIT '=' TBOOL ';'
2074 < {
2075 <  if (conf_parser_ctx.pass == 2)
2076 <  {
2077 <    if (yylval.number)
2078 <      yy_aconf->flags |= CONF_FLAGS_NOLIMIT;
2079 <    else
2080 <      yy_aconf->flags &= ~CONF_FLAGS_NOLIMIT;
2081 <  }
2082 < };
2083 <
2084 < auth_can_flood: CAN_FLOOD '=' TBOOL ';'
2085 < {
2086 <  if (conf_parser_ctx.pass == 2)
2087 <  {
2088 <    if (yylval.number)
2089 <      yy_aconf->flags |= CONF_FLAGS_CAN_FLOOD;
2090 <    else
2091 <      yy_aconf->flags &= ~CONF_FLAGS_CAN_FLOOD;
2092 <  }
2093 < };
2094 <
2095 < auth_no_tilde: NO_TILDE '=' TBOOL ';'
1717 >    block_state.flags.value |= CONF_FLAGS_EXEMPTRESV;
1718 > } | T_WEBIRC
1719   {
1720    if (conf_parser_ctx.pass == 2)
1721 <  {
1722 <    if (yylval.number)
2100 <      yy_aconf->flags |= CONF_FLAGS_NO_TILDE;
2101 <    else
2102 <      yy_aconf->flags &= ~CONF_FLAGS_NO_TILDE;
2103 <  }
2104 < };
2105 <
2106 < auth_gline_exempt: GLINE_EXEMPT '=' TBOOL ';'
1721 >    block_state.flags.value |= CONF_FLAGS_WEBIRC;
1722 > } | NEED_PASSWORD
1723   {
1724    if (conf_parser_ctx.pass == 2)
1725 <  {
2110 <    if (yylval.number)
2111 <      yy_aconf->flags |= CONF_FLAGS_EXEMPTGLINE;
2112 <    else
2113 <      yy_aconf->flags &= ~CONF_FLAGS_EXEMPTGLINE;
2114 <  }
1725 >    block_state.flags.value |= CONF_FLAGS_NEED_PASSWORD;
1726   };
1727  
2117 /* XXX - need check for illegal hostnames here */
1728   auth_spoof: SPOOF '=' QSTRING ';'
1729   {
1730 <  if (conf_parser_ctx.pass == 2)
1731 <  {
2122 <    MyFree(yy_conf->name);
1730 >  if (conf_parser_ctx.pass != 2)
1731 >    break;
1732  
1733 <    if (strlen(yylval.string) < HOSTLEN)
1734 <    {    
1735 <      DupString(yy_conf->name, yylval.string);
1736 <      yy_aconf->flags |= CONF_FLAGS_SPOOF_IP;
2128 <    }
2129 <    else
2130 <    {
2131 <      ilog(L_ERROR, "Spoofs must be less than %d..ignoring it", HOSTLEN);
2132 <      yy_conf->name = NULL;
2133 <    }
1733 >  if (strlen(yylval.string) <= HOSTLEN && valid_hostname(yylval.string))
1734 >  {
1735 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1736 >    block_state.flags.value |= CONF_FLAGS_SPOOF_IP;
1737    }
1738 +  else
1739 +    ilog(LOG_TYPE_IRCD, "Spoof either is too long or contains invalid characters. Ignoring it.");
1740   };
1741  
1742   auth_redir_serv: REDIRSERV '=' QSTRING ';'
1743   {
1744 <  if (conf_parser_ctx.pass == 2)
1745 <  {
1746 <    yy_aconf->flags |= CONF_FLAGS_REDIR;
1747 <    MyFree(yy_conf->name);
1748 <    DupString(yy_conf->name, yylval.string);
2144 <  }
1744 >  if (conf_parser_ctx.pass != 2)
1745 >    break;
1746 >
1747 >  strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1748 >  block_state.flags.value |= CONF_FLAGS_REDIR;
1749   };
1750  
1751   auth_redir_port: REDIRPORT '=' NUMBER ';'
1752   {
1753 <  if (conf_parser_ctx.pass == 2)
1754 <  {
2151 <    yy_aconf->flags |= CONF_FLAGS_REDIR;
2152 <    yy_aconf->port = $3;
2153 <  }
2154 < };
1753 >  if (conf_parser_ctx.pass != 2)
1754 >    break;
1755  
1756 < auth_need_password: NEED_PASSWORD '=' TBOOL ';'
1757 < {
2158 <  if (conf_parser_ctx.pass == 2)
2159 <  {
2160 <    if (yylval.number)
2161 <      yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
2162 <    else
2163 <      yy_aconf->flags &= ~CONF_FLAGS_NEED_PASSWORD;
2164 <  }
1756 >  block_state.flags.value |= CONF_FLAGS_REDIR;
1757 >  block_state.port.value = $3;
1758   };
1759  
1760  
# Line 2170 | Line 1763 | auth_need_password: NEED_PASSWORD '=' TB
1763   ***************************************************************************/
1764   resv_entry: RESV
1765   {
1766 <  if (conf_parser_ctx.pass == 2)
1767 <  {
1768 <    MyFree(resv_reason);
1769 <    resv_reason = NULL;
1770 <  }
1766 >  if (conf_parser_ctx.pass != 2)
1767 >    break;
1768 >
1769 >  reset_block_state();
1770 >  strlcpy(block_state.rpass.buf, CONF_NOREASON, sizeof(block_state.rpass.buf));
1771   } '{' resv_items '}' ';'
1772   {
1773 <  if (conf_parser_ctx.pass == 2)
1774 <  {
1775 <    MyFree(resv_reason);
1776 <    resv_reason = NULL;
2184 <  }
1773 >  if (conf_parser_ctx.pass != 2)
1774 >    break;
1775 >
1776 >  create_resv(block_state.name.buf, block_state.rpass.buf, &block_state.mask.list);
1777   };
1778  
1779   resv_items:     resv_items resv_item | resv_item;
1780 < resv_item:      resv_creason | resv_channel | resv_nick | error ';' ;
1780 > resv_item:      resv_mask | resv_reason | resv_exempt | error ';' ;
1781  
1782 < resv_creason: REASON '=' QSTRING ';'
1782 > resv_mask: MASK '=' QSTRING ';'
1783   {
1784    if (conf_parser_ctx.pass == 2)
1785 <  {
2194 <    MyFree(resv_reason);
2195 <    DupString(resv_reason, yylval.string);
2196 <  }
1785 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1786   };
1787  
1788 < resv_channel: CHANNEL '=' QSTRING ';'
1788 > resv_reason: REASON '=' QSTRING ';'
1789   {
1790    if (conf_parser_ctx.pass == 2)
1791 <  {
2203 <    if (IsChanPrefix(*yylval.string))
2204 <    {
2205 <      char def_reason[] = "No reason";
2206 <
2207 <      create_channel_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
2208 <    }
2209 <  }
2210 <  /* ignore it for now.. but we really should make a warning if
2211 <   * its an erroneous name --fl_ */
1791 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
1792   };
1793  
1794 < resv_nick: NICK '=' QSTRING ';'
1794 > resv_exempt: EXEMPT '=' QSTRING ';'
1795   {
1796    if (conf_parser_ctx.pass == 2)
1797 <  {
1798 <    char def_reason[] = "No reason";
1797 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.mask.list);
1798 > };
1799 >
1800 >
1801 > /***************************************************************************
1802 > *  section service
1803 > ***************************************************************************/
1804 > service_entry: T_SERVICE '{' service_items '}' ';';
1805  
1806 <    create_nick_resv(yylval.string, resv_reason != NULL ? resv_reason : def_reason, 1);
1806 > service_items:     service_items service_item | service_item;
1807 > service_item:      service_name | error;
1808 >
1809 > service_name: NAME '=' QSTRING ';'
1810 > {
1811 >  if (conf_parser_ctx.pass != 2)
1812 >    break;
1813 >
1814 >  if (valid_servname(yylval.string))
1815 >  {
1816 >    struct MaskItem *conf = conf_make(CONF_SERVICE);
1817 >    conf->name = xstrdup(yylval.string);
1818    }
1819   };
1820  
# Line 2226 | Line 1823 | resv_nick: NICK '=' QSTRING ';'
1823   ***************************************************************************/
1824   shared_entry: T_SHARED
1825   {
1826 <  if (conf_parser_ctx.pass == 2)
1827 <  {
1828 <    yy_conf = make_conf_item(ULINE_TYPE);
1829 <    yy_match_item = map_to_conf(yy_conf);
1830 <    yy_match_item->action = SHARED_ALL;
1831 <  }
1826 >  if (conf_parser_ctx.pass != 2)
1827 >    break;
1828 >
1829 >  reset_block_state();
1830 >
1831 >  strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1832 >  strlcpy(block_state.user.buf, "*", sizeof(block_state.user.buf));
1833 >  strlcpy(block_state.host.buf, "*", sizeof(block_state.host.buf));
1834 >  block_state.flags.value = SHARED_ALL;
1835   } '{' shared_items '}' ';'
1836   {
1837 <  if (conf_parser_ctx.pass == 2)
1838 <  {
1839 <    yy_conf = NULL;
1840 <  }
1837 >  struct MaskItem *conf = NULL;
1838 >
1839 >  if (conf_parser_ctx.pass != 2)
1840 >    break;
1841 >
1842 >  conf = conf_make(CONF_ULINE);
1843 >  conf->flags = block_state.flags.value;
1844 >  conf->name = xstrdup(block_state.name.buf);
1845 >  conf->user = xstrdup(block_state.user.buf);
1846 >  conf->host = xstrdup(block_state.host.buf);
1847   };
1848  
1849   shared_items: shared_items shared_item | shared_item;
# Line 2246 | Line 1852 | shared_item:  shared_name | shared_user
1852   shared_name: NAME '=' QSTRING ';'
1853   {
1854    if (conf_parser_ctx.pass == 2)
1855 <  {
2250 <    MyFree(yy_conf->name);
2251 <    DupString(yy_conf->name, yylval.string);
2252 <  }
1855 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1856   };
1857  
1858   shared_user: USER '=' QSTRING ';'
# Line 2260 | Line 1863 | shared_user: USER '=' QSTRING ';'
1863  
1864      nuh.nuhmask  = yylval.string;
1865      nuh.nickptr  = NULL;
1866 <    nuh.userptr  = userbuf;
1867 <    nuh.hostptr  = hostbuf;
1866 >    nuh.userptr  = block_state.user.buf;
1867 >    nuh.hostptr  = block_state.host.buf;
1868  
1869      nuh.nicksize = 0;
1870 <    nuh.usersize = sizeof(userbuf);
1871 <    nuh.hostsize = sizeof(hostbuf);
1870 >    nuh.usersize = sizeof(block_state.user.buf);
1871 >    nuh.hostsize = sizeof(block_state.host.buf);
1872  
1873      split_nuh(&nuh);
2271
2272    DupString(yy_match_item->user, userbuf);
2273    DupString(yy_match_item->host, hostbuf);
1874    }
1875   };
1876  
1877   shared_type: TYPE
1878   {
1879    if (conf_parser_ctx.pass == 2)
1880 <    yy_match_item->action = 0;
1880 >    block_state.flags.value = 0;
1881   } '=' shared_types ';' ;
1882  
1883   shared_types: shared_types ',' shared_type_item | shared_type_item;
1884   shared_type_item: KLINE
1885   {
1886    if (conf_parser_ctx.pass == 2)
1887 <    yy_match_item->action |= SHARED_KLINE;
1888 < } | TKLINE
1887 >    block_state.flags.value |= SHARED_KLINE;
1888 > } | UNKLINE
1889   {
1890    if (conf_parser_ctx.pass == 2)
1891 <    yy_match_item->action |= SHARED_TKLINE;
1892 < } | UNKLINE
1891 >    block_state.flags.value |= SHARED_UNKLINE;
1892 > } | T_DLINE
1893   {
1894    if (conf_parser_ctx.pass == 2)
1895 <    yy_match_item->action |= SHARED_UNKLINE;
1896 < } | XLINE
1895 >    block_state.flags.value |= SHARED_DLINE;
1896 > } | T_UNDLINE
1897   {
1898    if (conf_parser_ctx.pass == 2)
1899 <    yy_match_item->action |= SHARED_XLINE;
1900 < } | TXLINE
1899 >    block_state.flags.value |= SHARED_UNDLINE;
1900 > } | XLINE
1901   {
1902    if (conf_parser_ctx.pass == 2)
1903 <    yy_match_item->action |= SHARED_TXLINE;
1903 >    block_state.flags.value |= SHARED_XLINE;
1904   } | T_UNXLINE
1905   {
1906    if (conf_parser_ctx.pass == 2)
1907 <    yy_match_item->action |= SHARED_UNXLINE;
1907 >    block_state.flags.value |= SHARED_UNXLINE;
1908   } | RESV
1909   {
1910    if (conf_parser_ctx.pass == 2)
1911 <    yy_match_item->action |= SHARED_RESV;
2312 < } | TRESV
2313 < {
2314 <  if (conf_parser_ctx.pass == 2)
2315 <    yy_match_item->action |= SHARED_TRESV;
1911 >    block_state.flags.value |= SHARED_RESV;
1912   } | T_UNRESV
1913   {
1914    if (conf_parser_ctx.pass == 2)
1915 <    yy_match_item->action |= SHARED_UNRESV;
1915 >    block_state.flags.value |= SHARED_UNRESV;
1916   } | T_LOCOPS
1917   {
1918    if (conf_parser_ctx.pass == 2)
1919 <    yy_match_item->action |= SHARED_LOCOPS;
1919 >    block_state.flags.value |= SHARED_LOCOPS;
1920   } | T_ALL
1921   {
1922    if (conf_parser_ctx.pass == 2)
1923 <    yy_match_item->action = SHARED_ALL;
1923 >    block_state.flags.value = SHARED_ALL;
1924   };
1925  
1926   /***************************************************************************
# Line 2332 | Line 1928 | shared_type_item: KLINE
1928   ***************************************************************************/
1929   cluster_entry: T_CLUSTER
1930   {
1931 <  if (conf_parser_ctx.pass == 2)
1932 <  {
1933 <    yy_conf = make_conf_item(CLUSTER_TYPE);
1934 <    yy_conf->flags = SHARED_ALL;
1935 <  }
1931 >  if (conf_parser_ctx.pass != 2)
1932 >    break;
1933 >
1934 >  reset_block_state();
1935 >
1936 >  strlcpy(block_state.name.buf, "*", sizeof(block_state.name.buf));
1937 >  block_state.flags.value = SHARED_ALL;
1938   } '{' cluster_items '}' ';'
1939   {
1940 <  if (conf_parser_ctx.pass == 2)
1941 <  {
1942 <    if (yy_conf->name == NULL)
1943 <      DupString(yy_conf->name, "*");
1944 <    yy_conf = NULL;
1945 <  }
1940 >  struct MaskItem *conf = NULL;
1941 >
1942 >  if (conf_parser_ctx.pass != 2)
1943 >    break;
1944 >
1945 >  conf = conf_make(CONF_CLUSTER);
1946 >  conf->flags = block_state.flags.value;
1947 >  conf->name = xstrdup(block_state.name.buf);
1948   };
1949  
1950   cluster_items:  cluster_items cluster_item | cluster_item;
# Line 2353 | Line 1953 | cluster_item:  cluster_name | cluster_typ
1953   cluster_name: NAME '=' QSTRING ';'
1954   {
1955    if (conf_parser_ctx.pass == 2)
1956 <    DupString(yy_conf->name, yylval.string);
1956 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
1957   };
1958  
1959   cluster_type: TYPE
1960   {
1961    if (conf_parser_ctx.pass == 2)
1962 <    yy_conf->flags = 0;
1962 >    block_state.flags.value = 0;
1963   } '=' cluster_types ';' ;
1964  
1965   cluster_types:  cluster_types ',' cluster_type_item | cluster_type_item;
1966   cluster_type_item: KLINE
1967   {
1968    if (conf_parser_ctx.pass == 2)
1969 <    yy_conf->flags |= SHARED_KLINE;
1970 < } | TKLINE
1969 >    block_state.flags.value |= SHARED_KLINE;
1970 > } | UNKLINE
1971   {
1972    if (conf_parser_ctx.pass == 2)
1973 <    yy_conf->flags |= SHARED_TKLINE;
1974 < } | UNKLINE
1973 >    block_state.flags.value |= SHARED_UNKLINE;
1974 > } | T_DLINE
1975   {
1976    if (conf_parser_ctx.pass == 2)
1977 <    yy_conf->flags |= SHARED_UNKLINE;
1978 < } | XLINE
1977 >    block_state.flags.value |= SHARED_DLINE;
1978 > } | T_UNDLINE
1979   {
1980    if (conf_parser_ctx.pass == 2)
1981 <    yy_conf->flags |= SHARED_XLINE;
1982 < } | TXLINE
1981 >    block_state.flags.value |= SHARED_UNDLINE;
1982 > } | XLINE
1983   {
1984    if (conf_parser_ctx.pass == 2)
1985 <    yy_conf->flags |= SHARED_TXLINE;
1985 >    block_state.flags.value |= SHARED_XLINE;
1986   } | T_UNXLINE
1987   {
1988    if (conf_parser_ctx.pass == 2)
1989 <    yy_conf->flags |= SHARED_UNXLINE;
1989 >    block_state.flags.value |= SHARED_UNXLINE;
1990   } | RESV
1991   {
1992    if (conf_parser_ctx.pass == 2)
1993 <    yy_conf->flags |= SHARED_RESV;
2394 < } | TRESV
2395 < {
2396 <  if (conf_parser_ctx.pass == 2)
2397 <    yy_conf->flags |= SHARED_TRESV;
1993 >    block_state.flags.value |= SHARED_RESV;
1994   } | T_UNRESV
1995   {
1996    if (conf_parser_ctx.pass == 2)
1997 <    yy_conf->flags |= SHARED_UNRESV;
1997 >    block_state.flags.value |= SHARED_UNRESV;
1998   } | T_LOCOPS
1999   {
2000    if (conf_parser_ctx.pass == 2)
2001 <    yy_conf->flags |= SHARED_LOCOPS;
2001 >    block_state.flags.value |= SHARED_LOCOPS;
2002   } | T_ALL
2003   {
2004    if (conf_parser_ctx.pass == 2)
2005 <    yy_conf->flags = SHARED_ALL;
2005 >    block_state.flags.value = SHARED_ALL;
2006   };
2007  
2008   /***************************************************************************
# Line 2414 | Line 2010 | cluster_type_item: KLINE
2010   ***************************************************************************/
2011   connect_entry: CONNECT  
2012   {
2417  if (conf_parser_ctx.pass == 2)
2418  {
2419    yy_conf = make_conf_item(SERVER_TYPE);
2420    yy_aconf = (struct AccessItem *)map_to_conf(yy_conf);
2421    yy_aconf->passwd = NULL;
2422    /* defaults */
2423    yy_aconf->port = PORTNUM;
2013  
2014 <    if (ConfigFileEntry.burst_away)
2015 <      yy_aconf->flags = CONF_FLAGS_BURST_AWAY;
2427 <  }
2428 <  else
2429 <  {
2430 <    MyFree(class_name);
2431 <    class_name = NULL;
2432 <  }
2433 < } connect_name_b '{' connect_items '}' ';'
2434 < {
2435 <  if (conf_parser_ctx.pass == 2)
2436 <  {
2437 <    struct CollectItem *yy_hconf=NULL;
2438 <    struct CollectItem *yy_lconf=NULL;
2439 <    dlink_node *ptr;
2440 <    dlink_node *next_ptr;
2441 < #ifdef HAVE_LIBCRYPTO
2442 <    if (yy_aconf->host &&
2443 <        ((yy_aconf->passwd && yy_aconf->spasswd) ||
2444 <         (yy_aconf->rsa_public_key && IsConfCryptLink(yy_aconf))))
2445 < #else /* !HAVE_LIBCRYPTO */
2446 <      if (yy_aconf->host && !IsConfCryptLink(yy_aconf) &&
2447 <          yy_aconf->passwd && yy_aconf->spasswd)
2448 < #endif /* !HAVE_LIBCRYPTO */
2449 <        {
2450 <          if (conf_add_server(yy_conf, class_name) == -1)
2451 <          {
2452 <            delete_conf_item(yy_conf);
2453 <            yy_conf = NULL;
2454 <            yy_aconf = NULL;
2455 <          }
2456 <        }
2457 <        else
2458 <        {
2459 <          /* Even if yy_conf ->name is NULL
2460 <           * should still unhook any hub/leaf confs still pending
2461 <           */
2462 <          unhook_hub_leaf_confs();
2463 <
2464 <          if (yy_conf->name != NULL)
2465 <          {
2466 < #ifndef HAVE_LIBCRYPTO
2467 <            if (IsConfCryptLink(yy_aconf))
2468 <              yyerror("Ignoring connect block -- no OpenSSL support");
2469 < #else
2470 <            if (IsConfCryptLink(yy_aconf) && !yy_aconf->rsa_public_key)
2471 <              yyerror("Ignoring connect block -- missing key");
2472 < #endif
2473 <            if (yy_aconf->host == NULL)
2474 <              yyerror("Ignoring connect block -- missing host");
2475 <            else if (!IsConfCryptLink(yy_aconf) &&
2476 <                    (!yy_aconf->passwd || !yy_aconf->spasswd))
2477 <              yyerror("Ignoring connect block -- missing password");
2478 <          }
2479 <
2480 <
2481 <          /* XXX
2482 <           * This fixes a try_connections() core (caused by invalid class_ptr
2483 <           * pointers) reported by metalrock. That's an ugly fix, but there
2484 <           * is currently no better way. The entire config subsystem needs an
2485 <           * rewrite ASAP. make_conf_item() shouldn't really add things onto
2486 <           * a doubly linked list immediately without any sanity checks!  -Michael
2487 <           */
2488 <          delete_conf_item(yy_conf);
2489 <
2490 <          yy_aconf = NULL;
2491 <          yy_conf = NULL;
2492 <        }
2493 <
2494 <      /*
2495 <       * yy_conf is still pointing at the server that is having
2496 <       * a connect block built for it. This means, y_aconf->name
2497 <       * points to the actual irc name this server will be known as.
2498 <       * Now this new server has a set or even just one hub_mask (or leaf_mask)
2499 <       * given in the link list at yy_hconf. Fill in the HUB confs
2500 <       * from this link list now.
2501 <       */        
2502 <      DLINK_FOREACH_SAFE(ptr, next_ptr, hub_conf_list.head)
2503 <      {
2504 <        struct ConfItem *new_hub_conf;
2505 <        struct MatchItem *match_item;
2014 >  if (conf_parser_ctx.pass != 2)
2015 >    break;
2016  
2017 <        yy_hconf = ptr->data;
2017 >  reset_block_state();
2018 >  block_state.port.value = PORTNUM;
2019 > } '{' connect_items '}' ';'
2020 > {
2021 >  struct MaskItem *conf = NULL;
2022 >  struct addrinfo hints, *res;
2023 >
2024 >  if (conf_parser_ctx.pass != 2)
2025 >    break;
2026 >
2027 >  if (!block_state.name.buf[0] ||
2028 >      !block_state.host.buf[0])
2029 >    break;
2030 >
2031 >  if (!block_state.rpass.buf[0] ||
2032 >      !block_state.spass.buf[0])
2033 >    break;
2034 >
2035 >  if (has_wildcards(block_state.name.buf) ||
2036 >      has_wildcards(block_state.host.buf))
2037 >    break;
2038 >
2039 >  conf = conf_make(CONF_SERVER);
2040 >  conf->port = block_state.port.value;
2041 >  conf->flags = block_state.flags.value;
2042 >  conf->aftype = block_state.aftype.value;
2043 >  conf->host = xstrdup(block_state.host.buf);
2044 >  conf->name = xstrdup(block_state.name.buf);
2045 >  conf->passwd = xstrdup(block_state.rpass.buf);
2046 >  conf->spasswd = xstrdup(block_state.spass.buf);
2047 >  conf->cipher_list = xstrdup(block_state.ciph.buf);
2048  
2049 <        /* yy_conf == NULL is a fatal error for this connect block! */
2050 <        if ((yy_conf != NULL) && (yy_conf->name != NULL))
2511 <        {
2512 <          new_hub_conf = make_conf_item(HUB_TYPE);
2513 <          match_item = (struct MatchItem *)map_to_conf(new_hub_conf);
2514 <          DupString(new_hub_conf->name, yy_conf->name);
2515 <          if (yy_hconf->user != NULL)
2516 <            DupString(match_item->user, yy_hconf->user);
2517 <          else
2518 <            DupString(match_item->user, "*");
2519 <          if (yy_hconf->host != NULL)
2520 <            DupString(match_item->host, yy_hconf->host);
2521 <          else
2522 <            DupString(match_item->host, "*");
2523 <        }
2524 <        dlinkDelete(&yy_hconf->node, &hub_conf_list);
2525 <        free_collect_item(yy_hconf);
2526 <      }
2049 >  dlinkMoveList(&block_state.leaf.list, &conf->leaf_list);
2050 >  dlinkMoveList(&block_state.hub.list, &conf->hub_list);
2051  
2052 <      /* Ditto for the LEAF confs */
2052 >  if (block_state.bind.buf[0])
2053 >  {
2054 >    memset(&hints, 0, sizeof(hints));
2055  
2056 <      DLINK_FOREACH_SAFE(ptr, next_ptr, leaf_conf_list.head)
2057 <      {
2058 <        struct ConfItem *new_leaf_conf;
2533 <        struct MatchItem *match_item;
2056 >    hints.ai_family   = AF_UNSPEC;
2057 >    hints.ai_socktype = SOCK_STREAM;
2058 >    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
2059  
2060 <        yy_lconf = ptr->data;
2060 >    if (getaddrinfo(block_state.bind.buf, NULL, &hints, &res))
2061 >      ilog(LOG_TYPE_IRCD, "Invalid netmask for server vhost(%s)", block_state.bind.buf);
2062 >    else
2063 >    {
2064 >      assert(res != NULL);
2065  
2066 <        if ((yy_conf != NULL) && (yy_conf->name != NULL))
2067 <        {
2068 <          new_leaf_conf = make_conf_item(LEAF_TYPE);
2069 <          match_item = (struct MatchItem *)map_to_conf(new_leaf_conf);
2070 <          DupString(new_leaf_conf->name, yy_conf->name);
2542 <          if (yy_lconf->user != NULL)
2543 <            DupString(match_item->user, yy_lconf->user);
2544 <          else
2545 <            DupString(match_item->user, "*");
2546 <          if (yy_lconf->host != NULL)
2547 <            DupString(match_item->host, yy_lconf->host);
2548 <          else
2549 <            DupString(match_item->host, "*");
2550 <        }
2551 <        dlinkDelete(&yy_lconf->node, &leaf_conf_list);
2552 <        free_collect_item(yy_lconf);
2553 <      }
2554 <      MyFree(class_name);
2555 <      class_name = NULL;
2556 <      yy_conf = NULL;
2557 <      yy_aconf = NULL;
2066 >      memcpy(&conf->bind, res->ai_addr, res->ai_addrlen);
2067 >      conf->bind.ss.ss_family = res->ai_family;
2068 >      conf->bind.ss_len = res->ai_addrlen;
2069 >      freeaddrinfo(res);
2070 >    }
2071    }
2072 +
2073 +  conf_add_class_to_conf(conf, block_state.class.buf);
2074 +  lookup_confhost(conf);
2075   };
2076  
2561 connect_name_b: | connect_name_t;
2077   connect_items:  connect_items connect_item | connect_item;
2078   connect_item:   connect_name | connect_host | connect_vhost |
2079                  connect_send_password | connect_accept_password |
2080 <                connect_aftype | connect_port |
2081 <                connect_fakename | connect_flags | connect_hub_mask |
2082 <                connect_leaf_mask | connect_class | connect_auto |
2083 <                connect_encrypted | connect_compressed | connect_cryptlink |
2569 <                connect_rsa_public_key_file | connect_cipher_preference |
2570 <                connect_topicburst | error ';' ;
2080 >                connect_aftype | connect_port | connect_ssl_cipher_list |
2081 >                connect_flags | connect_hub_mask | connect_leaf_mask |
2082 >                connect_class | connect_encrypted |
2083 >                error ';' ;
2084  
2085   connect_name: NAME '=' QSTRING ';'
2086   {
2087    if (conf_parser_ctx.pass == 2)
2088 <  {
2576 <    if (yy_conf->name != NULL)
2577 <      yyerror("Multiple connect name entry");
2578 <
2579 <    MyFree(yy_conf->name);
2580 <    DupString(yy_conf->name, yylval.string);
2581 <  }
2582 < };
2583 <
2584 < connect_name_t: QSTRING
2585 < {
2586 <  if (conf_parser_ctx.pass == 2)
2587 <  {
2588 <    if (yy_conf->name != NULL)
2589 <      yyerror("Multiple connect name entry");
2590 <
2591 <    MyFree(yy_conf->name);
2592 <    DupString(yy_conf->name, yylval.string);
2593 <  }
2088 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
2089   };
2090  
2091   connect_host: HOST '=' QSTRING ';'
2092   {
2093    if (conf_parser_ctx.pass == 2)
2094 <  {
2600 <    MyFree(yy_aconf->host);
2601 <    DupString(yy_aconf->host, yylval.string);
2602 <  }
2094 >    strlcpy(block_state.host.buf, yylval.string, sizeof(block_state.host.buf));
2095   };
2096  
2097   connect_vhost: VHOST '=' QSTRING ';'
2098   {
2099    if (conf_parser_ctx.pass == 2)
2100 <  {
2609 <    struct addrinfo hints, *res;
2610 <
2611 <    memset(&hints, 0, sizeof(hints));
2612 <
2613 <    hints.ai_family   = AF_UNSPEC;
2614 <    hints.ai_socktype = SOCK_STREAM;
2615 <    hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;
2616 <
2617 <    if (irc_getaddrinfo(yylval.string, NULL, &hints, &res))
2618 <      ilog(L_ERROR, "Invalid netmask for server vhost(%s)", yylval.string);
2619 <    else
2620 <    {
2621 <      assert(res != NULL);
2622 <
2623 <      memcpy(&yy_aconf->my_ipnum, res->ai_addr, res->ai_addrlen);
2624 <      yy_aconf->my_ipnum.ss.ss_family = res->ai_family;
2625 <      yy_aconf->my_ipnum.ss_len = res->ai_addrlen;
2626 <      irc_freeaddrinfo(res);
2627 <    }
2628 <  }
2100 >    strlcpy(block_state.bind.buf, yylval.string, sizeof(block_state.bind.buf));
2101   };
2102  
2103   connect_send_password: SEND_PASSWORD '=' QSTRING ';'
2104   {
2105 <  if (conf_parser_ctx.pass == 2)
2106 <  {
2635 <    if ($3[0] == ':')
2636 <      yyerror("Server passwords cannot begin with a colon");
2637 <    else if (strchr($3, ' ') != NULL)
2638 <      yyerror("Server passwords cannot contain spaces");
2639 <    else {
2640 <      if (yy_aconf->spasswd != NULL)
2641 <        memset(yy_aconf->spasswd, 0, strlen(yy_aconf->spasswd));
2105 >  if (conf_parser_ctx.pass != 2)
2106 >    break;
2107  
2108 <      MyFree(yy_aconf->spasswd);
2109 <      DupString(yy_aconf->spasswd, yylval.string);
2110 <    }
2111 <  }
2108 >  if ($3[0] == ':')
2109 >    conf_error_report("Server passwords cannot begin with a colon");
2110 >  else if (strchr($3, ' ') != NULL)
2111 >    conf_error_report("Server passwords cannot contain spaces");
2112 >  else
2113 >    strlcpy(block_state.spass.buf, yylval.string, sizeof(block_state.spass.buf));
2114   };
2115  
2116   connect_accept_password: ACCEPT_PASSWORD '=' QSTRING ';'
2117   {
2118 <  if (conf_parser_ctx.pass == 2)
2119 <  {
2653 <    if ($3[0] == ':')
2654 <      yyerror("Server passwords cannot begin with a colon");
2655 <    else if (strchr($3, ' ') != NULL)
2656 <      yyerror("Server passwords cannot contain spaces");
2657 <    else {
2658 <      if (yy_aconf->passwd != NULL)
2659 <        memset(yy_aconf->passwd, 0, strlen(yy_aconf->passwd));
2118 >  if (conf_parser_ctx.pass != 2)
2119 >    break;
2120  
2121 <      MyFree(yy_aconf->passwd);
2122 <      DupString(yy_aconf->passwd, yylval.string);
2123 <    }
2124 <  }
2121 >  if ($3[0] == ':')
2122 >    conf_error_report("Server passwords cannot begin with a colon");
2123 >  else if (strchr($3, ' ') != NULL)
2124 >    conf_error_report("Server passwords cannot contain spaces");
2125 >  else
2126 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2127   };
2128  
2129   connect_port: PORT '=' NUMBER ';'
2130   {
2131    if (conf_parser_ctx.pass == 2)
2132 <    yy_aconf->port = $3;
2132 >    block_state.port.value = $3;
2133   };
2134  
2135   connect_aftype: AFTYPE '=' T_IPV4 ';'
2136   {
2137    if (conf_parser_ctx.pass == 2)
2138 <    yy_aconf->aftype = AF_INET;
2138 >    block_state.aftype.value = AF_INET;
2139   } | AFTYPE '=' T_IPV6 ';'
2140   {
2141   #ifdef IPV6
2142    if (conf_parser_ctx.pass == 2)
2143 <    yy_aconf->aftype = AF_INET6;
2143 >    block_state.aftype.value = AF_INET6;
2144   #endif
2145   };
2146  
2685 connect_fakename: FAKENAME '=' QSTRING ';'
2686 {
2687  if (conf_parser_ctx.pass == 2)
2688  {
2689    MyFree(yy_aconf->fakename);
2690    DupString(yy_aconf->fakename, yylval.string);
2691  }
2692 };
2693
2147   connect_flags: IRCD_FLAGS
2148   {
2149 +  block_state.flags.value &= CONF_FLAGS_ENCRYPTED;
2150   } '='  connect_flags_items ';';
2151  
2152   connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;
2153 < connect_flags_item: NOT  { not_atom = 1; } connect_flags_item_atom
2700 <                        |  { not_atom = 0; } connect_flags_item_atom;
2701 <
2702 < connect_flags_item_atom: COMPRESSED
2703 < {
2704 <  if (conf_parser_ctx.pass == 2)
2705 < #ifndef HAVE_LIBZ
2706 <    yyerror("Ignoring flags = compressed; -- no zlib support");
2707 < #else
2708 < {
2709 <   if (not_atom)ClearConfCompressed(yy_aconf);
2710 <   else SetConfCompressed(yy_aconf);
2711 < }
2712 < #endif
2713 < } | CRYPTLINK
2714 < {
2715 <  if (conf_parser_ctx.pass == 2)
2716 <  {
2717 <    if (not_atom)ClearConfCryptLink(yy_aconf);
2718 <    else SetConfCryptLink(yy_aconf);
2719 <  }
2720 < } | AUTOCONN
2153 > connect_flags_item: AUTOCONN
2154   {
2155    if (conf_parser_ctx.pass == 2)
2156 <  {
2157 <    if (not_atom)ClearConfAllowAutoConn(yy_aconf);
2725 <    else SetConfAllowAutoConn(yy_aconf);
2726 <  }
2727 < } | BURST_AWAY
2156 >    block_state.flags.value |= CONF_FLAGS_ALLOW_AUTO_CONN;
2157 > } | T_SSL
2158   {
2159    if (conf_parser_ctx.pass == 2)
2160 <  {
2731 <    if (not_atom)ClearConfAwayBurst(yy_aconf);
2732 <    else SetConfAwayBurst(yy_aconf);
2733 <  }
2734 < } | TOPICBURST
2735 < {
2736 <  if (conf_parser_ctx.pass == 2)
2737 <  {
2738 <    if (not_atom)ClearConfTopicBurst(yy_aconf);
2739 <    else SetConfTopicBurst(yy_aconf);
2740 <  }
2741 < }
2742 < ;
2743 <
2744 < connect_rsa_public_key_file: RSA_PUBLIC_KEY_FILE '=' QSTRING ';'
2745 < {
2746 < #ifdef HAVE_LIBCRYPTO
2747 <  if (conf_parser_ctx.pass == 2)
2748 <  {
2749 <    BIO *file;
2750 <
2751 <    if (yy_aconf->rsa_public_key != NULL)
2752 <    {
2753 <      RSA_free(yy_aconf->rsa_public_key);
2754 <      yy_aconf->rsa_public_key = NULL;
2755 <    }
2756 <
2757 <    if (yy_aconf->rsa_public_key_file != NULL)
2758 <    {
2759 <      MyFree(yy_aconf->rsa_public_key_file);
2760 <      yy_aconf->rsa_public_key_file = NULL;
2761 <    }
2762 <
2763 <    DupString(yy_aconf->rsa_public_key_file, yylval.string);
2764 <
2765 <    if ((file = BIO_new_file(yylval.string, "r")) == NULL)
2766 <    {
2767 <      yyerror("Ignoring rsa_public_key_file -- file doesn't exist");
2768 <      break;
2769 <    }
2770 <
2771 <    yy_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
2772 <
2773 <    if (yy_aconf->rsa_public_key == NULL)
2774 <    {
2775 <      yyerror("Ignoring rsa_public_key_file -- Key invalid; check key syntax.");
2776 <      break;
2777 <    }
2778 <      
2779 <    BIO_set_close(file, BIO_CLOSE);
2780 <    BIO_free(file);
2781 <  }
2782 < #endif /* HAVE_LIBCRYPTO */
2160 >    block_state.flags.value |= CONF_FLAGS_SSL;
2161   };
2162  
2163   connect_encrypted: ENCRYPTED '=' TBOOL ';'
# Line 2787 | Line 2165 | connect_encrypted: ENCRYPTED '=' TBOOL '
2165    if (conf_parser_ctx.pass == 2)
2166    {
2167      if (yylval.number)
2168 <      yy_aconf->flags |= CONF_FLAGS_ENCRYPTED;
2168 >      block_state.flags.value |= CONF_FLAGS_ENCRYPTED;
2169      else
2170 <      yy_aconf->flags &= ~CONF_FLAGS_ENCRYPTED;
2793 <  }
2794 < };
2795 <
2796 < connect_cryptlink: CRYPTLINK '=' TBOOL ';'
2797 < {
2798 <  if (conf_parser_ctx.pass == 2)
2799 <  {
2800 <    if (yylval.number)
2801 <      yy_aconf->flags |= CONF_FLAGS_CRYPTLINK;
2802 <    else
2803 <      yy_aconf->flags &= ~CONF_FLAGS_CRYPTLINK;
2804 <  }
2805 < };
2806 <
2807 < connect_compressed: COMPRESSED '=' TBOOL ';'
2808 < {
2809 <  if (conf_parser_ctx.pass == 2)
2810 <  {
2811 <    if (yylval.number)
2812 < #ifndef HAVE_LIBZ
2813 <      yyerror("Ignoring compressed=yes; -- no zlib support");
2814 < #else
2815 <      yy_aconf->flags |= CONF_FLAGS_COMPRESSED;
2816 < #endif
2817 <    else
2818 <      yy_aconf->flags &= ~CONF_FLAGS_COMPRESSED;
2819 <  }
2820 < };
2821 <
2822 < connect_auto: AUTOCONN '=' TBOOL ';'
2823 < {
2824 <  if (conf_parser_ctx.pass == 2)
2825 <  {
2826 <    if (yylval.number)
2827 <      yy_aconf->flags |= CONF_FLAGS_ALLOW_AUTO_CONN;
2828 <    else
2829 <      yy_aconf->flags &= ~CONF_FLAGS_ALLOW_AUTO_CONN;
2830 <  }
2831 < };
2832 <
2833 < connect_topicburst: TOPICBURST '=' TBOOL ';'
2834 < {
2835 <  if (conf_parser_ctx.pass == 2)
2836 <  {
2837 <    if (yylval.number)
2838 <      SetConfTopicBurst(yy_aconf);
2839 <    else
2840 <      ClearConfTopicBurst(yy_aconf);
2170 >      block_state.flags.value &= ~CONF_FLAGS_ENCRYPTED;
2171    }
2172   };
2173  
2174   connect_hub_mask: HUB_MASK '=' QSTRING ';'
2175   {
2176    if (conf_parser_ctx.pass == 2)
2177 <  {
2848 <    struct CollectItem *yy_tmp;
2849 <
2850 <    yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2851 <    DupString(yy_tmp->host, yylval.string);
2852 <    DupString(yy_tmp->user, "*");
2853 <    dlinkAdd(yy_tmp, &yy_tmp->node, &hub_conf_list);
2854 <  }
2177 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.hub.list);
2178   };
2179  
2180   connect_leaf_mask: LEAF_MASK '=' QSTRING ';'
2181   {
2182    if (conf_parser_ctx.pass == 2)
2183 <  {
2861 <    struct CollectItem *yy_tmp;
2862 <
2863 <    yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2864 <    DupString(yy_tmp->host, yylval.string);
2865 <    DupString(yy_tmp->user, "*");
2866 <    dlinkAdd(yy_tmp, &yy_tmp->node, &leaf_conf_list);
2867 <  }
2183 >    dlinkAdd(xstrdup(yylval.string), make_dlink_node(), &block_state.leaf.list);
2184   };
2185  
2186   connect_class: CLASS '=' QSTRING ';'
2187   {
2188    if (conf_parser_ctx.pass == 2)
2189 <  {
2874 <    MyFree(class_name);
2875 <    DupString(class_name, yylval.string);
2876 <  }
2189 >    strlcpy(block_state.class.buf, yylval.string, sizeof(block_state.class.buf));
2190   };
2191  
2192 < connect_cipher_preference: CIPHER_PREFERENCE '=' QSTRING ';'
2192 > connect_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
2193   {
2194   #ifdef HAVE_LIBCRYPTO
2195    if (conf_parser_ctx.pass == 2)
2196 <  {
2884 <    struct EncCapability *ecap;
2885 <    const char *cipher_name;
2886 <    int found = 0;
2887 <
2888 <    yy_aconf->cipher_preference = NULL;
2889 <    cipher_name = yylval.string;
2890 <
2891 <    for (ecap = CipherTable; ecap->name; ecap++)
2892 <    {
2893 <      if ((irccmp(ecap->name, cipher_name) == 0) &&
2894 <          (ecap->cap & CAP_ENC_MASK))
2895 <      {
2896 <        yy_aconf->cipher_preference = ecap;
2897 <        found = 1;
2898 <        break;
2899 <      }
2900 <    }
2901 <
2902 <    if (!found)
2903 <      yyerror("Invalid cipher");
2904 <  }
2196 >    strlcpy(block_state.ciph.buf, yylval.string, sizeof(block_state.ciph.buf));
2197   #else
2198    if (conf_parser_ctx.pass == 2)
2199 <    yyerror("Ignoring cipher_preference -- no OpenSSL support");
2199 >    conf_error_report("Ignoring connect::ciphers -- no OpenSSL support");
2200   #endif
2201   };
2202  
2203 +
2204   /***************************************************************************
2205   *  section kill
2206   ***************************************************************************/
2207   kill_entry: KILL
2208   {
2209    if (conf_parser_ctx.pass == 2)
2210 <  {
2918 <    userbuf[0] = hostbuf[0] = reasonbuf[0] = '\0';
2919 <    regex_ban = 0;
2920 <  }
2210 >    reset_block_state();
2211   } '{' kill_items '}' ';'
2212   {
2213 <  if (conf_parser_ctx.pass == 2)
2924 <  {
2925 <    if (userbuf[0] && hostbuf[0])
2926 <    {
2927 <      if (regex_ban)
2928 <      {
2929 <        pcre *exp_user = NULL;
2930 <        pcre *exp_host = NULL;
2931 <        const char *errptr = NULL;
2932 <
2933 <        if (!(exp_user = ircd_pcre_compile(userbuf, &errptr)) ||
2934 <            !(exp_host = ircd_pcre_compile(hostbuf, &errptr)))
2935 <        {
2936 <          ilog(L_ERROR, "Failed to add regular expression based K-Line: %s",
2937 <               errptr);
2938 <          break;
2939 <        }
2940 <
2941 <        yy_conf = make_conf_item(RKLINE_TYPE);
2942 <        yy_aconf = map_to_conf(yy_conf);
2213 >  struct MaskItem *conf = NULL;
2214  
2215 <        yy_aconf->regexuser = exp_user;
2216 <        yy_aconf->regexhost = exp_host;
2215 >  if (conf_parser_ctx.pass != 2)
2216 >    break;
2217  
2218 <        DupString(yy_aconf->user, userbuf);
2219 <        DupString(yy_aconf->host, hostbuf);
2218 >  if (!block_state.user.buf[0] ||
2219 >      !block_state.host.buf[0])
2220 >    break;
2221  
2222 <        if (reasonbuf[0])
2223 <          DupString(yy_aconf->reason, reasonbuf);
2224 <        else
2953 <          DupString(yy_aconf->reason, "No reason");
2954 <      }
2955 <      else
2956 <      {
2957 <        yy_conf = make_conf_item(KLINE_TYPE);
2958 <        yy_aconf = map_to_conf(yy_conf);
2959 <
2960 <        DupString(yy_aconf->user, userbuf);
2961 <        DupString(yy_aconf->host, hostbuf);
2962 <
2963 <        if (reasonbuf[0])
2964 <          DupString(yy_aconf->reason, reasonbuf);
2965 <        else
2966 <          DupString(yy_aconf->reason, "No reason");
2967 <        add_conf_by_address(CONF_KILL, yy_aconf);
2968 <      }
2969 <    }
2970 <    else
2971 <      delete_conf_item(yy_conf);
2222 >  conf = conf_make(CONF_KLINE);
2223 >  conf->user = xstrdup(block_state.user.buf);
2224 >  conf->host = xstrdup(block_state.host.buf);
2225  
2226 <    yy_conf = NULL;
2227 <    yy_aconf = NULL;
2228 <  }
2226 >  if (block_state.rpass.buf[0])
2227 >    conf->reason = xstrdup(block_state.rpass.buf);
2228 >  else
2229 >    conf->reason = xstrdup(CONF_NOREASON);
2230 >  add_conf_by_address(CONF_KLINE, conf);
2231   };
2232  
2978 kill_type: TYPE
2979 {
2980 } '='  kill_type_items ';';
2981
2982 kill_type_items: kill_type_items ',' kill_type_item | kill_type_item;
2983 kill_type_item: REGEX_T
2984 {
2985  if (conf_parser_ctx.pass == 2)
2986    regex_ban = 1;
2987 };
2988
2233   kill_items:     kill_items kill_item | kill_item;
2234 < kill_item:      kill_user | kill_reason | kill_type | error;
2234 > kill_item:      kill_user | kill_reason | error;
2235  
2236   kill_user: USER '=' QSTRING ';'
2237   {
2238 +
2239    if (conf_parser_ctx.pass == 2)
2240    {
2241      struct split_nuh_item nuh;
2242  
2243      nuh.nuhmask  = yylval.string;
2244      nuh.nickptr  = NULL;
2245 <    nuh.userptr  = userbuf;
2246 <    nuh.hostptr  = hostbuf;
2245 >    nuh.userptr  = block_state.user.buf;
2246 >    nuh.hostptr  = block_state.host.buf;
2247  
2248      nuh.nicksize = 0;
2249 <    nuh.usersize = sizeof(userbuf);
2250 <    nuh.hostsize = sizeof(hostbuf);
2249 >    nuh.usersize = sizeof(block_state.user.buf);
2250 >    nuh.hostsize = sizeof(block_state.host.buf);
2251  
2252      split_nuh(&nuh);
2253    }
# Line 3011 | Line 2256 | kill_user: USER '=' QSTRING ';'
2256   kill_reason: REASON '=' QSTRING ';'
2257   {
2258    if (conf_parser_ctx.pass == 2)
2259 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2259 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2260   };
2261  
2262   /***************************************************************************
# Line 3020 | Line 2265 | kill_reason: REASON '=' QSTRING ';'
2265   deny_entry: DENY
2266   {
2267    if (conf_parser_ctx.pass == 2)
2268 <  {
3024 <    yy_conf = make_conf_item(DLINE_TYPE);
3025 <    yy_aconf = map_to_conf(yy_conf);
3026 <    /* default reason */
3027 <    DupString(yy_aconf->reason, "No reason");
3028 <  }
2268 >    reset_block_state();
2269   } '{' deny_items '}' ';'
2270   {
2271 <  if (conf_parser_ctx.pass == 2)
2271 >  struct MaskItem *conf = NULL;
2272 >
2273 >  if (conf_parser_ctx.pass != 2)
2274 >    break;
2275 >
2276 >  if (!block_state.addr.buf[0])
2277 >    break;
2278 >
2279 >  if (parse_netmask(block_state.addr.buf, NULL, NULL) != HM_HOST)
2280    {
2281 <    if (yy_aconf->host && parse_netmask(yy_aconf->host, NULL, NULL) != HM_HOST)
2282 <      add_conf_by_address(CONF_DLINE, yy_aconf);
2281 >    conf = conf_make(CONF_DLINE);
2282 >    conf->host = xstrdup(block_state.addr.buf);
2283 >
2284 >    if (block_state.rpass.buf[0])
2285 >      conf->reason = xstrdup(block_state.rpass.buf);
2286      else
2287 <      delete_conf_item(yy_conf);
2288 <    yy_conf = NULL;
3038 <    yy_aconf = NULL;
2287 >      conf->reason = xstrdup(CONF_NOREASON);
2288 >    add_conf_by_address(CONF_DLINE, conf);
2289    }
2290   };
2291  
# Line 3045 | Line 2295 | deny_item:      deny_ip | deny_reason |
2295   deny_ip: IP '=' QSTRING ';'
2296   {
2297    if (conf_parser_ctx.pass == 2)
2298 <  {
3049 <    MyFree(yy_aconf->host);
3050 <    DupString(yy_aconf->host, yylval.string);
3051 <  }
2298 >    strlcpy(block_state.addr.buf, yylval.string, sizeof(block_state.addr.buf));
2299   };
2300  
2301   deny_reason: REASON '=' QSTRING ';'
2302   {
2303    if (conf_parser_ctx.pass == 2)
2304 <  {
3058 <    MyFree(yy_aconf->reason);
3059 <    DupString(yy_aconf->reason, yylval.string);
3060 <  }
2304 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2305   };
2306  
2307   /***************************************************************************
# Line 3074 | Line 2318 | exempt_ip: IP '=' QSTRING ';'
2318    {
2319      if (yylval.string[0] && parse_netmask(yylval.string, NULL, NULL) != HM_HOST)
2320      {
2321 <      yy_conf = make_conf_item(EXEMPTDLINE_TYPE);
2322 <      yy_aconf = map_to_conf(yy_conf);
3079 <      DupString(yy_aconf->host, yylval.string);
2321 >      struct MaskItem *conf = conf_make(CONF_EXEMPT);
2322 >      conf->host = xstrdup(yylval.string);
2323  
2324 <      add_conf_by_address(CONF_EXEMPTDLINE, yy_aconf);
3082 <
3083 <      yy_conf = NULL;
3084 <      yy_aconf = NULL;
2324 >      add_conf_by_address(CONF_EXEMPT, conf);
2325      }
2326    }
2327   };
# Line 3092 | Line 2332 | exempt_ip: IP '=' QSTRING ';'
2332   gecos_entry: GECOS
2333   {
2334    if (conf_parser_ctx.pass == 2)
2335 <  {
3096 <    regex_ban = 0;
3097 <    reasonbuf[0] = gecos_name[0] = '\0';
3098 <  }
2335 >    reset_block_state();
2336   } '{' gecos_items '}' ';'
2337   {
2338 <  if (conf_parser_ctx.pass == 2)
3102 <  {
3103 <    if (gecos_name[0])
3104 <    {
3105 <      if (regex_ban)
3106 <      {
3107 <        pcre *exp_p = NULL;
3108 <        const char *errptr = NULL;
2338 >  struct MaskItem *conf = NULL;
2339  
2340 <        if (!(exp_p = ircd_pcre_compile(gecos_name, &errptr)))
2341 <        {
3112 <          ilog(L_ERROR, "Failed to add regular expression based X-Line: %s",
3113 <               errptr);
3114 <          break;
3115 <        }
3116 <
3117 <        yy_conf = make_conf_item(RXLINE_TYPE);
3118 <        yy_conf->regexpname = exp_p;
3119 <      }
3120 <      else
3121 <        yy_conf = make_conf_item(XLINE_TYPE);
2340 >  if (conf_parser_ctx.pass != 2)
2341 >    break;
2342  
2343 <      yy_match_item = map_to_conf(yy_conf);
2344 <      DupString(yy_conf->name, gecos_name);
3125 <
3126 <      if (reasonbuf[0])
3127 <        DupString(yy_match_item->reason, reasonbuf);
3128 <      else
3129 <        DupString(yy_match_item->reason, "No reason");
3130 <    }
3131 <  }
3132 < };
2343 >  if (!block_state.name.buf[0])
2344 >    break;
2345  
2346 < gecos_flags: TYPE
2347 < {
3136 < } '='  gecos_flags_items ';';
2346 >  conf = conf_make(CONF_XLINE);
2347 >  conf->name = xstrdup(block_state.name.buf);
2348  
2349 < gecos_flags_items: gecos_flags_items ',' gecos_flags_item | gecos_flags_item;
2350 < gecos_flags_item: REGEX_T
2351 < {
2352 <  if (conf_parser_ctx.pass == 2)
3142 <    regex_ban = 1;
2349 >  if (block_state.rpass.buf[0])
2350 >    conf->reason = xstrdup(block_state.rpass.buf);
2351 >  else
2352 >    conf->reason = xstrdup(CONF_NOREASON);
2353   };
2354  
2355   gecos_items: gecos_items gecos_item | gecos_item;
2356 < gecos_item:  gecos_name | gecos_reason | gecos_flags | error;
2356 > gecos_item:  gecos_name | gecos_reason | error;
2357  
2358   gecos_name: NAME '=' QSTRING ';'
2359   {
2360    if (conf_parser_ctx.pass == 2)
2361 <    strlcpy(gecos_name, yylval.string, sizeof(gecos_name));
2361 >    strlcpy(block_state.name.buf, yylval.string, sizeof(block_state.name.buf));
2362   };
2363  
2364   gecos_reason: REASON '=' QSTRING ';'
2365   {
2366    if (conf_parser_ctx.pass == 2)
2367 <    strlcpy(reasonbuf, yylval.string, sizeof(reasonbuf));
2367 >    strlcpy(block_state.rpass.buf, yylval.string, sizeof(block_state.rpass.buf));
2368   };
2369  
2370   /***************************************************************************
# Line 3169 | Line 2379 | general_item:       general_hide_spoof_i
2379                      general_max_nick_time | general_max_nick_changes |
2380                      general_max_accept | general_anti_spam_exit_message_time |
2381                      general_ts_warn_delta | general_ts_max_delta |
2382 <                    general_kill_chase_time_limit | general_kline_with_reason |
2383 <                    general_kline_reason | general_invisible_on_connect |
2382 >                    general_kill_chase_time_limit |
2383 >                    general_invisible_on_connect |
2384                      general_warn_no_nline | general_dots_in_ident |
2385                      general_stats_o_oper_only | general_stats_k_oper_only |
2386                      general_pace_wait | general_stats_i_oper_only |
2387                      general_pace_wait_simple | general_stats_P_oper_only |
2388                      general_short_motd | general_no_oper_flood |
2389                      general_true_no_oper_flood | general_oper_pass_resv |
3180                    general_idletime | general_message_locale |
2390                      general_oper_only_umodes | general_max_targets |
2391                      general_use_egd | general_egdpool_path |
2392                      general_oper_umodes | general_caller_id_wait |
2393                      general_opers_bypass_callerid | general_default_floodcount |
2394                      general_min_nonwildcard | general_min_nonwildcard_simple |
2395 <                    general_servlink_path | general_disable_remote_commands |
3187 <                    general_default_cipher_preference |
3188 <                    general_compression_level | general_client_flood |
2395 >                    general_disable_remote_commands |
2396                      general_throttle_time | general_havent_read_conf |
2397 <                    general_dot_in_ip6_addr | general_ping_cookie |
2398 <                    general_disable_auth | general_burst_away |
2399 <                    general_tkline_expire_notices | general_gline_min_cidr |
2400 <                    general_gline_min_cidr6 | general_use_whois_actually |
2401 <                    general_reject_hold_time | general_stats_e_disabled |
2402 <                    general_max_watch |
2397 >                    general_ping_cookie |
2398 >                    general_disable_auth |
2399 >                    general_tkline_expire_notices | general_gline_enable |
2400 >                    general_gline_duration | general_gline_request_duration |
2401 >                    general_gline_min_cidr |
2402 >                    general_gline_min_cidr6 |
2403 >                    general_stats_e_disabled |
2404 >                    general_max_watch | general_services_name |
2405                      error;
2406  
2407  
# Line 3201 | Line 2410 | general_max_watch: MAX_WATCH '=' NUMBER
2410    ConfigFileEntry.max_watch = $3;
2411   };
2412  
2413 < general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
2413 > general_gline_enable: GLINE_ENABLE '=' TBOOL ';'
2414   {
2415 <  ConfigFileEntry.gline_min_cidr = $3;
2415 >  if (conf_parser_ctx.pass == 2)
2416 >    ConfigFileEntry.glines = yylval.number;
2417   };
2418  
2419 < general_gline_min_cidr6: GLINE_MIN_CIDR6 '=' NUMBER ';'
2419 > general_gline_duration: GLINE_DURATION '=' timespec ';'
2420   {
2421 <  ConfigFileEntry.gline_min_cidr6 = $3;
2421 >  if (conf_parser_ctx.pass == 2)
2422 >    ConfigFileEntry.gline_time = $3;
2423   };
2424  
2425 < general_burst_away: BURST_AWAY '=' TBOOL ';'
2425 > general_gline_request_duration: GLINE_REQUEST_DURATION '=' timespec ';'
2426   {
2427 <  ConfigFileEntry.burst_away = yylval.number;
2427 >  if (conf_parser_ctx.pass == 2)
2428 >    ConfigFileEntry.gline_request_time = $3;
2429   };
2430  
2431 < general_use_whois_actually: USE_WHOIS_ACTUALLY '=' TBOOL ';'
2431 > general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
2432   {
2433 <  ConfigFileEntry.use_whois_actually = yylval.number;
2433 >  ConfigFileEntry.gline_min_cidr = $3;
2434   };
2435  
2436 < general_reject_hold_time: TREJECT_HOLD_TIME '=' timespec ';'
2436 > general_gline_min_cidr6: GLINE_MIN_CIDR6 '=' NUMBER ';'
2437   {
2438 <  GlobalSetOptions.rejecttime = yylval.number;
2438 >  ConfigFileEntry.gline_min_cidr6 = $3;
2439   };
2440  
2441   general_tkline_expire_notices: TKLINE_EXPIRE_NOTICES '=' TBOOL ';'
# Line 3231 | Line 2443 | general_tkline_expire_notices: TKLINE_EX
2443    ConfigFileEntry.tkline_expire_notices = yylval.number;
2444   };
2445  
2446 < general_kill_chase_time_limit: KILL_CHASE_TIME_LIMIT '=' NUMBER ';'
2446 > general_kill_chase_time_limit: KILL_CHASE_TIME_LIMIT '=' timespec ';'
2447   {
2448    ConfigFileEntry.kill_chase_time_limit = $3;
2449   };
# Line 3296 | Line 2508 | general_havent_read_conf: HAVENT_READ_CO
2508   {
2509    if (($3 > 0) && conf_parser_ctx.pass == 1)
2510    {
2511 <    ilog(L_CRIT, "You haven't read your config file properly.");
2512 <    ilog(L_CRIT, "There is a line in the example conf that will kill your server if not removed.");
2513 <    ilog(L_CRIT, "Consider actually reading/editing the conf file, and removing this line.");
2511 >    ilog(LOG_TYPE_IRCD, "You haven't read your config file properly.");
2512 >    ilog(LOG_TYPE_IRCD, "There is a line in the example conf that will kill your server if not removed.");
2513 >    ilog(LOG_TYPE_IRCD, "Consider actually reading/editing the conf file, and removing this line.");
2514      exit(0);
2515    }
2516   };
2517  
3306 general_kline_with_reason: KLINE_WITH_REASON '=' TBOOL ';'
3307 {
3308  ConfigFileEntry.kline_with_reason = yylval.number;
3309 };
3310
3311 general_kline_reason: KLINE_REASON '=' QSTRING ';'
3312 {
3313  if (conf_parser_ctx.pass == 2)
3314  {
3315    MyFree(ConfigFileEntry.kline_reason);
3316    DupString(ConfigFileEntry.kline_reason, yylval.string);
3317  }
3318 };
3319
2518   general_invisible_on_connect: INVISIBLE_ON_CONNECT '=' TBOOL ';'
2519   {
2520    ConfigFileEntry.invisible_on_connect = yylval.number;
# Line 3398 | Line 2596 | general_oper_pass_resv: OPER_PASS_RESV '
2596    ConfigFileEntry.oper_pass_resv = yylval.number;
2597   };
2598  
3401 general_message_locale: MESSAGE_LOCALE '=' QSTRING ';'
3402 {
3403  if (conf_parser_ctx.pass == 2)
3404  {
3405    if (strlen(yylval.string) > LOCALE_LENGTH-2)
3406      yylval.string[LOCALE_LENGTH-1] = '\0';
3407
3408    set_locale(yylval.string);
3409  }
3410 };
3411
3412 general_idletime: IDLETIME '=' timespec ';'
3413 {
3414  ConfigFileEntry.idletime = $3;
3415 };
3416
2599   general_dots_in_ident: DOTS_IN_IDENT '=' NUMBER ';'
2600   {
2601    ConfigFileEntry.dots_in_ident = $3;
# Line 3424 | Line 2606 | general_max_targets: MAX_TARGETS '=' NUM
2606    ConfigFileEntry.max_targets = $3;
2607   };
2608  
2609 < general_servlink_path: SERVLINK_PATH '=' QSTRING ';'
3428 < {
3429 <  if (conf_parser_ctx.pass == 2)
3430 <  {
3431 <    MyFree(ConfigFileEntry.servlink_path);
3432 <    DupString(ConfigFileEntry.servlink_path, yylval.string);
3433 <  }
3434 < };
3435 <
3436 < general_default_cipher_preference: DEFAULT_CIPHER_PREFERENCE '=' QSTRING ';'
2609 > general_use_egd: USE_EGD '=' TBOOL ';'
2610   {
2611 < #ifdef HAVE_LIBCRYPTO
3439 <  if (conf_parser_ctx.pass == 2)
3440 <  {
3441 <    struct EncCapability *ecap;
3442 <    const char *cipher_name;
3443 <    int found = 0;
3444 <
3445 <    ConfigFileEntry.default_cipher_preference = NULL;
3446 <    cipher_name = yylval.string;
3447 <
3448 <    for (ecap = CipherTable; ecap->name; ecap++)
3449 <    {
3450 <      if ((irccmp(ecap->name, cipher_name) == 0) &&
3451 <          (ecap->cap & CAP_ENC_MASK))
3452 <      {
3453 <        ConfigFileEntry.default_cipher_preference = ecap;
3454 <        found = 1;
3455 <        break;
3456 <      }
3457 <    }
3458 <
3459 <    if (!found)
3460 <      yyerror("Invalid cipher");
3461 <  }
3462 < #else
3463 <  if (conf_parser_ctx.pass == 2)
3464 <    yyerror("Ignoring default_cipher_preference -- no OpenSSL support");
3465 < #endif
2611 >  ConfigFileEntry.use_egd = yylval.number;
2612   };
2613  
2614 < general_compression_level: COMPRESSION_LEVEL '=' NUMBER ';'
2614 > general_egdpool_path: EGDPOOL_PATH '=' QSTRING ';'
2615   {
2616    if (conf_parser_ctx.pass == 2)
2617    {
2618 <    ConfigFileEntry.compression_level = $3;
2619 < #ifndef HAVE_LIBZ
3474 <    yyerror("Ignoring compression_level -- no zlib support");
3475 < #else
3476 <    if ((ConfigFileEntry.compression_level < 1) ||
3477 <        (ConfigFileEntry.compression_level > 9))
3478 <    {
3479 <      yyerror("Ignoring invalid compression_level, using default");
3480 <      ConfigFileEntry.compression_level = 0;
3481 <    }
3482 < #endif
2618 >    MyFree(ConfigFileEntry.egdpool_path);
2619 >    ConfigFileEntry.egdpool_path = xstrdup(yylval.string);
2620    }
2621   };
2622  
2623 < general_use_egd: USE_EGD '=' TBOOL ';'
3487 < {
3488 <  ConfigFileEntry.use_egd = yylval.number;
3489 < };
3490 <
3491 < general_egdpool_path: EGDPOOL_PATH '=' QSTRING ';'
2623 > general_services_name: T_SERVICES_NAME '=' QSTRING ';'
2624   {
2625 <  if (conf_parser_ctx.pass == 2)
2625 >  if (conf_parser_ctx.pass == 2 && valid_servname(yylval.string))
2626    {
2627 <    MyFree(ConfigFileEntry.egdpool_path);
2628 <    DupString(ConfigFileEntry.egdpool_path, yylval.string);
2627 >    MyFree(ConfigFileEntry.service_name);
2628 >    ConfigFileEntry.service_name = xstrdup(yylval.string);
2629    }
2630   };
2631  
# Line 3524 | Line 2656 | umode_oitem:     T_BOTS
2656   } | T_CCONN
2657   {
2658    ConfigFileEntry.oper_umodes |= UMODE_CCONN;
3527 } | T_CCONN_FULL
3528 {
3529  ConfigFileEntry.oper_umodes |= UMODE_CCONN_FULL;
2659   } | T_DEAF
2660   {
2661    ConfigFileEntry.oper_umodes |= UMODE_DEAF;
# Line 3536 | Line 2665 | umode_oitem:     T_BOTS
2665   } | T_FULL
2666   {
2667    ConfigFileEntry.oper_umodes |= UMODE_FULL;
2668 + } | HIDDEN
2669 + {
2670 +  ConfigFileEntry.oper_umodes |= UMODE_HIDDEN;
2671   } | T_SKILL
2672   {
2673    ConfigFileEntry.oper_umodes |= UMODE_SKILL;
# Line 3575 | Line 2707 | umode_oitem:     T_BOTS
2707   } | T_LOCOPS
2708   {
2709    ConfigFileEntry.oper_umodes |= UMODE_LOCOPS;
2710 + } | T_NONONREG
2711 + {
2712 +  ConfigFileEntry.oper_umodes |= UMODE_REGONLY;
2713 + } | T_FARCONNECT
2714 + {
2715 +  ConfigFileEntry.oper_umodes |= UMODE_FARCONNECT;
2716   };
2717  
2718   general_oper_only_umodes: OPER_ONLY_UMODES
# Line 3589 | Line 2727 | umode_item:    T_BOTS
2727   } | T_CCONN
2728   {
2729    ConfigFileEntry.oper_only_umodes |= UMODE_CCONN;
3592 } | T_CCONN_FULL
3593 {
3594  ConfigFileEntry.oper_only_umodes |= UMODE_CCONN_FULL;
2730   } | T_DEAF
2731   {
2732    ConfigFileEntry.oper_only_umodes |= UMODE_DEAF;
# Line 3604 | Line 2739 | umode_item:    T_BOTS
2739   } | T_SKILL
2740   {
2741    ConfigFileEntry.oper_only_umodes |= UMODE_SKILL;
2742 + } | HIDDEN
2743 + {
2744 +  ConfigFileEntry.oper_only_umodes |= UMODE_HIDDEN;
2745   } | T_NCHANGE
2746   {
2747    ConfigFileEntry.oper_only_umodes |= UMODE_NCHANGE;
# Line 3640 | Line 2778 | umode_item:    T_BOTS
2778   } | T_LOCOPS
2779   {
2780    ConfigFileEntry.oper_only_umodes |= UMODE_LOCOPS;
2781 + } | T_NONONREG
2782 + {
2783 +  ConfigFileEntry.oper_only_umodes |= UMODE_REGONLY;
2784 + } | T_FARCONNECT
2785 + {
2786 +  ConfigFileEntry.oper_only_umodes |= UMODE_FARCONNECT;
2787   };
2788  
2789   general_min_nonwildcard: MIN_NONWILDCARD '=' NUMBER ';'
# Line 3657 | Line 2801 | general_default_floodcount: DEFAULT_FLOO
2801    ConfigFileEntry.default_floodcount = $3;
2802   };
2803  
3660 general_client_flood: T_CLIENT_FLOOD '=' sizespec ';'
3661 {
3662  ConfigFileEntry.client_flood = $3;
3663 };
3664
3665 general_dot_in_ip6_addr: DOT_IN_IP6_ADDR '=' TBOOL ';'
3666 {
3667  ConfigFileEntry.dot_in_ip6_addr = yylval.number;
3668 };
3669
3670 /***************************************************************************
3671 *  section glines
3672 ***************************************************************************/
3673 gline_entry: GLINES
3674 {
3675  if (conf_parser_ctx.pass == 2)
3676  {
3677    yy_conf = make_conf_item(GDENY_TYPE);
3678    yy_aconf = map_to_conf(yy_conf);
3679  }
3680 } '{' gline_items '}' ';'
3681 {
3682  if (conf_parser_ctx.pass == 2)
3683  {
3684    /*
3685     * since we re-allocate yy_conf/yy_aconf after the end of action=, at the
3686     * end we will have one extra, so we should free it.
3687     */
3688    if (yy_conf->name == NULL || yy_aconf->user == NULL)
3689    {
3690      delete_conf_item(yy_conf);
3691      yy_conf = NULL;
3692      yy_aconf = NULL;
3693    }
3694  }
3695 };
3696
3697 gline_items:        gline_items gline_item | gline_item;
3698 gline_item:         gline_enable |
3699                    gline_duration |
3700                    gline_logging |
3701                    gline_user |
3702                    gline_server |
3703                    gline_action |
3704                    error;
3705
3706 gline_enable: ENABLE '=' TBOOL ';'
3707 {
3708  if (conf_parser_ctx.pass == 2)
3709    ConfigFileEntry.glines = yylval.number;
3710 };
3711
3712 gline_duration: DURATION '=' timespec ';'
3713 {
3714  if (conf_parser_ctx.pass == 2)
3715    ConfigFileEntry.gline_time = $3;
3716 };
3717
3718 gline_logging: LOGGING
3719 {
3720  if (conf_parser_ctx.pass == 2)
3721    ConfigFileEntry.gline_logging = 0;
3722 } '=' gline_logging_types ';';
3723 gline_logging_types:     gline_logging_types ',' gline_logging_type_item | gline_logging_type_item;
3724 gline_logging_type_item: T_REJECT
3725 {
3726  if (conf_parser_ctx.pass == 2)
3727    ConfigFileEntry.gline_logging |= GDENY_REJECT;
3728 } | T_BLOCK
3729 {
3730  if (conf_parser_ctx.pass == 2)
3731    ConfigFileEntry.gline_logging |= GDENY_BLOCK;
3732 };
3733
3734 gline_user: USER '=' QSTRING ';'
3735 {
3736  if (conf_parser_ctx.pass == 2)
3737  {
3738    struct split_nuh_item nuh;
3739
3740    nuh.nuhmask  = yylval.string;
3741    nuh.nickptr  = NULL;
3742    nuh.userptr  = userbuf;
3743    nuh.hostptr  = hostbuf;
3744
3745    nuh.nicksize = 0;
3746    nuh.usersize = sizeof(userbuf);
3747    nuh.hostsize = sizeof(hostbuf);
3748
3749    split_nuh(&nuh);
3750
3751    if (yy_aconf->user == NULL)
3752    {
3753      DupString(yy_aconf->user, userbuf);
3754      DupString(yy_aconf->host, hostbuf);
3755    }
3756    else
3757    {
3758      struct CollectItem *yy_tmp = MyMalloc(sizeof(struct CollectItem));
3759
3760      DupString(yy_tmp->user, userbuf);
3761      DupString(yy_tmp->host, hostbuf);
3762
3763      dlinkAdd(yy_tmp, &yy_tmp->node, &col_conf_list);
3764    }
3765  }
3766 };
3767
3768 gline_server: NAME '=' QSTRING ';'
3769 {
3770  if (conf_parser_ctx.pass == 2)  
3771  {
3772    MyFree(yy_conf->name);
3773    DupString(yy_conf->name, yylval.string);
3774  }
3775 };
3776
3777 gline_action: ACTION
3778 {
3779  if (conf_parser_ctx.pass == 2)
3780    yy_aconf->flags = 0;
3781 } '=' gdeny_types ';'
3782 {
3783  if (conf_parser_ctx.pass == 2)
3784  {
3785    struct CollectItem *yy_tmp = NULL;
3786    dlink_node *ptr, *next_ptr;
3787
3788    DLINK_FOREACH_SAFE(ptr, next_ptr, col_conf_list.head)
3789    {
3790      struct AccessItem *new_aconf;
3791      struct ConfItem *new_conf;
3792
3793      yy_tmp = ptr->data;
3794      new_conf = make_conf_item(GDENY_TYPE);
3795      new_aconf = map_to_conf(new_conf);
3796
3797      new_aconf->flags = yy_aconf->flags;
3798
3799      if (yy_conf->name != NULL)
3800        DupString(new_conf->name, yy_conf->name);
3801      else
3802        DupString(new_conf->name, "*");
3803      if (yy_aconf->user != NULL)
3804         DupString(new_aconf->user, yy_tmp->user);
3805      else  
3806        DupString(new_aconf->user, "*");
3807      if (yy_aconf->host != NULL)
3808        DupString(new_aconf->host, yy_tmp->host);
3809      else
3810        DupString(new_aconf->host, "*");
3811
3812      dlinkDelete(&yy_tmp->node, &col_conf_list);
3813    }
3814
3815    /*
3816     * In case someone has fed us with more than one action= after user/name
3817     * which would leak memory  -Michael
3818     */
3819    if (yy_conf->name == NULL || yy_aconf->user == NULL)
3820      delete_conf_item(yy_conf);
3821
3822    yy_conf = make_conf_item(GDENY_TYPE);
3823    yy_aconf = map_to_conf(yy_conf);
3824  }
3825 };
3826
3827 gdeny_types: gdeny_types ',' gdeny_type_item | gdeny_type_item;
3828 gdeny_type_item: T_REJECT
3829 {
3830  if (conf_parser_ctx.pass == 2)
3831    yy_aconf->flags |= GDENY_REJECT;
3832 } | T_BLOCK
3833 {
3834  if (conf_parser_ctx.pass == 2)
3835    yy_aconf->flags |= GDENY_BLOCK;
3836 };
2804  
2805   /***************************************************************************
2806   *  section channel
# Line 3842 | Line 2809 | channel_entry: CHANNEL
2809    '{' channel_items '}' ';';
2810  
2811   channel_items:      channel_items channel_item | channel_item;
2812 < channel_item:       channel_disable_local_channels | channel_use_except |
2813 <                    channel_use_invex | channel_use_knock |
2814 <                    channel_max_bans | channel_knock_delay |
2815 <                    channel_knock_delay_channel | channel_max_chans_per_user |
3849 <                    channel_quiet_on_ban | channel_default_split_user_count |
2812 > channel_item:       channel_max_bans |
2813 >                    channel_knock_delay | channel_knock_delay_channel |
2814 >                    channel_max_chans_per_user | channel_max_chans_per_oper |
2815 >                    channel_default_split_user_count |
2816                      channel_default_split_server_count |
2817 <                    channel_no_create_on_split | channel_restrict_channels |
2818 <                    channel_no_join_on_split | channel_burst_topicwho |
2817 >                    channel_no_create_on_split |
2818 >                    channel_no_join_on_split |
2819                      channel_jflood_count | channel_jflood_time |
2820                      channel_disable_fake_channels | error;
2821  
# Line 3858 | Line 2824 | channel_disable_fake_channels: DISABLE_F
2824    ConfigChannel.disable_fake_channels = yylval.number;
2825   };
2826  
3861 channel_restrict_channels: RESTRICT_CHANNELS '=' TBOOL ';'
3862 {
3863  ConfigChannel.restrict_channels = yylval.number;
3864 };
3865
3866 channel_disable_local_channels: DISABLE_LOCAL_CHANNELS '=' TBOOL ';'
3867 {
3868  ConfigChannel.disable_local_channels = yylval.number;
3869 };
3870
3871 channel_use_except: USE_EXCEPT '=' TBOOL ';'
3872 {
3873  ConfigChannel.use_except = yylval.number;
3874 };
3875
3876 channel_use_invex: USE_INVEX '=' TBOOL ';'
3877 {
3878  ConfigChannel.use_invex = yylval.number;
3879 };
3880
3881 channel_use_knock: USE_KNOCK '=' TBOOL ';'
3882 {
3883  ConfigChannel.use_knock = yylval.number;
3884 };
3885
2827   channel_knock_delay: KNOCK_DELAY '=' timespec ';'
2828   {
2829    ConfigChannel.knock_delay = $3;
# Line 3898 | Line 2839 | channel_max_chans_per_user: MAX_CHANS_PE
2839    ConfigChannel.max_chans_per_user = $3;
2840   };
2841  
2842 < channel_quiet_on_ban: QUIET_ON_BAN '=' TBOOL ';'
2842 > channel_max_chans_per_oper: MAX_CHANS_PER_OPER '=' NUMBER ';'
2843   {
2844 <  ConfigChannel.quiet_on_ban = yylval.number;
2844 >  ConfigChannel.max_chans_per_oper = $3;
2845   };
2846  
2847   channel_max_bans: MAX_BANS '=' NUMBER ';'
# Line 3928 | Line 2869 | channel_no_join_on_split: NO_JOIN_ON_SPL
2869    ConfigChannel.no_join_on_split = yylval.number;
2870   };
2871  
3931 channel_burst_topicwho: BURST_TOPICWHO '=' TBOOL ';'
3932 {
3933  ConfigChannel.burst_topicwho = yylval.number;
3934 };
3935
2872   channel_jflood_count: JOIN_FLOOD_COUNT '=' NUMBER ';'
2873   {
2874    GlobalSetOptions.joinfloodcount = yylval.number;
# Line 3951 | Line 2887 | serverhide_entry: SERVERHIDE
2887  
2888   serverhide_items:   serverhide_items serverhide_item | serverhide_item;
2889   serverhide_item:    serverhide_flatten_links | serverhide_hide_servers |
2890 +                    serverhide_hide_services |
2891                      serverhide_links_delay |
3955                    serverhide_disable_hidden |
2892                      serverhide_hidden | serverhide_hidden_name |
2893                      serverhide_hide_server_ips |
2894                      error;
# Line 3969 | Line 2905 | serverhide_hide_servers: HIDE_SERVERS '=
2905      ConfigServerHide.hide_servers = yylval.number;
2906   };
2907  
2908 + serverhide_hide_services: HIDE_SERVICES '=' TBOOL ';'
2909 + {
2910 +  if (conf_parser_ctx.pass == 2)
2911 +    ConfigServerHide.hide_services = yylval.number;
2912 + };
2913 +
2914   serverhide_hidden_name: HIDDEN_NAME '=' QSTRING ';'
2915   {
2916    if (conf_parser_ctx.pass == 2)
2917    {
2918      MyFree(ConfigServerHide.hidden_name);
2919 <    DupString(ConfigServerHide.hidden_name, yylval.string);
2919 >    ConfigServerHide.hidden_name = xstrdup(yylval.string);
2920    }
2921   };
2922  
# Line 3998 | Line 2940 | serverhide_hidden: HIDDEN '=' TBOOL ';'
2940      ConfigServerHide.hidden = yylval.number;
2941   };
2942  
4001 serverhide_disable_hidden: DISABLE_HIDDEN '=' TBOOL ';'
4002 {
4003  if (conf_parser_ctx.pass == 2)
4004    ConfigServerHide.disable_hidden = yylval.number;
4005 };
4006
2943   serverhide_hide_server_ips: HIDE_SERVER_IPS '=' TBOOL ';'
2944   {
2945    if (conf_parser_ctx.pass == 2)

Diff Legend

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