Blame SOURCES/0002-Add-getentropy-emulation-through-syscall.patch

b61140
From 6a92ea98544e0d03d4ce0563ad765ae21773b0fd Mon Sep 17 00:00:00 2001
b61140
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
b61140
Date: Tue, 25 Apr 2017 11:00:36 +0200
b61140
Subject: [PATCH libICE 2/2] Add getentropy emulation through syscall
b61140
b61140
RHEL/f24/f25 only patch
b61140
b61140
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
b61140
---
b61140
 src/iceauth.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
b61140
 1 file changed, 49 insertions(+)
b61140
b61140
diff --git a/src/iceauth.c b/src/iceauth.c
b61140
index 9b77eac..9af62f5 100644
b61140
--- a/src/iceauth.c
b61140
+++ b/src/iceauth.c
b61140
@@ -78,6 +78,55 @@ emulate_getrandom_buf (
b61140
     }
b61140
 }
b61140
 
b61140
+#ifndef HAVE_GETENTROPY
b61140
+#include <sys/syscall.h>
b61140
+#include <errno.h>
b61140
+
b61140
+/* code taken from libressl, license: */
b61140
+/*
b61140
+ * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org>
b61140
+ * Copyright (c) 2014 Bob Beck <beck@obtuse.com>
b61140
+ *
b61140
+ * Permission to use, copy, modify, and distribute this software for any
b61140
+ * purpose with or without fee is hereby granted, provided that the above
b61140
+ * copyright notice and this permission notice appear in all copies.
b61140
+ *
b61140
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
b61140
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
b61140
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
b61140
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
b61140
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
b61140
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
b61140
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
b61140
+ *
b61140
+ * Emulation of getentropy(2) as documented at:
b61140
+ * http://man.openbsd.org/getentropy.2
b61140
+ */
b61140
+#ifdef __NR_getrandom
b61140
+static int
b61140
+getentropy(void *buf, size_t len)
b61140
+{
b61140
+	int pre_errno = errno;
b61140
+	int ret;
b61140
+	if (len > 256)
b61140
+		return (-1);
b61140
+	do {
b61140
+		ret = syscall(__NR_getrandom, buf, len, 0);
b61140
+	} while (ret == -1 && errno == EINTR);
b61140
+
b61140
+	if (ret != len)
b61140
+		return (-1);
b61140
+	errno = pre_errno;
b61140
+
b61140
+	fprintf(stderr, "generating cookie with syscall\n");
b61140
+
b61140
+	return (0);
b61140
+}
b61140
+#define HAVE_GETENTROPY 1
b61140
+#endif /* __NR_getrandom */
b61140
+
b61140
+#endif /* HAVE_GETENTROPY */
b61140
+
b61140
 static void
b61140
 arc4random_buf (
b61140
 	char *auth,
b61140
-- 
b61140
2.9.3
b61140