CBL-Mariner/SPECS-EXTENDED/openrdate/openrdate_sysctl.patch

56 строки
1.2 KiB
Diff

Author: Filip Januš
Fedora 34 and later doesn't support using ssys/sysctl.h header file and
sysctl function, openrdate uses sysctl for acces to random numbers.
This patch change calling sysctl to getentropy.
diff -ur openrdate-1.2/src/arc4random.c new/src/arc4random.c
--- openrdate-1.2/src/arc4random.c 2008-11-22 00:22:49.000000000 +0100
+++ new/src/arc4random.c 2020-08-13 11:51:43.109147967 +0200
@@ -44,7 +44,7 @@
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
-#include <sys/sysctl.h>
+#include <linux/sysctl.h>
#if defined __NO_SYSCTL__
#include <err.h>
@@ -71,6 +71,7 @@
#define inline
#endif /* !__GNUC__ */
+
struct arc4_stream {
u_int8_t i;
u_int8_t j;
@@ -115,11 +116,7 @@
static void
arc4_stir(void)
{
-#ifndef __NO_SYSCTL__
- int i, mib[2];
-#else /* !__NO_SYSCTL__ */
- int i;
-#endif /* !__NO_SYSCTL__ */
+ int i;
size_t len;
u_char rnd[128];
@@ -128,15 +125,11 @@
rs_initialized = 1;
}
-#ifndef __NO_SYSCTL__
- mib[0] = CTL_KERN;
- mib[1] = KERN_ARND;
-#endif /* __NO_SYSCTL__ */
len = sizeof(rnd);
#ifndef __NO_SYSCTL__
- sysctl(mib, 2, rnd, &len, NULL, 0);
+ getentropy(rnd, len);
#else /* __NO_SYSCTL__ */
int rndfd = open(RND_DEV, O_RDONLY);