Fix failed builds on F31 (#1735096)

This commit is contained in:
Petr Menšík 2019-07-31 20:50:37 +02:00
parent f5fd7025ab
commit 8503847793
3 changed files with 159 additions and 1 deletions

View File

@ -0,0 +1,100 @@
From 21c540903974d39dbe0e0eefe26143e93f52d58e Mon Sep 17 00:00:00 2001
From: Petr Mensik <pemensik@redhat.com>
Date: Wed, 31 Jul 2019 20:35:35 +0200
Subject: [PATCH] Add support for SO_TIMESTAMP
Recent kernel no longer supports SIOCGSTAMP. Make it compile without its
support. Use SO_TIMESTAMP message, since already obtained for interface
index.
---
src/dhcp.c | 54 ++++++++++++++++++++++++++++++++++++------------------
1 file changed, 36 insertions(+), 18 deletions(-)
diff --git a/src/dhcp.c b/src/dhcp.c
index f8d323b..fd8ffc3 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -61,6 +61,9 @@ static int make_fd(int port)
#endif
#if defined(HAVE_LINUX_NETWORK)
setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &oneopt, sizeof(oneopt)) == -1 ||
+# ifdef SO_TIMESTAMP
+ setsockopt(fd, SOL_SOCKET, SO_TIMESTAMP, &oneopt, sizeof(oneopt)) == -1 ||
+# endif
#else
setsockopt(fd, IPPROTO_IP, IP_RECVIF, &oneopt, sizeof(oneopt)) == -1 ||
#endif
@@ -152,13 +155,13 @@ void dhcp_packet(time_t now, int pxe_fd)
time_t recvtime = now;
#ifdef HAVE_LINUX_NETWORK
struct arpreq arp_req;
- struct timeval tv;
+ struct timeval tv = {0, };
#endif
union {
struct cmsghdr align; /* this ensures alignment */
#if defined(HAVE_LINUX_NETWORK)
- char control[CMSG_SPACE(sizeof(struct in_pktinfo))];
+ char control[CMSG_SPACE(sizeof(struct in_pktinfo)+sizeof(struct timeval))];
#elif defined(HAVE_SOLARIS_NETWORK)
char control[CMSG_SPACE(sizeof(unsigned int))];
#elif defined(HAVE_BSD_NETWORK)
@@ -178,23 +181,38 @@ void dhcp_packet(time_t now, int pxe_fd)
(sz < (ssize_t)(sizeof(*mess) - sizeof(mess->options))))
return;
- #if defined (HAVE_LINUX_NETWORK)
- if (ioctl(fd, SIOCGSTAMP, &tv) == 0)
- recvtime = tv.tv_sec;
-
+#if defined (HAVE_LINUX_NETWORK)
if (msg.msg_controllen >= sizeof(struct cmsghdr))
- for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
- if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_PKTINFO)
- {
- union {
- unsigned char *c;
- struct in_pktinfo *p;
- } p;
- p.c = CMSG_DATA(cmptr);
- iface_index = p.p->ipi_ifindex;
- if (p.p->ipi_addr.s_addr != INADDR_BROADCAST)
- unicast_dest = 1;
- }
+ {
+ for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
+ if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_PKTINFO)
+ {
+ union {
+ unsigned char *c;
+ struct in_pktinfo *p;
+ } p;
+ p.c = CMSG_DATA(cmptr);
+ iface_index = p.p->ipi_ifindex;
+ if (p.p->ipi_addr.s_addr != INADDR_BROADCAST)
+ unicast_dest = 1;
+ }
+#ifdef SO_TIMESTAMP
+ else if (cmptr->cmsg_level == SOL_SOCKET && cmptr->cmsg_type == SO_TIMESTAMP)
+ {
+ union {
+ unsigned char *c;
+ struct timeval *tv;
+ } p;
+ p.c = CMSG_DATA(cmptr);
+ recvtime = tv.tv_sec = p.tv->tv_sec;
+ }
+#endif
+ }
+
+#ifdef SIOCGSTAMP
+ if (tv.tv_sec == 0 && ioctl(fd, SIOCGSTAMP, &tv) == 0)
+ recvtime = tv.tv_sec;
+#endif
#elif defined(HAVE_BSD_NETWORK)
if (msg.msg_controllen >= sizeof(struct cmsghdr))
--
2.20.1

