Replace call to deprecated sysctl
This commit is contained in:
parent
f16ba589c3
commit
9c6fb6c6d9
@ -135,6 +135,8 @@ Patch16: cjdns.python3.patch
|
||||
# patch build to use system libuv
|
||||
Patch18: cjdns.libuv.patch
|
||||
Patch19: cjdns.fuzz.patch
|
||||
# patch to use /proc/sys/kernel/random/uuid instead of sysctl
|
||||
Patch20: cjdns.sysctl.patch
|
||||
|
||||
BuildRequires: nodejs, nodejs-ronn, python2
|
||||
|
||||
@ -240,7 +242,7 @@ cp %{SOURCE2} contrib/systemd
|
||||
|
||||
%if 0%{use_embedded}
|
||||
# disable CPU opt
|
||||
%else !use_embedded
|
||||
%else
|
||||
# use system nacl library if provided.
|
||||
if test -x %{nacl_lib}; then
|
||||
%if 0%{use_libsodium}
|
||||
@ -278,6 +280,7 @@ cp node_build/dependencies/libuv/include/tree.h dependencies/uv_tree.h
|
||||
rm -rf node_build/dependencies/libuv
|
||||
%endif
|
||||
%patch19 -p1 -b .fuzz
|
||||
%patch20 -p1 -b .sysctl
|
||||
|
||||
cp %{SOURCE1} README_Fedora.md
|
||||
|
||||
@ -355,7 +358,6 @@ NO_TEST=1 CJDNS_RELEASE_VERSION="%{name}-%{version}-%{release}" ./do
|
||||
# https://github.com/cjdelisle/cjdns/commits/master/node_build/dependencies/libuv
|
||||
|
||||
%check
|
||||
# test suite is executed in %%build
|
||||
build_linux/test_testcjdroute_c all >test.out
|
||||
|
||||
%install
|
||||
|
49
cjdns.sysctl.patch
Normal file
49
cjdns.sysctl.patch
Normal file
@ -0,0 +1,49 @@
|
||||
diff -up ./crypto/random/seed/LinuxRandomUuidSysctlRandomSeed.c.sysctl ./crypto/random/seed/LinuxRandomUuidSysctlRandomSeed.c
|
||||
--- ./crypto/random/seed/LinuxRandomUuidSysctlRandomSeed.c.sysctl 2019-05-02 04:02:32.000000000 -0400
|
||||
+++ ./crypto/random/seed/LinuxRandomUuidSysctlRandomSeed.c 2019-07-31 15:43:45.626839153 -0400
|
||||
@@ -19,20 +19,39 @@
|
||||
#include "util/Hex.h"
|
||||
|
||||
#include <unistd.h>
|
||||
-#include <sys/syscall.h>
|
||||
-#include <sys/sysctl.h>
|
||||
+#include <fcntl.h>
|
||||
|
||||
static int getUUID(uint64_t output[2])
|
||||
{
|
||||
- int mib[] = { CTL_KERN, KERN_RANDOM, RANDOM_UUID };
|
||||
- size_t sixteen = 16;
|
||||
-
|
||||
+ uint8_t uuid[40];
|
||||
Bits_memset(output, 0, 16);
|
||||
- if (sysctl(mib, 3, output, &sixteen, NULL, 0)
|
||||
+ int fd = open("/proc/sys/kernel/random/uuid",O_RDONLY);
|
||||
+ if (fd < 0)
|
||||
+ {
|
||||
+ return -1;
|
||||
+ }
|
||||
+ int rc = read(fd,uuid,36);
|
||||
+ close(fd);
|
||||
+ if (rc < 32)
|
||||
+ {
|
||||
+ return -1;
|
||||
+ }
|
||||
+ uuid[rc] = 0;
|
||||
+ /* strip '-' */
|
||||
+ int i,j = 0;
|
||||
+ for (i = 0; uuid[i] != 0; ++i) {
|
||||
+ if (uuid[i] != '-')
|
||||
+ {
|
||||
+ uuid[j++] = uuid[i];
|
||||
+ }
|
||||
+ }
|
||||
+ uuid[j] = 0;
|
||||
+ if (Hex_decode((uint8_t*) output, 16, uuid, j) != 16
|
||||
|| Bits_isZero(output, 16))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user