Preserve getrandom method when removing sysctl calls.

This commit is contained in:
Stuart D. Gathman 2019-08-06 18:48:52 -04:00
parent d1e2816cdf
commit 091c817631
2 changed files with 35 additions and 12 deletions

View File

@ -80,7 +80,7 @@
Name: cjdns
# major version is cjdns protocol version:
Version: 20.3
Release: 5%{?dist}
Release: 6%{?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

View File

@ -1,11 +1,34 @@
diff -up ./crypto/random/seed/SystemRandomSeed.c.sysctl ./crypto/random/seed/SystemRandomSeed.c
--- ./crypto/random/seed/SystemRandomSeed.c.sysctl 2019-08-06 12:28:23.084611733 -0400
+++ ./crypto/random/seed/SystemRandomSeed.c 2019-08-06 12:28:36.864803551 -0400
@@ -19,7 +19,6 @@
#include "crypto/random/seed/RtlGenRandomSeed.h"
#include "crypto/random/seed/BsdKernArndSysctlRandomSeed.h"
#include "crypto/random/seed/DevUrandomRandomSeed.h"
-#include "crypto/random/seed/LinuxRandomUuidSysctlRandomSeed.h"
#include "crypto/random/seed/ProcSysKernelRandomUuidRandomSeed.h"
#include "crypto/random/seed/GetEntropyRandomSeed.h"
#include "crypto/random/seed/SystemRandomSeed.h"
diff -up ./crypto/random/seed/LinuxRandomUuidSysctlRandomSeed.c.sysctl ./crypto/random/seed/LinuxRandomUuidSysctlRandomSeed.c
--- ./crypto/random/seed/LinuxRandomUuidSysctlRandomSeed.c.sysctl 2019-08-06 18:33:43.271999689 -0400
+++ ./crypto/random/seed/LinuxRandomUuidSysctlRandomSeed.c 2019-08-06 18:34:21.804537236 -0400
@@ -20,6 +20,7 @@
#include <unistd.h>
#include <sys/syscall.h>
+#ifndef SYS_getrandom
#include <sys/sysctl.h>
static int getUUID(uint64_t output[2])
@@ -35,6 +36,7 @@ static int getUUID(uint64_t output[2])
}
return 0;
}
+#endif
static int get(struct RandomSeed* randomSeed, uint64_t output[8])
{
@@ -48,11 +50,13 @@ static int get(struct RandomSeed* random
if (ret == 64 && !Bits_isZero(output, 64)) {
return 0;
}
-#endif
+ return -1;
+#else
if (getUUID(output) || getUUID(output+2) || getUUID(output+4) || getUUID(output+6)) {
return -1;
}
return 0;
+#endif
}
struct RandomSeed* LinuxRandomUuidSysctlRandomSeed_new(struct Allocator* alloc)