- use arc4random in e2fsprogs' libuuid

- disable uuidd, it wasn't properly enabled in the port anyway (and most
situations where /dev/random would fail, the uuidd socket would also be
inaccessible)
This commit is contained in:
sthen 2014-11-10 20:38:50 +00:00
parent cc04f06b44
commit 0b2c69e94c
3 changed files with 59 additions and 5 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.34 2014/11/08 11:28:04 sthen Exp $ # $OpenBSD: Makefile,v 1.35 2014/11/10 20:38:50 sthen Exp $
COMMENT= utilities to manipulate ext2 filesystems COMMENT= utilities to manipulate ext2 filesystems
DISTNAME= e2fsprogs-1.42.12 DISTNAME= e2fsprogs-1.42.12
REVISION= 0
CATEGORIES= sysutils devel CATEGORIES= sysutils devel
SHARED_LIBS= blkid 0.0 \ SHARED_LIBS= blkid 0.0 \
com_err 21.0 \ com_err 21.0 \
@ -25,7 +26,9 @@ MODULES= devel/gettext
SEPARATE_BUILD= Yes SEPARATE_BUILD= Yes
CONFIGURE_STYLE= autoconf CONFIGURE_STYLE= autoconf
AUTOCONF_VERSION= 2.69 AUTOCONF_VERSION= 2.69
CONFIGURE_ARGS+= --enable-elf-shlibs --disable-tls CONFIGURE_ARGS+= --disable-tls \
--disable-uuidd \
--enable-elf-shlibs
CONFIGURE_ENV= CPPFLAGS="-D_EXT2_USE_C_VERSIONS_" CONFIGURE_ENV= CPPFLAGS="-D_EXT2_USE_C_VERSIONS_"
USE_GMAKE= Yes USE_GMAKE= Yes

View File

@ -0,0 +1,53 @@
$OpenBSD: patch-lib_uuid_gen_uuid_c,v 1.1 2014/11/10 20:38:50 sthen Exp $
--- lib/uuid/gen_uuid.c.orig Sat Nov 8 10:51:53 2014
+++ lib/uuid/gen_uuid.c Sat Nov 8 11:12:57 2014
@@ -167,8 +167,17 @@ static int get_random_fd(void)
return fd;
}
-
+#ifdef __OpenBSD__
/*
+ * On OpenBSD, arc4random does not require a device node, so we can
+ * use it always.
+ */
+static void get_random_bytes(void *buf, int nbytes)
+{
+ arc4random_buf(buf, nbytes);
+}
+#else
+/*
* Generate a series of random bytes. Use /dev/urandom if possible,
* and if not, use srandom/random.
*/
@@ -213,6 +222,7 @@ static void get_random_bytes(void *buf, int nbytes)
return;
}
+#endif
/*
* Get the ethernet hardware address, if we can find it...
@@ -663,7 +673,17 @@ void uuid_generate_random(uuid_t out)
}
+#ifdef __OpenBSD__
/*
+ * On OpenBSD, arc4random does not require a device node, so we can
+ * use it always.
+ */
+void uuid_generate(uuid_t out)
+{
+ uuid_generate_random(out);
+}
+#else
+/*
* This is the generic front-end to uuid_generate_random and
* uuid_generate_time. It uses uuid_generate_random only if
* /dev/urandom is available, since otherwise we won't have
@@ -676,3 +696,4 @@ void uuid_generate(uuid_t out)
else
uuid_generate_time(out);
}
+#endif

View File

@ -1,4 +1,4 @@
@comment $OpenBSD: PLIST,v 1.15 2014/11/08 11:28:04 sthen Exp $ @comment $OpenBSD: PLIST,v 1.16 2014/11/10 20:38:50 sthen Exp $
@conflict e2fs-uuid-* @conflict e2fs-uuid-*
@conflict uuid-* @conflict uuid-*
@conflict ossp-uuid-<1.6.2p2 @conflict ossp-uuid-<1.6.2p2
@ -101,7 +101,6 @@ lib/pkgconfig/uuid.pc
@man man/man8/mklost+found.8 @man man/man8/mklost+found.8
@man man/man8/resize2fs.8 @man man/man8/resize2fs.8
@man man/man8/tune2fs.8 @man man/man8/tune2fs.8
@man man/man8/uuidd.8
@bin sbin/badblocks @bin sbin/badblocks
@bin sbin/blkid @bin sbin/blkid
@bin sbin/debugfs @bin sbin/debugfs
@ -127,7 +126,6 @@ lib/pkgconfig/uuid.pc
@bin sbin/mklost+found @bin sbin/mklost+found
@bin sbin/resize2fs @bin sbin/resize2fs
@bin sbin/tune2fs @bin sbin/tune2fs
@bin sbin/uuidd
share/et/ share/et/
share/et/et_c.awk share/et/et_c.awk
share/et/et_h.awk share/et/et_h.awk