Gentoo Archives: gentoo-commits

From: Mikle Kolyada <zlogene@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-cluster/keepalived/, sys-cluster/keepalived/files/
Date: Thu, 15 Nov 2018 13:49:48
Message-Id: 1542289741.bb99b23e3f30a44d4880944ff42731297a0c5e3e.zlogene@gentoo
1 commit: bb99b23e3f30a44d4880944ff42731297a0c5e3e
2 Author: Tomas Mozes <hydrapolic <AT> gmail <DOT> com>
3 AuthorDate: Thu Nov 15 09:58:16 2018 +0000
4 Commit: Mikle Kolyada <zlogene <AT> gentoo <DOT> org>
5 CommitDate: Thu Nov 15 13:49:01 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bb99b23e
7
8 sys-cluster/keepalived: fix crash during shutdown
9
10 Bug: https://bugs.gentoo.org/670856
11 Bug: https://github.com/acassen/keepalived/issues/1061
12 Package-Manager: Portage-2.3.51, Repoman-2.3.12
13 Signed-off-by: Tomáš Mózes <hydrapolic <AT> gmail.com>
14 Closes: https://github.com/gentoo/gentoo/pull/10422
15 Signed-off-by: Mikle Kolyada <zlogene <AT> gentoo.org>
16
17 .../files/keepalived-2.0.10-snmp-crash-fix.patch | 122 +++++++++++++++++++++
18 sys-cluster/keepalived/keepalived-2.0.10-r1.ebuild | 76 +++++++++++++
19 2 files changed, 198 insertions(+)
20
21 diff --git a/sys-cluster/keepalived/files/keepalived-2.0.10-snmp-crash-fix.patch b/sys-cluster/keepalived/files/keepalived-2.0.10-snmp-crash-fix.patch
22 new file mode 100644
23 index 00000000000..c1a5ab36180
24 --- /dev/null
25 +++ b/sys-cluster/keepalived/files/keepalived-2.0.10-snmp-crash-fix.patch
26 @@ -0,0 +1,122 @@
27 +diff --git a/keepalived/check/check_snmp.c b/keepalived/check/check_snmp.c
28 +index 67ae0e4f9..95c6e6f83 100644
29 +--- a/keepalived/check/check_snmp.c
30 ++++ b/keepalived/check/check_snmp.c
31 +@@ -1451,6 +1451,9 @@ static struct variable8 check_vars[] = {
32 + void
33 + check_snmp_agent_init(const char *snmp_socket)
34 + {
35 ++ if (snmp_running)
36 ++ return;
37 ++
38 + /* We handle the global oid if we are running SNMP */
39 + snmp_agent_init(snmp_socket, true);
40 + snmp_register_mib(check_oid, OID_LENGTH(check_oid), "Healthchecker",
41 +@@ -1462,6 +1465,9 @@ check_snmp_agent_init(const char *snmp_socket)
42 + void
43 + check_snmp_agent_close()
44 + {
45 ++ if (!snmp_running)
46 ++ return;
47 ++
48 + snmp_unregister_mib(check_oid, OID_LENGTH(check_oid));
49 + snmp_agent_close(true);
50 + }
51 +diff --git a/keepalived/core/snmp.c b/keepalived/core/snmp.c
52 +index a9472feae..eb5bed20a 100644
53 +--- a/keepalived/core/snmp.c
54 ++++ b/keepalived/core/snmp.c
55 +@@ -325,6 +325,9 @@ snmp_unregister_mib(oid *myoid, size_t len)
56 + void
57 + snmp_agent_init(const char *snmp_socket, bool base_mib)
58 + {
59 ++ if (snmp_running)
60 ++ return;
61 ++
62 + log_message(LOG_INFO, "Starting SNMP subagent");
63 + netsnmp_enable_subagent();
64 + snmp_disable_log();
65 +@@ -378,6 +381,9 @@ snmp_agent_init(const char *snmp_socket, bool base_mib)
66 + void
67 + snmp_agent_close(bool base_mib)
68 + {
69 ++ if (!snmp_running)
70 ++ return;
71 ++
72 + if (base_mib)
73 + snmp_unregister_mib(global_oid, OID_LENGTH(global_oid));
74 + snmp_shutdown(global_name);
75 +diff --git a/keepalived/vrrp/vrrp_snmp.c b/keepalived/vrrp/vrrp_snmp.c
76 +index ca9d46768..db696159c 100644
77 +--- a/keepalived/vrrp/vrrp_snmp.c
78 ++++ b/keepalived/vrrp/vrrp_snmp.c
79 +@@ -4552,6 +4552,9 @@ vrrp_handles_global_oid(void)
80 + void
81 + vrrp_snmp_agent_init(const char *snmp_socket)
82 + {
83 ++ if (snmp_running)
84 ++ return;
85 ++
86 + /* We let the check process handle the global OID if it is running and with snmp */
87 + snmp_agent_init(snmp_socket, vrrp_handles_global_oid());
88 +
89 +@@ -4581,6 +4584,9 @@ vrrp_snmp_agent_init(const char *snmp_socket)
90 + void
91 + vrrp_snmp_agent_close(void)
92 + {
93 ++ if (!snmp_running)
94 ++ return;
95 ++
96 + #ifdef _WITH_SNMP_VRRP_
97 + if (global_data->enable_snmp_vrrp)
98 + snmp_unregister_mib(vrrp_oid, OID_LENGTH(vrrp_oid));
99 +diff --git a/lib/scheduler.c b/lib/scheduler.c
100 +index 0a1c334c3..9090a7f88 100644
101 +--- a/lib/scheduler.c
102 ++++ b/lib/scheduler.c
103 +@@ -1630,7 +1630,7 @@ thread_fetch_next_queue(thread_master_t *m)
104 + if (!ev->read) {
105 + log_message(LOG_INFO, "scheduler: No read thread bound on fd:%d (fl:0x%.4X)"
106 + , ev->fd, ep_ev->events);
107 +- assert(0);
108 ++ continue;
109 + }
110 + thread_move_ready(m, &m->read, ev->read, THREAD_READY_FD);
111 + ev->read = NULL;
112 +@@ -1641,7 +1641,7 @@ thread_fetch_next_queue(thread_master_t *m)
113 + if (!ev->write) {
114 + log_message(LOG_INFO, "scheduler: No write thread bound on fd:%d (fl:0x%.4X)"
115 + , ev->fd, ep_ev->events);
116 +- assert(0);
117 ++ continue;
118 + }
119 + thread_move_ready(m, &m->write, ev->write, THREAD_READY_FD);
120 + ev->write = NULL;
121 +@@ -1710,7 +1710,12 @@ process_threads(thread_master_t *m)
122 + thread = thread_trim_head(thread_list);
123 + if (!shutting_down ||
124 + (thread->type == THREAD_READY_FD &&
125 +- (thread->u.fd == m->timer_fd || thread->u.fd == m->signal_fd)) ||
126 ++ (thread->u.fd == m->timer_fd ||
127 ++ thread->u.fd == m->signal_fd
128 ++#ifdef _WITH_SNMP_
129 ++ || FD_ISSET(thread->u.fd, &m->snmp_fdset)
130 ++#endif
131 ++ )) ||
132 + thread->type == THREAD_CHILD ||
133 + thread->type == THREAD_CHILD_TIMEOUT ||
134 + thread->type == THREAD_CHILD_TERMINATED ||
135 +diff --git a/lib/utils.c b/lib/utils.c
136 +index 6f9ec254d..e5b82b524 100644
137 +--- a/lib/utils.c
138 ++++ b/lib/utils.c
139 +@@ -789,7 +789,9 @@ FILE *fopen_safe(const char *path, const char *mode)
140 + {
141 + int fd;
142 + FILE *file;
143 ++#ifdef ENABLE_LOG_FILE_APPEND
144 + int flags = O_NOFOLLOW | O_CREAT | O_CLOEXEC;
145 ++#endif
146 + int sav_errno;
147 + char file_tmp_name[] = "/tmp/keepalivedXXXXXX";
148 +
149
150 diff --git a/sys-cluster/keepalived/keepalived-2.0.10-r1.ebuild b/sys-cluster/keepalived/keepalived-2.0.10-r1.ebuild
151 new file mode 100644
152 index 00000000000..5eea98a00f6
153 --- /dev/null
154 +++ b/sys-cluster/keepalived/keepalived-2.0.10-r1.ebuild
155 @@ -0,0 +1,76 @@
156 +# Copyright 1999-2018 Gentoo Authors
157 +# Distributed under the terms of the GNU General Public License v2
158 +
159 +EAPI=7
160 +
161 +inherit autotools systemd
162 +
163 +DESCRIPTION="A strong & robust keepalive facility to the Linux Virtual Server project"
164 +HOMEPAGE="http://www.keepalived.org/"
165 +SRC_URI="http://www.keepalived.org/software/${P}.tar.gz"
166 +
167 +LICENSE="GPL-2"
168 +SLOT="0"
169 +KEYWORDS="~alpha ~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sparc ~x86"
170 +IUSE="dbus debug ipv6 -json snmp"
171 +
172 +RDEPEND="dev-libs/libnl:=
173 + dev-libs/openssl:=
174 + dev-libs/popt
175 + net-libs/libnfnetlink
176 + sys-apps/iproute2
177 + dbus? ( sys-apps/dbus )
178 + json? ( dev-libs/json-c:= )
179 + snmp? ( net-analyzer/net-snmp )"
180 +DEPEND="${RDEPEND}
181 + >=sys-kernel/linux-headers-4.4"
182 +
183 +DOCS=(
184 + README CONTRIBUTORS INSTALL ChangeLog AUTHOR TODO
185 + doc/keepalived.conf.SYNOPSIS doc/NOTE_vrrp_vmac.txt
186 +)
187 +
188 +PATCHES=(
189 + "${FILESDIR}/${P}-snmp-crash-fix.patch"
190 +)
191 +
192 +src_prepare() {
193 + default
194 +
195 + eautoreconf
196 +}
197 +
198 +src_configure() {
199 + STRIP=/bin/true \
200 + econf \
201 + --with-kernel-dir=/usr \
202 + --enable-sha1 \
203 + --enable-vrrp \
204 + $(use_enable dbus) \
205 + $(use_enable dbus dbus-create-instance) \
206 + $(use_enable debug) \
207 + $(use_enable json) \
208 + $(use_enable snmp)
209 +}
210 +
211 +src_install() {
212 + default
213 +
214 + newinitd "${FILESDIR}"/keepalived.init-r1 keepalived
215 + newconfd "${FILESDIR}"/keepalived.confd-r1 keepalived
216 +
217 + systemd_newunit "${FILESDIR}"/${PN}.service ${PN}.service
218 + systemd_install_serviced "${FILESDIR}/${PN}.service.conf"
219 +
220 + use snmp && dodoc doc/KEEPALIVED-MIB.txt
221 +
222 + docinto genhash
223 + dodoc genhash/README genhash/AUTHOR genhash/ChangeLog
224 + # This was badly named by upstream, it's more HOWTO than anything else.
225 + newdoc INSTALL INSTALL+HOWTO
226 +
227 + # Security risk to bundle SSL certs
228 + rm -v "${ED}"/etc/keepalived/samples/*.pem || die
229 + # Clean up sysvinit files
230 + rm -rv "${ED}"/etc/sysconfig || die
231 +}