51
dnsmasq-2.80-nettle.patch Normal file
View File

@ -0,0 +1,51 @@
From f332e9e3c5d5671ed8435a06daa2b45272cd20cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
Date: Wed, 31 Jul 2019 19:44:39 +0200
Subject: [PATCH] Compile with nettle 3.5
Nettle library no longer provides direct access to selected variables.
Use getter functions with backward compatibility with nettle 3.3.
---
src/crypto.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/crypto.c b/src/crypto.c
index ebb871e..24bfc76 100644
--- a/src/crypto.c
+++ b/src/crypto.c
@@ -26,6 +26,14 @@
#include <nettle/nettle-meta.h>
#include <nettle/bignum.h>
+#ifndef nettle_hashes
+/* nettle 3.4 introduced getters, but ecc-curve does not have its own.
+ * nettle_hashes were first defined in the same version.
+ * nettle 3.5 no longer provides globals without getter access. */
+#define nettle_get_secp_256r1 (&nettle_secp_256r1)
+#define nettle_get_secp_384r1 (&nettle_secp_384r1)
+#endif
+
/* Implement a "hash-function" to the nettle API, which simply returns
the input data, concatenated into a single, statically maintained, buffer.
@@ -294,7 +302,7 @@ static int dnsmasq_ecdsa_verify(struct blockdata *key_data, unsigned int key_len
if (!(key_256 = whine_malloc(sizeof(struct ecc_point))))
return 0;
- nettle_ecc_point_init(key_256, &nettle_secp_256r1);
+ nettle_ecc_point_init(key_256, nettle_get_secp_256r1());
}
key = key_256;
@@ -307,7 +315,7 @@ static int dnsmasq_ecdsa_verify(struct blockdata *key_data, unsigned int key_len
if (!(key_384 = whine_malloc(sizeof(struct ecc_point))))
return 0;
- nettle_ecc_point_init(key_384, &nettle_secp_384r1);
+ nettle_ecc_point_init(key_384, nettle_get_secp_384r1());
}
key = key_384;
--
2.20.1

View File

@ -13,7 +13,7 @@
Name: dnsmasq Name: dnsmasq
Version: 2.80 Version: 2.80
Release: 7%{?extraversion:.%{extraversion}}%{?dist} Release: 8%{?extraversion:.%{extraversion}}%{?dist}
Summary: A lightweight DHCP/caching DNS server Summary: A lightweight DHCP/caching DNS server
License: GPLv2 or GPLv3 License: GPLv2 or GPLv3
@ -30,6 +30,9 @@ Patch5: dnsmasq-2.79-randomize-ports.patch
Patch6: dnsmasq-2.80-rh1674067.patch Patch6: dnsmasq-2.80-rh1674067.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=1728701 # https://bugzilla.redhat.com/show_bug.cgi?id=1728701
Patch7: dnsmasq-2.80-rh1728701.patch Patch7: dnsmasq-2.80-rh1728701.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=1735096
Patch8: dnsmasq-2.80-nettle.patch
Patch9: dnsmasq-2.80-dhcp-timestamp.patch
# This is workaround to nettle bug #1549190 # This is workaround to nettle bug #1549190
# https://bugzilla.redhat.com/show_bug.cgi?id=1549190 # https://bugzilla.redhat.com/show_bug.cgi?id=1549190
@ -162,6 +165,10 @@ install -Dpm 644 %{SOURCE2} %{buildroot}%{_sysusersdir}/%{name}.conf
%{_mandir}/man1/dhcp_* %{_mandir}/man1/dhcp_*
%changelog %changelog
* Wed Jul 31 2019 Petr Menšík <pemensik@redhat.com> - 2.80-8
- Compile with nettle 3.5
- Support missing SIOCGSTAMP ioctl
* Wed Jul 31 2019 Petr Menšík <pemensik@redhat.com> - 2.80-7 * Wed Jul 31 2019 Petr Menšík <pemensik@redhat.com> - 2.80-7
- Fix TCP listener after interface recreated (#1728701) - Fix TCP listener after interface recreated (#1728701)