~ubuntu-branches/ubuntu/trusty/syslog-ng/trusty-proposed

« back to all changes in this revision

Viewing changes to lib/rewrite-expr-grammar.y

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS), Gergely Nagy
  • Date: 2011-10-11 14:30:48 UTC
  • mfrom: (1.3.7)
  • Revision ID: package-import@ubuntu.com-20111011143048-r1iljux9xbvj3lwh
Tags: 3.3.1.dfsg-1
* New upstream release with important fixes from upstream git tree with
  non-free manpages removed.
* Drop syslog-ng.conf(5) (closes: #496521).
* syslog-ng(8) is generated, and does not mention -Q anymore
  (closes: #616069).
* Supports CAP_SYSLOG on recent kernels (closes: #630172).
* Does not use g_timeout_add_seconds anymore (closes: #609154).

[ Gergely Nagy <algernon@madhouse-project.org> ]
* Update debian/copyright to DEP-5 format.
* Simplified the logrotate file by merging identical entries.
* Include local configuration files from /etc/syslog-ng/conf.d/ (Closes:
  #609050).
* Update syslog-ng.conf to be fully 3.3 compliant.
* Compress both source and binaries (except the syslog-ng meta
  package) with xz, instead of gzip.
* Use dpkg triggers to restart syslog-ng when appropriate.
* Include DFSG-free manual pages for all binaries.
* Build with Hardening enabled.
* Mention syslog(3) in /etc/default/syslog-ng, instead of
  <linux/kernel.h> (Closes: #608605)
* Support 'status' in the init script.
  Patch from Peter Eisentraut <petere@debian.org> (Closes: #644458)
* Build-Depend on libevtlog-dev (>= 0.2.12-5~) for correct shlibs.
* Use [linux-any] in Build-Depends instead of hardcoded links.
  (Closes: #634715)
* Use $SYSLOGNG_OPTS in the init script when reloading syslog-ng.
  (Closes: #589081)

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
 
42
42
LogRewrite *last_rewrite;
43
43
 
 
44
static gboolean
 
45
is_sdata_valid(const gchar *buffer)
 
46
{
 
47
  gboolean result = FALSE;
 
48
  const gchar *dot;
 
49
  int dot_found = 0;
 
50
  if (strlen(buffer)>6 && strncmp(buffer,".SDATA.",7)==0)
 
51
    {
 
52
      dot = memchr(buffer,'.',strlen(buffer));
 
53
      while (dot && strlen(dot)>1)
 
54
        {
 
55
          dot_found++;
 
56
          dot++;
 
57
          dot = memchr(dot, '.',strlen(dot));
 
58
        }
 
59
      if (dot_found >= 3)
 
60
        result = TRUE;
 
61
    }
 
62
  return result;
 
63
}
 
64
 
44
65
}
45
66
 
46
67
%name-prefix "rewrite_expr_"
47
68
%lex-param {CfgLexer *lexer}
48
69
%parse-param {CfgLexer *lexer}
49
70
%parse-param {GList **result}
 
71
%parse-param {gpointer arg}
50
72
 
51
73
%type   <ptr> rewrite_expr
52
74
%type   <ptr> rewrite_expr_list
88
110
          {                                                             \
89
111
            gchar __buf[256];                                           \
90
112
            g_snprintf(__buf, sizeof(__buf), errorfmt ? errorfmt : "x", ## __VA_ARGS__); \
91
 
            yyerror(& (token), lexer, NULL, __buf);                     \
 
113
            yyerror(& (token), lexer, NULL, NULL, __buf);               \
92
114
          }                                                             \
93
115
        YYERROR;                                                        \
94
116
      }                                                                 \
114
136
%token LL_CONTEXT_PRAGMA              11
115
137
%token LL_CONTEXT_FORMAT              12
116
138
%token LL_CONTEXT_TEMPLATE_FUNC       13
 
139
%token LL_CONTEXT_INNER_DEST          14
 
140
%token LL_CONTEXT_INNER_SRC           15
117
141
 
118
142
/* statements */
119
143
%token KW_SOURCE                      10000
148
172
 
149
173
%token KW_SYSLOG                      10060
150
174
 
151
 
 
152
175
/* option items */
153
176
%token KW_MARK_FREQ                   10071
154
177
%token KW_STATS_FREQ                  10072
192
215
%token KW_HOST_OVERRIDE               10166
193
216
 
194
217
%token KW_THROTTLE                    10170
 
218
%token KW_THREADED                    10171
195
219
 
196
220
/* log statement options */
197
221
%token KW_FLAGS                       10190
276
300
%token LL_EOL                         10428
277
301
%token LL_ERROR                       10429
278
302
 
 
303
/* value pairs */
 
304
%token KW_VALUE_PAIRS                 10500
 
305
%token KW_SELECT                      10501
 
306
%token KW_EXCLUDE                     10502
 
307
%token KW_PAIR                        10503
 
308
%token KW_KEY                         10504
 
309
%token KW_SCOPE                       10505
 
310
 
 
311
 
 
312
%type   <ptr> value_pair_option
279
313
 
280
314
%type   <num> yesno
281
315
%type   <num> dnsmode
334
368
            p = plugin_find(configuration, context, $1);
335
369
            CHECK_ERROR(p, @1, "%s plugin %s not found", cfg_lexer_lookup_context_name_by_type(context), $1);
336
370
 
337
 
            last_rewrite = (LogRewrite *) plugin_parse_config(p, configuration, &@1);
 
371
            last_rewrite = (LogRewrite *) plugin_parse_config(p, configuration, &@1, NULL);
338
372
            free($1);
339
373
            if (!last_rewrite)
340
374
              {
384
418
                            NULL);
385
419
                last_rewrite->value_handle = LM_V_MESSAGE;
386
420
              }
 
421
 
 
422
            /* SDATA validation */
 
423
            if (strlen($3)>6 && strncmp($3,".SDATA.",7)==0)
 
424
              {
 
425
                if (!is_sdata_valid($3))
 
426
                  {
 
427
                    msg_error("Invalid structured data format",evt_tag_str("SDATA",$3), NULL);
 
428
                    YYERROR;
 
429
                  }
 
430
              }
387
431
            free($3);
388
432
          }
389
433
        | KW_CONDITION '('
390
434
          {
391
435
            FilterExprNode *filter_expr;
392
436
 
393
 
            CHECK_ERROR(cfg_parser_parse(&filter_expr_parser, lexer, (gpointer *) &filter_expr), @1, NULL);
 
437
            CHECK_ERROR(cfg_parser_parse(&filter_expr_parser, lexer, (gpointer *) &filter_expr, NULL), @1, NULL);
394
438
            log_rewrite_set_condition(last_rewrite, filter_expr);
395
439
          } ')'
396
440
        ;
456
500
        ;
457
501
 
458
502
 
 
503
/* LogSource related options */
 
504
source_option
 
505
        /* NOTE: plugins need to set "last_source_options" in order to incorporate this rule in their grammar */
 
506
        : KW_LOG_IW_SIZE '(' LL_NUMBER ')'      { last_source_options->init_window_size = $3; }
 
507
        | KW_CHAIN_HOSTNAMES '(' yesno ')'      { last_source_options->chain_hostnames = $3; }
 
508
        | KW_NORMALIZE_HOSTNAMES '(' yesno ')'  { last_source_options->normalize_hostnames = $3; }
 
509
        | KW_KEEP_HOSTNAME '(' yesno ')'        { last_source_options->keep_hostname = $3; }
 
510
        | KW_USE_FQDN '(' yesno ')'             { last_source_options->use_fqdn = $3; }
 
511
        | KW_USE_DNS '(' dnsmode ')'            { last_source_options->use_dns = $3; }
 
512
        | KW_DNS_CACHE '(' yesno ')'            { last_source_options->use_dns_cache = $3; }
 
513
        | KW_PROGRAM_OVERRIDE '(' string ')'    { last_source_options->program_override = g_strdup($3); free($3); }
 
514
        | KW_HOST_OVERRIDE '(' string ')'       { last_source_options->host_override = g_strdup($3); free($3); }
 
515
        | KW_LOG_PREFIX '(' string ')'          { gchar *p = strrchr($3, ':'); if (p) *p = 0; last_source_options->program_override = g_strdup($3); free($3); }
 
516
        | KW_KEEP_TIMESTAMP '(' yesno ')'       { last_source_options->keep_timestamp = $3; }
 
517
        | KW_TAGS '(' string_list ')'           { log_source_options_set_tags(last_source_options, $3); }
 
518
        ;
 
519
 
 
520
 
459
521
source_reader_options
460
522
        : source_reader_option source_reader_options
461
523
        |
462
524
        ;
463
525
 
 
526
/* LogReader related options, inherits from LogSource */
464
527
source_reader_option
465
 
        : KW_LOG_IW_SIZE '(' LL_NUMBER ')'              { last_reader_options->super.init_window_size = $3; }
466
 
        | KW_CHAIN_HOSTNAMES '(' yesno ')'      { last_reader_options->super.chain_hostnames = $3; }
467
 
        | KW_NORMALIZE_HOSTNAMES '(' yesno ')'  { last_reader_options->super.normalize_hostnames = $3; }
468
 
        | KW_KEEP_HOSTNAME '(' yesno ')'        { last_reader_options->super.keep_hostname = $3; }
469
 
        | KW_USE_FQDN '(' yesno ')'             { last_reader_options->super.use_fqdn = $3; }
470
 
        | KW_USE_DNS '(' dnsmode ')'            { last_reader_options->super.use_dns = $3; }
471
 
        | KW_DNS_CACHE '(' yesno ')'            { last_reader_options->super.use_dns_cache = $3; }
472
 
        | KW_PROGRAM_OVERRIDE '(' string ')'    { last_reader_options->super.program_override = g_strdup($3); free($3); }
473
 
        | KW_HOST_OVERRIDE '(' string ')'       { last_reader_options->super.host_override = g_strdup($3); free($3); }
474
 
        | KW_LOG_PREFIX '(' string ')'          { gchar *p = strrchr($3, ':'); if (p) *p = 0; last_reader_options->super.program_override = g_strdup($3); free($3); }
475
 
        | KW_TIME_ZONE '(' string ')'           { last_reader_options->parse_options.recv_time_zone = g_strdup($3); free($3); }
 
528
        /* NOTE: plugins need to set "last_reader_options" in order to incorporate this rule in their grammar */
 
529
 
 
530
        : KW_TIME_ZONE '(' string ')'           { last_reader_options->parse_options.recv_time_zone = g_strdup($3); free($3); }
476
531
        | KW_CHECK_HOSTNAME '(' yesno ')'       { last_reader_options->check_hostname = $3; }
477
532
        | KW_FLAGS '(' source_reader_option_flags ')'
478
533
        | KW_LOG_MSG_SIZE '(' LL_NUMBER ')'     { last_reader_options->msg_size = $3; }
479
534
        | KW_LOG_FETCH_LIMIT '(' LL_NUMBER ')'  { last_reader_options->fetch_limit = $3; }
480
535
        | KW_PAD_SIZE '(' LL_NUMBER ')'         { last_reader_options->padding = $3; }
481
 
        | KW_KEEP_TIMESTAMP '(' yesno ')'       { last_reader_options->super.keep_timestamp = $3; }
482
536
        | KW_ENCODING '(' string ')'            { last_reader_options->text_encoding = g_strdup($3); free($3); }
483
 
        | KW_TAGS '(' string_list ')'           { log_reader_options_set_tags(last_reader_options, $3); }
484
537
        | KW_FORMAT '(' string ')'              { last_reader_options->parse_options.format = g_strdup($3); free($3); }
485
538
        | KW_DEFAULT_LEVEL '(' level_string ')'
486
539
          {
494
547
              last_reader_options->parse_options.default_pri = LOG_NOTICE;
495
548
            last_reader_options->parse_options.default_pri = (last_reader_options->parse_options.default_pri & 7) | $3;
496
549
          }
 
550
        | { last_source_options = &last_reader_options->super; } source_option
497
551
        ;
498
552
 
499
553
source_reader_option_flags
500
554
        : string source_reader_option_flags     { CHECK_ERROR(log_reader_options_process_flag(last_reader_options, $1), @1, "Unknown flag %s", $1); free($1); }
 
555
        | KW_CHECK_HOSTNAME source_reader_option_flags     { log_reader_options_process_flag(last_reader_options, "check-hostname"); }
501
556
        |
502
557
        ;
503
558
 
 
559
dest_driver_option
 
560
        /* NOTE: plugins need to set "last_driver" in order to incorporate this rule in their grammar */
 
561
 
 
562
        : KW_LOG_FIFO_SIZE '(' LL_NUMBER ')'    { ((LogDestDriver *) last_driver)->log_fifo_size = $3; }
 
563
        | KW_THROTTLE '(' LL_NUMBER ')'         { ((LogDestDriver *) last_driver)->throttle = $3; }
 
564
        | LL_IDENTIFIER
 
565
          {
 
566
            Plugin *p;
 
567
            gint context = LL_CONTEXT_INNER_DEST;
 
568
            gpointer value;
 
569
 
 
570
            p = plugin_find(configuration, context, $1);
 
571
            CHECK_ERROR(p, @1, "%s plugin %s not found", cfg_lexer_lookup_context_name_by_type(context), $1);
 
572
 
 
573
            value = plugin_parse_config(p, configuration, &@1, last_driver);
 
574
 
 
575
            free($1);
 
576
            if (!value)
 
577
              {
 
578
                YYERROR;
 
579
              }
 
580
            log_driver_add_plugin(last_driver, (LogDriverPlugin *) value);
 
581
          }
 
582
        ;
 
583
 
504
584
dest_writer_options
505
585
        : dest_writer_option dest_writer_options
506
586
        |
507
587
        ;
508
588
 
509
589
dest_writer_option
 
590
        /* NOTE: plugins need to set "last_writer_options" in order to incorporate this rule in their grammar */
 
591
 
510
592
        : KW_FLAGS '(' dest_writer_options_flags ')' { last_writer_options->options = $3; }
511
 
        | KW_LOG_FIFO_SIZE '(' LL_NUMBER ')'    { last_writer_options->mem_fifo_size = $3; }
512
593
        | KW_FLUSH_LINES '(' LL_NUMBER ')'              { last_writer_options->flush_lines = $3; }
513
594
        | KW_FLUSH_TIMEOUT '(' LL_NUMBER ')'    { last_writer_options->flush_timeout = $3; }
514
595
        | KW_SUPPRESS '(' LL_NUMBER ')'            { last_writer_options->suppress = $3; }
515
596
        | KW_TEMPLATE '(' string ')'            {
516
597
                                                  GError *error = NULL;
517
598
 
518
 
                                                  last_writer_options->template = cfg_check_inline_template(configuration, $3);
519
 
                                                  CHECK_ERROR(log_template_compile(last_writer_options->template, &error), @3, "Error compiling template (%s)", error->message);
 
599
                                                  last_writer_options->template = cfg_check_inline_template(configuration, $3, &error);
 
600
                                                  CHECK_ERROR(last_writer_options->template != NULL, @3, "Error compiling template (%s)", error->message);
520
601
                                                  free($3);
521
602
                                                }
522
603
        | KW_TEMPLATE_ESCAPE '(' yesno ')'      { log_writer_options_set_template_escape(last_writer_options, $3); }
523
604
        | KW_TIME_ZONE '(' string ')'           { last_writer_options->template_options.time_zone[LTZ_SEND] = g_strdup($3); free($3); }
524
605
        | KW_TS_FORMAT '(' string ')'           { last_writer_options->template_options.ts_format = cfg_ts_format_value($3); free($3); }
525
606
        | KW_FRAC_DIGITS '(' LL_NUMBER ')'      { last_writer_options->template_options.frac_digits = $3; }
526
 
        | KW_THROTTLE '(' LL_NUMBER ')'         { last_writer_options->throttle = $3; }
 
607
        | KW_PAD_SIZE '(' LL_NUMBER ')'         { last_writer_options->padding = $3; }
527
608
        ;
528
609
 
529
610
dest_writer_options_flags
531
612
        |                                       { $$ = 0; }
532
613
        ;
533
614
 
 
615
value_pair_option
 
616
        : KW_VALUE_PAIRS
 
617
          { last_value_pairs = value_pairs_new(); }
 
618
          '(' vp_options ')'
 
619
          { $$ = last_value_pairs; }
 
620
        ;
 
621
 
 
622
vp_options
 
623
        : vp_option vp_options
 
624
        |
 
625
        ;
 
626
 
 
627
vp_option
 
628
        : KW_PAIR '(' string ':' string ')'      { value_pairs_add_pair(last_value_pairs, configuration, $3, $5); free($3); free($5); }
 
629
        | KW_PAIR '(' string string ')'          { value_pairs_add_pair(last_value_pairs, configuration, $3, $4); free($3); free($4); }
 
630
        | KW_KEY '(' string ')'             {
 
631
                gchar *k = g_strconcat("$", $3, NULL);
 
632
                value_pairs_add_pair(last_value_pairs, configuration, $3, k);
 
633
                g_free(k);
 
634
                free($3);
 
635
          }
 
636
        | KW_EXCLUDE '(' string ')'              { value_pairs_add_exclude_glob(last_value_pairs, $3); free($3); }
 
637
        | KW_SCOPE '(' vp_scope_list ')'
 
638
        ;
 
639
 
 
640
vp_scope_list
 
641
        : string vp_scope_list              { value_pairs_add_scope(last_value_pairs, $1); free($1); }
 
642
        |
 
643
        ;
 
644
 
534
645
 
535
646
%%