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

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

Diff Legend

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