diff options
16 files changed, 965 insertions, 91 deletions
diff --git a/meta-oe/recipes-support/syslog-ng/files/Fix-the-memory-leak-problem-for-mutex.patch b/meta-oe/recipes-support/syslog-ng/files/Fix-the-memory-leak-problem-for-mutex.patch new file mode 100644 index 0000000000..89022aaf00 --- /dev/null +++ b/meta-oe/recipes-support/syslog-ng/files/Fix-the-memory-leak-problem-for-mutex.patch | |||
@@ -0,0 +1,58 @@ | |||
1 | Fix the memory leak problem for mutex | ||
2 | |||
3 | Upstream-Status: Pending | ||
4 | |||
5 | Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com> | ||
6 | --- | ||
7 | lib/logqueue.c | 1 + | ||
8 | modules/affile/affile-dest.c | 2 ++ | ||
9 | modules/dbparser/dbparser.c | 1 + | ||
10 | 3 files changed, 4 insertions(+), 0 deletions(-) | ||
11 | |||
12 | diff --git a/lib/logqueue.c b/lib/logqueue.c | ||
13 | index 337a3c1..10edcf0 100644 | ||
14 | --- a/lib/logqueue.c | ||
15 | +++ b/lib/logqueue.c | ||
16 | @@ -188,6 +188,7 @@ log_queue_init_instance(LogQueue *self, const gchar *persist_name) | ||
17 | void | ||
18 | log_queue_free_method(LogQueue *self) | ||
19 | { | ||
20 | + g_static_mutex_free(&self->lock); | ||
21 | g_free(self->persist_name); | ||
22 | g_free(self); | ||
23 | } | ||
24 | diff --git a/modules/affile/affile-dest.c b/modules/affile/affile-dest.c | ||
25 | index a2bcdad..ce79f6f 100644 | ||
26 | --- a/modules/affile/affile-dest.c | ||
27 | +++ b/modules/affile/affile-dest.c | ||
28 | @@ -305,6 +305,7 @@ affile_dw_free(LogPipe *s) | ||
29 | { | ||
30 | AFFileDestWriter *self = (AFFileDestWriter *) s; | ||
31 | |||
32 | + g_static_mutex_free(&self->lock); | ||
33 | log_pipe_unref((LogPipe *) self->writer); | ||
34 | self->writer = NULL; | ||
35 | g_free(self->filename); | ||
36 | @@ -687,6 +688,7 @@ affile_dd_free(LogPipe *s) | ||
37 | /* NOTE: this must be NULL as deinit has freed it, otherwise we'd have circular references */ | ||
38 | g_assert(self->single_writer == NULL && self->writer_hash == NULL); | ||
39 | |||
40 | + g_static_mutex_free(&self->lock); | ||
41 | log_template_unref(self->filename_template); | ||
42 | log_writer_options_destroy(&self->writer_options); | ||
43 | log_dest_driver_free(s); | ||
44 | diff --git a/modules/dbparser/dbparser.c b/modules/dbparser/dbparser.c | ||
45 | index f1248b5..9775701 100644 | ||
46 | --- a/modules/dbparser/dbparser.c | ||
47 | +++ b/modules/dbparser/dbparser.c | ||
48 | @@ -284,6 +284,7 @@ log_db_parser_free(LogPipe *s) | ||
49 | { | ||
50 | LogDBParser *self = (LogDBParser *) s; | ||
51 | |||
52 | + g_static_mutex_free(&self->lock); | ||
53 | if (self->db) | ||
54 | pattern_db_free(self->db); | ||
55 | |||
56 | -- | ||
57 | 1.7.1 | ||
58 | |||
diff --git a/meta-oe/recipes-support/syslog-ng/files/Fix-the-memory-leak-problem-when-HAVE_ENVIRON-defined.patch b/meta-oe/recipes-support/syslog-ng/files/Fix-the-memory-leak-problem-when-HAVE_ENVIRON-defined.patch new file mode 100644 index 0000000000..2ac9c0be0f --- /dev/null +++ b/meta-oe/recipes-support/syslog-ng/files/Fix-the-memory-leak-problem-when-HAVE_ENVIRON-defined.patch | |||
@@ -0,0 +1,27 @@ | |||
1 | Fix the memory leak problem when HAVE_ENVIRON is defined | ||
2 | |||
3 | Upstream-Status: Pending | ||
4 | |||
5 | Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com> | ||
6 | --- | ||
7 | --- a/lib/gprocess.c | ||
8 | +++ b/lib/gprocess.c | ||
9 | @@ -1421,6 +1421,18 @@ | ||
10 | void | ||
11 | g_process_finish(void) | ||
12 | { | ||
13 | +#ifdef HAVE_ENVIRON | ||
14 | + int i = 0; | ||
15 | + | ||
16 | + while (environ[i]) { | ||
17 | + g_free(environ[i]); | ||
18 | + ++i; | ||
19 | + } | ||
20 | + if (environ) | ||
21 | + g_free(environ); | ||
22 | + if (process_opts.argv_orig) | ||
23 | + free(process_opts.argv_orig); | ||
24 | +#endif | ||
25 | g_process_remove_pidfile(); | ||
26 | } | ||
27 | |||
diff --git a/meta-oe/recipes-support/syslog-ng/files/afsql-afsql_dd_insert_db-refactor.patch b/meta-oe/recipes-support/syslog-ng/files/afsql-afsql_dd_insert_db-refactor.patch new file mode 100644 index 0000000000..42e181bb1f --- /dev/null +++ b/meta-oe/recipes-support/syslog-ng/files/afsql-afsql_dd_insert_db-refactor.patch | |||
@@ -0,0 +1,494 @@ | |||
1 | From 23e80b75508187baaa823a68ea019b72e0b2305c Mon Sep 17 00:00:00 2001 | ||
2 | From: Budai Laszlo <lbudai@balabit.hu> | ||
3 | Date: Tue, 12 Nov 2013 13:19:04 +0100 | ||
4 | Subject: [PATCH] afsql: afsql_dd_insert_db() refactor | ||
5 | |||
6 | Upstream-Status: Backport | ||
7 | |||
8 | A lot of the code that was previously in afsql_dd_insert_db() have been | ||
9 | extracted to smaller functions, and afsql_dd_insert_db() was rebuilt on | ||
10 | top of these. At the same time, memory leaks were plugged, and in case | ||
11 | of a transaction error, backlog rewinding has been fixed too, to not | ||
12 | loose messages since the last BEGIN command. | ||
13 | |||
14 | Signed-off-by: Juhasz Viktor <jviktor@balabit.hu> | ||
15 | Signed-off-by: Laszlo Budai <lbudai@balabit.hu> | ||
16 | --- | ||
17 | modules/afsql/afsql.c | 301 ++++++++++++++++++++++++++++++++------------------ | ||
18 | 1 file changed, 192 insertions(+), 109 deletions(-) | ||
19 | |||
20 | diff --git a/modules/afsql/afsql.c b/modules/afsql/afsql.c | ||
21 | index 12f6aab..a6a8190 100644 | ||
22 | --- a/modules/afsql/afsql.c | ||
23 | +++ b/modules/afsql/afsql.c | ||
24 | @@ -456,24 +456,21 @@ afsql_dd_create_index(AFSqlDestDriver *s | ||
25 | * | ||
26 | * NOTE: This function can only be called from the database thread. | ||
27 | **/ | ||
28 | -static GString * | ||
29 | -afsql_dd_validate_table(AFSqlDestDriver *self, LogMessage *msg) | ||
30 | +static gboolean | ||
31 | +afsql_dd_validate_table(AFSqlDestDriver *self, GString *table) | ||
32 | { | ||
33 | - GString *query_string, *table; | ||
34 | + GString *query_string; | ||
35 | dbi_result db_res; | ||
36 | gboolean success = FALSE; | ||
37 | gint i; | ||
38 | |||
39 | - table = g_string_sized_new(32); | ||
40 | - log_template_format(self->table, msg, &self->template_options, LTZ_LOCAL, 0, NULL, table); | ||
41 | - | ||
42 | if (self->flags & AFSQL_DDF_DONT_CREATE_TABLES) | ||
43 | - return table; | ||
44 | + return TRUE; | ||
45 | |||
46 | afsql_dd_check_sql_identifier(table->str, TRUE); | ||
47 | |||
48 | if (g_hash_table_lookup(self->validated_tables, table->str)) | ||
49 | - return table; | ||
50 | + return TRUE; | ||
51 | |||
52 | query_string = g_string_sized_new(32); | ||
53 | g_string_printf(query_string, "SELECT * FROM %s WHERE 0=1", table->str); | ||
54 | @@ -544,14 +541,9 @@ afsql_dd_validate_table(AFSqlDestDriver | ||
55 | /* we have successfully created/altered the destination table, record this information */ | ||
56 | g_hash_table_insert(self->validated_tables, g_strdup(table->str), GUINT_TO_POINTER(TRUE)); | ||
57 | } | ||
58 | - else | ||
59 | - { | ||
60 | - g_string_free(table, TRUE); | ||
61 | - table = NULL; | ||
62 | - } | ||
63 | g_string_free(query_string, TRUE); | ||
64 | |||
65 | - return table; | ||
66 | + return success; | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | @@ -581,6 +573,20 @@ afsql_dd_begin_txn(AFSqlDestDriver *self | ||
71 | } | ||
72 | |||
73 | /** | ||
74 | + * afsql_dd_handle_transaction_error: | ||
75 | + * | ||
76 | + * Handle errors inside during a SQL transaction (e.g. INSERT or COMMIT failures). | ||
77 | + * | ||
78 | + * NOTE: This function can only be called from the database thread. | ||
79 | + **/ | ||
80 | +static void | ||
81 | +afsql_dd_handle_transaction_error(AFSqlDestDriver *self) | ||
82 | +{ | ||
83 | + log_queue_rewind_backlog(self->queue); | ||
84 | + self->flush_lines_queued = 0; | ||
85 | +} | ||
86 | + | ||
87 | +/** | ||
88 | * afsql_dd_begin_txn: | ||
89 | * | ||
90 | * Commit SQL transaction. | ||
91 | @@ -596,14 +602,14 @@ afsql_dd_commit_txn(AFSqlDestDriver *sel | ||
92 | if (success) | ||
93 | { | ||
94 | log_queue_ack_backlog(self->queue, self->flush_lines_queued); | ||
95 | + self->flush_lines_queued = 0; | ||
96 | } | ||
97 | else | ||
98 | { | ||
99 | - msg_notice("SQL transaction commit failed, rewinding backlog and starting again", | ||
100 | - NULL); | ||
101 | - log_queue_rewind_backlog(self->queue); | ||
102 | + msg_error("SQL transaction commit failed, rewinding backlog and starting again", | ||
103 | + NULL); | ||
104 | + afsql_dd_handle_transaction_error(self); | ||
105 | } | ||
106 | - self->flush_lines_queued = 0; | ||
107 | return success; | ||
108 | } | ||
109 | |||
110 | @@ -644,12 +650,13 @@ afsql_dd_set_dbd_opt_numeric(gpointer ke | ||
111 | } | ||
112 | |||
113 | static gboolean | ||
114 | -afsql_dd_connect(AFSqlDestDriver *self) | ||
115 | +afsql_dd_ensure_initialized_connection(AFSqlDestDriver *self) | ||
116 | { | ||
117 | if (self->dbi_ctx) | ||
118 | return TRUE; | ||
119 | |||
120 | self->dbi_ctx = dbi_conn_new(self->type); | ||
121 | + | ||
122 | if (!self->dbi_ctx) | ||
123 | { | ||
124 | msg_error("No such DBI driver", | ||
125 | @@ -659,10 +666,12 @@ afsql_dd_connect(AFSqlDestDriver *self) | ||
126 | } | ||
127 | |||
128 | dbi_conn_set_option(self->dbi_ctx, "host", self->host); | ||
129 | + | ||
130 | if (strcmp(self->type, "mysql")) | ||
131 | dbi_conn_set_option(self->dbi_ctx, "port", self->port); | ||
132 | else | ||
133 | dbi_conn_set_option_numeric(self->dbi_ctx, "port", atoi(self->port)); | ||
134 | + | ||
135 | dbi_conn_set_option(self->dbi_ctx, "username", self->user); | ||
136 | dbi_conn_set_option(self->dbi_ctx, "password", self->password); | ||
137 | dbi_conn_set_option(self->dbi_ctx, "dbname", self->database); | ||
138 | @@ -691,6 +700,7 @@ afsql_dd_connect(AFSqlDestDriver *self) | ||
139 | evt_tag_str("database", self->database), | ||
140 | evt_tag_str("error", dbi_error), | ||
141 | NULL); | ||
142 | + | ||
143 | return FALSE; | ||
144 | } | ||
145 | |||
146 | @@ -713,104 +723,145 @@ afsql_dd_connect(AFSqlDestDriver *self) | ||
147 | return TRUE; | ||
148 | } | ||
149 | |||
150 | -static gboolean | ||
151 | -afsql_dd_insert_fail_handler(AFSqlDestDriver *self, LogMessage *msg, | ||
152 | - LogPathOptions *path_options) | ||
153 | +static GString * | ||
154 | +afsql_dd_ensure_accessible_database_table(AFSqlDestDriver *self, LogMessage *msg) | ||
155 | { | ||
156 | - if (self->failed_message_counter < self->num_retries - 1) | ||
157 | - { | ||
158 | - log_queue_push_head(self->queue, msg, path_options); | ||
159 | - | ||
160 | - /* database connection status sanity check after failed query */ | ||
161 | - if (dbi_conn_ping(self->dbi_ctx) != 1) | ||
162 | - { | ||
163 | - const gchar *dbi_error; | ||
164 | - | ||
165 | - dbi_conn_error(self->dbi_ctx, &dbi_error); | ||
166 | - msg_error("Error, no SQL connection after failed query attempt", | ||
167 | - evt_tag_str("type", self->type), | ||
168 | - evt_tag_str("host", self->host), | ||
169 | - evt_tag_str("port", self->port), | ||
170 | - evt_tag_str("username", self->user), | ||
171 | - evt_tag_str("database", self->database), | ||
172 | - evt_tag_str("error", dbi_error), | ||
173 | - NULL); | ||
174 | - return FALSE; | ||
175 | - } | ||
176 | + GString *table = g_string_sized_new(32); | ||
177 | + log_template_format(self->table, msg, &self->template_options, LTZ_LOCAL, 0, NULL, table); | ||
178 | |||
179 | - self->failed_message_counter++; | ||
180 | - return FALSE; | ||
181 | + if (!afsql_dd_validate_table(self, table)) | ||
182 | + { | ||
183 | + /* If validate table is FALSE then close the connection and wait time_reopen time (next call) */ | ||
184 | + msg_error("Error checking table, disconnecting from database, trying again shortly", | ||
185 | + evt_tag_int("time_reopen", self->time_reopen), | ||
186 | + NULL); | ||
187 | + g_string_free(table, TRUE); | ||
188 | + return NULL; | ||
189 | } | ||
190 | |||
191 | - msg_error("Multiple failures while inserting this record into the database, message dropped", | ||
192 | - evt_tag_int("attempts", self->num_retries), | ||
193 | - NULL); | ||
194 | - stats_counter_inc(self->dropped_messages); | ||
195 | - log_msg_drop(msg, path_options); | ||
196 | - self->failed_message_counter = 0; | ||
197 | - return TRUE; | ||
198 | + return table; | ||
199 | } | ||
200 | |||
201 | static GString * | ||
202 | -afsql_dd_construct_query(AFSqlDestDriver *self, GString *table, | ||
203 | - LogMessage *msg) | ||
204 | +afsql_dd_build_insert_command(AFSqlDestDriver *self, LogMessage *msg, GString *table) | ||
205 | { | ||
206 | - GString *value; | ||
207 | - GString *query_string; | ||
208 | - gint i; | ||
209 | + GString *insert_command = g_string_sized_new(256); | ||
210 | + GString *value = g_string_sized_new(512); | ||
211 | + gint i, j; | ||
212 | |||
213 | - value = g_string_sized_new(256); | ||
214 | - query_string = g_string_sized_new(512); | ||
215 | + g_string_printf(insert_command, "INSERT INTO %s (", table->str); | ||
216 | |||
217 | - g_string_printf(query_string, "INSERT INTO %s (", table->str); | ||
218 | for (i = 0; i < self->fields_len; i++) | ||
219 | { | ||
220 | - g_string_append(query_string, self->fields[i].name); | ||
221 | - if (i != self->fields_len - 1) | ||
222 | - g_string_append(query_string, ", "); | ||
223 | + if ((self->fields[i].flags & AFSQL_FF_DEFAULT) == 0 && self->fields[i].value != NULL) | ||
224 | + { | ||
225 | + g_string_append(insert_command, self->fields[i].name); | ||
226 | + | ||
227 | + j = i + 1; | ||
228 | + while (j < self->fields_len && (self->fields[j].flags & AFSQL_FF_DEFAULT) == AFSQL_FF_DEFAULT) | ||
229 | + j++; | ||
230 | + | ||
231 | + if (j < self->fields_len) | ||
232 | + g_string_append(insert_command, ", "); | ||
233 | + } | ||
234 | } | ||
235 | - g_string_append(query_string, ") VALUES ("); | ||
236 | + | ||
237 | + g_string_append(insert_command, ") VALUES ("); | ||
238 | |||
239 | for (i = 0; i < self->fields_len; i++) | ||
240 | { | ||
241 | gchar *quoted; | ||
242 | |||
243 | - if (self->fields[i].value == NULL) | ||
244 | - { | ||
245 | - /* the config used the 'default' value for this column -> the fields[i].value is NULL, use SQL default */ | ||
246 | - g_string_append(query_string, "DEFAULT"); | ||
247 | - } | ||
248 | - else | ||
249 | + if ((self->fields[i].flags & AFSQL_FF_DEFAULT) == 0 && self->fields[i].value != NULL) | ||
250 | { | ||
251 | log_template_format(self->fields[i].value, msg, &self->template_options, LTZ_SEND, self->seq_num, NULL, value); | ||
252 | - | ||
253 | if (self->null_value && strcmp(self->null_value, value->str) == 0) | ||
254 | { | ||
255 | - g_string_append(query_string, "NULL"); | ||
256 | + g_string_append(insert_command, "NULL"); | ||
257 | } | ||
258 | else | ||
259 | { | ||
260 | dbi_conn_quote_string_copy(self->dbi_ctx, value->str, "ed); | ||
261 | if (quoted) | ||
262 | { | ||
263 | - g_string_append(query_string, quoted); | ||
264 | + g_string_append(insert_command, quoted); | ||
265 | free(quoted); | ||
266 | } | ||
267 | else | ||
268 | { | ||
269 | - g_string_append(query_string, "''"); | ||
270 | + g_string_append(insert_command, "''"); | ||
271 | } | ||
272 | } | ||
273 | - } | ||
274 | |||
275 | - if (i != self->fields_len - 1) | ||
276 | - g_string_append(query_string, ", "); | ||
277 | + j = i + 1; | ||
278 | + while (j < self->fields_len && (self->fields[j].flags & AFSQL_FF_DEFAULT) == AFSQL_FF_DEFAULT) | ||
279 | + j++; | ||
280 | + if (j < self->fields_len) | ||
281 | + g_string_append(insert_command, ", "); | ||
282 | + } | ||
283 | } | ||
284 | - g_string_append(query_string, ")"); | ||
285 | + | ||
286 | + g_string_append(insert_command, ")"); | ||
287 | |||
288 | g_string_free(value, TRUE); | ||
289 | |||
290 | - return query_string; | ||
291 | + return insert_command; | ||
292 | +} | ||
293 | + | ||
294 | +static inline gboolean | ||
295 | +afsql_dd_is_transaction_handling_enabled(const AFSqlDestDriver *self) | ||
296 | +{ | ||
297 | + return self->flush_lines_queued != -1; | ||
298 | +} | ||
299 | + | ||
300 | +static inline gboolean | ||
301 | +afsql_dd_should_start_new_transaction(const AFSqlDestDriver *self) | ||
302 | +{ | ||
303 | + return self->flush_lines_queued == 0; | ||
304 | +} | ||
305 | + | ||
306 | +static inline gboolean | ||
307 | +afsql_dd_should_commit_transaction(const AFSqlDestDriver *self) | ||
308 | +{ | ||
309 | + return afsql_dd_is_transaction_handling_enabled(self) && self->flush_lines_queued == self->flush_lines; | ||
310 | +} | ||
311 | + | ||
312 | +static inline gboolean | ||
313 | +afsql_dd_handle_insert_row_error_depending_on_connection_availability(AFSqlDestDriver *self, | ||
314 | + LogMessage *msg, | ||
315 | + LogPathOptions *path_options) | ||
316 | +{ | ||
317 | + const gchar *dbi_error, *error_message; | ||
318 | + | ||
319 | + if (dbi_conn_ping(self->dbi_ctx) == 1) | ||
320 | + { | ||
321 | + log_queue_push_head(self->queue, msg, path_options); | ||
322 | + return TRUE; | ||
323 | + } | ||
324 | + | ||
325 | + if (afsql_dd_is_transaction_handling_enabled(self)) | ||
326 | + { | ||
327 | + error_message = "SQL connection lost in the middle of a transaction," | ||
328 | + " rewinding backlog and starting again"; | ||
329 | + afsql_dd_handle_transaction_error(self); | ||
330 | + } | ||
331 | + else | ||
332 | + { | ||
333 | + error_message = "Error, no SQL connection after failed query attempt"; | ||
334 | + log_queue_push_head(self->queue, msg, path_options); | ||
335 | + } | ||
336 | + | ||
337 | + dbi_conn_error(self->dbi_ctx, &dbi_error); | ||
338 | + msg_error(error_message, | ||
339 | + evt_tag_str("type", self->type), | ||
340 | + evt_tag_str("host", self->host), | ||
341 | + evt_tag_str("port", self->port), | ||
342 | + evt_tag_str("username", self->user), | ||
343 | + evt_tag_str("database", self->database), | ||
344 | + evt_tag_str("error", dbi_error), | ||
345 | + NULL); | ||
346 | + | ||
347 | + return FALSE; | ||
348 | } | ||
349 | |||
350 | /** | ||
351 | @@ -824,61 +875,93 @@ afsql_dd_construct_query(AFSqlDestDriver | ||
352 | static gboolean | ||
353 | afsql_dd_insert_db(AFSqlDestDriver *self) | ||
354 | { | ||
355 | - GString *table, *query_string; | ||
356 | + GString *table = NULL; | ||
357 | + GString *insert_command = NULL; | ||
358 | LogMessage *msg; | ||
359 | gboolean success; | ||
360 | LogPathOptions path_options = LOG_PATH_OPTIONS_INIT; | ||
361 | |||
362 | - afsql_dd_connect(self); | ||
363 | + if (!afsql_dd_ensure_initialized_connection(self)) | ||
364 | + return FALSE; | ||
365 | |||
366 | - success = log_queue_pop_head(self->queue, &msg, &path_options, (self->flags & AFSQL_DDF_EXPLICIT_COMMITS), FALSE); | ||
367 | + /* connection established, try to insert a message */ | ||
368 | + success = log_queue_pop_head(self->queue, &msg, &path_options, FALSE, self->flags & AFSQL_DDF_EXPLICIT_COMMITS); | ||
369 | if (!success) | ||
370 | return TRUE; | ||
371 | |||
372 | msg_set_context(msg); | ||
373 | |||
374 | - table = afsql_dd_validate_table(self, msg); | ||
375 | + table = afsql_dd_ensure_accessible_database_table(self, msg); | ||
376 | + | ||
377 | if (!table) | ||
378 | { | ||
379 | - /* If validate table is FALSE then close the connection and wait time_reopen time (next call) */ | ||
380 | - msg_error("Error checking table, disconnecting from database, trying again shortly", | ||
381 | - evt_tag_int("time_reopen", self->time_reopen), | ||
382 | - NULL); | ||
383 | - msg_set_context(NULL); | ||
384 | - g_string_free(table, TRUE); | ||
385 | - return afsql_dd_insert_fail_handler(self, msg, &path_options); | ||
386 | + success = FALSE; | ||
387 | + goto out; | ||
388 | } | ||
389 | |||
390 | - query_string = afsql_dd_construct_query(self, table, msg); | ||
391 | + if (afsql_dd_should_start_new_transaction(self) && !afsql_dd_begin_txn(self)) | ||
392 | + { | ||
393 | + success = FALSE; | ||
394 | + goto out; | ||
395 | + } | ||
396 | |||
397 | - if (self->flush_lines_queued == 0 && !afsql_dd_begin_txn(self)) | ||
398 | - return FALSE; | ||
399 | + insert_command = afsql_dd_build_insert_command(self, msg, table); | ||
400 | + success = afsql_dd_run_query(self, insert_command->str, FALSE, NULL); | ||
401 | |||
402 | - success = afsql_dd_run_query(self, query_string->str, FALSE, NULL); | ||
403 | if (success && self->flush_lines_queued != -1) | ||
404 | { | ||
405 | self->flush_lines_queued++; | ||
406 | |||
407 | - if (self->flush_lines && self->flush_lines_queued == self->flush_lines && !afsql_dd_commit_txn(self)) | ||
408 | - return FALSE; | ||
409 | + if (afsql_dd_should_commit_transaction(self) && !afsql_dd_commit_txn(self)) | ||
410 | + { | ||
411 | + /* Assuming that in case of error, the queue is rewound by afsql_dd_commit_txn() */ | ||
412 | + | ||
413 | + g_string_free(insert_command, TRUE); | ||
414 | + msg_set_context(NULL); | ||
415 | + | ||
416 | + return FALSE; | ||
417 | + } | ||
418 | } | ||
419 | |||
420 | - g_string_free(table, TRUE); | ||
421 | - g_string_free(query_string, TRUE); | ||
422 | + out: | ||
423 | + | ||
424 | + if (table != NULL) | ||
425 | + g_string_free(table, TRUE); | ||
426 | + | ||
427 | + if (insert_command != NULL) | ||
428 | + g_string_free(insert_command, TRUE); | ||
429 | |||
430 | msg_set_context(NULL); | ||
431 | |||
432 | - if (!success) | ||
433 | - return afsql_dd_insert_fail_handler(self, msg, &path_options); | ||
434 | + if (success) | ||
435 | + { | ||
436 | + log_msg_ack(msg, &path_options); | ||
437 | + log_msg_unref(msg); | ||
438 | + step_sequence_number(&self->seq_num); | ||
439 | + self->failed_message_counter = 0; | ||
440 | + } | ||
441 | + else | ||
442 | + { | ||
443 | + if (self->failed_message_counter < self->num_retries - 1) | ||
444 | + { | ||
445 | + if (!afsql_dd_handle_insert_row_error_depending_on_connection_availability(self, msg, &path_options)) | ||
446 | + return FALSE; | ||
447 | |||
448 | - /* we only ACK if each INSERT is a separate transaction */ | ||
449 | - if ((self->flags & AFSQL_DDF_EXPLICIT_COMMITS) == 0) | ||
450 | - log_msg_ack(msg, &path_options); | ||
451 | - log_msg_unref(msg); | ||
452 | - step_sequence_number(&self->seq_num); | ||
453 | - self->failed_message_counter = 0; | ||
454 | + self->failed_message_counter++; | ||
455 | + } | ||
456 | + else | ||
457 | + { | ||
458 | + msg_error("Multiple failures while inserting this record into the database, message dropped", | ||
459 | + evt_tag_int("attempts", self->num_retries), | ||
460 | + NULL); | ||
461 | + stats_counter_inc(self->dropped_messages); | ||
462 | + log_msg_drop(msg, &path_options); | ||
463 | + self->failed_message_counter = 0; | ||
464 | + success = TRUE; | ||
465 | + } | ||
466 | + } | ||
467 | |||
468 | - return TRUE; | ||
469 | + return success; | ||
470 | } | ||
471 | |||
472 | static void | ||
473 | @@ -895,7 +978,7 @@ afsql_dd_message_became_available_in_the | ||
474 | static void | ||
475 | afsql_dd_wait_for_suspension_wakeup(AFSqlDestDriver *self) | ||
476 | { | ||
477 | - /* we got suspended, probably because of a connection error, | ||
478 | + /* we got suspended, probably because of a connection error, | ||
479 | * during this time we only get wakeups if we need to be | ||
480 | * terminated. */ | ||
481 | if (!self->db_thread_terminate) | ||
482 | @@ -974,8 +1057,7 @@ afsql_dd_database_thread(gpointer arg) | ||
483 | |||
484 | afsql_dd_commit_txn(self); | ||
485 | } | ||
486 | - | ||
487 | - exit: | ||
488 | +exit: | ||
489 | afsql_dd_disconnect(self); | ||
490 | |||
491 | msg_verbose("Database thread finished", | ||
492 | -- | ||
493 | 1.8.4.1 | ||
494 | |||
diff --git a/meta-oe/recipes-support/syslog-ng/files/deinit-the-new-config-when-reverting-to-the.patch b/meta-oe/recipes-support/syslog-ng/files/deinit-the-new-config-when-reverting-to-the.patch new file mode 100644 index 0000000000..484af7e2ef --- /dev/null +++ b/meta-oe/recipes-support/syslog-ng/files/deinit-the-new-config-when-reverting-to-the.patch | |||
@@ -0,0 +1,36 @@ | |||
1 | From 86842df8bff5c97e44fc55d2fb7fc6c10f56ab84 Mon Sep 17 00:00:00 2001 | ||
2 | From: Gergely Nagy <algernon@balabit.hu> | ||
3 | Date: Fri, 13 Dec 2013 13:46:15 +0100 | ||
4 | Subject: [PATCH] mainloop: Deinit the new config when reverting to the old one | ||
5 | |||
6 | Upstream-Status: Backport | ||
7 | |||
8 | When reloading, and the new config fails, deinit it before initializing | ||
9 | the old config. This is so that conflicting things do not remain held by | ||
10 | the half-initialized new config, while the old tries to take it | ||
11 | over. (It also removed a couple of memory leaks, most likely.) | ||
12 | |||
13 | The reason we can do this, is because cfg_tree_stop() (called by | ||
14 | cfg_deinit()) goes over all the known nodes, and log_pipe_deinit() is | ||
15 | also smart enough to not deinit a node that has not been inited before. | ||
16 | |||
17 | Signed-off-by: Gergely Nagy <algernon@balabit.hu> | ||
18 | --- | ||
19 | lib/mainloop.c | 1 + | ||
20 | 1 file changed, 1 insertion(+) | ||
21 | |||
22 | diff --git a/lib/mainloop.c b/lib/mainloop.c | ||
23 | index 34655fa..e6fbb59 100644 | ||
24 | --- a/lib/mainloop.c | ||
25 | +++ b/lib/mainloop.c | ||
26 | @@ -510,6 +510,7 @@ main_loop_reload_config_apply(void) | ||
27 | { | ||
28 | msg_error("Error initializing new configuration, reverting to old config", NULL); | ||
29 | cfg_persist_config_move(main_loop_new_config, main_loop_old_config); | ||
30 | + cfg_deinit(main_loop_new_config); | ||
31 | if (!cfg_init(main_loop_old_config)) | ||
32 | { | ||
33 | /* hmm. hmmm, error reinitializing old configuration, we're hosed. | ||
34 | -- | ||
35 | 1.8.4.1 | ||
36 | |||
diff --git a/meta-oe/recipes-support/syslog-ng/files/fix-a-memory-leak-in-log_driver_free.patch b/meta-oe/recipes-support/syslog-ng/files/fix-a-memory-leak-in-log_driver_free.patch new file mode 100644 index 0000000000..260347413b --- /dev/null +++ b/meta-oe/recipes-support/syslog-ng/files/fix-a-memory-leak-in-log_driver_free.patch | |||
@@ -0,0 +1,33 @@ | |||
1 | From a269669ba3cb6d1c06a3322b4a6a035cb787d085 Mon Sep 17 00:00:00 2001 | ||
2 | From: Gergely Nagy <algernon@balabit.hu> | ||
3 | Date: Tue, 14 Jan 2014 13:58:05 +0100 | ||
4 | Subject: [PATCH] driver: Fix a memory leak in log_driver_free() | ||
5 | |||
6 | Upstream-Status: Backport | ||
7 | |||
8 | After freeing up the members of self->plugins, free self->plugins itself | ||
9 | too. | ||
10 | |||
11 | Signed-off-by: Gergely Nagy <algernon@balabit.hu> | ||
12 | --- | ||
13 | lib/driver.c | 4 ++++ | ||
14 | 1 file changed, 4 insertions(+) | ||
15 | |||
16 | diff --git a/lib/driver.c b/lib/driver.c | ||
17 | index d77fe57..a6867b9 100644 | ||
18 | --- a/lib/driver.c | ||
19 | +++ b/lib/driver.c | ||
20 | @@ -91,6 +91,10 @@ log_driver_free(LogPipe *s) | ||
21 | { | ||
22 | log_driver_plugin_free((LogDriverPlugin *) l->data); | ||
23 | } | ||
24 | + if (self->plugins) | ||
25 | + { | ||
26 | + g_list_free(self->plugins); | ||
27 | + } | ||
28 | if (self->group) | ||
29 | g_free(self->group); | ||
30 | if (self->id) | ||
31 | -- | ||
32 | 1.8.4.1 | ||
33 | |||
diff --git a/meta-oe/recipes-support/syslog-ng/files/fix-config-libnet.patch b/meta-oe/recipes-support/syslog-ng/files/fix-config-libnet.patch new file mode 100644 index 0000000000..755803c213 --- /dev/null +++ b/meta-oe/recipes-support/syslog-ng/files/fix-config-libnet.patch | |||
@@ -0,0 +1,66 @@ | |||
1 | Subject: [PATCH] add libnet enable option | ||
2 | |||
3 | Upstream-Status: Pending | ||
4 | |||
5 | This would avoid a implicit auto-detecting result. | ||
6 | |||
7 | Signed-off-by: Ming Liu <ming.liu@windriver.com> | ||
8 | Signed-off-by: Jackie Huang <jackie.huang@windriver.com> | ||
9 | --- | ||
10 | configure.ac | 27 +++++++++++++++++---------- | ||
11 | 1 files changed, 17 insertions(+), 10 deletions(-) | ||
12 | |||
13 | diff --git a/configure.ac b/configure.ac | ||
14 | index b1e18b4..8e13025 100644 | ||
15 | --- a/configure.ac | ||
16 | +++ b/configure.ac | ||
17 | @@ -73,6 +73,9 @@ AC_CONFIG_HEADERS(config.h) | ||
18 | dnl *************************************************************************** | ||
19 | dnl Arguments | ||
20 | |||
21 | +AC_ARG_ENABLE(libnet, | ||
22 | + [ --enable-libnet Enable libnet support.],, enable_libnet="no") | ||
23 | + | ||
24 | AC_ARG_WITH(libnet, | ||
25 | [ --with-libnet=path use path to libnet-config script], | ||
26 | , | ||
27 | @@ -768,22 +771,26 @@ dnl *************************************************************************** | ||
28 | dnl libnet headers/libraries | ||
29 | dnl *************************************************************************** | ||
30 | AC_MSG_CHECKING(for LIBNET) | ||
31 | -if test "x$with_libnet" = "x"; then | ||
32 | - LIBNET_CONFIG="`which libnet-config`" | ||
33 | -else | ||
34 | - LIBNET_CONFIG="$with_libnet/libnet-config" | ||
35 | -fi | ||
36 | +if test "x$enable_libnet" = xyes; then | ||
37 | + if test "x$with_libnet" = "x"; then | ||
38 | + LIBNET_CONFIG="`which libnet-config`" | ||
39 | + else | ||
40 | + LIBNET_CONFIG="$with_libnet/libnet-config" | ||
41 | + fi | ||
42 | + | ||
43 | + if test -n "$LIBNET_CONFIG" -a -x "$LIBNET_CONFIG"; then | ||
44 | + LIBNET_CFLAGS="`$LIBNET_CONFIG --defines`" | ||
45 | + LIBNET_LIBS="`$LIBNET_CONFIG --libs`" | ||
46 | + AC_MSG_RESULT(yes) | ||
47 | + else | ||
48 | + AC_MSG_ERROR([Could not find libnet, and libnet support was explicitly enabled.]) | ||
49 | + fi | ||
50 | |||
51 | -if test -n "$LIBNET_CONFIG" -a -x "$LIBNET_CONFIG"; then | ||
52 | - LIBNET_CFLAGS="`$LIBNET_CONFIG --defines`" | ||
53 | - LIBNET_LIBS="`$LIBNET_CONFIG --libs`" | ||
54 | - AC_MSG_RESULT(yes) | ||
55 | else | ||
56 | LIBNET_LIBS= | ||
57 | AC_MSG_RESULT(no) | ||
58 | fi | ||
59 | |||
60 | - | ||
61 | if test "x$enable_spoof_source" = "xauto"; then | ||
62 | AC_MSG_CHECKING(whether to enable spoof source support) | ||
63 | if test "x$LIBNET_LIBS" != "x"; then | ||
64 | -- | ||
65 | 1.7.1 | ||
66 | |||
diff --git a/meta-oe/recipes-support/syslog-ng/files/fix-invalid-ownership.patch b/meta-oe/recipes-support/syslog-ng/files/fix-invalid-ownership.patch new file mode 100644 index 0000000000..faf967247f --- /dev/null +++ b/meta-oe/recipes-support/syslog-ng/files/fix-invalid-ownership.patch | |||
@@ -0,0 +1,28 @@ | |||
1 | syslog-ng: fix wrong ownership issue | ||
2 | |||
3 | Upstream-Status: Pending | ||
4 | |||
5 | The ownership of build user is preserved for some target files, fixed it by | ||
6 | adding --no-same-owner option to tar when extracting files. | ||
7 | |||
8 | Signed-off-by: Ming Liu <ming.liu@windriver.com> | ||
9 | --- | ||
10 | scl/Makefile.am | 2 +- | ||
11 | 1 files changed, 1 insertions(+), 1 deletions(-) | ||
12 | |||
13 | diff --git a/scl/Makefile.am b/scl/Makefile.am | ||
14 | index 57fad5d..2a29ca5 100644 | ||
15 | --- a/scl/Makefile.am | ||
16 | +++ b/scl/Makefile.am | ||
17 | @@ -14,7 +14,7 @@ scl-install-data-local: | ||
18 | fi; \ | ||
19 | done | ||
20 | $(mkinstalldirs) $(DESTDIR)/$(scldir) | ||
21 | - (cd $(srcdir)/scl; tar cf - $(SCL_SUBDIRS)) | (cd $(DESTDIR)/$(scldir) && tar xf -) | ||
22 | + (cd $(srcdir)/scl; tar cf - $(SCL_SUBDIRS)) | (cd $(DESTDIR)/$(scldir) && tar xf - --no-same-owner) | ||
23 | chmod -R u+rwX $(DESTDIR)/$(scldir) | ||
24 | |||
25 | scl-uninstall-local: | ||
26 | -- | ||
27 | 1.7.1 | ||
28 | |||
diff --git a/meta-oe/recipes-support/syslog-ng/files/free-global-LogTemplateOptions.patch b/meta-oe/recipes-support/syslog-ng/files/free-global-LogTemplateOptions.patch new file mode 100644 index 0000000000..d439a2607b --- /dev/null +++ b/meta-oe/recipes-support/syslog-ng/files/free-global-LogTemplateOptions.patch | |||
@@ -0,0 +1,30 @@ | |||
1 | From 3ef6ca8044260c77118edca6dead807a2edcb5ef Mon Sep 17 00:00:00 2001 | ||
2 | From: Balazs Scheidler <bazsi@balabit.hu> | ||
3 | Date: Thu, 31 Oct 2013 13:20:12 +0100 | ||
4 | Subject: [PATCH] cfg: free global LogTemplateOptions | ||
5 | |||
6 | Upstream-Status: Backport | ||
7 | |||
8 | This fixes a potential memory leak when global template specific | ||
9 | options were specified, such as local-time-zone(), send-time-zone() etc. | ||
10 | |||
11 | Signed-off-by: Balazs Scheidler <bazsi@balabit.hu> | ||
12 | --- | ||
13 | lib/cfg.c | 1 + | ||
14 | 1 file changed, 1 insertion(+) | ||
15 | |||
16 | diff --git a/lib/cfg.c b/lib/cfg.c | ||
17 | index 7f040b8..adeaaf8 100644 | ||
18 | --- a/lib/cfg.c | ||
19 | +++ b/lib/cfg.c | ||
20 | @@ -411,6 +411,7 @@ cfg_free(GlobalConfig *self) | ||
21 | g_free(self->proto_template_name); | ||
22 | log_template_unref(self->file_template); | ||
23 | log_template_unref(self->proto_template); | ||
24 | + log_template_options_destroy(&self->template_options); | ||
25 | |||
26 | if (self->bad_hostname_compiled) | ||
27 | regfree(&self->bad_hostname); | ||
28 | -- | ||
29 | 1.8.4.1 | ||
30 | |||
diff --git a/meta-oe/recipes-support/syslog-ng/files/initscript b/meta-oe/recipes-support/syslog-ng/files/initscript index b95e8adc20..0772cc2929 100644 --- a/meta-oe/recipes-support/syslog-ng/files/initscript +++ b/meta-oe/recipes-support/syslog-ng/files/initscript | |||
@@ -5,19 +5,31 @@ | |||
5 | # > update-rc.d syslog-ng defaults 5 | 5 | # > update-rc.d syslog-ng defaults 5 |
6 | # | 6 | # |
7 | 7 | ||
8 | # Source function library | ||
9 | . /etc/init.d/functions | ||
8 | 10 | ||
9 | syslog_ng=/usr/sbin/syslog-ng | 11 | syslog_ng=/usr/sbin/syslog-ng |
10 | test -x "$syslog_ng" || exit 0 | 12 | test -x "$syslog_ng" || exit 0 |
11 | 13 | ||
14 | PIDFILE=/var/run/syslog-ng/syslog-ng.pid | ||
15 | |||
16 | create_xconsole() { | ||
17 | test -e /dev/xconsole || mknod -m 640 /dev/xconsole p | ||
18 | test -x /sbin/restorecon && /sbin/restorecon /dev/xconsole | ||
19 | } | ||
20 | |||
21 | RETVAL=0 | ||
22 | |||
12 | case "$1" in | 23 | case "$1" in |
13 | start) | 24 | start) |
14 | echo -n "Starting syslog-ng:" | 25 | echo -n "Starting syslog-ng:" |
15 | start-stop-daemon --start --quiet --exec $syslog_ng | 26 | create_xconsole |
27 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $syslog_ng | ||
16 | echo "." | 28 | echo "." |
17 | ;; | 29 | ;; |
18 | stop) | 30 | stop) |
19 | echo -n "Stopping syslog-ng:" | 31 | echo -n "Stopping syslog-ng:" |
20 | start-stop-daemon --stop --quiet --pidfile /var/run/syslog-ng.pid | 32 | start-stop-daemon --stop --quiet --pidfile $PIDFILE |
21 | echo "." | 33 | echo "." |
22 | ;; | 34 | ;; |
23 | reload|force-reload) | 35 | reload|force-reload) |
@@ -25,7 +37,7 @@ case "$1" in | |||
25 | ;; | 37 | ;; |
26 | restart) | 38 | restart) |
27 | echo "Stopping syslog-ng:" | 39 | echo "Stopping syslog-ng:" |
28 | start-stop-daemon --stop --quiet --pidfile /var/run/syslog-ng.pid | 40 | start-stop-daemon --stop --quiet --pidfile $PIDFILE |
29 | echo -n "Waiting for syslog-ng to die off" | 41 | echo -n "Waiting for syslog-ng to die off" |
30 | for i in 1 2 3 ; | 42 | for i in 1 2 3 ; |
31 | do | 43 | do |
@@ -34,12 +46,17 @@ case "$1" in | |||
34 | done | 46 | done |
35 | echo "" | 47 | echo "" |
36 | echo -n "Starting syslog-ng:" | 48 | echo -n "Starting syslog-ng:" |
37 | start-stop-daemon --start --quiet --exec $syslog_ng | 49 | create_xconsole |
50 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $syslog_ng | ||
38 | echo "." | 51 | echo "." |
39 | ;; | 52 | ;; |
53 | status) | ||
54 | status $syslog_ng | ||
55 | RETVAL=$? | ||
56 | ;; | ||
40 | *) | 57 | *) |
41 | echo "Usage: /etc/init.d/syslog-ng {start|stop|reload|restart|force-reload}" | 58 | echo "Usage: $0 {start|stop|reload|restart|force-reload|status}" |
42 | exit 1 | 59 | exit 1 |
43 | esac | 60 | esac |
44 | 61 | ||
45 | exit 0 | 62 | exit $RETVAL |
diff --git a/meta-oe/recipes-support/syslog-ng/files/logwriter-still-free-the-unconsumed-item.patch b/meta-oe/recipes-support/syslog-ng/files/logwriter-still-free-the-unconsumed-item.patch new file mode 100644 index 0000000000..31110933f0 --- /dev/null +++ b/meta-oe/recipes-support/syslog-ng/files/logwriter-still-free-the-unconsumed-item.patch | |||
@@ -0,0 +1,47 @@ | |||
1 | logwritter: still free the unconsumed item during reloading configuration | ||
2 | |||
3 | Otherwise we have no chance to free this stuff. | ||
4 | |||
5 | Upstream-Status: Pending | ||
6 | |||
7 | Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com> | ||
8 | --- | ||
9 | --- a/lib/logwriter.c | ||
10 | +++ b/lib/logwriter.c | ||
11 | @@ -39,6 +39,7 @@ | ||
12 | #include <iv.h> | ||
13 | #include <iv_event.h> | ||
14 | #include <iv_work.h> | ||
15 | +#include "logproto/logproto-text-client.h" | ||
16 | |||
17 | typedef enum | ||
18 | { | ||
19 | @@ -978,6 +979,7 @@ | ||
20 | gint count = 0; | ||
21 | gboolean ignore_throttle = (flush_mode >= LW_FLUSH_QUEUE); | ||
22 | LogProtoStatus status = LPS_SUCCESS; | ||
23 | + LogProtoTextClient *self_text; | ||
24 | |||
25 | if (!proto) | ||
26 | return FALSE; | ||
27 | @@ -1035,7 +1037,18 @@ | ||
28 | } | ||
29 | else | ||
30 | { | ||
31 | - /* push back to the queue */ | ||
32 | - log_queue_push_head(self->queue, lm, &path_options); | ||
33 | + self_text = (LogProtoTextClient *) proto; | ||
34 | + /* free the unconsumed message during reloading configuration */ | ||
35 | + if ((LW_FLUSH_QUEUE == flush_mode) && self_text->partial_free && self_text->partial) | ||
36 | + { | ||
37 | + self_text->partial_free(self_text->partial); | ||
38 | + self_text->partial = NULL; | ||
39 | + log_msg_unref(lm); | ||
40 | + } | ||
41 | + else | ||
42 | + { | ||
43 | + /* push back to the queue */ | ||
44 | + log_queue_push_head(self->queue, lm, &path_options); | ||
45 | + } | ||
46 | msg_set_context(NULL); | ||
47 | log_msg_refcache_stop(); | ||
diff --git a/meta-oe/recipes-support/syslog-ng/files/syslog-ng-verify-the-list-before-del.patch b/meta-oe/recipes-support/syslog-ng/files/syslog-ng-verify-the-list-before-del.patch new file mode 100644 index 0000000000..e8119b84bc --- /dev/null +++ b/meta-oe/recipes-support/syslog-ng/files/syslog-ng-verify-the-list-before-del.patch | |||
@@ -0,0 +1,38 @@ | |||
1 | Verify the validity of the pointer before delete it | ||
2 | |||
3 | Otherwise, we got a crash at logqueue-fifo.c:344 | ||
4 | 344 iv_list_del(&node->list); | ||
5 | |||
6 | Upstream-Status: Pending | ||
7 | |||
8 | Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com> | ||
9 | --- | ||
10 | --- a/lib/logqueue-fifo.c | ||
11 | +++ b/lib/logqueue-fifo.c | ||
12 | @@ -339,15 +339,18 @@ | ||
13 | *msg = node->msg; | ||
14 | path_options->ack_needed = node->ack_needed; | ||
15 | self->qoverflow_output_len--; | ||
16 | - if (!push_to_backlog) | ||
17 | + if ((&node->list) && (&node->list)->next && (&node->list)->prev) | ||
18 | { | ||
19 | - iv_list_del(&node->list); | ||
20 | - log_msg_free_queue_node(node); | ||
21 | - } | ||
22 | - else | ||
23 | - { | ||
24 | - iv_list_del_init(&node->list); | ||
25 | - } | ||
26 | + if (!push_to_backlog) | ||
27 | + { | ||
28 | + iv_list_del(&node->list); | ||
29 | + log_msg_free_queue_node(node); | ||
30 | + } | ||
31 | + else | ||
32 | + { | ||
33 | + iv_list_del_init(&node->list); | ||
34 | + } | ||
35 | + } | ||
36 | } | ||
37 | else | ||
38 | { | ||
diff --git a/meta-oe/recipes-support/syslog-ng/files/syslog-ng.conf b/meta-oe/recipes-support/syslog-ng/files/syslog-ng.conf index e760dfbdc5..f0da2b703c 100644 --- a/meta-oe/recipes-support/syslog-ng/files/syslog-ng.conf +++ b/meta-oe/recipes-support/syslog-ng/files/syslog-ng.conf | |||
@@ -1,11 +1,11 @@ | |||
1 | @version: 3.2 | 1 | @version: 3.5 |
2 | # | 2 | # |
3 | # Syslog-ng configuration file, compatible with default Debian syslogd | 3 | # Syslog-ng configuration file, compatible with default Debian syslogd |
4 | # installation. Originally written by anonymous (I can't find his name) | 4 | # installation. Originally written by anonymous (I can't find his name) |
5 | # Revised, and rewrited by me (SZALAY Attila <sasa@debian.org>) | 5 | # Revised, and rewrited by me (SZALAY Attila <sasa@debian.org>) |
6 | 6 | ||
7 | # First, set some global options. | 7 | # First, set some global options. |
8 | options { long_hostnames(off); flush_lines(0); use_dns(no); use_fqdn(no); | 8 | options { chain_hostnames(off); flush_lines(0); use_dns(no); use_fqdn(no); |
9 | owner("root"); group("adm"); perm(0640); stats_freq(0); | 9 | owner("root"); group("adm"); perm(0640); stats_freq(0); |
10 | bad_hostname("^gconfd$"); | 10 | bad_hostname("^gconfd$"); |
11 | }; | 11 | }; |
@@ -83,7 +83,7 @@ destination d_ppp { file("/var/log/ppp.log"); }; | |||
83 | ######################## | 83 | ######################## |
84 | # Filters | 84 | # Filters |
85 | ######################## | 85 | ######################## |
86 | # Here's come the filter options. With this rules, we can set which | 86 | # Here's come the filter options. With this rules, we can set which |
87 | # message go where. | 87 | # message go where. |
88 | 88 | ||
89 | filter f_dbg { level(debug); }; | 89 | filter f_dbg { level(debug); }; |
@@ -95,7 +95,7 @@ filter f_crit { level(crit .. emerg); }; | |||
95 | 95 | ||
96 | filter f_debug { level(debug) and not facility(auth, authpriv, news, mail); }; | 96 | filter f_debug { level(debug) and not facility(auth, authpriv, news, mail); }; |
97 | filter f_error { level(err .. emerg) ; }; | 97 | filter f_error { level(err .. emerg) ; }; |
98 | filter f_messages { level(info,notice,warn) and | 98 | filter f_messages { level(info,notice,warn) and |
99 | not facility(auth,authpriv,cron,daemon,mail,news); }; | 99 | not facility(auth,authpriv,cron,daemon,mail,news); }; |
100 | 100 | ||
101 | filter f_auth { facility(auth, authpriv) and not filter(f_debug); }; | 101 | filter f_auth { facility(auth, authpriv) and not filter(f_debug); }; |
diff --git a/meta-oe/recipes-support/syslog-ng/files/volatiles.03_syslog-ng b/meta-oe/recipes-support/syslog-ng/files/volatiles.03_syslog-ng new file mode 100644 index 0000000000..3c4a50d54f --- /dev/null +++ b/meta-oe/recipes-support/syslog-ng/files/volatiles.03_syslog-ng | |||
@@ -0,0 +1 @@ | |||
d root root 0755 /var/run/syslog-ng none | |||
diff --git a/meta-oe/recipes-support/syslog-ng/syslog-ng.inc b/meta-oe/recipes-support/syslog-ng/syslog-ng.inc index e0c9055977..01c9b202cc 100644 --- a/meta-oe/recipes-support/syslog-ng/syslog-ng.inc +++ b/meta-oe/recipes-support/syslog-ng/syslog-ng.inc | |||
@@ -1,98 +1,90 @@ | |||
1 | DESCRIPTION = "Alternative system logger daemon" | 1 | SUMMARY = "Alternative system logger daemon" |
2 | DEPENDS = "libol flex eventlog glib-2.0" | 2 | DESCRIPTION = "syslog-ng, as the name shows, is a syslogd replacement, \ |
3 | LICENSE = "GPL LGPL" | 3 | but with new functionality for the new generation. The original syslogd \ |
4 | LIC_FILES_CHKSUM = "file://COPYING;md5=7ec1bcc46f28b11f4722e20d9b7dd4d5" | 4 | allows messages only to be sorted based on priority/facility pairs; \ |
5 | 5 | syslog-ng adds the possibility to filter based on message contents using \ | |
6 | # syslog initscript is handled explicitly because order of | 6 | regular expressions. The new configuration scheme is intuitive and powerful. \ |
7 | # update-rc.d and update-alternatives is important | 7 | Forwarding logs over TCP and remembering all forwarding hops makes it \ |
8 | RDEPENDS_${PN} += " ${@base_conditional("ONLINE_PACKAGE_MANAGEMENT", "none", "", "update-rc.d", d)}" | 8 | ideal for firewalled environments. \ |
9 | " | ||
10 | HOMEPAGE = "http://www.balabit.com/network-security/syslog-ng/opensource-logging-system" | ||
9 | 11 | ||
10 | INC_PR = "r12" | 12 | LICENSE = "GPLv2 & LGPLv2.1" |
13 | LIC_FILES_CHKSUM = "file://COPYING;md5=e0e8658d9be248f01b7933df24dc1408" | ||
11 | 14 | ||
12 | inherit autotools systemd | 15 | DEPENDS = "flex eventlog glib-2.0" |
13 | 16 | ||
14 | SRC_URI = "http://www.balabit.com/downloads/files/syslog-ng/sources/${PV}/source/${BPN}_${PV}.tar.gz" | 17 | SRC_URI = "http://www.balabit.com/downloads/files/syslog-ng/sources/${PV}/source/${BPN}_${PV}.tar.gz \ |
18 | file://syslog-ng.conf \ | ||
19 | file://initscript \ | ||
20 | file://volatiles.03_syslog-ng \ | ||
21 | " | ||
15 | 22 | ||
16 | noipv6 = "${@base_contains('DISTRO_FEATURES', 'ipv6', '', '--disable-ipv6', d)}" | 23 | inherit autotools systemd pkgconfig update-rc.d update-alternatives |
17 | 24 | ||
18 | EXTRA_OECONF = " \ | 25 | EXTRA_OECONF = " \ |
19 | --with-libnet=${STAGING_BINDIR_CROSS} \ | ||
20 | --enable-dynamic-linking \ | 26 | --enable-dynamic-linking \ |
21 | ${noipv6} \ | ||
22 | --enable-ssl \ | ||
23 | --disable-sub-streams \ | 27 | --disable-sub-streams \ |
24 | --disable-pacct \ | 28 | --disable-pacct \ |
25 | --disable-linux-caps \ | 29 | --localstatedir=${localstatedir}/run/${BPN} \ |
26 | --disable-pcre \ | 30 | --sysconfdir=${sysconfdir}/${BPN} \ |
27 | --disable-sql \ | 31 | --with-module-dir=${libdir}/${BPN} \ |
32 | --with-sysroot=${STAGING_DIR_HOST} \ | ||
28 | " | 33 | " |
29 | 34 | ||
30 | EXTRA_OECONF += "${@base_contains('DISTRO_FEATURES', 'systemd', '--with-systemdsystemunitdir=${systemd_unitdir}/system/', '--without-systemdsystemunitdir', d)}" | 35 | PACKAGECONFIG ??= "openssl \ |
31 | EXTRA_OECONF += "${@base_contains('DISTRO_FEATURES', 'systemd', '--enable-systemd', '--disable-systemd', d)}" | 36 | ${@base_contains('DISTRO_FEATURES', 'ipv6', 'ipv6', '', d)} \ |
37 | ${@base_contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \ | ||
38 | " | ||
39 | PACKAGECONFIG[openssl] = "--enable-ssl,--disable-ssl,openssl," | ||
40 | PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,," | ||
41 | PACKAGECONFIG[systemd] = "--enable-systemd --with-systemdsystemunitdir=${systemd_unitdir}/system/,--disable-systemd --without-systemdsystemunitdir,systemd," | ||
42 | PACKAGECONFIG[linux-caps] = "--enable-linux-caps,--disable-linux-caps,libcap," | ||
43 | PACKAGECONFIG[pcre] = "--enable-pcre,--disable-pcre,libpcre," | ||
44 | PACKAGECONFIG[dbi] = "--enable-sql,--disable-sql,libdbi," | ||
45 | PACKAGECONFIG[libnet] = "--enable-libnet --with-libnet=${STAGING_BINDIR_CROSS},--disable-libnet,libnet," | ||
46 | PACKAGECONFIG[smtp] = "--enable-smtp --with-libesmtp=${STAGING_LIBDIR},--disable-smtp,libesmtp," | ||
32 | 47 | ||
33 | do_configure_prepend() { | 48 | do_configure_prepend() { |
34 | eval "${@base_contains('DISTRO_FEATURES', 'largefile', '', 'sed -i -e "s/-D_LARGEFILE_SOURCE//" -e "s/-D_FILE_OFFSET_BITS=64//" ${S}/configure.in', d)}" | 49 | eval "${@base_contains('DISTRO_FEATURES', 'largefile', '', 'sed -i -e "s/-D_LARGEFILE_SOURCE//" -e "s/-D_FILE_OFFSET_BITS=64//" ${S}/configure.in', d)}" |
35 | } | 50 | } |
36 | 51 | ||
37 | # rename modules.conf because it breaks update-modules | ||
38 | # see http://lists.linuxtogo.org/pipermail/openembedded-devel/2011-October/035537.html | ||
39 | do_install_append() { | 52 | do_install_append() { |
40 | mv ${D}/${sysconfdir}/modules.conf ${D}/${sysconfdir}/scl-modules.conf | 53 | install -d ${D}/${sysconfdir}/${BPN} |
41 | sed -i "s#@include 'modules.conf'#@include 'scl-modules.conf'#g" ${D}/${sysconfdir}/scl.conf | 54 | install ${WORKDIR}/syslog-ng.conf ${D}${sysconfdir}/${BPN}/${BPN}.conf |
42 | install -d ${D}/${sysconfdir}/${PN} | ||
43 | install ${WORKDIR}/syslog-ng.conf ${D}${sysconfdir}/${PN}.conf | ||
44 | install -d ${D}/${sysconfdir}/init.d | 55 | install -d ${D}/${sysconfdir}/init.d |
45 | install -m 755 ${WORKDIR}/initscript ${D}/${sysconfdir}/init.d/syslog.${PN} | 56 | install -m 755 ${WORKDIR}/initscript ${D}/${sysconfdir}/init.d/syslog.${BPN} |
57 | install -d ${D}/${sysconfdir}/default/volatiles/ | ||
58 | install -m 755 ${WORKDIR}/volatiles.03_syslog-ng ${D}/${sysconfdir}/default/volatiles/03_syslog-ng | ||
59 | |||
60 | # Remove /var/run as it is created on startup | ||
61 | rm -rf ${D}${localstatedir}/run | ||
46 | } | 62 | } |
47 | 63 | ||
48 | FILES_${PN} = "${bindir}/* ${sbindir}/* ${libexecdir}/* ${libdir}/lib*${SOLIBS} \ | 64 | FILES_${PN} += "${datadir}/include/scl/ ${datadir}/xsd ${datadir}/tools" |
49 | ${sysconfdir} ${sharedstatedir} ${localstatedir} \ | 65 | |
50 | ${base_bindir}/* ${base_sbindir}/* \ | 66 | # This overcomes the syslog-ng rdepends on syslog-ng-dev QA Error |
51 | ${base_libdir}/*${SOLIBS} \ | 67 | PACKAGES =+ "${PN}-libs ${PN}-libs-dev ${PN}-libs-dbg" |
52 | ${datadir}/${BPN} ${libdir}/${BPN}/*${SOLIBS} \ | 68 | FILES_${PN}-libs = "${libdir}/${BPN}/*.so ${libdir}/libsyslog-ng-*.so*" |
53 | ${datadir}/include/scl/ ${datadir}/xsd" | 69 | FILES_${PN}-libs-dev = "${libdir}/${BPN}/lib*.la" |
54 | FILES_${PN}-dev += "${libdir}/${BPN}/lib*.la ${libdir}/${BPN}/*${SOLIBSDEV}" | 70 | FILES_${PN}-libs-dbg = "${libdir}/${BPN}/.debug" |
55 | CONFFILES_${PN} = "${sysconfdir}/${PN}.conf ${sysconfdir}/scl.conf ${sysconfdir}/scl-modules.conf" | 71 | INSANE_SKIP_${PN}-libs = "dev-so" |
72 | RDEPENDS_${PN} += "${PN}-libs" | ||
73 | |||
74 | CONFFILES_${PN} = "${sysconfdir}/${BPN}.conf ${sysconfdir}/scl.conf" | ||
75 | |||
76 | # syslog initscript is handled explicitly because order of | ||
77 | # update-rc.d and update-alternatives is important | ||
78 | RDEPENDS_${PN} += " ${@base_conditional("ONLINE_PACKAGE_MANAGEMENT", "none", "", "update-rc.d", d)}" | ||
56 | 79 | ||
57 | RPROVIDES_${PN} += "${PN}-systemd" | 80 | RPROVIDES_${PN} += "${PN}-systemd" |
58 | RREPLACES_${PN} += "${PN}-systemd" | 81 | RREPLACES_${PN} += "${PN}-systemd" |
59 | RCONFLICTS_${PN} += "${PN}-systemd" | 82 | RCONFLICTS_${PN} += "${PN}-systemd" |
60 | SYSTEMD_SERVICE_${PN} = "${PN}.service" | 83 | SYSTEMD_SERVICE_${PN} = "${PN}.service" |
61 | 84 | ||
62 | pkg_postinst_${PN} () { | 85 | ALTERNATIVE_${PN} = "syslog-init" |
63 | /etc/init.d/syslog stop | 86 | ALTERNATIVE_PRIORITY[syslog-init] = "200" |
64 | update-alternatives --install ${sysconfdir}/init.d/syslog syslog-init syslog.${PN} 200 | 87 | ALTERNATIVE_LINK_NAME[syslog-init] = "${sysconfdir}/init.d/syslog" |
65 | |||
66 | if test "x$D" != "x"; then | ||
67 | OPT="-r $D" | ||
68 | else | ||
69 | OPT="-s" | ||
70 | fi | ||
71 | # remove all rc.d-links potentially created from alternative | ||
72 | # syslog packages before creating new ones | ||
73 | update-rc.d $OPT -f syslog remove | ||
74 | update-rc.d $OPT syslog start 20 2 3 4 5 . stop 90 0 1 6 . | ||
75 | } | ||
76 | 88 | ||
77 | pkg_prerm_${PN} () { | 89 | INITSCRIPT_NAME = "syslog" |
78 | if test "x$D" = "x"; then | 90 | INITSCRIPT_PARAMS = "start 20 2 3 4 5 . stop 90 0 1 6 ." |
79 | if test "$1" = "upgrade" -o "$1" = "remove"; then | ||
80 | /etc/init.d/syslog stop | ||
81 | fi | ||
82 | fi | ||
83 | |||
84 | update-alternatives --remove syslog-init syslog.${PN} | ||
85 | } | ||
86 | |||
87 | pkg_postrm_${PN} () { | ||
88 | if test "x$D" != "x"; then | ||
89 | OPT="-r $D" | ||
90 | else | ||
91 | OPT="" | ||
92 | fi | ||
93 | if test "$1" = "remove" -o "$1" = "purge"; then | ||
94 | if ! test -e "/etc/init.d/syslog"; then | ||
95 | update-rc.d $OPT syslog remove | ||
96 | fi | ||
97 | fi | ||
98 | } | ||
diff --git a/meta-oe/recipes-support/syslog-ng/syslog-ng_3.2.5.bb b/meta-oe/recipes-support/syslog-ng/syslog-ng_3.2.5.bb deleted file mode 100644 index 6d1fee7ae2..0000000000 --- a/meta-oe/recipes-support/syslog-ng/syslog-ng_3.2.5.bb +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | require syslog-ng.inc | ||
2 | PR = "${INC_PR}.1" | ||
3 | |||
4 | SRC_URI += " \ | ||
5 | file://syslog-ng.conf \ | ||
6 | file://initscript \ | ||
7 | " | ||
8 | |||
9 | SRC_URI[md5sum] = "60737452ce898f9dc7170dfdc9bfd732" | ||
10 | SRC_URI[sha256sum] = "ffc9f3a0ebea836c1c737b1ff49efe731d885af1d8aacf9eca79d9144eeefa89" | ||
diff --git a/meta-oe/recipes-support/syslog-ng/syslog-ng_3.5.4.1.bb b/meta-oe/recipes-support/syslog-ng/syslog-ng_3.5.4.1.bb new file mode 100644 index 0000000000..12b0dc32bd --- /dev/null +++ b/meta-oe/recipes-support/syslog-ng/syslog-ng_3.5.4.1.bb | |||
@@ -0,0 +1,17 @@ | |||
1 | require syslog-ng.inc | ||
2 | |||
3 | SRC_URI += " \ | ||
4 | file://afsql-afsql_dd_insert_db-refactor.patch \ | ||
5 | file://deinit-the-new-config-when-reverting-to-the.patch \ | ||
6 | file://fix-a-memory-leak-in-log_driver_free.patch \ | ||
7 | file://fix-config-libnet.patch \ | ||
8 | file://fix-invalid-ownership.patch \ | ||
9 | file://Fix-the-memory-leak-problem-for-mutex.patch \ | ||
10 | file://Fix-the-memory-leak-problem-when-HAVE_ENVIRON-defined.patch \ | ||
11 | file://free-global-LogTemplateOptions.patch \ | ||
12 | file://logwriter-still-free-the-unconsumed-item.patch \ | ||
13 | file://syslog-ng-verify-the-list-before-del.patch \ | ||
14 | " | ||
15 | |||
16 | SRC_URI[md5sum] = "ff3bf223ebafbaa92b69a2d5b729f368" | ||
17 | SRC_URI[sha256sum] = "92c6969e4172b4fd32390f80043b4de7b116f29989d8c2e5a8a687ee6dcd6f66" | ||