| 1 |
michael |
5052 |
/* |
| 2 |
|
|
* Copyright (C) 2002-2003 Erik Fears |
| 3 |
|
|
* |
| 4 |
|
|
* This program is free software; you can redistribute it and/or |
| 5 |
|
|
* modify it under the terms of the GNU General Public License |
| 6 |
|
|
* as published by the Free Software Foundation; either version 2 |
| 7 |
|
|
* of the License, or (at your option) any later version. |
| 8 |
|
|
* |
| 9 |
|
|
* This program is distributed in the hope that it will be useful, |
| 10 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
|
|
* GNU General Public License for more details. |
| 13 |
|
|
* |
| 14 |
|
|
* You should have received a copy of the GNU General Public License |
| 15 |
|
|
* along with this program; if not, write to |
| 16 |
|
|
* |
| 17 |
|
|
* The Free Software Foundation, Inc. |
| 18 |
|
|
* 59 Temple Place - Suite 330 |
| 19 |
|
|
* Boston, MA 02111-1307, USA. |
| 20 |
|
|
* |
| 21 |
|
|
* |
| 22 |
|
|
*/ |
| 23 |
|
|
|
| 24 |
|
|
|
| 25 |
|
|
%{ |
| 26 |
|
|
#include <stdio.h> |
| 27 |
|
|
#include <string.h> |
| 28 |
|
|
#include "malloc.h" |
| 29 |
|
|
#include "config.h" |
| 30 |
|
|
|
| 31 |
michael |
5072 |
int yylex(void); |
| 32 |
|
|
|
| 33 |
michael |
5052 |
int yydebug=0; |
| 34 |
|
|
void *tmp; /* Variable to temporarily hold nodes before insertion to list */ |
| 35 |
|
|
|
| 36 |
|
|
%} |
| 37 |
|
|
|
| 38 |
|
|
%token AWAY |
| 39 |
|
|
%token BAN_UNKNOWN |
| 40 |
|
|
%token BLACKLIST |
| 41 |
michael |
5080 |
%token BYTES KBYTES MBYTES |
| 42 |
michael |
5052 |
%token CHANNEL |
| 43 |
|
|
%token CONNREGEX |
| 44 |
|
|
%token DNS_FDLIMIT |
| 45 |
|
|
%token DNSBL_FROM |
| 46 |
|
|
%token DNSBL_TO |
| 47 |
|
|
%token EXEMPT |
| 48 |
|
|
%token FD |
| 49 |
|
|
%token INVITE |
| 50 |
|
|
%token IRC |
| 51 |
|
|
%token KLINE |
| 52 |
|
|
%token KEY |
| 53 |
|
|
%token MASK |
| 54 |
|
|
%token MAX_READ |
| 55 |
|
|
%token MODE |
| 56 |
|
|
%token NAME |
| 57 |
|
|
%token NEGCACHE |
| 58 |
|
|
%token NICK |
| 59 |
|
|
%token NICKSERV |
| 60 |
|
|
%token OPER |
| 61 |
|
|
%token OPM |
| 62 |
|
|
%token OPTIONS |
| 63 |
|
|
%token PASSWORD |
| 64 |
|
|
%token PERFORM |
| 65 |
|
|
%token PIDFILE |
| 66 |
|
|
%token PORT |
| 67 |
|
|
%token PROTOCOL |
| 68 |
|
|
%token REALNAME |
| 69 |
|
|
%token REPLY |
| 70 |
|
|
%token SCANLOG |
| 71 |
|
|
%token SCANNER |
| 72 |
michael |
5080 |
%token SECONDS MINUTES HOURS DAYS WEEKS MONTHS YEARS |
| 73 |
michael |
5052 |
%token SENDMAIL |
| 74 |
|
|
%token SERVER |
| 75 |
|
|
%token TARGET_IP |
| 76 |
|
|
%token TARGET_PORT |
| 77 |
|
|
%token TARGET_STRING |
| 78 |
|
|
%token TIMEOUT |
| 79 |
|
|
%token TYPE |
| 80 |
|
|
%token USERNAME |
| 81 |
|
|
%token USER |
| 82 |
|
|
%token VHOST |
| 83 |
|
|
|
| 84 |
|
|
%union |
| 85 |
|
|
{ |
| 86 |
|
|
int number; |
| 87 |
|
|
char *string; |
| 88 |
|
|
} |
| 89 |
|
|
|
| 90 |
|
|
%token <number> NUMBER |
| 91 |
|
|
%token <string> STRING |
| 92 |
|
|
%token <number> PROTOCOLTYPE |
| 93 |
michael |
5080 |
%type <number> timespec |
| 94 |
|
|
%type <number> timespec_ |
| 95 |
|
|
%type <number> sizespec |
| 96 |
|
|
%type <number> sizespec_ |
| 97 |
michael |
5052 |
|
| 98 |
|
|
%% |
| 99 |
|
|
|
| 100 |
michael |
5068 |
config: |
| 101 |
|
|
| config config_items |
| 102 |
michael |
5052 |
; |
| 103 |
|
|
|
| 104 |
|
|
config_items: irc_entry | |
| 105 |
|
|
options_entry | |
| 106 |
|
|
opm_entry | |
| 107 |
|
|
user_entry | |
| 108 |
|
|
scanner_entry | |
| 109 |
|
|
exempt_entry; |
| 110 |
|
|
|
| 111 |
michael |
5080 |
timespec_: { $$ = 0; } | timespec; |
| 112 |
|
|
timespec: NUMBER timespec_ { $$ = $1 + $2; } | |
| 113 |
|
|
NUMBER SECONDS timespec_ { $$ = $1 + $3; } | |
| 114 |
|
|
NUMBER MINUTES timespec_ { $$ = $1 * 60 + $3; } | |
| 115 |
|
|
NUMBER HOURS timespec_ { $$ = $1 * 60 * 60 + $3; } | |
| 116 |
|
|
NUMBER DAYS timespec_ { $$ = $1 * 60 * 60 * 24 + $3; } | |
| 117 |
|
|
NUMBER WEEKS timespec_ { $$ = $1 * 60 * 60 * 24 * 7 + $3; } | |
| 118 |
|
|
NUMBER MONTHS timespec_ { $$ = $1 * 60 * 60 * 24 * 7 * 4 + $3; } | |
| 119 |
|
|
NUMBER YEARS timespec_ { $$ = $1 * 60 * 60 * 24 * 365 + $3; } |
| 120 |
|
|
; |
| 121 |
michael |
5052 |
|
| 122 |
michael |
5080 |
sizespec_: { $$ = 0; } | sizespec; |
| 123 |
|
|
sizespec: NUMBER sizespec_ { $$ = $1 + $2; } | |
| 124 |
|
|
NUMBER BYTES sizespec_ { $$ = $1 + $3; } | |
| 125 |
|
|
NUMBER KBYTES sizespec_ { $$ = $1 * 1024 + $3; } | |
| 126 |
|
|
NUMBER MBYTES sizespec_ { $$ = $1 * 1024 * 1024 + $3; } |
| 127 |
|
|
; |
| 128 |
|
|
|
| 129 |
michael |
5052 |
/*************************** OPTIONS BLOCK ***********************/ |
| 130 |
|
|
|
| 131 |
|
|
options_entry: OPTIONS '{' options_items '}' ';'; |
| 132 |
|
|
|
| 133 |
michael |
5068 |
options_items: options_items options_item | |
| 134 |
michael |
5052 |
options_item; |
| 135 |
|
|
|
| 136 |
|
|
options_item: options_negcache | |
| 137 |
|
|
options_pidfile | |
| 138 |
|
|
options_dns_fdlimit | |
| 139 |
|
|
options_scanlog | |
| 140 |
|
|
error; |
| 141 |
|
|
|
| 142 |
michael |
5080 |
options_negcache: NEGCACHE '=' timespec ';' |
| 143 |
michael |
5052 |
{ |
| 144 |
|
|
OptionsItem->negcache = $3; |
| 145 |
|
|
}; |
| 146 |
|
|
|
| 147 |
|
|
options_pidfile: PIDFILE '=' STRING ';' |
| 148 |
|
|
{ |
| 149 |
|
|
MyFree(OptionsItem->pidfile); |
| 150 |
|
|
OptionsItem->pidfile = DupString($3); |
| 151 |
|
|
}; |
| 152 |
|
|
|
| 153 |
|
|
options_dns_fdlimit: DNS_FDLIMIT '=' NUMBER ';' |
| 154 |
|
|
{ |
| 155 |
|
|
OptionsItem->dns_fdlimit = $3; |
| 156 |
|
|
}; |
| 157 |
|
|
|
| 158 |
|
|
options_scanlog: SCANLOG '=' STRING ';' |
| 159 |
|
|
{ |
| 160 |
|
|
MyFree(OptionsItem->scanlog); |
| 161 |
|
|
OptionsItem->scanlog = DupString($3); |
| 162 |
|
|
}; |
| 163 |
|
|
|
| 164 |
|
|
/*************************** IRC BLOCK ***************************/ |
| 165 |
|
|
|
| 166 |
|
|
irc_entry: IRC '{' irc_items '}' ';'; |
| 167 |
|
|
|
| 168 |
|
|
irc_items: irc_items irc_item | |
| 169 |
|
|
irc_item; |
| 170 |
|
|
|
| 171 |
|
|
irc_item: irc_away | |
| 172 |
|
|
irc_connregex | |
| 173 |
|
|
irc_kline | |
| 174 |
|
|
irc_nick | |
| 175 |
|
|
irc_nickserv | |
| 176 |
|
|
irc_mode | |
| 177 |
|
|
irc_oper | |
| 178 |
|
|
irc_password | |
| 179 |
|
|
irc_port | |
| 180 |
|
|
irc_realname | |
| 181 |
|
|
irc_server | |
| 182 |
|
|
irc_username | |
| 183 |
|
|
irc_vhost | |
| 184 |
|
|
irc_perform | |
| 185 |
|
|
channel_entry | |
| 186 |
|
|
error; |
| 187 |
|
|
|
| 188 |
|
|
irc_away: AWAY '=' STRING ';' |
| 189 |
|
|
{ |
| 190 |
|
|
MyFree(IRCItem->away); |
| 191 |
|
|
IRCItem->away = DupString($3); |
| 192 |
|
|
}; |
| 193 |
|
|
|
| 194 |
|
|
irc_kline: KLINE '=' STRING ';' |
| 195 |
|
|
{ |
| 196 |
|
|
MyFree(IRCItem->kline); |
| 197 |
|
|
IRCItem->kline = DupString($3); |
| 198 |
|
|
}; |
| 199 |
|
|
|
| 200 |
|
|
irc_mode: MODE '=' STRING ';' |
| 201 |
|
|
{ |
| 202 |
|
|
MyFree(IRCItem->mode); |
| 203 |
|
|
IRCItem->mode = DupString($3); |
| 204 |
|
|
}; |
| 205 |
|
|
|
| 206 |
|
|
irc_nick: NICK '=' STRING ';' |
| 207 |
|
|
{ |
| 208 |
|
|
MyFree(IRCItem->nick); |
| 209 |
|
|
IRCItem->nick = DupString($3); |
| 210 |
|
|
}; |
| 211 |
|
|
|
| 212 |
|
|
irc_nickserv: NICKSERV '=' STRING ';' |
| 213 |
|
|
{ |
| 214 |
|
|
MyFree(IRCItem->nickserv); |
| 215 |
|
|
IRCItem->nickserv = DupString($3); |
| 216 |
|
|
}; |
| 217 |
|
|
|
| 218 |
|
|
irc_oper: OPER '=' STRING ';' |
| 219 |
|
|
{ |
| 220 |
|
|
MyFree(IRCItem->oper); |
| 221 |
|
|
IRCItem->oper = DupString($3); |
| 222 |
|
|
}; |
| 223 |
|
|
|
| 224 |
|
|
irc_password: PASSWORD '=' STRING ';' |
| 225 |
|
|
{ |
| 226 |
|
|
MyFree(IRCItem->password); |
| 227 |
|
|
IRCItem->password = DupString($3); |
| 228 |
|
|
}; |
| 229 |
|
|
|
| 230 |
|
|
irc_perform: PERFORM '=' STRING ';' |
| 231 |
|
|
{ |
| 232 |
|
|
node_t *node; |
| 233 |
|
|
node = node_create(DupString($3)); |
| 234 |
|
|
|
| 235 |
|
|
list_add(IRCItem->performs, node); |
| 236 |
|
|
}; |
| 237 |
|
|
|
| 238 |
|
|
irc_port: PORT '=' NUMBER ';' |
| 239 |
|
|
{ |
| 240 |
|
|
IRCItem->port = $3; |
| 241 |
|
|
}; |
| 242 |
|
|
|
| 243 |
|
|
irc_realname: REALNAME '=' STRING ';' |
| 244 |
|
|
{ |
| 245 |
|
|
MyFree(IRCItem->realname); |
| 246 |
|
|
IRCItem->realname = DupString($3); |
| 247 |
|
|
}; |
| 248 |
|
|
|
| 249 |
|
|
irc_server: SERVER '=' STRING ';' |
| 250 |
|
|
{ |
| 251 |
|
|
MyFree(IRCItem->server); |
| 252 |
|
|
IRCItem->server = DupString($3); |
| 253 |
|
|
}; |
| 254 |
|
|
|
| 255 |
|
|
irc_username: USERNAME '=' STRING ';' |
| 256 |
|
|
{ |
| 257 |
|
|
MyFree(IRCItem->username); |
| 258 |
|
|
IRCItem->username = DupString($3); |
| 259 |
|
|
}; |
| 260 |
|
|
|
| 261 |
|
|
irc_vhost: VHOST '=' STRING ';' |
| 262 |
|
|
{ |
| 263 |
|
|
MyFree(IRCItem->vhost); |
| 264 |
|
|
IRCItem->vhost = DupString($3); |
| 265 |
|
|
}; |
| 266 |
|
|
|
| 267 |
|
|
irc_connregex: CONNREGEX '=' STRING ';' |
| 268 |
|
|
{ |
| 269 |
|
|
MyFree(IRCItem->connregex); |
| 270 |
|
|
IRCItem->connregex = DupString($3); |
| 271 |
|
|
}; |
| 272 |
|
|
|
| 273 |
|
|
|
| 274 |
|
|
/************************** CHANNEL BLOCK *************************/ |
| 275 |
|
|
|
| 276 |
|
|
channel_entry: |
| 277 |
|
|
{ |
| 278 |
|
|
node_t *node; |
| 279 |
|
|
struct ChannelConf *item; |
| 280 |
|
|
|
| 281 |
|
|
item = MyMalloc(sizeof *item); |
| 282 |
|
|
|
| 283 |
|
|
item->name = DupString(""); |
| 284 |
|
|
item->key = DupString(""); |
| 285 |
|
|
item->invite = DupString(""); |
| 286 |
|
|
|
| 287 |
|
|
node = node_create(item); |
| 288 |
|
|
list_add(IRCItem->channels, node); |
| 289 |
|
|
|
| 290 |
|
|
tmp = (void *) item; |
| 291 |
|
|
} |
| 292 |
|
|
CHANNEL '{' channel_items '}' ';'; |
| 293 |
|
|
|
| 294 |
|
|
channel_items: channel_items channel_item | |
| 295 |
|
|
channel_item; |
| 296 |
|
|
|
| 297 |
|
|
channel_item: channel_name | |
| 298 |
|
|
channel_key | |
| 299 |
|
|
channel_invite; |
| 300 |
|
|
|
| 301 |
|
|
channel_name: NAME '=' STRING ';' |
| 302 |
|
|
{ |
| 303 |
|
|
struct ChannelConf *item = tmp; |
| 304 |
|
|
|
| 305 |
|
|
MyFree(item->name); |
| 306 |
|
|
item->name = DupString($3); |
| 307 |
|
|
}; |
| 308 |
|
|
|
| 309 |
|
|
channel_key: KEY '=' STRING ';' |
| 310 |
|
|
{ |
| 311 |
|
|
struct ChannelConf *item = tmp; |
| 312 |
|
|
|
| 313 |
|
|
MyFree(item->key); |
| 314 |
|
|
item->key = DupString($3); |
| 315 |
|
|
}; |
| 316 |
|
|
|
| 317 |
|
|
channel_invite: INVITE '=' STRING ';' |
| 318 |
|
|
{ |
| 319 |
|
|
struct ChannelConf *item = tmp; |
| 320 |
|
|
|
| 321 |
|
|
MyFree(item->invite); |
| 322 |
|
|
item->invite = DupString($3); |
| 323 |
|
|
}; |
| 324 |
|
|
|
| 325 |
|
|
/*************************** USER BLOCK ***************************/ |
| 326 |
|
|
|
| 327 |
|
|
user_entry: |
| 328 |
|
|
{ |
| 329 |
|
|
node_t *node; |
| 330 |
|
|
struct UserConf *item; |
| 331 |
|
|
|
| 332 |
|
|
item = MyMalloc(sizeof *item); |
| 333 |
|
|
|
| 334 |
|
|
item->masks = list_create(); |
| 335 |
|
|
item->scanners = list_create(); |
| 336 |
|
|
|
| 337 |
|
|
node = node_create(item); |
| 338 |
|
|
list_add(UserItemList, node); |
| 339 |
|
|
|
| 340 |
|
|
tmp = (void *) item; |
| 341 |
|
|
} |
| 342 |
|
|
USER '{' user_items '}' ';' ; |
| 343 |
|
|
|
| 344 |
|
|
user_items: user_items user_item | |
| 345 |
|
|
user_item; |
| 346 |
|
|
|
| 347 |
|
|
user_item: user_mask | |
| 348 |
|
|
user_scanner | |
| 349 |
|
|
error; |
| 350 |
|
|
|
| 351 |
|
|
user_mask: MASK '=' STRING ';' |
| 352 |
|
|
{ |
| 353 |
|
|
struct UserConf *item = (struct UserConf *) tmp; |
| 354 |
|
|
|
| 355 |
|
|
node_t *node; |
| 356 |
|
|
node = node_create((void *) DupString($3)); |
| 357 |
|
|
|
| 358 |
|
|
list_add(item->masks, node); |
| 359 |
|
|
}; |
| 360 |
|
|
|
| 361 |
|
|
user_scanner: SCANNER '=' STRING ';' |
| 362 |
|
|
{ |
| 363 |
|
|
struct UserConf *item = (struct UserConf *) tmp; |
| 364 |
|
|
|
| 365 |
|
|
node_t *node; |
| 366 |
|
|
node = node_create((void *) DupString($3)); |
| 367 |
|
|
|
| 368 |
|
|
list_add(item->scanners, node); |
| 369 |
|
|
}; |
| 370 |
|
|
|
| 371 |
|
|
/*************************** SCANNER BLOCK ***************************/ |
| 372 |
|
|
|
| 373 |
|
|
scanner_entry: |
| 374 |
|
|
{ |
| 375 |
|
|
node_t *node; |
| 376 |
|
|
struct ScannerConf *item, *olditem; |
| 377 |
|
|
|
| 378 |
|
|
item = MyMalloc(sizeof *item); |
| 379 |
|
|
|
| 380 |
|
|
/* Setup ScannerConf defaults */ |
| 381 |
|
|
item->name = DupString("undefined"); |
| 382 |
|
|
|
| 383 |
|
|
if(LIST_SIZE(ScannerItemList) > 0) |
| 384 |
|
|
{ |
| 385 |
|
|
olditem = ScannerItemList->tail->data; |
| 386 |
|
|
|
| 387 |
|
|
item->vhost = DupString(olditem->vhost); |
| 388 |
|
|
item->fd = olditem->fd; |
| 389 |
|
|
item->target_ip = DupString(olditem->target_ip); |
| 390 |
|
|
item->target_port = olditem->target_port; |
| 391 |
|
|
item->timeout = olditem->timeout; |
| 392 |
|
|
item->max_read = olditem->max_read; |
| 393 |
|
|
|
| 394 |
|
|
item->target_string = olditem->target_string; |
| 395 |
|
|
item->target_string_created = 0; |
| 396 |
|
|
} |
| 397 |
|
|
else |
| 398 |
|
|
{ |
| 399 |
|
|
item->vhost = DupString("0.0.0.0"); |
| 400 |
|
|
item->fd = 512; |
| 401 |
|
|
item->target_ip = DupString("127.0.0.1"); |
| 402 |
|
|
item->target_port = 6667; |
| 403 |
|
|
item->timeout = 30; |
| 404 |
|
|
item->max_read = 4096; |
| 405 |
|
|
|
| 406 |
|
|
item->target_string = list_create(); |
| 407 |
|
|
item->target_string_created = 1; |
| 408 |
|
|
} |
| 409 |
|
|
|
| 410 |
|
|
item->protocols = list_create(); |
| 411 |
|
|
|
| 412 |
|
|
node = node_create(item); |
| 413 |
|
|
|
| 414 |
|
|
list_add(ScannerItemList, node); |
| 415 |
|
|
tmp = (void *) item; |
| 416 |
|
|
} |
| 417 |
|
|
SCANNER '{' scanner_items '}' ';' ; |
| 418 |
|
|
|
| 419 |
|
|
scanner_items: scanner_items scanner_item | |
| 420 |
|
|
scanner_item; |
| 421 |
|
|
|
| 422 |
|
|
scanner_item: scanner_name | |
| 423 |
|
|
scanner_vhost | |
| 424 |
|
|
scanner_fd | |
| 425 |
|
|
scanner_target_ip | |
| 426 |
|
|
scanner_target_port | |
| 427 |
|
|
scanner_target_string | |
| 428 |
|
|
scanner_protocol | |
| 429 |
|
|
scanner_timeout | |
| 430 |
|
|
scanner_max_read | |
| 431 |
|
|
error; |
| 432 |
|
|
|
| 433 |
|
|
scanner_name: NAME '=' STRING ';' |
| 434 |
|
|
{ |
| 435 |
|
|
struct ScannerConf *item = (struct ScannerConf *) tmp; |
| 436 |
|
|
MyFree(item->name); |
| 437 |
|
|
item->name = DupString($3); |
| 438 |
|
|
}; |
| 439 |
|
|
|
| 440 |
|
|
scanner_vhost: VHOST '=' STRING ';' |
| 441 |
|
|
{ |
| 442 |
|
|
struct ScannerConf *item = (struct ScannerConf *) tmp; |
| 443 |
|
|
MyFree(item->vhost); |
| 444 |
|
|
item->vhost = DupString($3); |
| 445 |
|
|
}; |
| 446 |
|
|
|
| 447 |
|
|
scanner_target_ip: TARGET_IP '=' STRING ';' |
| 448 |
|
|
{ |
| 449 |
|
|
struct ScannerConf *item = (struct ScannerConf *) tmp; |
| 450 |
|
|
MyFree(item->target_ip); |
| 451 |
|
|
item->target_ip = DupString($3); |
| 452 |
|
|
}; |
| 453 |
|
|
|
| 454 |
|
|
scanner_target_string: TARGET_STRING '=' STRING ';' |
| 455 |
|
|
{ |
| 456 |
|
|
struct ScannerConf *item = (struct ScannerConf *) tmp; |
| 457 |
|
|
|
| 458 |
|
|
node_t *node; |
| 459 |
|
|
node = node_create($3); |
| 460 |
|
|
|
| 461 |
|
|
if(item->target_string_created == 0) |
| 462 |
|
|
{ |
| 463 |
|
|
item->target_string = list_create(); |
| 464 |
|
|
item->target_string_created = 1; |
| 465 |
|
|
} |
| 466 |
|
|
|
| 467 |
|
|
list_add(item->target_string, node); |
| 468 |
|
|
}; |
| 469 |
|
|
|
| 470 |
|
|
scanner_fd: FD '=' NUMBER ';' |
| 471 |
|
|
{ |
| 472 |
|
|
struct ScannerConf *item = (struct ScannerConf *) tmp; |
| 473 |
|
|
item->fd = $3; |
| 474 |
|
|
}; |
| 475 |
|
|
|
| 476 |
|
|
scanner_target_port: TARGET_PORT '=' NUMBER ';' |
| 477 |
|
|
{ |
| 478 |
|
|
struct ScannerConf *item = (struct ScannerConf *) tmp; |
| 479 |
|
|
item->target_port = $3; |
| 480 |
|
|
}; |
| 481 |
|
|
|
| 482 |
michael |
5080 |
scanner_timeout: TIMEOUT '=' timespec ';' |
| 483 |
michael |
5052 |
{ |
| 484 |
|
|
struct ScannerConf *item = (struct ScannerConf *) tmp; |
| 485 |
|
|
item->timeout = $3; |
| 486 |
|
|
}; |
| 487 |
|
|
|
| 488 |
michael |
5080 |
scanner_max_read: MAX_READ '=' sizespec ';' |
| 489 |
michael |
5052 |
{ |
| 490 |
|
|
struct ScannerConf *item = (struct ScannerConf *) tmp; |
| 491 |
|
|
item->max_read = $3; |
| 492 |
|
|
}; |
| 493 |
|
|
|
| 494 |
|
|
scanner_protocol: PROTOCOL '=' PROTOCOLTYPE ':' NUMBER ';' |
| 495 |
|
|
{ |
| 496 |
|
|
struct ProtocolConf *item; |
| 497 |
|
|
struct ScannerConf *item2; |
| 498 |
|
|
|
| 499 |
|
|
node_t *node; |
| 500 |
|
|
|
| 501 |
|
|
item = MyMalloc(sizeof *item); |
| 502 |
|
|
item->type = $3; |
| 503 |
|
|
item->port = $5; |
| 504 |
|
|
|
| 505 |
|
|
item2 = (struct ScannerConf *) tmp; |
| 506 |
|
|
|
| 507 |
|
|
node = node_create(item); |
| 508 |
|
|
list_add(item2->protocols, node); |
| 509 |
|
|
}; |
| 510 |
|
|
|
| 511 |
|
|
/*************************** OPM BLOCK ***************************/ |
| 512 |
|
|
|
| 513 |
|
|
opm_entry: OPM '{' opm_items '}' ';' ; |
| 514 |
|
|
|
| 515 |
michael |
5068 |
opm_items: opm_items opm_item | |
| 516 |
michael |
5052 |
opm_item; |
| 517 |
|
|
|
| 518 |
|
|
opm_item: opm_dnsbl_from | |
| 519 |
|
|
opm_dnsbl_to | |
| 520 |
|
|
opm_sendmail | |
| 521 |
|
|
opm_blacklist_entry | |
| 522 |
|
|
error; |
| 523 |
|
|
|
| 524 |
|
|
opm_dnsbl_from: DNSBL_FROM '=' STRING ';' |
| 525 |
|
|
{ |
| 526 |
|
|
MyFree(OpmItem->dnsbl_from); |
| 527 |
|
|
OpmItem->dnsbl_from = DupString($3); |
| 528 |
|
|
}; |
| 529 |
|
|
|
| 530 |
|
|
opm_dnsbl_to: DNSBL_TO '=' STRING ';' |
| 531 |
|
|
{ |
| 532 |
|
|
MyFree(OpmItem->dnsbl_to); |
| 533 |
|
|
OpmItem->dnsbl_to = DupString($3); |
| 534 |
|
|
}; |
| 535 |
|
|
|
| 536 |
|
|
opm_sendmail: SENDMAIL '=' STRING ';' |
| 537 |
|
|
{ |
| 538 |
|
|
MyFree(OpmItem->sendmail); |
| 539 |
|
|
OpmItem->sendmail = DupString($3); |
| 540 |
|
|
}; |
| 541 |
|
|
|
| 542 |
|
|
/************************** BLACKLIST BLOCK *************************/ |
| 543 |
|
|
|
| 544 |
|
|
opm_blacklist_entry: |
| 545 |
|
|
{ |
| 546 |
|
|
node_t *node; |
| 547 |
|
|
struct BlacklistConf *item; |
| 548 |
|
|
|
| 549 |
|
|
item = MyMalloc(sizeof *item); |
| 550 |
|
|
|
| 551 |
|
|
item->name = DupString(""); |
| 552 |
|
|
item->kline = DupString(""); |
| 553 |
|
|
item->ban_unknown = 0; |
| 554 |
|
|
item->type = A_BITMASK; |
| 555 |
|
|
item->reply = list_create(); |
| 556 |
|
|
|
| 557 |
|
|
node = node_create(item); |
| 558 |
|
|
list_add(OpmItem->blacklists, node); |
| 559 |
|
|
|
| 560 |
|
|
tmp = (void *) item; |
| 561 |
|
|
} |
| 562 |
|
|
BLACKLIST '{' blacklist_items '}' ';'; |
| 563 |
|
|
|
| 564 |
michael |
5068 |
blacklist_items: blacklist_items blacklist_item | |
| 565 |
|
|
blacklist_item; |
| 566 |
michael |
5052 |
|
| 567 |
|
|
blacklist_item: blacklist_name | |
| 568 |
|
|
blacklist_type | |
| 569 |
|
|
blacklist_kline | |
| 570 |
|
|
blacklist_ban_unknown | |
| 571 |
|
|
blacklist_reply | |
| 572 |
|
|
error; |
| 573 |
|
|
|
| 574 |
|
|
blacklist_name: NAME '=' STRING ';' { |
| 575 |
|
|
struct BlacklistConf *item = tmp; |
| 576 |
|
|
|
| 577 |
|
|
MyFree(item->name); |
| 578 |
|
|
item->name = DupString($3); |
| 579 |
|
|
}; |
| 580 |
|
|
|
| 581 |
|
|
blacklist_kline: KLINE '=' STRING ';' { |
| 582 |
|
|
struct BlacklistConf *item = tmp; |
| 583 |
|
|
|
| 584 |
|
|
MyFree(item->kline); |
| 585 |
|
|
item->kline = DupString($3); |
| 586 |
|
|
}; |
| 587 |
|
|
|
| 588 |
|
|
blacklist_type: TYPE '=' STRING ';' { |
| 589 |
|
|
struct BlacklistConf *item = tmp; |
| 590 |
|
|
|
| 591 |
|
|
if(strcmp("A record bitmask", $3) == 0) |
| 592 |
|
|
item->type = A_BITMASK; |
| 593 |
|
|
else if(strcmp("A record reply", $3) == 0) |
| 594 |
|
|
item->type = A_REPLY; |
| 595 |
|
|
else |
| 596 |
|
|
yyerror("Unknown blacklist type defined"); |
| 597 |
|
|
}; |
| 598 |
|
|
|
| 599 |
|
|
blacklist_ban_unknown: BAN_UNKNOWN '=' NUMBER ';' { |
| 600 |
|
|
struct BlacklistConf *item = tmp; |
| 601 |
|
|
|
| 602 |
|
|
item->ban_unknown = $3; |
| 603 |
|
|
}; |
| 604 |
|
|
|
| 605 |
|
|
blacklist_reply: REPLY '{' blacklist_reply_items '}' ';'; |
| 606 |
|
|
|
| 607 |
michael |
5068 |
blacklist_reply_items: blacklist_reply_items blacklist_reply_item | |
| 608 |
michael |
5052 |
blacklist_reply_item; |
| 609 |
|
|
|
| 610 |
|
|
blacklist_reply_item: NUMBER '=' STRING ';' |
| 611 |
|
|
{ |
| 612 |
|
|
struct BlacklistReplyConf *item; |
| 613 |
|
|
struct BlacklistConf *blacklist = tmp; |
| 614 |
|
|
node_t *node; |
| 615 |
|
|
|
| 616 |
|
|
item = MyMalloc(sizeof *item); |
| 617 |
|
|
|
| 618 |
|
|
item->number = $1; |
| 619 |
|
|
item->type = DupString($3); |
| 620 |
|
|
|
| 621 |
|
|
node = node_create(item); |
| 622 |
|
|
list_add(blacklist->reply, node); |
| 623 |
|
|
}; |
| 624 |
|
|
|
| 625 |
|
|
/*************************** EXEMPT BLOCK ***************************/ |
| 626 |
|
|
|
| 627 |
|
|
|
| 628 |
|
|
exempt_entry: EXEMPT '{' exempt_items '}' ';' ; |
| 629 |
|
|
|
| 630 |
michael |
5068 |
exempt_items: exempt_items exempt_item | |
| 631 |
michael |
5052 |
exempt_item; |
| 632 |
|
|
|
| 633 |
|
|
exempt_item: exempt_mask | |
| 634 |
|
|
error; |
| 635 |
|
|
|
| 636 |
|
|
exempt_mask: MASK '=' STRING ';' |
| 637 |
|
|
{ |
| 638 |
|
|
node_t *node; |
| 639 |
|
|
node = node_create(DupString($3)); |
| 640 |
|
|
|
| 641 |
|
|
list_add(ExemptItem->masks, node); |
| 642 |
|
|
}; |
| 643 |
|
|
|
| 644 |
|
|
%% |