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 1622 by michael, Thu Nov 1 13:16:37 2012 UTC

# Line 1 | Line 1
1   /*
2   *  ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 < *  ircd_parser.y: Parses the ircd configuration file.
3 > *  conf_parser.y: Parses the ircd configuration file.
4   *
5   *  Copyright (C) 2005 by the past and present ircd coders, and others.
6   *
# Line 32 | Line 32
32   #include "stdinc.h"
33   #include "ircd.h"
34   #include "list.h"
35 < #include "s_conf.h"
35 > #include "conf.h"
36   #include "event.h"
37 < #include "s_log.h"
37 > #include "log.h"
38   #include "client.h"     /* for UMODE_ALL only */
39   #include "irc_string.h"
40   #include "sprintf_irc.h"
# Line 52 | Line 52
52   #include <openssl/rsa.h>
53   #include <openssl/bio.h>
54   #include <openssl/pem.h>
55 + #include <openssl/dh.h>
56   #endif
57  
58 + int yylex(void);
59 +
60   static char *class_name = NULL;
61   static struct ConfItem *yy_conf = NULL;
62   static struct AccessItem *yy_aconf = NULL;
# Line 62 | Line 65 | static struct ClassItem *yy_class = NULL
65   static char *yy_class_name = NULL;
66  
67   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 };
68   static unsigned int listener_flags = 0;
69   static unsigned int regex_ban = 0;
70   static char userbuf[IRCD_BUFSIZE];
# Line 104 | Line 105 | free_collect_item(struct CollectItem *it
105    MyFree(item);
106   }
107  
107 static void
108 unhook_hub_leaf_confs(void)
109 {
110  dlink_node *ptr;
111  dlink_node *next_ptr;
112  struct CollectItem *yy_hconf;
113  struct CollectItem *yy_lconf;
114
115  DLINK_FOREACH_SAFE(ptr, next_ptr, hub_conf_list.head)
116  {
117    yy_hconf = ptr->data;
118    dlinkDelete(&yy_hconf->node, &hub_conf_list);
119    free_collect_item(yy_hconf);
120  }
121
122  DLINK_FOREACH_SAFE(ptr, next_ptr, leaf_conf_list.head)
123  {
124    yy_lconf = ptr->data;
125    dlinkDelete(&yy_lconf->node, &leaf_conf_list);
126    free_collect_item(yy_lconf);
127  }
128 }
129
108   %}
109  
110   %union {
# Line 135 | Line 113 | unhook_hub_leaf_confs(void)
113   }
114  
115   %token  ACCEPT_PASSWORD
138 %token  ACTION
116   %token  ADMIN
117   %token  AFTYPE
141 %token  T_ALLOW
118   %token  ANTI_NICK_FLOOD
119   %token  ANTI_SPAM_EXIT_MESSAGE_TIME
120   %token  AUTOCONN
121 < %token  T_BLOCK
146 < %token  BURST_AWAY
147 < %token  BURST_TOPICWHO
148 < %token  BYTES KBYTES MBYTES GBYTES TBYTES
121 > %token  BYTES KBYTES MBYTES
122   %token  CALLER_ID_WAIT
123   %token  CAN_FLOOD
124   %token  CHANNEL
125   %token  CIDR_BITLEN_IPV4
126   %token  CIDR_BITLEN_IPV6
154 %token  CIPHER_PREFERENCE
127   %token  CLASS
156 %token  COMPRESSED
157 %token  COMPRESSION_LEVEL
128   %token  CONNECT
129   %token  CONNECTFREQ
160 %token  CRYPTLINK
161 %token  DEFAULT_CIPHER_PREFERENCE
130   %token  DEFAULT_FLOODCOUNT
131   %token  DEFAULT_SPLIT_SERVER_COUNT
132   %token  DEFAULT_SPLIT_USER_COUNT
# Line 167 | Line 135 | unhook_hub_leaf_confs(void)
135   %token  DIE
136   %token  DISABLE_AUTH
137   %token  DISABLE_FAKE_CHANNELS
170 %token  DISABLE_HIDDEN
171 %token  DISABLE_LOCAL_CHANNELS
138   %token  DISABLE_REMOTE_COMMANDS
139   %token  DOTS_IN_IDENT
174 %token  DURATION
140   %token  EGDPOOL_PATH
141   %token  EMAIL
177 %token  ENABLE
142   %token  ENCRYPTED
143   %token  EXCEED_LIMIT
144   %token  EXEMPT
# Line 184 | Line 148 | unhook_hub_leaf_confs(void)
148   %token  GECOS
149   %token  GENERAL
150   %token  GLINE
151 < %token  GLINES
151 > %token  GLINE_DURATION
152 > %token  GLINE_ENABLE
153   %token  GLINE_EXEMPT
154 < %token  GLINE_TIME
154 > %token  GLINE_REQUEST_DURATION
155   %token  GLINE_MIN_CIDR
156   %token  GLINE_MIN_CIDR6
157   %token  GLOBAL_KILL
# Line 194 | Line 159 | unhook_hub_leaf_confs(void)
159   %token  NEED_IDENT
160   %token  HAVENT_READ_CONF
161   %token  HIDDEN
197 %token  HIDDEN_ADMIN
162   %token  HIDDEN_NAME
199 %token  HIDDEN_OPER
163   %token  HIDE_SERVER_IPS
164   %token  HIDE_SERVERS
165   %token  HIDE_SPOOF_IPS
# Line 210 | Line 173 | unhook_hub_leaf_confs(void)
173   %token  KILL_CHASE_TIME_LIMIT
174   %token  KLINE
175   %token  KLINE_EXEMPT
213 %token  KLINE_REASON
214 %token  KLINE_WITH_REASON
176   %token  KNOCK_DELAY
177   %token  KNOCK_DELAY_CHANNEL
178   %token  LEAF_MASK
# Line 220 | Line 181 | unhook_hub_leaf_confs(void)
181   %token  T_LOG
182   %token  MAX_ACCEPT
183   %token  MAX_BANS
184 + %token  MAX_CHANS_PER_OPER
185   %token  MAX_CHANS_PER_USER
186   %token  MAX_GLOBAL
187   %token  MAX_IDENT
# Line 245 | Line 207 | unhook_hub_leaf_confs(void)
207   %token  NO_OPER_FLOOD
208   %token  NO_TILDE
209   %token  NUMBER
248 %token  NUMBER_PER_IDENT
210   %token  NUMBER_PER_CIDR
211   %token  NUMBER_PER_IP
251 %token  NUMBER_PER_IP_GLOBAL
212   %token  OPERATOR
213   %token  OPERS_BYPASS_CALLERID
214   %token  OPER_ONLY_UMODES
# Line 272 | Line 232 | unhook_hub_leaf_confs(void)
232   %token  REDIRSERV
233   %token  REGEX_T
234   %token  REHASH
275 %token  TREJECT_HOLD_TIME
235   %token  REMOTE
236   %token  REMOTEBAN
237   %token  RESTRICT_CHANNELS
279 %token  RESTRICTED
238   %token  RSA_PRIVATE_KEY_FILE
239   %token  RSA_PUBLIC_KEY_FILE
240   %token  SSL_CERTIFICATE_FILE
241 < %token  T_SSL_CONNECTION_METHOD
241 > %token  SSL_DH_PARAM_FILE
242 > %token  T_SSL_CLIENT_METHOD
243 > %token  T_SSL_SERVER_METHOD
244   %token  T_SSLV3
245   %token  T_TLSV1
246   %token  RESV
# Line 290 | Line 250 | unhook_hub_leaf_confs(void)
250   %token  SEND_PASSWORD
251   %token  SERVERHIDE
252   %token  SERVERINFO
293 %token  SERVLINK_PATH
253   %token  IRCD_SID
254   %token  TKLINE_EXPIRE_NOTICES
255   %token  T_SHARED
256   %token  T_CLUSTER
257   %token  TYPE
258   %token  SHORT_MOTD
300 %token  SILENT
259   %token  SPOOF
260   %token  SPOOF_NOTICE
261   %token  STATS_E_DISABLED
# Line 307 | Line 265 | unhook_hub_leaf_confs(void)
265   %token  STATS_P_OPER_ONLY
266   %token  TBOOL
267   %token  TMASKED
310 %token  T_REJECT
268   %token  TS_MAX_DELTA
269   %token  TS_WARN_DELTA
270   %token  TWODOTS
# Line 317 | Line 274 | unhook_hub_leaf_confs(void)
274   %token  T_CALLERID
275   %token  T_CCONN
276   %token  T_CCONN_FULL
277 < %token  T_CLIENT_FLOOD
277 > %token  T_SSL_CIPHER_LIST
278   %token  T_DEAF
279   %token  T_DEBUG
280   %token  T_DLINE
324 %token  T_DRONE
281   %token  T_EXTERNAL
282   %token  T_FULL
283   %token  T_INVISIBLE
# Line 331 | Line 287 | unhook_hub_leaf_confs(void)
287   %token  T_MAX_CLIENTS
288   %token  T_NCHANGE
289   %token  T_OPERWALL
290 + %token  T_RECVQ
291   %token  T_REJ
292   %token  T_SERVER
293   %token  T_SERVNOTICE
294 + %token  T_SET
295   %token  T_SKILL
296   %token  T_SPY
297   %token  T_SSL
298   %token  T_UMODES
299   %token  T_UNAUTH
300 + %token  T_UNDLINE
301   %token  T_UNLIMITED
302   %token  T_UNRESV
303   %token  T_UNXLINE
# Line 347 | Line 306 | unhook_hub_leaf_confs(void)
306   %token  T_RESTART
307   %token  T_SERVICE
308   %token  T_SERVICES_NAME
350 %token  T_TIMESTAMP
309   %token  THROTTLE_TIME
352 %token  TOPICBURST
310   %token  TRUE_NO_OPER_FLOOD
354 %token  TKLINE
355 %token  TXLINE
356 %token  TRESV
311   %token  UNKLINE
312   %token  USER
313   %token  USE_EGD
360 %token  USE_EXCEPT
361 %token  USE_INVEX
362 %token  USE_KNOCK
314   %token  USE_LOGGING
364 %token  USE_WHOIS_ACTUALLY
315   %token  VHOST
316   %token  VHOST6
317   %token  XLINE
368 %token  WARN
318   %token  WARN_NO_NLINE
319   %token  T_SIZE
320   %token  T_FILE
# Line 400 | Line 349 | conf_item:        admin_entry
349                  | deny_entry
350                  | exempt_entry
351                  | general_entry
403                | gline_entry
352                  | gecos_entry
353                  | modules_entry
354                  | error ';'
# Line 471 | Line 419 | serverinfo_items:       serverinfo_items
419   serverinfo_item:        serverinfo_name | serverinfo_vhost |
420                          serverinfo_hub | serverinfo_description |
421                          serverinfo_network_name | serverinfo_network_desc |
422 <                        serverinfo_max_clients |
422 >                        serverinfo_max_clients | serverinfo_ssl_dh_param_file |
423                          serverinfo_rsa_private_key_file | serverinfo_vhost6 |
424                          serverinfo_sid | serverinfo_ssl_certificate_file |
425 <                        serverinfo_ssl_connection_method |
425 >                        serverinfo_ssl_client_method | serverinfo_ssl_server_method |
426 >                        serverinfo_ssl_cipher_list |
427                          error ';' ;
428  
429  
430 < serverinfo_ssl_connection_method: T_SSL_CONNECTION_METHOD
430 > serverinfo_ssl_client_method: T_SSL_CLIENT_METHOD '=' client_method_types ';' ;
431 > serverinfo_ssl_server_method: T_SSL_SERVER_METHOD '=' server_method_types ';' ;
432 >
433 > client_method_types: client_method_types ',' client_method_type_item | client_method_type_item;
434 > client_method_type_item: T_SSLV3
435   {
436   #ifdef HAVE_LIBCRYPTO
437 <  if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
438 <    ServerInfo.tls_version = 0;
437 >  if (conf_parser_ctx.pass == 2 && ServerInfo.client_ctx)
438 >    SSL_CTX_clear_options(ServerInfo.client_ctx, SSL_OP_NO_SSLv3);
439   #endif
440 < } '=' method_types ';'
440 > } | T_TLSV1
441   {
442   #ifdef HAVE_LIBCRYPTO
443 <  if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
444 <  {
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 <  }
443 >  if (conf_parser_ctx.pass == 2 && ServerInfo.client_ctx)
444 >    SSL_CTX_clear_options(ServerInfo.client_ctx, SSL_OP_NO_TLSv1);
445   #endif
446   };
447  
448 < method_types: method_types ',' method_type_item | method_type_item;
449 < method_type_item: T_SSLV3
448 > server_method_types: server_method_types ',' server_method_type_item | server_method_type_item;
449 > server_method_type_item: T_SSLV3
450   {
451   #ifdef HAVE_LIBCRYPTO
452 <  if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
453 <    ServerInfo.tls_version |= CONF_SERVER_INFO_TLS_VERSION_SSLV3;
452 >  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
453 >    SSL_CTX_clear_options(ServerInfo.server_ctx, SSL_OP_NO_SSLv3);
454   #endif
455   } | T_TLSV1
456   {
457   #ifdef HAVE_LIBCRYPTO
458 <  if (conf_parser_ctx.boot && conf_parser_ctx.pass == 2)
459 <    ServerInfo.tls_version |= CONF_SERVER_INFO_TLS_VERSION_TLSV1;
458 >  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
459 >    SSL_CTX_clear_options(ServerInfo.server_ctx, SSL_OP_NO_TLSv1);
460   #endif
461   };
462  
# Line 524 | Line 472 | serverinfo_ssl_certificate_file: SSL_CER
472      }
473  
474      if (SSL_CTX_use_certificate_file(ServerInfo.server_ctx, yylval.string,
475 +                                     SSL_FILETYPE_PEM) <= 0 ||
476 +        SSL_CTX_use_certificate_file(ServerInfo.client_ctx, yylval.string,
477                                       SSL_FILETYPE_PEM) <= 0)
478      {
479        yyerror(ERR_lib_error_string(ERR_get_error()));
# Line 531 | Line 481 | serverinfo_ssl_certificate_file: SSL_CER
481      }
482  
483      if (SSL_CTX_use_PrivateKey_file(ServerInfo.server_ctx, ServerInfo.rsa_private_key_file,
484 +                                    SSL_FILETYPE_PEM) <= 0 ||
485 +        SSL_CTX_use_PrivateKey_file(ServerInfo.client_ctx, ServerInfo.rsa_private_key_file,
486                                      SSL_FILETYPE_PEM) <= 0)
487      {
488        yyerror(ERR_lib_error_string(ERR_get_error()));
489        break;
490      }
491  
492 <    if (!SSL_CTX_check_private_key(ServerInfo.server_ctx))
492 >    if (!SSL_CTX_check_private_key(ServerInfo.server_ctx) ||
493 >        !SSL_CTX_check_private_key(ServerInfo.client_ctx))
494      {
495        yyerror(ERR_lib_error_string(ERR_get_error()));
496        break;
# Line 573 | Line 526 | serverinfo_rsa_private_key_file: RSA_PRI
526        break;
527      }
528  
529 <    ServerInfo.rsa_private_key = (RSA *)PEM_read_bio_RSAPrivateKey(file, NULL,
577 <      0, NULL);
529 >    ServerInfo.rsa_private_key = PEM_read_bio_RSAPrivateKey(file, NULL, 0, NULL);
530  
531      BIO_set_close(file, BIO_CLOSE);
532      BIO_free(file);
# Line 606 | Line 558 | serverinfo_rsa_private_key_file: RSA_PRI
558   #endif
559   };
560  
561 + serverinfo_ssl_dh_param_file: SSL_DH_PARAM_FILE '=' QSTRING ';'
562 + {
563 + /* TBD - XXX: error reporting */
564 + #ifdef HAVE_LIBCRYPTO
565 +  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
566 +  {
567 +    BIO *file = BIO_new_file(yylval.string, "r");
568 +
569 +    if (file)
570 +    {
571 +      DH *dh = PEM_read_bio_DHparams(file, NULL, NULL, NULL);
572 +
573 +      BIO_free(file);
574 +
575 +      if (dh)
576 +      {
577 +        if (DH_size(dh) < 128)
578 +          ilog(LOG_TYPE_IRCD, "Ignoring serverinfo::ssl_dh_param_file -- need at least a 1024 bit DH prime size");
579 +        else
580 +          SSL_CTX_set_tmp_dh(ServerInfo.server_ctx, dh);
581 +
582 +        DH_free(dh);
583 +      }
584 +    }
585 +  }
586 + #endif
587 + };
588 +
589 + serverinfo_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
590 + {
591 + #ifdef HAVE_LIBCRYPTO
592 +  if (conf_parser_ctx.pass == 2 && ServerInfo.server_ctx)
593 +    SSL_CTX_set_cipher_list(ServerInfo.server_ctx, yylval.string);
594 + #endif
595 + };
596 +
597   serverinfo_name: NAME '=' QSTRING ';'
598   {
599    /* this isn't rehashable */
# Line 797 | Line 785 | admin_description: DESCRIPTION '=' QSTRI
785   logging_entry:          T_LOG  '{' logging_items '}' ';' ;
786   logging_items:          logging_items logging_item | logging_item ;
787  
788 < logging_item:           logging_use_logging | logging_timestamp | logging_file_entry |
788 > logging_item:           logging_use_logging | logging_file_entry |
789                          error ';' ;
790  
791   logging_use_logging: USE_LOGGING '=' TBOOL ';'
# Line 806 | Line 794 | logging_use_logging: USE_LOGGING '=' TBO
794      ConfigLoggingEntry.use_logging = yylval.number;
795   };
796  
809 logging_timestamp: T_TIMESTAMP '=' TBOOL ';'
810 {
811  if (conf_parser_ctx.pass == 2)
812    ConfigLoggingEntry.timestamp = yylval.number;
813 };
814
797   logging_file_entry:
798   {
799    lfile[0] = '\0';
# Line 896 | Line 878 | oper_entry: OPERATOR
878      MyFree(class_name);
879      class_name = NULL;
880    }
881 < } oper_name_b '{' oper_items '}' ';'
881 > } '{' oper_items '}' ';'
882   {
883    if (conf_parser_ctx.pass == 2)
884    {
# Line 931 | Line 913 | oper_entry: OPERATOR
913          DupString(new_aconf->host, yy_tmp->host);
914        else
915          DupString(new_aconf->host, "*");
916 +
917 +      new_aconf->type = parse_netmask(new_aconf->host, &new_aconf->addr,
918 +                                     &new_aconf->bits);
919 +
920        conf_add_class_to_conf(new_conf, class_name);
921        if (yy_aconf->passwd != NULL)
922          DupString(new_aconf->passwd, yy_aconf->passwd);
# Line 945 | Line 931 | oper_entry: OPERATOR
931                    yy_aconf->rsa_public_key_file);
932  
933          file = BIO_new_file(yy_aconf->rsa_public_key_file, "r");
934 <        new_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file,
934 >        new_aconf->rsa_public_key = PEM_read_bio_RSA_PUBKEY(file,
935                                                             NULL, 0, NULL);
936          BIO_set_close(file, BIO_CLOSE);
937          BIO_free(file);
# Line 977 | Line 963 | oper_entry: OPERATOR
963    }
964   };
965  
980 oper_name_b: | oper_name_t;
966   oper_items:     oper_items oper_item | oper_item;
967   oper_item:      oper_name | oper_user | oper_password |
968                  oper_umodes | oper_class | oper_encrypted |
# Line 987 | Line 972 | oper_name: NAME '=' QSTRING ';'
972   {
973    if (conf_parser_ctx.pass == 2)
974    {
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
975      MyFree(yy_conf->name);
976      DupString(yy_conf->name, yylval.string);
977    }
# Line 1028 | Line 998 | oper_user: USER '=' QSTRING ';'
998      {
999        DupString(yy_aconf->user, userbuf);
1000        DupString(yy_aconf->host, hostbuf);
1001 +
1002 +      yy_aconf->type = parse_netmask(yy_aconf->host, &yy_aconf->addr,
1003 +                                    &yy_aconf->bits);
1004      }
1005      else
1006      {
# Line 1092 | Line 1065 | oper_rsa_public_key_file: RSA_PUBLIC_KEY
1065        break;
1066      }
1067  
1068 <    yy_aconf->rsa_public_key = (RSA *)PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
1068 >    yy_aconf->rsa_public_key = PEM_read_bio_RSA_PUBKEY(file, NULL, 0, NULL);
1069  
1070      if (yy_aconf->rsa_public_key == NULL)
1071      {
# Line 1146 | Line 1119 | oper_umodes_item:  T_BOTS
1119   {
1120    if (conf_parser_ctx.pass == 2)
1121      yy_aconf->modes |= UMODE_FULL;
1122 + } | HIDDEN
1123 + {
1124 +  if (conf_parser_ctx.pass == 2)
1125 +    yy_aconf->modes |= UMODE_HIDDEN;
1126   } | T_SKILL
1127   {
1128    if (conf_parser_ctx.pass == 2)
# Line 1223 | Line 1200 | oper_flags_item: GLOBAL_KILL
1200   {
1201    if (conf_parser_ctx.pass == 2)
1202      yy_aconf->port |= OPER_FLAG_UNKLINE;
1203 + } | T_DLINE
1204 + {
1205 +  if (conf_parser_ctx.pass == 2)
1206 +    yy_aconf->port |= OPER_FLAG_DLINE;
1207 + } | T_UNDLINE
1208 + {
1209 +  if (conf_parser_ctx.pass == 2)
1210 +    yy_aconf->port |= OPER_FLAG_UNDLINE;
1211   } | XLINE
1212   {
1213    if (conf_parser_ctx.pass == 2)
# Line 1247 | Line 1232 | oper_flags_item: GLOBAL_KILL
1232   {
1233    if (conf_parser_ctx.pass == 2)
1234      yy_aconf->port |= OPER_FLAG_ADMIN;
1250 } | HIDDEN_ADMIN
1251 {
1252  if (conf_parser_ctx.pass == 2)
1253    yy_aconf->port |= OPER_FLAG_HIDDEN_ADMIN;
1235   } | NICK_CHANGES
1236   {
1237    if (conf_parser_ctx.pass == 2)
# Line 1267 | Line 1248 | oper_flags_item: GLOBAL_KILL
1248   {
1249    if (conf_parser_ctx.pass == 2)
1250      yy_aconf->port |= OPER_FLAG_OPER_SPY;
1270 } | HIDDEN_OPER
1271 {
1272  if (conf_parser_ctx.pass == 2)
1273    yy_aconf->port |= OPER_FLAG_HIDDEN_OPER;
1251   } | REMOTEBAN
1252   {
1253    if (conf_parser_ctx.pass == 2)
1254      yy_aconf->port |= OPER_FLAG_REMOTEBAN;
1255 + } | T_SET
1256 + {
1257 +  if (conf_parser_ctx.pass == 2)
1258 +    yy_aconf->port |= OPER_FLAG_SET;
1259   } | MODULE
1260   {
1261    if (conf_parser_ctx.pass == 2)
# Line 1292 | Line 1273 | class_entry: CLASS
1273      yy_conf = make_conf_item(CLASS_TYPE);
1274      yy_class = map_to_conf(yy_conf);
1275    }
1276 < } class_name_b '{' class_items '}' ';'
1276 > } '{' class_items '}' ';'
1277   {
1278    if (conf_parser_ctx.pass == 1)
1279    {
# Line 1303 | Line 1284 | class_entry: CLASS
1284        delete_conf_item(yy_conf);
1285      else
1286      {
1287 <      cconf = find_exact_name_conf(CLASS_TYPE, yy_class_name, NULL, NULL);
1287 >      cconf = find_exact_name_conf(CLASS_TYPE, NULL, yy_class_name, NULL, NULL);
1288  
1289        if (cconf != NULL)                /* The class existed already */
1290        {
# Line 1335 | Line 1316 | class_entry: CLASS
1316    }
1317   };
1318  
1338 class_name_b: | class_name_t;
1339
1319   class_items:    class_items class_item | class_item;
1320   class_item:     class_name |
1321                  class_cidr_bitlen_ipv4 | class_cidr_bitlen_ipv6 |
# Line 1349 | Line 1328 | class_item:     class_name |
1328                  class_max_global |
1329                  class_max_local |
1330                  class_max_ident |
1331 <                class_sendq |
1331 >                class_sendq | class_recvq |
1332                  error ';' ;
1333  
1334   class_name: NAME '=' QSTRING ';'
# Line 1361 | Line 1340 | class_name: NAME '=' QSTRING ';'
1340    }
1341   };
1342  
1364 class_name_t: QSTRING
1365 {
1366  if (conf_parser_ctx.pass == 1)
1367  {
1368    MyFree(yy_class_name);
1369    DupString(yy_class_name, yylval.string);
1370  }
1371 };
1372
1343   class_ping_time: PING_TIME '=' timespec ';'
1344   {
1345    if (conf_parser_ctx.pass == 1)
1346 <    PingFreq(yy_class) = $3;
1346 >    yy_class->ping_freq = $3;
1347   };
1348  
1349   class_ping_warning: PING_WARNING '=' timespec ';'
1350   {
1351    if (conf_parser_ctx.pass == 1)
1352 <    PingWarning(yy_class) = $3;
1352 >    yy_class->ping_warning = $3;
1353   };
1354  
1355   class_number_per_ip: NUMBER_PER_IP '=' NUMBER ';'
1356   {
1357    if (conf_parser_ctx.pass == 1)
1358 <    MaxPerIp(yy_class) = $3;
1358 >    yy_class->max_perip = $3;
1359   };
1360  
1361   class_connectfreq: CONNECTFREQ '=' timespec ';'
1362   {
1363    if (conf_parser_ctx.pass == 1)
1364 <    ConFreq(yy_class) = $3;
1364 >    yy_class->con_freq = $3;
1365   };
1366  
1367   class_max_number: MAX_NUMBER '=' NUMBER ';'
1368   {
1369    if (conf_parser_ctx.pass == 1)
1370 <    MaxTotal(yy_class) = $3;
1370 >    yy_class->max_total = $3;
1371   };
1372  
1373   class_max_global: MAX_GLOBAL '=' NUMBER ';'
1374   {
1375    if (conf_parser_ctx.pass == 1)
1376 <    MaxGlobal(yy_class) = $3;
1376 >    yy_class->max_global = $3;
1377   };
1378  
1379   class_max_local: MAX_LOCAL '=' NUMBER ';'
1380   {
1381    if (conf_parser_ctx.pass == 1)
1382 <    MaxLocal(yy_class) = $3;
1382 >    yy_class->max_local = $3;
1383   };
1384  
1385   class_max_ident: MAX_IDENT '=' NUMBER ';'
1386   {
1387    if (conf_parser_ctx.pass == 1)
1388 <    MaxIdent(yy_class) = $3;
1388 >    yy_class->max_ident = $3;
1389   };
1390  
1391   class_sendq: SENDQ '=' sizespec ';'
1392   {
1393    if (conf_parser_ctx.pass == 1)
1394 <    MaxSendq(yy_class) = $3;
1394 >    yy_class->max_sendq = $3;
1395 > };
1396 >
1397 > class_recvq: T_RECVQ '=' sizespec ';'
1398 > {
1399 >  if (conf_parser_ctx.pass == 1)
1400 >    if ($3 >= CLIENT_FLOOD_MIN && $3 <= CLIENT_FLOOD_MAX)
1401 >      yy_class->max_recvq = $3;
1402   };
1403  
1404   class_cidr_bitlen_ipv4: CIDR_BITLEN_IPV4 '=' NUMBER ';'
1405   {
1406    if (conf_parser_ctx.pass == 1)
1407 <    CidrBitlenIPV4(yy_class) = $3;
1407 >    yy_class->cidr_bitlen_ipv4 = $3 > 32 ? 32 : $3;
1408   };
1409  
1410   class_cidr_bitlen_ipv6: CIDR_BITLEN_IPV6 '=' NUMBER ';'
1411   {
1412    if (conf_parser_ctx.pass == 1)
1413 <    CidrBitlenIPV6(yy_class) = $3;
1413 >    yy_class->cidr_bitlen_ipv6 = $3 > 128 ? 128 : $3;
1414   };
1415  
1416   class_number_per_cidr: NUMBER_PER_CIDR '=' NUMBER ';'
1417   {
1418    if (conf_parser_ctx.pass == 1)
1419 <    NumberPerCidr(yy_class) = $3;
1419 >    yy_class->number_per_cidr = $3;
1420   };
1421  
1422   /***************************************************************************
# Line 1654 | Line 1631 | auth_user: USER '=' QSTRING ';'
1631    }
1632   };
1633  
1657 /* XXX - IP/IPV6 tags don't exist anymore - put IP/IPV6 into user. */
1658
1634   auth_passwd: PASSWORD '=' QSTRING ';'
1635   {
1636    if (conf_parser_ctx.pass == 2)
# Line 1732 | Line 1707 | auth_flags_item: SPOOF_NOTICE
1707      yy_aconf->flags |= CONF_FLAGS_NEED_PASSWORD;
1708   };
1709  
1735 /* XXX - need check for illegal hostnames here */
1710   auth_spoof: SPOOF '=' QSTRING ';'
1711   {
1712    if (conf_parser_ctx.pass == 2)
1713    {
1714      MyFree(yy_conf->name);
1715  
1716 <    if (strlen(yylval.string) < HOSTLEN)
1716 >    if (strlen(yylval.string) <= HOSTLEN && valid_hostname(yylval.string))
1717      {    
1718        DupString(yy_conf->name, yylval.string);
1719        yy_aconf->flags |= CONF_FLAGS_SPOOF_IP;
1720      }
1721      else
1722      {
1723 <      ilog(LOG_TYPE_IRCD, "Spoofs must be less than %d..ignoring it", HOSTLEN);
1723 >      ilog(LOG_TYPE_IRCD, "Spoof either is too long or contains invalid characters. Ignoring it.");
1724        yy_conf->name = NULL;
1725      }
1726    }
# Line 1912 | Line 1886 | shared_type_item: KLINE
1886   {
1887    if (conf_parser_ctx.pass == 2)
1888      yy_match_item->action |= SHARED_KLINE;
1915 } | TKLINE
1916 {
1917  if (conf_parser_ctx.pass == 2)
1918    yy_match_item->action |= SHARED_TKLINE;
1889   } | UNKLINE
1890   {
1891    if (conf_parser_ctx.pass == 2)
1892      yy_match_item->action |= SHARED_UNKLINE;
1893 < } | XLINE
1893 > } | T_DLINE
1894   {
1895    if (conf_parser_ctx.pass == 2)
1896 <    yy_match_item->action |= SHARED_XLINE;
1897 < } | TXLINE
1896 >    yy_match_item->action |= SHARED_DLINE;
1897 > } | T_UNDLINE
1898 > {
1899 >  if (conf_parser_ctx.pass == 2)
1900 >    yy_match_item->action |= SHARED_UNDLINE;
1901 > } | XLINE
1902   {
1903    if (conf_parser_ctx.pass == 2)
1904 <    yy_match_item->action |= SHARED_TXLINE;
1904 >    yy_match_item->action |= SHARED_XLINE;
1905   } | T_UNXLINE
1906   {
1907    if (conf_parser_ctx.pass == 2)
# Line 1936 | Line 1910 | shared_type_item: KLINE
1910   {
1911    if (conf_parser_ctx.pass == 2)
1912      yy_match_item->action |= SHARED_RESV;
1939 } | TRESV
1940 {
1941  if (conf_parser_ctx.pass == 2)
1942    yy_match_item->action |= SHARED_TRESV;
1913   } | T_UNRESV
1914   {
1915    if (conf_parser_ctx.pass == 2)
# Line 1994 | Line 1964 | cluster_type_item: KLINE
1964   {
1965    if (conf_parser_ctx.pass == 2)
1966      yy_conf->flags |= SHARED_KLINE;
1997 } | TKLINE
1998 {
1999  if (conf_parser_ctx.pass == 2)
2000    yy_conf->flags |= SHARED_TKLINE;
1967   } | UNKLINE
1968   {
1969    if (conf_parser_ctx.pass == 2)
1970      yy_conf->flags |= SHARED_UNKLINE;
1971 < } | XLINE
1971 > } | T_DLINE
1972   {
1973    if (conf_parser_ctx.pass == 2)
1974 <    yy_conf->flags |= SHARED_XLINE;
1975 < } | TXLINE
1974 >    yy_conf->flags |= SHARED_DLINE;
1975 > } | T_UNDLINE
1976 > {
1977 >  if (conf_parser_ctx.pass == 2)
1978 >    yy_conf->flags |= SHARED_UNDLINE;
1979 > } | XLINE
1980   {
1981    if (conf_parser_ctx.pass == 2)
1982 <    yy_conf->flags |= SHARED_TXLINE;
1982 >    yy_conf->flags |= SHARED_XLINE;
1983   } | T_UNXLINE
1984   {
1985    if (conf_parser_ctx.pass == 2)
# Line 2018 | Line 1988 | cluster_type_item: KLINE
1988   {
1989    if (conf_parser_ctx.pass == 2)
1990      yy_conf->flags |= SHARED_RESV;
2021 } | TRESV
2022 {
2023  if (conf_parser_ctx.pass == 2)
2024    yy_conf->flags |= SHARED_TRESV;
1991   } | T_UNRESV
1992   {
1993    if (conf_parser_ctx.pass == 2)
# Line 2044 | Line 2010 | connect_entry: CONNECT
2010    if (conf_parser_ctx.pass == 2)
2011    {
2012      yy_conf = make_conf_item(SERVER_TYPE);
2013 <    yy_aconf = (struct AccessItem *)map_to_conf(yy_conf);
2014 <    yy_aconf->passwd = NULL;
2013 >    yy_aconf = map_to_conf(yy_conf);
2014 >
2015      /* defaults */
2016      yy_aconf->port = PORTNUM;
2017    }
# Line 2054 | Line 2020 | connect_entry: CONNECT
2020      MyFree(class_name);
2021      class_name = NULL;
2022    }
2023 < } connect_name_b '{' connect_items '}' ';'
2023 > } '{' connect_items '}' ';'
2024   {
2025    if (conf_parser_ctx.pass == 2)
2026    {
2027 <    struct CollectItem *yy_hconf=NULL;
2028 <    struct CollectItem *yy_lconf=NULL;
2029 <    dlink_node *ptr;
2030 <    dlink_node *next_ptr;
2031 < #ifdef HAVE_LIBCRYPTO
2032 <    if (yy_aconf->host &&
2033 <        ((yy_aconf->passwd && yy_aconf->spasswd) ||
2034 <         (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)
2027 >    if (yy_aconf->host && yy_aconf->passwd && yy_aconf->spasswd)
2028 >    {
2029 >      if (conf_add_server(yy_conf, class_name) == -1)
2030 >        delete_conf_item(yy_conf);
2031 >    }
2032 >    else
2033 >    {
2034 >      if (yy_conf->name != NULL)
2035        {
2036 <        struct ConfItem *new_hub_conf;
2037 <        struct MatchItem *match_item;
2038 <
2039 <        yy_hconf = ptr->data;
2132 <
2133 <        /* yy_conf == NULL is a fatal error for this connect block! */
2134 <        if ((yy_conf != NULL) && (yy_conf->name != NULL))
2135 <        {
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);
2036 >        if (yy_aconf->host == NULL)
2037 >          yyerror("Ignoring connect block -- missing host");
2038 >        else if (!yy_aconf->passwd || !yy_aconf->spasswd)
2039 >          yyerror("Ignoring connect block -- missing password");
2040        }
2041  
2042 <      /* Ditto for the LEAF confs */
2043 <
2044 <      DLINK_FOREACH_SAFE(ptr, next_ptr, leaf_conf_list.head)
2045 <      {
2046 <        struct ConfItem *new_leaf_conf;
2047 <        struct MatchItem *match_item;
2048 <
2049 <        yy_lconf = ptr->data;
2042 >      /* XXX
2043 >       * This fixes a try_connections() core (caused by invalid class_ptr
2044 >       * pointers) reported by metalrock. That's an ugly fix, but there
2045 >       * is currently no better way. The entire config subsystem needs an
2046 >       * rewrite ASAP. make_conf_item() shouldn't really add things onto
2047 >       * a doubly linked list immediately without any sanity checks!  -Michael
2048 >       */
2049 >      delete_conf_item(yy_conf);
2050 >    }
2051  
2052 <        if ((yy_conf != NULL) && (yy_conf->name != NULL))
2053 <        {
2054 <          new_leaf_conf = make_conf_item(LEAF_TYPE);
2055 <          match_item = (struct MatchItem *)map_to_conf(new_leaf_conf);
2165 <          DupString(new_leaf_conf->name, yy_conf->name);
2166 <          if (yy_lconf->user != NULL)
2167 <            DupString(match_item->user, yy_lconf->user);
2168 <          else
2169 <            DupString(match_item->user, "*");
2170 <          if (yy_lconf->host != NULL)
2171 <            DupString(match_item->host, yy_lconf->host);
2172 <          else
2173 <            DupString(match_item->host, "*");
2174 <        }
2175 <        dlinkDelete(&yy_lconf->node, &leaf_conf_list);
2176 <        free_collect_item(yy_lconf);
2177 <      }
2178 <      MyFree(class_name);
2179 <      class_name = NULL;
2180 <      yy_conf = NULL;
2181 <      yy_aconf = NULL;
2052 >    MyFree(class_name);
2053 >    class_name = NULL;
2054 >    yy_conf = NULL;
2055 >    yy_aconf = NULL;
2056    }
2057   };
2058  
2185 connect_name_b: | connect_name_t;
2059   connect_items:  connect_items connect_item | connect_item;
2060   connect_item:   connect_name | connect_host | connect_vhost |
2061                  connect_send_password | connect_accept_password |
2062 <                connect_aftype | connect_port |
2062 >                connect_aftype | connect_port | connect_ssl_cipher_list |
2063                  connect_flags | connect_hub_mask | connect_leaf_mask |
2064 <                connect_class | connect_encrypted |
2192 <                connect_rsa_public_key_file | connect_cipher_preference |
2064 >                connect_class | connect_encrypted |
2065                  error ';' ;
2066  
2067   connect_name: NAME '=' QSTRING ';'
2068   {
2069    if (conf_parser_ctx.pass == 2)
2070    {
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  }
2205 };
2206
2207 connect_name_t: QSTRING
2208 {
2209  if (conf_parser_ctx.pass == 2)
2210  {
2211    if (yy_conf->name != NULL)
2212      yyerror("Multiple connect name entry");
2213
2071      MyFree(yy_conf->name);
2072      DupString(yy_conf->name, yylval.string);
2073    }
# Line 2243 | Line 2100 | connect_vhost: VHOST '=' QSTRING ';'
2100      {
2101        assert(res != NULL);
2102  
2103 <      memcpy(&yy_aconf->my_ipnum, res->ai_addr, res->ai_addrlen);
2104 <      yy_aconf->my_ipnum.ss.ss_family = res->ai_family;
2105 <      yy_aconf->my_ipnum.ss_len = res->ai_addrlen;
2103 >      memcpy(&yy_aconf->bind, res->ai_addr, res->ai_addrlen);
2104 >      yy_aconf->bind.ss.ss_family = res->ai_family;
2105 >      yy_aconf->bind.ss_len = res->ai_addrlen;
2106        freeaddrinfo(res);
2107      }
2108    }
# Line 2310 | Line 2167 | connect_flags: IRCD_FLAGS
2167   } '='  connect_flags_items ';';
2168  
2169   connect_flags_items: connect_flags_items ',' connect_flags_item | connect_flags_item;
2170 < connect_flags_item: COMPRESSED
2314 < {
2315 <  if (conf_parser_ctx.pass == 2)
2316 < #ifndef HAVE_LIBZ
2317 <    yyerror("Ignoring flags = compressed; -- no zlib support");
2318 < #else
2319 < {
2320 <   SetConfCompressed(yy_aconf);
2321 < }
2322 < #endif
2323 < } | CRYPTLINK
2324 < {
2325 <  if (conf_parser_ctx.pass == 2)
2326 <    SetConfCryptLink(yy_aconf);
2327 < } | AUTOCONN
2170 > connect_flags_item: AUTOCONN
2171   {
2172    if (conf_parser_ctx.pass == 2)
2173      SetConfAllowAutoConn(yy_aconf);
2174 < } | 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 ';'
2174 > } | T_SSL
2175   {
2343 #ifdef HAVE_LIBCRYPTO
2176    if (conf_parser_ctx.pass == 2)
2177 <  {
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 */
2177 >    SetConfSSL(yy_aconf);
2178   };
2179  
2180   connect_encrypted: ENCRYPTED '=' TBOOL ';'
# Line 2394 | Line 2192 | connect_hub_mask: HUB_MASK '=' QSTRING '
2192   {
2193    if (conf_parser_ctx.pass == 2)
2194    {
2195 <    struct CollectItem *yy_tmp;
2195 >    char *mask;
2196  
2197 <    yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2198 <    DupString(yy_tmp->host, yylval.string);
2401 <    DupString(yy_tmp->user, "*");
2402 <    dlinkAdd(yy_tmp, &yy_tmp->node, &hub_conf_list);
2197 >    DupString(mask, yylval.string);
2198 >    dlinkAdd(mask, make_dlink_node(), &yy_aconf->hub_list);
2199    }
2200   };
2201  
# Line 2407 | Line 2203 | connect_leaf_mask: LEAF_MASK '=' QSTRING
2203   {
2204    if (conf_parser_ctx.pass == 2)
2205    {
2206 <    struct CollectItem *yy_tmp;
2206 >    char *mask;
2207  
2208 <    yy_tmp = (struct CollectItem *)MyMalloc(sizeof(struct CollectItem));
2209 <    DupString(yy_tmp->host, yylval.string);
2414 <    DupString(yy_tmp->user, "*");
2415 <    dlinkAdd(yy_tmp, &yy_tmp->node, &leaf_conf_list);
2208 >    DupString(mask, yylval.string);
2209 >    dlinkAdd(mask, make_dlink_node(), &yy_aconf->leaf_list);
2210    }
2211   };
2212  
# Line 2425 | Line 2219 | connect_class: CLASS '=' QSTRING ';'
2219    }
2220   };
2221  
2222 < connect_cipher_preference: CIPHER_PREFERENCE '=' QSTRING ';'
2222 > connect_ssl_cipher_list: T_SSL_CIPHER_LIST '=' QSTRING ';'
2223   {
2224   #ifdef HAVE_LIBCRYPTO
2225    if (conf_parser_ctx.pass == 2)
2226    {
2227 <    struct EncCapability *ecap;
2228 <    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");
2227 >    MyFree(yy_aconf->cipher_list);
2228 >    DupString(yy_aconf->cipher_list, yylval.string);
2229    }
2230   #else
2231    if (conf_parser_ctx.pass == 2)
2232 <    yyerror("Ignoring cipher_preference -- no OpenSSL support");
2232 >    yyerror("Ignoring connect::ciphers -- no OpenSSL support");
2233   #endif
2234   };
2235  
2236 +
2237   /***************************************************************************
2238   *  section kill
2239   ***************************************************************************/
# Line 2492 | Line 2269 | kill_entry: KILL
2269          yy_aconf->regexuser = exp_user;
2270          yy_aconf->regexhost = exp_host;
2271  
2272 +        SetConfMain(yy_aconf);
2273 +
2274          DupString(yy_aconf->user, userbuf);
2275          DupString(yy_aconf->host, hostbuf);
2276  
# Line 2508 | Line 2287 | kill_entry: KILL
2287        {
2288          yy_aconf = map_to_conf(make_conf_item(KLINE_TYPE));
2289  
2290 +        SetConfMain(yy_aconf);
2291 +
2292          DupString(yy_aconf->user, userbuf);
2293          DupString(yy_aconf->host, hostbuf);
2294  
# Line 2515 | Line 2296 | kill_entry: KILL
2296            DupString(yy_aconf->reason, reasonbuf);
2297          else
2298            DupString(yy_aconf->reason, "No reason");
2299 <        add_conf_by_address(CONF_KILL, yy_aconf);
2299 >        add_conf_by_address(CONF_KLINE, yy_aconf);
2300        }
2301      }
2302  
# Line 2577 | Line 2358 | deny_entry: DENY
2358      {
2359        yy_aconf = map_to_conf(make_conf_item(DLINE_TYPE));
2360        DupString(yy_aconf->host, hostbuf);
2361 +      SetConfMain(yy_aconf);
2362  
2363        if (reasonbuf[0])
2364          DupString(yy_aconf->reason, reasonbuf);
# Line 2665 | Line 2447 | gecos_entry: GECOS
2447        else
2448          yy_conf = make_conf_item(XLINE_TYPE);
2449  
2450 +      SetConfMain(yy_conf);
2451        yy_match_item = map_to_conf(yy_conf);
2452        DupString(yy_conf->name, gecos_name);
2453  
# Line 2714 | Line 2497 | general_item:       general_hide_spoof_i
2497                      general_max_nick_time | general_max_nick_changes |
2498                      general_max_accept | general_anti_spam_exit_message_time |
2499                      general_ts_warn_delta | general_ts_max_delta |
2500 <                    general_kill_chase_time_limit | general_kline_with_reason |
2501 <                    general_kline_reason | general_invisible_on_connect |
2500 >                    general_kill_chase_time_limit |
2501 >                    general_invisible_on_connect |
2502                      general_warn_no_nline | general_dots_in_ident |
2503                      general_stats_o_oper_only | general_stats_k_oper_only |
2504                      general_pace_wait | general_stats_i_oper_only |
# Line 2728 | Line 2511 | general_item:       general_hide_spoof_i
2511                      general_oper_umodes | general_caller_id_wait |
2512                      general_opers_bypass_callerid | general_default_floodcount |
2513                      general_min_nonwildcard | general_min_nonwildcard_simple |
2514 <                    general_servlink_path | general_disable_remote_commands |
2732 <                    general_default_cipher_preference |
2733 <                    general_compression_level | general_client_flood |
2514 >                    general_disable_remote_commands |
2515                      general_throttle_time | general_havent_read_conf |
2516                      general_ping_cookie |
2517                      general_disable_auth |
2518 <                    general_tkline_expire_notices | general_gline_min_cidr |
2519 <                    general_gline_min_cidr6 | general_use_whois_actually |
2520 <                    general_reject_hold_time | general_stats_e_disabled |
2518 >                    general_tkline_expire_notices | general_gline_enable |
2519 >                    general_gline_duration | general_gline_request_duration |
2520 >                    general_gline_min_cidr |
2521 >                    general_gline_min_cidr6 |
2522 >                    general_stats_e_disabled |
2523                      general_max_watch | general_services_name |
2524                      error;
2525  
# Line 2746 | Line 2529 | general_max_watch: MAX_WATCH '=' NUMBER
2529    ConfigFileEntry.max_watch = $3;
2530   };
2531  
2532 < general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
2532 > general_gline_enable: GLINE_ENABLE '=' TBOOL ';'
2533   {
2534 <  ConfigFileEntry.gline_min_cidr = $3;
2534 >  if (conf_parser_ctx.pass == 2)
2535 >    ConfigFileEntry.glines = yylval.number;
2536   };
2537  
2538 < general_gline_min_cidr6: GLINE_MIN_CIDR6 '=' NUMBER ';'
2538 > general_gline_duration: GLINE_DURATION '=' timespec ';'
2539   {
2540 <  ConfigFileEntry.gline_min_cidr6 = $3;
2540 >  if (conf_parser_ctx.pass == 2)
2541 >    ConfigFileEntry.gline_time = $3;
2542   };
2543  
2544 < general_use_whois_actually: USE_WHOIS_ACTUALLY '=' TBOOL ';'
2544 > general_gline_request_duration: GLINE_REQUEST_DURATION '=' timespec ';'
2545   {
2546 <  ConfigFileEntry.use_whois_actually = yylval.number;
2546 >  if (conf_parser_ctx.pass == 2)
2547 >    ConfigFileEntry.gline_request_time = $3;
2548   };
2549  
2550 < general_reject_hold_time: TREJECT_HOLD_TIME '=' timespec ';'
2550 > general_gline_min_cidr: GLINE_MIN_CIDR '=' NUMBER ';'
2551   {
2552 <  GlobalSetOptions.rejecttime = yylval.number;
2552 >  ConfigFileEntry.gline_min_cidr = $3;
2553 > };
2554 >
2555 > general_gline_min_cidr6: GLINE_MIN_CIDR6 '=' NUMBER ';'
2556 > {
2557 >  ConfigFileEntry.gline_min_cidr6 = $3;
2558   };
2559  
2560   general_tkline_expire_notices: TKLINE_EXPIRE_NOTICES '=' TBOOL ';'
# Line 2843 | Line 2634 | general_havent_read_conf: HAVENT_READ_CO
2634    }
2635   };
2636  
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
2637   general_invisible_on_connect: INVISIBLE_ON_CONNECT '=' TBOOL ';'
2638   {
2639    ConfigFileEntry.invisible_on_connect = yylval.number;
# Line 2959 | Line 2736 | general_max_targets: MAX_TARGETS '=' NUM
2736    ConfigFileEntry.max_targets = $3;
2737   };
2738  
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
2739   general_use_egd: USE_EGD '=' TBOOL ';'
2740   {
2741    ConfigFileEntry.use_egd = yylval.number;
# Line 3080 | Line 2798 | umode_oitem:     T_BOTS
2798   } | T_FULL
2799   {
2800    ConfigFileEntry.oper_umodes |= UMODE_FULL;
2801 + } | HIDDEN
2802 + {
2803 +  ConfigFileEntry.oper_umodes |= UMODE_HIDDEN;
2804   } | T_SKILL
2805   {
2806    ConfigFileEntry.oper_umodes |= UMODE_SKILL;
# Line 3148 | Line 2869 | umode_item:    T_BOTS
2869   } | T_SKILL
2870   {
2871    ConfigFileEntry.oper_only_umodes |= UMODE_SKILL;
2872 + } | HIDDEN
2873 + {
2874 +  ConfigFileEntry.oper_only_umodes |= UMODE_HIDDEN;
2875   } | T_NCHANGE
2876   {
2877    ConfigFileEntry.oper_only_umodes |= UMODE_NCHANGE;
# Line 3201 | Line 2925 | general_default_floodcount: DEFAULT_FLOO
2925    ConfigFileEntry.default_floodcount = $3;
2926   };
2927  
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 };
2928  
2929   /***************************************************************************
2930   *  section channel
# Line 3382 | Line 2933 | channel_entry: CHANNEL
2933    '{' channel_items '}' ';';
2934  
2935   channel_items:      channel_items channel_item | channel_item;
2936 < channel_item:       channel_disable_local_channels | channel_use_except |
2937 <                    channel_use_invex | channel_use_knock |
2938 <                    channel_max_bans | channel_knock_delay |
3388 <                    channel_knock_delay_channel | channel_max_chans_per_user |
2936 > channel_item:       channel_max_bans |
2937 >                    channel_knock_delay | channel_knock_delay_channel |
2938 >                    channel_max_chans_per_user | channel_max_chans_per_oper |
2939                      channel_quiet_on_ban | channel_default_split_user_count |
2940                      channel_default_split_server_count |
2941                      channel_no_create_on_split | channel_restrict_channels |
2942 <                    channel_no_join_on_split | channel_burst_topicwho |
2942 >                    channel_no_join_on_split |
2943                      channel_jflood_count | channel_jflood_time |
2944                      channel_disable_fake_channels | error;
2945  
# Line 3403 | Line 2953 | channel_restrict_channels: RESTRICT_CHAN
2953    ConfigChannel.restrict_channels = yylval.number;
2954   };
2955  
3406 channel_disable_local_channels: DISABLE_LOCAL_CHANNELS '=' TBOOL ';'
3407 {
3408  ConfigChannel.disable_local_channels = yylval.number;
3409 };
3410
3411 channel_use_except: USE_EXCEPT '=' TBOOL ';'
3412 {
3413  ConfigChannel.use_except = yylval.number;
3414 };
3415
3416 channel_use_invex: USE_INVEX '=' TBOOL ';'
3417 {
3418  ConfigChannel.use_invex = yylval.number;
3419 };
3420
3421 channel_use_knock: USE_KNOCK '=' TBOOL ';'
3422 {
3423  ConfigChannel.use_knock = yylval.number;
3424 };
3425
2956   channel_knock_delay: KNOCK_DELAY '=' timespec ';'
2957   {
2958    ConfigChannel.knock_delay = $3;
# Line 3438 | Line 2968 | channel_max_chans_per_user: MAX_CHANS_PE
2968    ConfigChannel.max_chans_per_user = $3;
2969   };
2970  
2971 + channel_max_chans_per_oper: MAX_CHANS_PER_OPER '=' NUMBER ';'
2972 + {
2973 +  ConfigChannel.max_chans_per_oper = $3;
2974 + };
2975 +
2976   channel_quiet_on_ban: QUIET_ON_BAN '=' TBOOL ';'
2977   {
2978    ConfigChannel.quiet_on_ban = yylval.number;
# Line 3468 | Line 3003 | channel_no_join_on_split: NO_JOIN_ON_SPL
3003    ConfigChannel.no_join_on_split = yylval.number;
3004   };
3005  
3471 channel_burst_topicwho: BURST_TOPICWHO '=' TBOOL ';'
3472 {
3473  ConfigChannel.burst_topicwho = yylval.number;
3474 };
3475
3006   channel_jflood_count: JOIN_FLOOD_COUNT '=' NUMBER ';'
3007   {
3008    GlobalSetOptions.joinfloodcount = yylval.number;
# Line 3492 | Line 3022 | serverhide_entry: SERVERHIDE
3022   serverhide_items:   serverhide_items serverhide_item | serverhide_item;
3023   serverhide_item:    serverhide_flatten_links | serverhide_hide_servers |
3024                      serverhide_links_delay |
3495                    serverhide_disable_hidden |
3025                      serverhide_hidden | serverhide_hidden_name |
3026                      serverhide_hide_server_ips |
3027                      error;
# Line 3538 | Line 3067 | serverhide_hidden: HIDDEN '=' TBOOL ';'
3067      ConfigServerHide.hidden = yylval.number;
3068   };
3069  
3541 serverhide_disable_hidden: DISABLE_HIDDEN '=' TBOOL ';'
3542 {
3543  if (conf_parser_ctx.pass == 2)
3544    ConfigServerHide.disable_hidden = yylval.number;
3545 };
3546
3070   serverhide_hide_server_ips: HIDE_SERVER_IPS '=' TBOOL ';'
3071   {
3072    if (conf_parser_ctx.pass == 2)

Diff Legend

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