Gentoo Archives: gentoo-commits

From: "Michael Sterrett (mr_bones_)" <mr_bones_@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-admin/syslog-ng/files: syslog-ng-3.3.5-threading.patch syslog-ng-3.3.5-utmpx.patch
Date: Fri, 08 Jun 2012 18:50:25
Message-Id: 20120608185014.EE45D2004C@flycatcher.gentoo.org
1 mr_bones_ 12/06/08 18:50:14
2
3 Added: syslog-ng-3.3.5-threading.patch
4 syslog-ng-3.3.5-utmpx.patch
5 Log:
6 Add a couple of upstream patches
7
8 (Portage version: 2.1.10.49/cvs/Linux x86_64)
9
10 Revision Changes Path
11 1.1 app-admin/syslog-ng/files/syslog-ng-3.3.5-threading.patch
12
13 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/syslog-ng/files/syslog-ng-3.3.5-threading.patch?rev=1.1&view=markup
14 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/syslog-ng/files/syslog-ng-3.3.5-threading.patch?rev=1.1&content-type=text/plain
15
16 Index: syslog-ng-3.3.5-threading.patch
17 ===================================================================
18 From c0afec5b46eb3508fd3b1449e37b7e550f7d35e2 Mon Sep 17 00:00:00 2001
19 From: Gergely Nagy <algernon@×××××××.hu>
20 Date: Fri, 08 Jun 2012 15:28:33 +0200
21 Subject: dnscache: Fix a memory corruption when destroying the DNS cache
22
23 The DNS cache gets destroyed every time a worker thread quits, which
24 is fine, as most of the dns cache variables are thread local.
25
26 However, dns_cache_hosts is not, it's a global static, and
27 dns_cache_destroy() was freeing that aswell.
28
29 The solution is to not free dns_cache_hosts when a worker stops, but
30 do so when syslog-ng stops. This patch introduces dns_cache_deinit()
31 which does just that, and removes the same thing from
32 dns_cache_destroy(), which now only touches thread-local variables.
33
34 Reported-by: EgonB <egon@×××××.ee>
35 Signed-off-by: Gergely Nagy <algernon@×××××××.hu>
36 ---
37 diff --git a/lib/dnscache.c b/lib/dnscache.c
38 index 49102b7..9cdc2c0 100644
39 --- a/lib/dnscache.c
40 +++ b/lib/dnscache.c
41 @@ -361,6 +361,12 @@ dns_cache_destroy(void)
42 cache_last.prev = NULL;
43 persist_first.next = NULL;
44 persist_last.prev = NULL;
45 +}
46 +
47 +void
48 +dns_cache_deinit(void)
49 +{
50 if (dns_cache_hosts)
51 g_free(dns_cache_hosts);
52 + dns_cache_hosts = NULL;
53 }
54 diff --git a/lib/dnscache.h b/lib/dnscache.h
55 index 8bae5f1..647ba19 100644
56 --- a/lib/dnscache.h
57 +++ b/lib/dnscache.h
58 @@ -34,5 +34,6 @@ void dns_cache_store(gboolean persistent, gint family, void *addr, const gchar *
59 void dns_cache_set_params(gint cache_size, gint expire, gint expire_failed, const gchar *hosts);
60 void dns_cache_init(void);
61 void dns_cache_destroy(void);
62 +void dns_cache_deinit(void);
63
64 #endif
65 diff --git a/lib/mainloop.c b/lib/mainloop.c
66 index 1203098..e294fa3 100644
67 --- a/lib/mainloop.c
68 +++ b/lib/mainloop.c
69 @@ -585,6 +585,7 @@ main_loop_exit_finish(void)
70 /* deinit the current configuration, as at this point we _know_ that no
71 * threads are running. This will unregister ivykis tasks and timers
72 * that could fire while the configuration is being destructed */
73 + dns_cache_deinit();
74 cfg_deinit(current_configuration);
75 iv_quit();
76 }
77 --
78 cgit v0.8.3.4-1-gaabc
79
80
81
82 1.1 app-admin/syslog-ng/files/syslog-ng-3.3.5-utmpx.patch
83
84 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/syslog-ng/files/syslog-ng-3.3.5-utmpx.patch?rev=1.1&view=markup
85 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/syslog-ng/files/syslog-ng-3.3.5-utmpx.patch?rev=1.1&content-type=text/plain
86
87 Index: syslog-ng-3.3.5-utmpx.patch
88 ===================================================================
89 From 4b450a09da83bc8e27bd7c8adccea3f125387fa7 Mon Sep 17 00:00:00 2001
90 From: Gergely Nagy <algernon@×××××××.hu>
91 Date: Tue, 5 Jun 2012 14:40:08 +0200
92 Subject: [PATCH] afuser: Use utmpx when available, instead of utmp
93
94 FreeBSD 9 removed support for utmp, and one must use the
95 POSIX-specified utmpx instead. The same utmpx is available on Linux
96 too (and it is the same as utmp there).
97
98 The patch below converts afuser to use utmpx when available, utmp
99 otherwise. It is based on the post-build sed magic applied to
100 syslog-ng within the FreeBSD ports collection, with other bits based
101 on a patch from Alex Zimnitsky.
102
103 Signed-off-by: Gergely Nagy <algernon@×××××××.hu>
104 ---
105 configure.in | 4 ++--
106 lib/utils.c | 2 +-
107 lib/utils.h | 7 ++++++-
108 modules/afuser/afuser.c | 20 +++++++++++++++++++-
109 4 files changed, 28 insertions(+), 5 deletions(-)
110
111 diff --git a/configure.in b/configure.in
112 index aafb980..c76d7d9 100644
113 --- a/configure.in
114 +++ b/configure.in
115 @@ -383,7 +383,7 @@ dnl ***************************************************************************
116
117 AC_HEADER_STDC
118 AC_CHECK_HEADER(dmalloc.h)
119 -AC_CHECK_HEADERS(strings.h getopt.h stropts.h sys/strlog.h door.h sys/capability.h sys/prctl.h)
120 +AC_CHECK_HEADERS(strings.h getopt.h stropts.h sys/strlog.h door.h sys/capability.h sys/prctl.h utmpx.h)
121 AC_CHECK_HEADERS(tcpd.h)
122
123
124 @@ -479,7 +479,7 @@ if test "x$enable_linux_caps" = "xyes" -o "x$enable_linux_caps" = "xauto"; then
125 AC_CHECK_LIB(cap, cap_set_proc, LIBCAP_LIBS="-lcap")
126 fi
127
128 -AC_CHECK_FUNCS(strdup strtol strtoll strtoimax inet_aton inet_ntoa getopt_long getaddrinfo getutent pread pwrite strcasestr memrchr localtime_r gmtime_r)
129 +AC_CHECK_FUNCS(strdup strtol strtoll strtoimax inet_aton inet_ntoa getopt_long getaddrinfo getutent getutxent pread pwrite strcasestr memrchr localtime_r gmtime_r)
130 old_LIBS=$LIBS
131 LIBS=$BASE_LIBS
132 AC_CHECK_FUNCS(clock_gettime)
133 diff --git a/lib/utils.c b/lib/utils.c
134 index 2b5c525..3c05426 100644
135 --- a/lib/utils.c
136 +++ b/lib/utils.c
137 @@ -47,7 +47,7 @@ int inet_aton(const char *cp, struct in_addr *addr)
138 }
139 #endif
140
141 -#ifndef HAVE_GETUTENT
142 +#if !defined(HAVE_GETUTENT) && !defined(HAVE_GETUTXENT)
143
144 static int utent_fd = -1;
145
146 diff --git a/lib/utils.h b/lib/utils.h
147 index 86e3a7f..a0f3dcc 100644
148 --- a/lib/utils.h
149 +++ b/lib/utils.h
150 @@ -28,13 +28,18 @@
151 #include <sys/types.h>
152 #include <sys/socket.h>
153 #include <netinet/in.h>
154 +
155 +#ifdef HAVE_UTMPX_H
156 +#include <utmpx.h>
157 +#else
158 #include <utmp.h>
159 +#endif
160
161 #ifndef HAVE_INET_ATON
162 int inet_aton(const char *cp, struct in_addr *addr);
163 #endif
164
165 -#ifndef HAVE_GETUTENT
166 +#if !defined(HAVE_GETUTENT) && !defined(HAVE_GETUTXENT)
167 struct utmp *getutent(void);
168 void endutent(void);
169 #endif
170 diff --git a/modules/afuser/afuser.c b/modules/afuser/afuser.c
171 index 8f170e5..7d082b2 100644
172 --- a/modules/afuser/afuser.c
173 +++ b/modules/afuser/afuser.c
174 @@ -25,7 +25,13 @@
175 #include "alarms.h"
176 #include "messages.h"
177
178 +#ifdef HAVE_UTMPX_H
179 +#include <utmpx.h>
180 +#define ut_name ut_user
181 +#else
182 #include <utmp.h>
183 +#endif
184 +
185 #include <string.h>
186 #include <fcntl.h>
187 #include <unistd.h>
188 @@ -46,7 +52,11 @@
189 {
190 AFUserDestDriver *self = (AFUserDestDriver *) s;
191 gchar buf[8192];
192 +#ifdef HAVE_UTMPX_H
193 + struct utmpx *ut;
194 +#else
195 struct utmp *ut;
196 +#endif
197 GString *timestamp;
198 time_t now;
199
200 @@ -63,7 +73,11 @@
201 g_string_free(timestamp, TRUE);
202
203 /* NOTE: there's a private implementations of getutent in utils.c on Systems which do not provide one. */
204 - while ((ut = getutent()))
205 +#ifdef HAVE_GETUTXENT
206 + while ((ut = getutxent()))
207 +#else
208 + while ((ut = getutent()))
209 +#endif
210 {
211 #if HAVE_MODERN_UTMP
212 if (ut->ut_type == USER_PROCESS &&
213 @@ -106,7 +120,11 @@
214 }
215 }
216 }
217 +#if HAVE_UTMPX_H
218 + endutxent();
219 +#else
220 endutent();
221 +#endif
222 finish:
223 log_msg_ack(msg, path_options);
224 log_msg_unref(msg);
225 --
226 1.7.10