Patches for gcc-11. Drop el6 support

This commit is contained in:
Stuart D. Gathman 2020-12-16 12:48:02 -05:00
parent b307cbafe4
commit 657e7a189e
3 changed files with 92 additions and 169 deletions

View File

@ -1,41 +0,0 @@
diff -up ./contrib/selinux/cjdns.te.el6 ./contrib/selinux/cjdns.te
--- ./contrib/selinux/cjdns.te.el6 2016-02-25 20:26:20.635992411 -0500
+++ ./contrib/selinux/cjdns.te 2016-02-25 20:28:05.804135692 -0500
@@ -5,9 +5,7 @@ require {
type tun_tap_device_t;
type node_t;
type port_t;
- type unreserved_port_t;
type tmp_t;
- type passwd_file_t;
type net_conf_t;
}
@@ -20,15 +18,12 @@ init_daemon_domain(cjdns_t,cjdns_exec_t)
allow cjdns_t cjdns_exec_t:file { execute_no_trans execmod };
allow cjdns_t self:capability { net_admin net_raw setuid setgid sys_chroot };
allow cjdns_t self:process { signal getcap setrlimit setcap };
-# translate username to uid
-allow cjdns_t passwd_file_t:file { read getattr open };
# translate host names
allow cjdns_t net_conf_t:file { read getattr open };
# allow network access
allow cjdns_t node_t:udp_socket node_bind;
allow cjdns_t port_t:udp_socket name_bind;
-allow cjdns_t unreserved_port_t:udp_socket name_bind;
allow cjdns_t self:netlink_route_socket { bind create getattr nlmsg_read read write nlmsg_write };
allow cjdns_t self:packet_socket { bind create ioctl read write };
allow cjdns_t self:tun_socket create;
diff -up ./node_build/FindPython2.js.el6 ./node_build/FindPython2.js
--- ./node_build/FindPython2.js.el6 2016-01-27 03:07:49.000000000 -0500
+++ ./node_build/FindPython2.js 2016-02-25 20:26:20.636992421 -0500
@@ -21,7 +21,7 @@ var PYTHONS = ["python", "python2", "pyt
var SCRIPT = [
'import sys;',
'print(sys.version_info);',
- 'exit(sys.version_info[0] != 2 or sys.version_info[1] < 7);'
+ 'exit(sys.version_info[0] != 2 or sys.version_info[1] < 6);'
].join('\n');
var find = module.exports.find = function (tempFile, callback) {

View File

@ -56,17 +56,8 @@
%global nacl_lib %{_libdir}/libnacl.so
%endif
%if 0%{?rhel} >= 5 && 0%{?rhel} < 7
%global use_systemd 0
%else
%global use_systemd 1
%endif
%if 0%{?rhel} == 6
%global use_upstart 1
%else
%global use_upstart 0
%endif
%if 0 && 0%{?fedora} > 30
%global use_marked 1
@ -85,7 +76,7 @@
Name: cjdns
# major version is cjdns protocol version:
Version: 21
Release: 3%{?dist}
Release: 4%{?dist}
Summary: The privacy-friendly network without borders
# cjdns is all GPLv3 except libuv which is MIT and BSD and ISC
# cnacl is unused except when use_embedded is true
@ -102,10 +93,8 @@ Source3: https://github.com/kapouer/marked-man/archive/0.7.0.tar.gz#/marked-man-
Source4: python-cjdns-0.2.tar.gz
# Add targeted selinux policy
Patch0: cjdns.selinux.patch
# Allow python2.6 for build. Python is not used during the build
# process. The python tools allegedly depend on python2.7, but that can
# be in Requires for the subpackage.
Patch1: cjdns.el6.patch
# Patch warnings detected by gcc-11
Patch2: cjdns.warnings.patch
# Fix RLIMIT_NPROC - setuid() bug. In its low priv process, cjdroute calls
#
# setrlimit(RLIMIT_NPROC, &(struct rlimit){ 0, 0 })
@ -263,7 +252,7 @@ Requires: python3-%{name} = %{version}-%{release}
Requires: python3-networkx
%else
Requires: python2-%{name} = %{version}-%{release}
%if 0%{?rhel} == 6 || 0%{?rhel} == 7
%if 0%{?rhel} == 7
Requires: python-networkx
Requires: python2-matplotlib
%else
@ -278,9 +267,6 @@ Python peer graph tools for cjdns.
%prep
%setup -qn cjdns-%{name}-v%{version}
%patch0 -b .selinux
%if 0%{?rhel} == 6
%patch1 -b .el6
%endif
%patch4 -b .genconf
%patch5 -b .sbin
@ -338,6 +324,7 @@ sed -i -e '/optimizeLevel:/ s/-O0/-O3/' node_build/make.js
#patch20 -p1 -b .sysctl
#patch22 -b .gcc10
%patch23 -b .32bit
%patch2 -b .warn
cp %{SOURCE1} README_Fedora.md
@ -354,10 +341,8 @@ find tools -type f | xargs grep -l '^#!\/usr\/bin\/env ' |
xargs sed -e '1 s,^#!/usr/bin/env ,#!/usr/bin/,' -i
# Fix deprecated Buffer ctor except on EL6
%if 0%{?rhel} != 6
sed -e '1,$ s/new Buffer/Buffer.from/' -i \
tools/lib/publicToIp6.js tools/lib/cjdnsadmin/cjdnsadmin.js
%endif
# Remove unpackaged code with undeclared licenses
%if !%{with_admin}
@ -442,9 +427,6 @@ NO_TEST=1 CJDNS_RELEASE_VERSION="%{name}-%{version}-%{release}" ./do
build_linux/test_testcjdroute_c all >test.out
%install
%if 0%{?rhel} == 5
rm -rf %{buildroot} # needed on RHEL5
%endif
# the main switch process
mkdir -p %{buildroot}%{_sbindir}
@ -745,6 +727,9 @@ fi
%{_bindir}/graphStats
%changelog
* Wed Dec 16 2020 Stuart Gathman <stuart@gathman.org> - 21-4
- Support gcc-11, drop el6 support.
* Fri Nov 27 2020 Stuart Gathman <stuart@gathman.org> - 21-3
- New python-cjdns release

View File

@ -1,109 +1,88 @@
diff -up ./crypto/CryptoAuth.c.warnings ./crypto/CryptoAuth.c
--- ./crypto/CryptoAuth.c.warnings 2018-01-30 19:04:59.000000000 -0500
+++ ./crypto/CryptoAuth.c 2018-03-14 14:38:20.689851389 -0400
@@ -85,6 +85,8 @@ static inline void getSharedSecret(uint8
uint8_t passwordHash[32],
struct Log* logger)
diff -up ./tunnel/IpTunnel.c.warn ./tunnel/IpTunnel.c
--- ./tunnel/IpTunnel.c.warn 2020-09-18 14:24:44.000000000 -0400
+++ ./tunnel/IpTunnel.c 2020-12-16 12:41:53.284105519 -0500
@@ -622,7 +622,7 @@ static Iface_DEFUN incomingControlMessag
Endian_bigEndianToHost32(x); \
}))
-static bool prefixMatches6(uint8_t* addressA, uint8_t* refAddr, uint8_t prefixLen)
+static bool prefixMatches6(const uint8_t* addressA, const uint8_t* refAddr, uint8_t prefixLen)
{
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
if (passwordHash == NULL) {
crypto_box_curve25519xsalsa20poly1305_beforenm(outputSecret, herPublicKey, myPrivateKey);
} else {
@@ -100,6 +102,7 @@ static inline void getSharedSecret(uint8
Bits_memcpy(buff.components.passwd, passwordHash, 32);
crypto_hash_sha256(outputSecret, buff.bytes, 64);
if (!prefixLen) {
Assert_true(Bits_isZero(refAddr, 16));
@@ -661,7 +661,7 @@ static bool isValidAddress4(uint8_t sour
return prefixMatches4(compareAddr, conn->connectionIp4, conn->connectionIp4Alloc);
}
-static bool isValidAddress6(uint8_t sourceAndDestIp6[32],
+static bool isValidAddress6(const uint8_t* sourceAndDestIp6,
bool isFromTun,
struct IpTunnel_Connection* conn)
{
@@ -669,7 +669,7 @@ static bool isValidAddress6(uint8_t sour
|| AddressCalc_validAddress(&sourceAndDestIp6[16])) {
return false;
}
+#pragma GCC diagnostic pop
if (Defined(Log_KEYS)) {
uint8_t myPublicKeyHex[65];
printHexPubKey(myPublicKeyHex, myPrivateKey);
diff -up ./dht/CJDHTConstants.h.warnings ./dht/CJDHTConstants.h
--- ./dht/CJDHTConstants.h.warnings 2018-01-30 19:04:59.000000000 -0500
+++ ./dht/CJDHTConstants.h 2018-03-14 14:38:20.689851389 -0400
@@ -17,7 +17,9 @@
#include "benc/String.h"
#include "util/version/Version.h"
-
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wunused-const-variable"
// Signifying that this message is a query and defining the query type.
static String* const CJDHTConstants_QUERY = String_CONST_SO("q");
@@ -61,5 +63,5 @@ static String* const CJDHTConstants_ENC_
// Encoding scheme and index for the closest peer along the path.
static String* const CJDHTConstants_PEER_ENC_SCHEME = String_CONST_SO("pes");
static String* const CJDHTConstants_PEER_ENC_INDEX = String_CONST_SO("pei");
-
+#pragma GCC diagnostic pop
#endif
diff -up ./node_build/dependencies/libuv/test/test-getsockname.c.warnings ./node_build/dependencies/libuv/test/test-getsockname.c
--- ./node_build/dependencies/libuv/test/test-getsockname.c.warnings 2018-01-30 19:04:59.000000000 -0500
+++ ./node_build/dependencies/libuv/test/test-getsockname.c 2018-03-14 14:38:20.690851402 -0400
@@ -18,7 +18,7 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
- uint8_t* compareAddr = (isFromTun)
+ const uint8_t* compareAddr = (isFromTun)
? ((conn->isOutgoing) ? sourceAndDestIp6 : &sourceAndDestIp6[16])
: ((conn->isOutgoing) ? &sourceAndDestIp6[16] : sourceAndDestIp6);
return prefixMatches6(compareAddr, conn->connectionIp6, conn->connectionIp6Alloc);
diff -up ./util/AddrTools.c.warn ./util/AddrTools.c
--- ./util/AddrTools.c.warn 2020-12-15 22:01:15.611690648 -0500
+++ ./util/AddrTools.c 2020-12-16 12:44:11.013175227 -0500
@@ -187,7 +187,7 @@ void AddrTools_printShortIp(uint8_t outp
* "fc4f:630d:e499:8f5b:c49f:6e6b:01ae:3120".
* @return 0 if successful, -1 if the hexAddr is malformed.
*/
-
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#include "uv.h"
#include "task.h"
diff -up ./util/Gcc.h.warnings ./util/Gcc.h
--- ./util/Gcc.h.warnings 2018-01-30 19:04:59.000000000 -0500
+++ ./util/Gcc.h 2018-03-14 14:38:20.690851402 -0400
@@ -52,6 +52,11 @@
#define Gcc_USE_RET \
__attribute__ ((warn_unused_result))
+#if __GNUC__ >= 7
+#define Gcc_FALLTHROUGH \
+ __attribute__ ((fallthrough))
+#endif
+
#elif defined(__clang__)
#define Gcc_NORETURN \
@@ -62,6 +67,9 @@
#endif
+#ifndef Gcc_FALLTHROUGH
+ #define Gcc_FALLTHROUGH (void)0
+#endif
#ifndef Gcc_PRINTF
#define Gcc_PRINTF( format_idx, arg_idx )
#endif
diff -up ./util/platform/netdev/NetPlatform_linux.c.warnings ./util/platform/netdev/NetPlatform_linux.c
--- ./util/platform/netdev/NetPlatform_linux.c.warnings 2018-01-30 19:04:59.000000000 -0500
+++ ./util/platform/netdev/NetPlatform_linux.c 2018-03-14 14:42:14.668850488 -0400
@@ -36,6 +36,7 @@
#include <linux/route.h>
#if ! defined(android)
#include <linux/ipv6_route.h>
+ #include <linux/ipv6.h>
#endif
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
@@ -167,7 +168,7 @@ void NetPlatform_addAddress(const char*
Except_throw(eh, "ioctl(SIOCSIFADDR) failed: [%s]", strerror(err));
}
- uint32_t x = (uint32_t)~0 << (32 - prefixLen);
+ uint32_t x = ~0U << (32 - prefixLen);
x = Endian_hostToBigEndian32(x);
memcpy(&sin.sin_addr, &x, 4);
memcpy(&ifRequest.ifr_addr, &sin, sizeof(struct sockaddr_in));
diff -up ./util/platform/Sockaddr.c.warnings ./util/platform/Sockaddr.c
--- ./util/platform/Sockaddr.c.warnings 2018-01-30 19:04:59.000000000 -0500
+++ ./util/platform/Sockaddr.c 2018-03-14 14:38:20.691851415 -0400
@@ -12,6 +12,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
-int AddrTools_parseIp(uint8_t out[16], const uint8_t hexAddr[40])
+int AddrTools_parseIp(uint8_t out[16], const uint8_t* hexAddr)
{
struct Sockaddr_storage ss;
if (Sockaddr_parse((const char*) hexAddr, &ss)
diff -up ./util/AddrTools.h.warn ./util/AddrTools.h
--- ./util/AddrTools.h.warn 2020-12-15 22:03:56.036099586 -0500
+++ ./util/AddrTools.h 2020-12-16 12:44:18.772291827 -0500
@@ -44,7 +44,7 @@ void AddrTools_printShortIp(uint8_t outp
* "fc4f:630d:e499:8f5b:c49f:6e6b:01ae:3120".
* @return 0 if successful, -1 if the hexAddr is malformed.
*/
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#include "util/events/libuv/UvWrapper.h"
#include "benc/String.h"
#include "memory/Allocator.h"
-int AddrTools_parseIp(uint8_t out[16], const uint8_t hexAddr[40]);
+int AddrTools_parseIp(uint8_t out[16], const uint8_t* hexAddr);
/**
* Parse out an ethernet MAC address.
diff -up ./util/Bits.h.warn ./util/Bits.h
--- ./util/Bits.h.warn 2020-12-15 21:52:43.800005230 -0500
+++ ./util/Bits.h 2020-12-15 21:52:57.496210893 -0500
@@ -98,7 +98,7 @@ static inline uint64_t Bits_bitReverse64
* @length the nuber of bytes to check for zero'd-ness.
* @return true if all bytes checked are zero.
*/
-static inline int Bits_isZero(void* buffer, size_t length)
+static inline int Bits_isZero(const void* buffer, size_t length)
{
uint8_t* buff = (uint8_t*) buffer;
for (size_t i = 0; i < length; i++) {
diff -up ./util/platform/Sockaddr.c.warn ./util/platform/Sockaddr.c
--- ./util/platform/Sockaddr.c.warn 2020-12-15 21:37:34.152353751 -0500
+++ ./util/platform/Sockaddr.c 2020-12-16 12:43:27.035514362 -0500
@@ -306,8 +306,9 @@ struct Sockaddr* Sockaddr_fromBytes(cons
struct Sockaddr_pvt* out = Allocator_calloc(alloc, addrLen + Sockaddr_OVERHEAD, 1);
Bits_memcpy(&out->ss, &ss, addrLen);
- out->pub.addrLen = addrLen + Sockaddr_OVERHEAD;
- return &out->pub;
+ struct Sockaddr* pub = &out->pub;
+ pub->addrLen = addrLen + Sockaddr_OVERHEAD;
+ return pub;
}
void Sockaddr_normalizeNative(void* nativeSockaddr)
@@ -344,4 +345,4 @@ void Sockaddr_addrFromHandle(struct Sock
addr->type = Sockaddr_HANDLE;
addr->addrLen = sizeof(struct Sockaddr);
Bits_memcpy(&((uint8_t*)addr)[4], &handle, 4);
-}
\ No newline at end of file
+}