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

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