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