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

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