Commit e5ed5fdd62aeec980dfeb596b191f7deeb364030

Guilherme Janczak 2021-12-31T08:25:08

Remove arc4random() OpenBSD support The arc4random() support for OpenBSD does not build. The intention was to include any portability code so that the library could be easily ported to such systems, but it makes little sense to build it on OpenBSD where most of the functionality will be already present, or the software would have been ported anyway. [guillem@hadrons.org: Reword commit message to add rationale. ] Closes: !15 Signed-off-by: Guillem Jover <guillem@hadrons.org>

diff --git a/COPYING b/COPYING
index c225ede..7fd11fa 100644
--- a/COPYING
+++ b/COPYING
@@ -364,7 +364,6 @@ Files:
  man/strtonum.3bsd
  src/arc4random.c
  src/arc4random_linux.h
- src/arc4random_openbsd.h
  src/arc4random_uniform.c
  src/arc4random_unix.h
  src/arc4random_win.h
diff --git a/src/Makefile.am b/src/Makefile.am
index ea0bdbe..7cf4a09 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,7 +66,6 @@ libbsd_la_SOURCES = \
 	arc4random.c \
 	arc4random.h \
 	arc4random_linux.h \
-	arc4random_openbsd.h \
 	arc4random_uniform.c \
 	arc4random_unix.h \
 	arc4random_win.h \
diff --git a/src/arc4random.h b/src/arc4random.h
index 812188b..b8675b4 100644
--- a/src/arc4random.h
+++ b/src/arc4random.h
@@ -32,9 +32,7 @@
 int
 getentropy(void *buf, size_t len);
 
-#if defined(__OpenBSD__)
-#include "arc4random_openbsd.h"
-#elif defined(__linux__)
+#if defined(__linux__)
 #include "arc4random_linux.h"
 #elif defined(_WIN32)
 #include "arc4random_win.h"
diff --git a/src/arc4random_openbsd.h b/src/arc4random_openbsd.h
deleted file mode 100644
index 9cd8b68..0000000
--- a/src/arc4random_openbsd.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*	$OpenBSD: arc4random.h,v 1.3 2014/07/20 20:51:13 bcook Exp $	*/
-
-/*
- * Copyright (c) 1996, David Mazieres <dm@uun.org>
- * Copyright (c) 2008, Damien Miller <djm@openbsd.org>
- * Copyright (c) 2013, Markus Friedl <markus@openbsd.org>
- * Copyright (c) 2014, Theo de Raadt <deraadt@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
- * Stub functions for portability.
- */
-#include <sys/mman.h>
-
-#include <signal.h>
-
-#include "thread_private.h"
-
-static inline void
-_getentropy_fail(void)
-{
-	raise(SIGKILL);
-}
-
-static inline int
-_rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
-{
-	struct {
-		struct _rs rs;
-		struct _rsx rsx;
-	} *p;
-
-	if ((p = mmap(NULL, sizeof(*p), PROT_READ|PROT_WRITE,
-	    MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
-		return (-1);
-	if (minherit(p, sizeof(*p), MAP_INHERIT_ZERO) == -1) {
-		munmap(p, sizeof(*p));
-		return (-1);
-	}
-
-	*rsp = &p->rs;
-	*rsxp = &p->rsx;
-	return (0);
-}
-
-static inline void
-_rs_forkdetect(void)
-{
-}