Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-misc/ntp/files/, net-misc/ntp/
Date: Mon, 28 Nov 2016 22:44:12
Message-Id: 1480373043.a118911c3b6177dd447258f6a334a5a2c7314948.whissi@gentoo
1 commit: a118911c3b6177dd447258f6a334a5a2c7314948
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Mon Nov 28 22:43:09 2016 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Mon Nov 28 22:44:03 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a118911c
7
8 net-misc/ntp: Fix building w/ SSL or against libressl
9
10 Acked-by: Lars Wendler <polynomial-c <AT> gentoo.org>
11 Gentoo-Bug: https://bugs.gentoo.org/600454
12 Gentoo-Bug: https://bugs.gentoo.org/600668
13
14 Package-Manager: portage-2.3.2
15
16 ...ntp-4.2.8_p9-fix-build-wo-ssl-or-libressl.patch | 236 +++++++++++++++++++++
17 net-misc/ntp/ntp-4.2.8_p9.ebuild | 1 +
18 2 files changed, 237 insertions(+)
19
20 diff --git a/net-misc/ntp/files/ntp-4.2.8_p9-fix-build-wo-ssl-or-libressl.patch b/net-misc/ntp/files/ntp-4.2.8_p9-fix-build-wo-ssl-or-libressl.patch
21 new file mode 100644
22 index 00000000..5166e5f
23 --- /dev/null
24 +++ b/net-misc/ntp/files/ntp-4.2.8_p9-fix-build-wo-ssl-or-libressl.patch
25 @@ -0,0 +1,236 @@
26 +Fix building with libressl or without SSL.
27 +
28 +Origin: http://bugs.ntp.org/attachment.cgi?id=1481
29 +
30 +LibreSSL fix from Joe Kappus (https://bugs.gentoo.org/show_bug.cgi?id=600668#c2)
31 +
32 +diff -Nru a/include/ntp_md5.h b/include/ntp_md5.h
33 +--- a/include/ntp_md5.h 2016-11-23 08:35:18.248130387 +0100
34 ++++ b/include/ntp_md5.h 2016-11-23 08:35:18.248130387 +0100
35 +@@ -8,6 +8,7 @@
36 +
37 + #ifdef OPENSSL
38 + # include "openssl/evp.h"
39 ++# include "libssl_compat.h"
40 + #else /* !OPENSSL follows */
41 + /*
42 + * Provide OpenSSL-alike MD5 API if we're not using OpenSSL
43 +@@ -23,6 +24,9 @@
44 + # endif
45 +
46 + typedef MD5_CTX EVP_MD_CTX;
47 ++
48 ++# define EVP_MD_CTX_free(c) free(c)
49 ++# define EVP_MD_CTX_new() calloc(1, sizeof(MD5_CTX))
50 + # define EVP_get_digestbynid(t) NULL
51 + # define EVP_md5() NULL
52 + # define EVP_MD_CTX_init(c)
53 +diff -Nru a/libntp/a_md5encrypt.c b/libntp/a_md5encrypt.c
54 +--- a/libntp/a_md5encrypt.c 2016-11-23 08:35:18.248130387 +0100
55 ++++ b/libntp/a_md5encrypt.c 2016-11-23 08:35:18.248130387 +0100
56 +@@ -11,7 +11,6 @@
57 + #include "ntp.h"
58 + #include "ntp_md5.h" /* provides OpenSSL digest API */
59 + #include "isc/string.h"
60 +-#include "libssl_compat.h"
61 + /*
62 + * MD5authencrypt - generate message digest
63 + *
64 +diff -Nru a/libntp/libssl_compat.c b/libntp/libssl_compat.c
65 +--- a/libntp/libssl_compat.c 2016-11-23 08:35:18.248130387 +0100
66 ++++ b/libntp/libssl_compat.c 2016-11-23 08:35:18.248130387 +0100
67 +@@ -15,15 +15,18 @@
68 + * ---------------------------------------------------------------------
69 + */
70 + #include "config.h"
71 +-
72 +-#include <string.h>
73 +-#include <openssl/bn.h>
74 +-#include <openssl/evp.h>
75 +-
76 + #include "ntp_types.h"
77 +
78 + /* ----------------------------------------------------------------- */
79 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
80 ++#ifdef OPENSSL
81 ++# include <string.h>
82 ++# include <openssl/bn.h>
83 ++# include <openssl/evp.h>
84 ++#endif
85 ++/* ----------------------------------------------------------------- */
86 ++
87 ++/* ----------------------------------------------------------------- */
88 ++#if defined(OPENSSL) && (OPENSSL_VERSION_NUMBER < 0x10100000L || defined LIBRESSL_VERSION_NUMBER)
89 + /* ----------------------------------------------------------------- */
90 +
91 + #include "libssl_compat.h"
92 +@@ -325,7 +328,7 @@
93 + }
94 +
95 + /* ----------------------------------------------------------------- */
96 +-#else /* OPENSSL_VERSION_NUMBER >= v1.1.0 */
97 ++#else /* OPENSSL && OPENSSL_VERSION_NUMBER >= v1.1.0 */
98 + /* ----------------------------------------------------------------- */
99 +
100 + NONEMPTY_TRANSLATION_UNIT
101 +diff -Nru a/ntpd/ntp_control.c b/ntpd/ntp_control.c
102 +--- a/ntpd/ntp_control.c 2016-11-23 08:35:18.256130015 +0100
103 ++++ b/ntpd/ntp_control.c 2016-11-23 08:35:18.260129828 +0100
104 +@@ -33,8 +33,6 @@
105 + # include "ntp_syscall.h"
106 + #endif
107 +
108 +-#include "libssl_compat.h"
109 +-
110 + /*
111 + * Structure to hold request procedure information
112 + */
113 +@@ -1653,8 +1651,10 @@
114 + }
115 +
116 + /*
117 +- * ctl_putcal - write a decoded calendar data into the response
118 ++ * ctl_putcal - write a decoded calendar data into the response.
119 ++ * only used with AUTOKEY currently, so compiled conditional
120 + */
121 ++#ifdef AUTOKEY
122 + static void
123 + ctl_putcal(
124 + const char *tag,
125 +@@ -1678,6 +1678,7 @@
126 +
127 + return;
128 + }
129 ++#endif
130 +
131 + /*
132 + * ctl_putfs - write a decoded filestamp into the response
133 +@@ -1838,7 +1839,7 @@
134 + char * oplim;
135 + char * iptr;
136 + char * iplim;
137 +- char * past_eq;
138 ++ char * past_eq = NULL;
139 +
140 + optr = output;
141 + oplim = output + sizeof(output);
142 +diff -Nru a/ntpd/ntp_io.c b/ntpd/ntp_io.c
143 +--- a/ntpd/ntp_io.c 2016-11-23 08:35:18.268129456 +0100
144 ++++ b/ntpd/ntp_io.c 2016-11-23 08:35:18.272129269 +0100
145 +@@ -516,13 +516,17 @@
146 + /*
147 + * function to dump the contents of the interface structure
148 + * for debugging use only.
149 ++ * We face a dilemma here -- sockets are FDs under POSIX and
150 ++ * actually HANDLES under Windows. So we use '%lld' as format
151 ++ * and cast the value to 'long long'; this should not hurt
152 ++ * with UNIX-like systems and does not truncate values on Win64.
153 + */
154 + void
155 + interface_dump(const endpt *itf)
156 + {
157 + printf("Dumping interface: %p\n", itf);
158 +- printf("fd = %d\n", itf->fd);
159 +- printf("bfd = %d\n", itf->bfd);
160 ++ printf("fd = %lld\n", (long long)itf->fd);
161 ++ printf("bfd = %lld\n", (long long)itf->bfd);
162 + printf("sin = %s,\n", stoa(&itf->sin));
163 + sockaddr_dump(&itf->sin);
164 + printf("bcast = %s,\n", stoa(&itf->bcast));
165 +@@ -570,11 +574,11 @@
166 + static void
167 + print_interface(const endpt *iface, const char *pfx, const char *sfx)
168 + {
169 +- printf("%sinterface #%d: fd=%d, bfd=%d, name=%s, flags=0x%x, ifindex=%u, sin=%s",
170 ++ printf("%sinterface #%d: fd=%lld, bfd=%lld, name=%s, flags=0x%x, ifindex=%u, sin=%s",
171 + pfx,
172 + iface->ifnum,
173 +- iface->fd,
174 +- iface->bfd,
175 ++ (long long)iface->fd,
176 ++ (long long)iface->bfd,
177 + iface->name,
178 + iface->flags,
179 + iface->ifindex,
180 +diff -Nru a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c
181 +--- a/ntpd/ntp_proto.c 2016-11-23 08:35:18.280128897 +0100
182 ++++ b/ntpd/ntp_proto.c 2016-11-23 08:35:18.284128711 +0100
183 +@@ -4054,7 +4054,7 @@
184 + ntoa(&peer->srcadr), peer->hmode, xkeyid, sendlen,
185 + peer->keynumber));
186 + #else /* !AUTOKEY follows */
187 +- DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d keyid %08x len %d\n",
188 ++ DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d keyid %08x len %zu\n",
189 + current_time, peer->dstadr ?
190 + ntoa(&peer->dstadr->sin) : "-",
191 + ntoa(&peer->srcadr), peer->hmode, xkeyid, sendlen));
192 +diff -Nru a/ports/winnt/ntpd/ntp_iocompletionport.c b/ports/winnt/ntpd/ntp_iocompletionport.c
193 +--- a/ports/winnt/ntpd/ntp_iocompletionport.c 2016-11-23 08:35:18.288128524 +0100
194 ++++ b/ports/winnt/ntpd/ntp_iocompletionport.c 2016-11-23 08:35:18.288128524 +0100
195 +@@ -1391,8 +1391,7 @@
196 + goto fail;
197 + }
198 +
199 +- ;
200 +- if ( ! (rio->ioreg_ctx = iopad = iohpCreate(rio))) {
201 ++ if (NULL == (rio->ioreg_ctx = iopad = iohpCreate(rio))) {
202 + msyslog(LOG_ERR, "%s: Failed to create shared lock",
203 + msgh);
204 + goto fail;
205 +@@ -1401,13 +1400,13 @@
206 + iopad->riofd = rio->fd;
207 + iopad->rsrc.rio = rio;
208 +
209 +- if (!(rio->device_ctx = DevCtxAttach(serial_devctx(h)))) {
210 ++ if (NULL == (rio->device_ctx = DevCtxAttach(serial_devctx(h)))) {
211 + msyslog(LOG_ERR, "%s: Failed to allocate device context",
212 + msgh);
213 + goto fail;
214 + }
215 +
216 +- if ( ! (lpo = IoCtxAlloc(iopad, rio->device_ctx))) {
217 ++ if (NULL == (lpo = IoCtxAlloc(iopad, rio->device_ctx))) {
218 + msyslog(LOG_ERR, "%: Failed to allocate IO context",
219 + msgh);
220 + goto fail;
221 +@@ -1594,7 +1593,6 @@
222 + static const char * const msg =
223 + "OnSocketSend: send to socket failed";
224 +
225 +- IoHndPad_T * iopad = NULL;
226 + endpt * ep = NULL;
227 + int rc;
228 +
229 +@@ -1662,7 +1660,7 @@
230 +
231 + INSIST(hndIOCPLPort && hMainRpcDone);
232 + if (iopad)
233 +- iocpl_notify(iopad, OnInterfaceDetach, -1);
234 ++ iocpl_notify(iopad, OnInterfaceDetach, (UINT_PTR)-1);
235 + }
236 +
237 + /* --------------------------------------------------------------------
238 +diff -Nru a/sntp/crypto.c b/sntp/crypto.c
239 +--- a/sntp/crypto.c 2016-11-23 08:35:18.288128524 +0100
240 ++++ b/sntp/crypto.c 2016-11-23 08:35:18.288128524 +0100
241 +@@ -2,7 +2,7 @@
242 + #include "crypto.h"
243 + #include <ctype.h>
244 + #include "isc/string.h"
245 +-#include "libssl_compat.h"
246 ++#include "ntp_md5.h"
247 +
248 + struct key *key_ptr;
249 + size_t key_cnt = 0;
250 +diff -urN ntp-4.2.8p9/include/libssl_compat.h ntp-4.2.8p9_fixed/include/libssl_compat.h
251 +--- a/include/libssl_compat.h 2016-11-21 07:28:40.000000000 -0500
252 ++++ b/include/libssl_compat.h 2016-11-23 12:10:33.014148604 -0500
253 +@@ -25,7 +25,7 @@
254 + #include "openssl/rsa.h"
255 +
256 + /* ----------------------------------------------------------------- */
257 +-#if OPENSSL_VERSION_NUMBER < 0x10100000L
258 ++#if (OPENSSL_VERSION_NUMBER < 0x10100000L || defined LIBRESSL_VERSION_NUMBER)
259 + /* ----------------------------------------------------------------- */
260 +
261 + # include <openssl/objects.h>
262
263 diff --git a/net-misc/ntp/ntp-4.2.8_p9.ebuild b/net-misc/ntp/ntp-4.2.8_p9.ebuild
264 index f643123..36be9a2 100644
265 --- a/net-misc/ntp/ntp-4.2.8_p9.ebuild
266 +++ b/net-misc/ntp/ntp-4.2.8_p9.ebuild
267 @@ -40,6 +40,7 @@ S=${WORKDIR}/${MY_P}
268 PATCHES=(
269 "${FILESDIR}"/${PN}-4.2.8-ipc-caps.patch #533966
270 "${FILESDIR}"/${PN}-4.2.8-sntp-test-pthreads.patch #563922
271 + "${FILESDIR}"/${P}-fix-build-wo-ssl-or-libressl.patch
272 )
273
274 pkg_setup() {