libuuid from e2fsprogs is used by a couple of dozen ports to generate
uuids.

(In theory they could be converted to use libc's new uuid functions,
but the API is different, and depending on how the checks are written,
it's often a pain to adapt an existing autoconf script to cope with a
function that needs an -l flag on some systems but not others, so it's
often not reasonable to do this conversion for a simple port.)

Diff below switches this uuid generation to arc4random_buf, avoiding
/dev/urandom problems, and disables the uuidd daemon - the latter wasn't
configured properly by this port anyway; it hardcodes a directory path
which doesn't exist, and there's no rc.d script. Removing this support
also avoids a strcpy in the library, so reduces APIWARN messages.

Does anyone foresee problems with doing this?

Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/e2fsprogs/Makefile,v
retrieving revision 1.34
diff -u -p -r1.34 Makefile
--- Makefile    8 Nov 2014 11:28:04 -0000       1.34
+++ Makefile    8 Nov 2014 12:05:47 -0000
@@ -3,6 +3,7 @@
 COMMENT=       utilities to manipulate ext2 filesystems
 
 DISTNAME=      e2fsprogs-1.42.12
+REVISION=      0
 CATEGORIES=    sysutils devel
 SHARED_LIBS=   blkid           0.0 \
                com_err         21.0 \
@@ -25,7 +26,9 @@ MODULES=      devel/gettext
 SEPARATE_BUILD=        Yes
 CONFIGURE_STYLE= autoconf
 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_"
 USE_GMAKE=     Yes
 
Index: patches/patch-lib_uuid_gen_uuid_c
===================================================================
RCS file: patches/patch-lib_uuid_gen_uuid_c
diff -N patches/patch-lib_uuid_gen_uuid_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-lib_uuid_gen_uuid_c   8 Nov 2014 12:05:47 -0000
@@ -0,0 +1,53 @@
+$OpenBSD$
+--- 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
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/sysutils/e2fsprogs/pkg/PLIST,v
retrieving revision 1.15
diff -u -p -r1.15 PLIST
--- pkg/PLIST   8 Nov 2014 11:28:04 -0000       1.15
+++ pkg/PLIST   8 Nov 2014 12:05:47 -0000
@@ -101,7 +101,6 @@ lib/pkgconfig/uuid.pc
 @man man/man8/mklost+found.8
 @man man/man8/resize2fs.8
 @man man/man8/tune2fs.8
-@man man/man8/uuidd.8
 @bin sbin/badblocks
 @bin sbin/blkid
 @bin sbin/debugfs
@@ -127,7 +126,6 @@ lib/pkgconfig/uuid.pc
 @bin sbin/mklost+found
 @bin sbin/resize2fs
 @bin sbin/tune2fs
-@bin sbin/uuidd
 share/et/
 share/et/et_c.awk
 share/et/et_h.awk

Reply via email to