From 325b917b083e41093758a704ed73b429558f2de3 Mon Sep 17 00:00:00 2001 From: Stuart D. Gathman Date: Jan 14 2017 21:56:22 +0000 Subject: Try to detect whether glibc has getentropy and use it. --- diff --git a/cjdns.entropy.patch b/cjdns.entropy.patch new file mode 100644 index 0000000..185e1a5 --- /dev/null +++ b/cjdns.entropy.patch @@ -0,0 +1,15 @@ +diff -up ./crypto/random/seed/GetEntropyRandomSeed.c.entropy ./crypto/random/seed/GetEntropyRandomSeed.c +--- ./crypto/random/seed/GetEntropyRandomSeed.c.entropy 2016-10-11 17:39:44.000000000 -0400 ++++ ./crypto/random/seed/GetEntropyRandomSeed.c 2017-01-14 16:54:53.211554142 -0500 +@@ -21,7 +21,10 @@ + #include + #include + +-#ifndef __OPENBSD__ ++#define GetEntropyRandomSeed_GLIBC_HAS_IT \ ++ (defined(__GNU_LIBRARY__) && defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 25)) ++ ++#if !defined(__OPENBSD__) && !GetEntropyRandomSeed_GLIBC_HAS_IT + static int getentropy(void *buf, size_t buflen) + { + int ret; diff --git a/cjdns.errors.patch b/cjdns.errors.patch deleted file mode 100644 index 0ae12c3..0000000 --- a/cjdns.errors.patch +++ /dev/null @@ -1,30 +0,0 @@ -diff -up ./crypto/random/seed/GetEntropyRandomSeed.c.errors ./crypto/random/seed/GetEntropyRandomSeed.c ---- ./crypto/random/seed/GetEntropyRandomSeed.c.errors 2017-01-14 13:42:22.043640582 -0500 -+++ ./crypto/random/seed/GetEntropyRandomSeed.c 2017-01-14 13:43:01.482108873 -0500 -@@ -22,7 +22,8 @@ - #include - - #ifndef __OPENBSD__ --static int getentropy(void *buf, size_t buflen) -+/* NOTE: getentropy() is already defined in unistd.h */ -+static int get_entropy(void *buf, size_t buflen) - { - int ret; - -@@ -48,7 +49,7 @@ static int getentropy(void *buf, size_t - - static int get(struct RandomSeed* randomSeed, uint64_t output[8]) - { -- if (getentropy(output, 64) < 0) { -+ if (get_entropy(output, 64) < 0) { - return -1; - } else { - return 0; -@@ -59,6 +60,6 @@ struct RandomSeed* GetEntropyRandomSeed_ - { - return Allocator_clone(alloc, (&(struct RandomSeed) { - .get = get, -- .name = "getentropy(2)" -+ .name = "get_entropy(2)" - })); - } diff --git a/cjdns.spec b/cjdns.spec index 3a2482d..0e4a045 100644 --- a/cjdns.spec +++ b/cjdns.spec @@ -92,8 +92,8 @@ Patch11: cjdns.sodium.patch Patch12: cjdns.sign.patch # Recognize ppc64, ppc64le, and s390x arches Patch13: cjdns.ppc64.patch -# Fix C coding errors -Patch14: cjdns.errors.patch +# getentropy(2) added to glibc in Fedora 26 +Patch14: cjdns.entropy.patch BuildRequires: nodejs, nodejs-ronn, python2 @@ -208,7 +208,7 @@ fi %patch9 -b .man %patch10 -b .tools %patch13 -b .ppc64 -%patch14 -b .errors +%patch14 -b .entropy cp %{SOURCE1} README_Fedora.md