Try to detect whether glibc has getentropy and use it.
This commit is contained in:
parent
27c8f5913d
commit
325b917b08
15
cjdns.entropy.patch
Normal file
15
cjdns.entropy.patch
Normal file
@ -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 <errno.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
-#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;
|
@ -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 <sys/syscall.h>
|
||||
|
||||
#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)"
|
||||
}));
|
||||
}
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user