~ubuntu-branches/ubuntu/oneiric/syslog-ng/oneiric

« back to all changes in this revision

Viewing changes to src/logprocess.c

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2011-05-16 22:02:46 UTC
  • mfrom: (26.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110516220246-nknmeu831n49bx1z
Tags: 3.2.4-1
* New upstream release, fixing infinite loop via PCRE and global. No CVE
  number yet, Vigil@nce id is 10648.
* Remove all patches, they were applied upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 2002-2009 BalaBit IT Ltd, Budapest, Hungary
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify it
5
 
 * under the terms of the GNU General Public License version 2 as published
6
 
 * by the Free Software Foundation.
7
 
 *
8
 
 * Note that this permission is granted for only version 2 of the GPL.
9
 
 *
10
 
 * As an additional exemption you are allowed to compile & link against the
11
 
 * OpenSSL libraries as published by the OpenSSL project. See the file
12
 
 * COPYING for details.
13
 
 *
14
 
 * This program is distributed in the hope that it will be useful,
15
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 * GNU General Public License for more details.
18
 
 *
19
 
 * You should have received a copy of the GNU General Public License
20
 
 * along with this program; if not, write to the Free Software
21
 
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
 
 */
23
 
 
24
 
#include "logprocess.h"
25
 
#include <string.h>
26
 
 
27
 
void
28
 
log_process_rule_init(LogProcessRule *self, const gchar *name)
29
 
{
30
 
  memset(self, 0, sizeof(LogProcessRule));
31
 
  self->ref_cnt = 1;
32
 
  self->name = g_strdup(name);
33
 
 
34
 
}
35
 
 
36
 
void
37
 
log_process_rule_ref(LogProcessRule *self)
38
 
39
 
  self->ref_cnt++;
40
 
}
41
 
 
42
 
void
43
 
log_process_rule_unref(LogProcessRule *self)
44
 
{
45
 
  if (--self->ref_cnt == 0)
46
 
    {
47
 
      if (self->free_fn)
48
 
        self->free_fn(self);
49
 
      g_free(self->name);
50
 
      g_free(self);
51
 
    }
52
 
}
53
 
 
54
 
static gboolean
55
 
log_process_pipe_init(LogPipe *self)
56
 
{
57
 
  return TRUE;
58
 
}
59
 
 
60
 
static gboolean 
61
 
log_process_pipe_deinit(LogPipe *self)
62
 
{
63
 
  return TRUE;
64
 
}
65
 
 
66
 
static void
67
 
log_process_pipe_queue(LogPipe *s, LogMessage *msg, const LogPathOptions *path_options)
68
 
{
69
 
  LogProcessPipe *self = (LogProcessPipe *) s;
70
 
  if (log_process_rule_process(self->rule, msg))
71
 
    {
72
 
      /* forward message */
73
 
      if (s->pipe_next)
74
 
        log_pipe_queue(s->pipe_next, msg, path_options);
75
 
      else
76
 
        log_msg_drop(msg, path_options);
77
 
    }
78
 
  else
79
 
    {
80
 
      if (path_options->matched)
81
 
        (*path_options->matched) = FALSE;
82
 
      log_msg_drop(msg, path_options);
83
 
    }
84
 
}
85
 
 
86
 
static void
87
 
log_process_pipe_free(LogPipe *s)
88
 
{
89
 
  LogProcessPipe *self = (LogProcessPipe *) s;
90
 
  
91
 
  log_process_rule_unref(self->rule);
92
 
  log_pipe_free(s);
93
 
}
94
 
 
95
 
LogPipe *
96
 
log_process_pipe_new(LogProcessRule *rule)
97
 
{
98
 
  LogProcessPipe *self = g_new0(LogProcessPipe, 1);
99
 
  
100
 
  log_pipe_init_instance(&self->super);
101
 
  log_process_rule_ref(rule);
102
 
  self->rule = rule;
103
 
  self->super.init = log_process_pipe_init;
104
 
  self->super.deinit = log_process_pipe_deinit;
105
 
  self->super.queue = log_process_pipe_queue;
106
 
  self->super.free_fn = log_process_pipe_free;
107
 
  return &self->super;
108
 
}
109