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

Diff Legend

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