commit:     13fb235948d859e2c248f68bc92644412a7f8a1b
Author:     Pacho Ramos <pacho <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 20 11:57:59 2018 +0000
Commit:     Pacho Ramos <pacho <AT> gentoo <DOT> org>
CommitDate: Sat Oct 20 12:16:49 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=13fb2359

dev-util/trinity: Apply Fedora/Debian fixes

Closes: https://bugs.gentoo.org/642936
Closes: https://bugs.gentoo.org/648962
Signed-off-by: Pacho Ramos <pacho <AT> gentoo.org>
Package-Manager: Portage-2.3.51, Repoman-2.3.11

 dev-util/trinity/files/trinity-autofs.patch        | 53 +++++++++++++++
 dev-util/trinity/files/trinity-irda.patch          | 47 +++++++++++++
 dev-util/trinity/files/trinity-memfd.patch         | 79 ++++++++++++++++++++++
 dev-util/trinity/files/trinity-net-protocols.patch | 11 +++
 dev-util/trinity/trinity-1.8.ebuild                | 15 +++-
 5 files changed, 202 insertions(+), 3 deletions(-)

diff --git a/dev-util/trinity/files/trinity-autofs.patch 
b/dev-util/trinity/files/trinity-autofs.patch
new file mode 100644
index 00000000000..b8a6c9fdbd5
--- /dev/null
+++ b/dev-util/trinity/files/trinity-autofs.patch
@@ -0,0 +1,53 @@
+--- a/configure.orig   2017-11-03 09:14:07.000000000 -0600
++++ b/configure        2017-11-18 14:25:52.095495407 -0700
+@@ -47,6 +47,29 @@ check_header()
+ echo "[*] Checking system headers."
+ 
+ 
#############################################################################################
++# Does auto_fs4 define AUTOFS_IOC_EXPIRE_(IN)DIRECT?
++echo -n "[*] Checking autofs headers ... "
++rm -f "$TMP" || exit 1
++
++cat >"$TMP.c" << EOF
++#include <linux/auto_fs4.h>
++
++int main()
++{
++      return AUTOFS_IOC_EXPIRE_INDIRECT + AUTOFS_IOC_EXPIRE_DIRECT;
++}
++EOF
++
++${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
++if [ ! -x "$TMP" ]; then
++      echo $RED "[NO]" $COL_RESET
++      MISSING_DEFS=1
++else
++      echo $GREEN "[YES]" $COL_RESET
++      echo "#define USE_AUTOFS_EXPIRE 1" >> $CONFIGH
++fi
++
++#############################################################################################
+ # Are ipv6 headers usable ?
+ [ -z "$IPV6" ] && IPV6=yes
+ if [[ "$IPV6" == "yes" ]]; then
+@@ -290,6 +313,7 @@ fi
+ 
+ 
#############################################################################################
+ 
++check_header linux/auto_fs4.h USE_AUTOFS_EXPIRE
+ check_header linux/caif/caif_socket.h USE_CAIF
+ check_header linux/fsmap.h USE_FSMAP
+ check_header linux/if_alg.h USE_IF_ALG
+--- a/ioctls/autofs.c.orig     2017-11-03 09:14:07.000000000 -0600
++++ b/ioctls/autofs.c  2017-11-18 14:21:14.487774564 -0700
+@@ -238,8 +238,10 @@ static const struct ioctl autofs_ioctls[
+       IOCTL(AUTOFS_IOC_SETTIMEOUT),
+       IOCTL(AUTOFS_IOC_EXPIRE),
+       IOCTL(AUTOFS_IOC_EXPIRE_MULTI),
++#ifdef PRE_4_14_KERNEL
+       IOCTL(AUTOFS_IOC_EXPIRE_INDIRECT),
+       IOCTL(AUTOFS_IOC_EXPIRE_DIRECT),
++#endif
+       IOCTL(AUTOFS_IOC_PROTOSUBVER),
+       IOCTL(AUTOFS_IOC_ASKUMOUNT),
+ 

diff --git a/dev-util/trinity/files/trinity-irda.patch 
b/dev-util/trinity/files/trinity-irda.patch
new file mode 100644
index 00000000000..eb298fd99d8
--- /dev/null
+++ b/dev-util/trinity/files/trinity-irda.patch
@@ -0,0 +1,47 @@
+--- a/configure.orig   2017-11-18 14:25:52.095495407 -0700
++++ b/configure        2018-07-21 11:44:59.235072132 -0600
+@@ -317,6 +317,7 @@ check_header linux/auto_fs4.h USE_AUTOFS
+ check_header linux/caif/caif_socket.h USE_CAIF
+ check_header linux/fsmap.h USE_FSMAP
+ check_header linux/if_alg.h USE_IF_ALG
++check_header linux/irda.h USE_IRDA
+ check_header linux/rds.h USE_RDS
+ check_header linux/vfio.h USE_VFIO
+ check_header drm/drm.h USE_DRM
+--- a/net/protocols.c.orig     2017-11-03 09:14:07.000000000 -0600
++++ b/net/protocols.c  2018-07-21 11:48:09.065940013 -0600
+@@ -26,7 +26,9 @@ const struct protoptr net_protocols[TRIN
+ #ifdef USE_RDS
+       [PF_RDS] = { .proto = &proto_rds },
+ #endif
++#ifdef USE_IRDA
+       [PF_IRDA] = { .proto = &proto_irda },
++#endif
+       [PF_LLC] = { .proto = &proto_llc },
+       [PF_CAN] = { .proto = &proto_can },
+       [PF_TIPC] = { .proto = &proto_tipc },
+--- a/net/proto-irda.c.orig    2017-11-03 09:14:07.000000000 -0600
++++ b/net/proto-irda.c 2018-07-21 11:45:34.330047712 -0600
+@@ -4,13 +4,15 @@
+ #include <sys/un.h>
+ /* old irda.h does not include something which defines sa_family_t */
+ #include <netinet/in.h>
+-#include <linux/irda.h>
+ #include <stdlib.h>
+ #include "net.h"
+ #include "random.h"
+ #include "utils.h"    // RAND_ARRAY
+ #include "compat.h"
+ 
++#ifdef USE_IRDA
++#include <linux/irda.h>
++
+ static void irda_gen_sockaddr(struct sockaddr **addr, socklen_t *addrlen)
+ {
+       struct sockaddr_irda *irda;
+@@ -53,3 +55,5 @@ const struct netproto proto_irda = {
+       .valid_triplets = irda_triplets,
+       .nr_triplets = ARRAY_SIZE(irda_triplets),
+ };
++
++#endif

diff --git a/dev-util/trinity/files/trinity-memfd.patch 
b/dev-util/trinity/files/trinity-memfd.patch
new file mode 100644
index 00000000000..d333aac2941
--- /dev/null
+++ b/dev-util/trinity/files/trinity-memfd.patch
@@ -0,0 +1,79 @@
+commit c93bb184ce996c4d77eefbae2ab0bf74f396ec45
+Author: Baruch Siach <[email protected]>
+Date:   Tue Mar 13 06:53:06 2018 +0200
+
+    memfd: fix build with glibc 2.27
+    
+    glibc 2.27 added a wrapper for memfd_create(). This causes build
+    failure:
+    
+    fds/memfd.c:19:12: error: static declaration of 'memfd_create' follows 
non-static declaration
+     static int memfd_create(__unused__ const char *uname, __unused__ unsigned 
int flag)
+                ^~~~~~~~~~~~
+    
+    Don't use the local definition when the libc provides one.
+    
+    Signed-off-by: Baruch Siach <[email protected]>
+
+diff --git a/configure b/configure
+index dc0a87d8c1ad..c0166af33048 100755
+--- a/configure
++++ b/configure
+@@ -289,6 +289,29 @@ else
+ fi
+ 
+ 
#############################################################################################
++# Does glibc provide memfd_create() syscall wrapper
++#
++echo -n "[*] Checking if glibc provides memfd_create.. "
++rm -f "$TMP" || exit 1
++
++cat >"$TMP.c" << EOF
++#include <sys/mman.h>
++
++void main()
++{
++      memfd_create();
++}
++EOF
++
++${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
++if [ ! -x "$TMP" ]; then
++      echo $RED "[NO]" $COL_RESET
++else
++      echo $GREEN "[YES]" $COL_RESET
++      echo "#define USE_MEMFD_CREATE 1" >> $CONFIGH
++fi
++
++#############################################################################################
+ 
+ check_header linux/caif/caif_socket.h USE_CAIF
+ check_header linux/fsmap.h USE_FSMAP
+diff --git a/fds/memfd.c b/fds/memfd.c
+index 210678e4571c..aaaac2f78f54 100644
+--- a/fds/memfd.c
++++ b/fds/memfd.c
+@@ -5,6 +5,7 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #include <unistd.h>
++#include <sys/mman.h>
+ 
+ #include "fd.h"
+ #include "memfd.h"
+@@ -16,6 +17,7 @@
+ #include "trinity.h"
+ #include "udp.h"
+ 
++#ifndef USE_MEMFD_CREATE
+ static int memfd_create(__unused__ const char *uname, __unused__ unsigned int 
flag)
+ {
+ #ifdef SYS_memfd_create
+@@ -24,6 +26,7 @@ static int memfd_create(__unused__ const char *uname, 
__unused__ unsigned int fl
+       return -ENOSYS;
+ #endif
+ }
++#endif
+ 
+ static void memfd_destructor(struct object *obj)
+ {

diff --git a/dev-util/trinity/files/trinity-net-protocols.patch 
b/dev-util/trinity/files/trinity-net-protocols.patch
new file mode 100644
index 00000000000..d2583b56ebd
--- /dev/null
+++ b/dev-util/trinity/files/trinity-net-protocols.patch
@@ -0,0 +1,11 @@
+--- a/syscalls/setsockopt.c.orig       2017-11-03 09:14:07.000000000 -0600
++++ b/syscalls/setsockopt.c    2017-11-18 13:44:19.283946230 -0700
+@@ -90,7 +90,7 @@ static void do_random_sso(struct sockopt
+ retry:
+       switch (rnd() % 4) {
+       case 0: /* do a random protocol, even if it doesn't match this socket. 
*/
+-              i = rnd() % PF_MAX;
++              i = rnd() % TRINITY_PF_MAX;
+               proto = net_protocols[i].proto;
+               if (proto != NULL) {
+                       if (proto->setsockopt != NULL) {

diff --git a/dev-util/trinity/trinity-1.8.ebuild 
b/dev-util/trinity/trinity-1.8.ebuild
index 1072988366e..2cb2ae2a86e 100644
--- a/dev-util/trinity/trinity-1.8.ebuild
+++ b/dev-util/trinity/trinity-1.8.ebuild
@@ -1,7 +1,7 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2018 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=6
+EAPI=7
 inherit toolchain-funcs
 
 DESCRIPTION="A Linux system call fuzz tester"
@@ -14,9 +14,18 @@ KEYWORDS="~amd64 ~x86"
 IUSE="examples"
 
 # We need newer headers to avoid compilation failures in the BPF stuff.
-DEPEND="app-arch/xz-utils
+DEPEND="
        >=sys-kernel/linux-headers-4.8
 "
+RDEPEND=""
+
+PATCHES=(
+       # Fixes from Fedora and Debian
+       "${FILESDIR}"/${PN}-autofs.patch
+       "${FILESDIR}"/${PN}-irda.patch
+       "${FILESDIR}"/${PN}-memfd.patch
+       "${FILESDIR}"/${PN}-net-protocols.patch
+)
 
 src_configure() {
        tc-export CC

Reply via email to