377 | 377 |
size_t off;
|
378 | 378 |
|
379 | 379 |
if (r->expr == NULL)
|
380 | |
strlcpy(s, "all", sizeof s);
|
|
380 |
strlcpy(s, "all ", sizeof s);
|
381 | 381 |
else {
|
382 | 382 |
*s = '\0';
|
383 | 383 |
off = 0;
|
|
409 | 409 |
su = xstrdup("");
|
410 | 410 |
if (r->lambda != NULL) {
|
411 | 411 |
make_actlist(r->lambda->list, desc, sizeof desc);
|
412 | |
log_debug2("added rule %u:%s%s matches=%s lambda=%s", r->idx,
|
|
412 |
log_debug2("added rule %u:%s%s matches=%slambda=%s", r->idx,
|
413 | 413 |
sa, su, s, desc);
|
414 | 414 |
} else if (r->actions != NULL) {
|
415 | 415 |
ss = fmt_strings(NULL, (struct strings *) r->actions);
|
416 | |
log_debug2("added rule %u:%s%s matches=%s actions=%s", r->idx,
|
|
416 |
log_debug2("added rule %u:%s%s matches=%sactions=%s", r->idx,
|
417 | 417 |
sa, su, s, ss);
|
418 | 418 |
xfree(ss);
|
419 | |
} else if (r->key.str != NULL) {
|
420 | |
log_debug2("added rule %u:%s matches=%s tag=%s (%s)", r->idx,
|
421 | |
sa, s, r->key.str, r->value.str);
|
422 | 419 |
} else
|
423 | |
log_debug2("added rule %u:%s matches=%s nested", r->idx, sa, s);
|
|
420 |
log_debug2("added rule %u:%s matches=%snested", r->idx, sa, s);
|
424 | 421 |
xfree(sa);
|
425 | 422 |
xfree(su);
|
426 | 423 |
}
|
|
507 | 504 |
} else if (ti->deliver == &deliver_mbox) {
|
508 | 505 |
struct deliver_mbox_data *data = ti->data;
|
509 | 506 |
xfree(data->path.str);
|
|
507 |
} else if (ti->deliver == &deliver_tag) {
|
|
508 |
struct deliver_tag_data *data = ti->data;
|
|
509 |
xfree(data->key.str);
|
|
510 |
if (data->value.str != NULL)
|
|
511 |
xfree(data->value.str);
|
510 | 512 |
} else if (ti->deliver == &deliver_smtp) {
|
511 | 513 |
struct deliver_smtp_data *data = ti->data;
|
512 | 514 |
xfree(data->to.str);
|
|
537 | 539 |
free_strings((struct strings *) r->actions);
|
538 | 540 |
ARRAY_FREEALL(r->actions);
|
539 | 541 |
}
|
540 | |
|
541 | |
if (r->key.str != NULL)
|
542 | |
xfree(r->key.str);
|
543 | |
if (r->value.str != NULL)
|
544 | |
xfree(r->value.str);
|
545 | 542 |
|
546 | 543 |
if (r->lambda != NULL)
|
547 | 544 |
free_action(r->lambda);
|
|
977 | 974 |
curfile = $2;
|
978 | 975 |
log_debug2("including file %s", curfile);
|
979 | 976 |
yyrestart(yyin);
|
980 | |
yylineno = 0;
|
|
977 |
yylineno = 1;
|
981 | 978 |
}
|
982 | 979 |
|
983 | 980 |
/** SIZE: <number> (long long) */
|
|
1879 | 1876 |
|
1880 | 1877 |
data->add_from = $2;
|
1881 | 1878 |
}
|
|
1879 |
| TOKTAG strv
|
|
1880 |
{
|
|
1881 |
struct deliver_tag_data *data;
|
|
1882 |
|
|
1883 |
if (*$2 == '\0')
|
|
1884 |
yyerror("invalid tag");
|
|
1885 |
|
|
1886 |
$$ = xcalloc(1, sizeof *$$);
|
|
1887 |
$$->deliver = &deliver_tag;
|
|
1888 |
|
|
1889 |
data = xcalloc(1, sizeof *data);
|
|
1890 |
$$->data = data;
|
|
1891 |
|
|
1892 |
data->key.str = $2;
|
|
1893 |
data->value.str = NULL;
|
|
1894 |
}
|
|
1895 |
| TOKTAG strv TOKVALUE strv
|
|
1896 |
{
|
|
1897 |
struct deliver_tag_data *data;
|
|
1898 |
|
|
1899 |
if (*$2 == '\0')
|
|
1900 |
yyerror("invalid tag");
|
|
1901 |
|
|
1902 |
$$ = xcalloc(1, sizeof *$$);
|
|
1903 |
$$->deliver = &deliver_tag;
|
|
1904 |
|
|
1905 |
data = xcalloc(1, sizeof *data);
|
|
1906 |
$$->data = data;
|
|
1907 |
|
|
1908 |
data->key.str = $2;
|
|
1909 |
data->value.str = $4;
|
|
1910 |
}
|
1882 | 1911 |
| TOKDROP
|
1883 | 1912 |
{
|
1884 | 1913 |
$$ = xcalloc(1, sizeof *$$);
|
|
2479 | 2508 |
perform: TOKTAG strv
|
2480 | 2509 |
/** [$2: strv (char *)] */
|
2481 | 2510 |
{
|
|
2511 |
struct action *t;
|
|
2512 |
struct actitem *ti;
|
|
2513 |
struct deliver_tag_data *data;
|
|
2514 |
char *file;
|
|
2515 |
|
|
2516 |
file = curfile == NULL ? conf.conf_file : curfile;
|
|
2517 |
log_warnx("%s: \"match ... tag\" is deprecated, please use "
|
|
2518 |
"\"match ... action tag\" at line %d", file, yylineno);
|
|
2519 |
|
2482 | 2520 |
if (*$2 == '\0')
|
2483 | 2521 |
yyerror("invalid tag");
|
2484 | 2522 |
|
|
2523 |
if (*$2 == '\0')
|
|
2524 |
yyerror("invalid tag");
|
|
2525 |
|
|
2526 |
ti = xcalloc(1, sizeof *$$);
|
|
2527 |
ti->deliver = &deliver_tag;
|
|
2528 |
|
|
2529 |
data = xcalloc(1, sizeof *data);
|
|
2530 |
ti->data = data;
|
|
2531 |
|
|
2532 |
data->key.str = $2;
|
|
2533 |
data->value.str = NULL;
|
|
2534 |
|
2485 | 2535 |
$$ = xcalloc(1, sizeof *$$);
|
2486 | 2536 |
$$->idx = ruleidx++;
|
2487 | |
$$->lambda = NULL;
|
2488 | 2537 |
$$->actions = NULL;
|
2489 | |
$$->key.str = $2;
|
2490 | |
$$->value.str = xstrdup("");
|
2491 | 2538 |
TAILQ_INIT(&$$->rules);
|
2492 | 2539 |
$$->stop = 0;
|
2493 | 2540 |
$$->users = NULL;
|
2494 | 2541 |
$$->find_uid = 0;
|
2495 | 2542 |
|
|
2543 |
t = $$->lambda = xcalloc(1, sizeof *$$->lambda);
|
|
2544 |
xsnprintf(t->name, sizeof t->name, "<rule %u>", $$->idx);
|
|
2545 |
t->users = NULL;
|
|
2546 |
t->find_uid = 0;
|
|
2547 |
t->list = xmalloc(sizeof *t->list);
|
|
2548 |
TAILQ_INIT(t->list);
|
|
2549 |
TAILQ_INSERT_HEAD(t->list, ti, entry);
|
|
2550 |
ti->idx = 0;
|
|
2551 |
|
2496 | 2552 |
if (currule == NULL)
|
2497 | 2553 |
TAILQ_INSERT_TAIL(&conf.rules, $$, entry);
|
2498 | 2554 |
else
|
|
2501 | 2557 |
| TOKTAG strv TOKVALUE strv
|
2502 | 2558 |
/** [$2: strv (char *)] [$4: strv (char *)] */
|
2503 | 2559 |
{
|
|
2560 |
struct action *t;
|
|
2561 |
struct actitem *ti;
|
|
2562 |
struct deliver_tag_data *data;
|
|
2563 |
char *file;
|
|
2564 |
|
|
2565 |
file = curfile == NULL ? conf.conf_file : curfile;
|
|
2566 |
log_warnx("%s: \"match ... tag\" is deprecated, please use "
|
|
2567 |
"\"match ... action tag\" at line %d", file, yylineno);
|
|
2568 |
|
2504 | 2569 |
if (*$2 == '\0')
|
2505 | 2570 |
yyerror("invalid tag");
|
|
2571 |
|
|
2572 |
if (*$2 == '\0')
|
|
2573 |
yyerror("invalid tag");
|
|
2574 |
|
|
2575 |
ti = xcalloc(1, sizeof *$$);
|
|
2576 |
ti->deliver = &deliver_tag;
|
|
2577 |
|
|
2578 |
data = xcalloc(1, sizeof *data);
|
|
2579 |
ti->data = data;
|
|
2580 |
|
|
2581 |
data->key.str = $2;
|
|
2582 |
data->value.str = $4;
|
2506 | 2583 |
|
2507 | 2584 |
$$ = xcalloc(1, sizeof *$$);
|
2508 | 2585 |
$$->idx = ruleidx++;
|
2509 | 2586 |
$$->actions = NULL;
|
2510 | |
$$->key.str = $2;
|
2511 | |
$$->value.str = $4;
|
2512 | 2587 |
TAILQ_INIT(&$$->rules);
|
2513 | 2588 |
$$->stop = 0;
|
2514 | 2589 |
$$->users = NULL;
|
2515 | 2590 |
$$->find_uid = 0;
|
2516 | 2591 |
|
|
2592 |
t = $$->lambda = xcalloc(1, sizeof *$$->lambda);
|
|
2593 |
xsnprintf(t->name, sizeof t->name, "<rule %u>", $$->idx);
|
|
2594 |
t->users = NULL;
|
|
2595 |
t->find_uid = 0;
|
|
2596 |
t->list = xmalloc(sizeof *t->list);
|
|
2597 |
TAILQ_INIT(t->list);
|
|
2598 |
TAILQ_INSERT_HEAD(t->list, ti, entry);
|
|
2599 |
ti->idx = 0;
|
|
2600 |
|
2517 | 2601 |
if (currule == NULL)
|
2518 | 2602 |
TAILQ_INSERT_TAIL(&conf.rules, $$, entry);
|
2519 | 2603 |
else
|
|
2526 | 2610 |
$$ = xcalloc(1, sizeof *$$);
|
2527 | 2611 |
$$->idx = ruleidx++;
|
2528 | 2612 |
$$->actions = NULL;
|
2529 | |
$$->key.str = NULL;
|
2530 | |
$$->value.str = NULL;
|
2531 | 2613 |
TAILQ_INIT(&$$->rules);
|
2532 | 2614 |
$$->stop = !$4;
|
2533 | 2615 |
$$->users = $1.users;
|
|
2554 | 2636 |
$$ = xcalloc(1, sizeof *$$);
|
2555 | 2637 |
$$->idx = ruleidx++;
|
2556 | 2638 |
$$->actions = NULL;
|
2557 | |
$$->key.str = NULL;
|
2558 | |
$$->value.str = NULL;
|
2559 | 2639 |
TAILQ_INIT(&$$->rules);
|
2560 | 2640 |
$$->stop = !$6;
|
2561 | 2641 |
$$->users = $1.users;
|
|
2580 | 2660 |
$$->idx = ruleidx++;
|
2581 | 2661 |
$$->lambda = NULL;
|
2582 | 2662 |
$$->actions = $2;
|
2583 | |
$$->key.str = NULL;
|
2584 | |
$$->value.str = NULL;
|
2585 | 2663 |
TAILQ_INIT(&$$->rules);
|
2586 | 2664 |
$$->stop = !$3;
|
2587 | 2665 |
$$->users = $1.users;
|
|
2598 | 2676 |
$$->idx = ruleidx++;
|
2599 | 2677 |
$$->lambda = NULL;
|
2600 | 2678 |
$$->actions = NULL;
|
2601 | |
$$->key.str = NULL;
|
2602 | |
$$->value.str = NULL;
|
2603 | 2679 |
TAILQ_INIT(&$$->rules);
|
2604 | 2680 |
$$->stop = 0;
|
2605 | 2681 |
$$->users = NULL;
|