In libuuid, rename random_get_bytes() to symbol name conflict on Solaris.

Should fix the build of libuuid, libblkid, and mcookie. PR 55086.
This commit is contained in:
dholland 2021-07-25 04:00:34 +00:00
parent 777194e552
commit 166714376d
5 changed files with 97 additions and 8 deletions

View file

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.22 2021/07/10 23:11:22 dholland Exp $
$NetBSD: distinfo,v 1.23 2021/07/25 04:00:34 dholland Exp $
SHA1 (util-linux-2.32.1.tar.xz) = de9271fb93fb651d21c027e2efb0cf0ac80f2e9a
RMD160 (util-linux-2.32.1.tar.xz) = bf61cb460eabcfdb90909dbcfd8e64bb9097ce65
@ -8,12 +8,14 @@ SHA1 (patch-Makefile.am) = a3470f6d286ca7c7ddebf27f9a205507b67f836d
SHA1 (patch-Makefile.in) = a415bb922d7154387f71882b1f1fa06c9e49c174
SHA1 (patch-configure) = 400904ae2e58b717e990ba26c111b90bc8f240d1
SHA1 (patch-include_c.h) = 4596369e4b742329be513952c66d1fa3705de017
SHA1 (patch-include_randutils.h) = d28ade8554d218f2af4a815a611b833b2036a5eb
SHA1 (patch-include_ttyutils.h) = fa2b253d568e5aface99727c397d3c4c892b2c93
SHA1 (patch-lib_ismounted.c) = 11f5148020dba2a22e1fbe4882fe423dfb11ad73
SHA1 (patch-lib_pager.c) = 3d4b65f9ccb6437bcc0777634660b5ae3150d14e
SHA1 (patch-lib_randutils.c) = 422e94d9bdaf6a77894b79d67285fd8a0cb1d05a
SHA1 (patch-lib_randutils.c) = aece9cb8ec033966d535955654cc27263b3c4976
SHA1 (patch-libblkid_docs_Makefile.in) = 97a1559dad77e32d78bd504d8d3523b9cc403c36
SHA1 (patch-libfdisk_docs_Makefile.in) = def97b85e8760cd18af736ab331e2f476f0c9c67
SHA1 (patch-libmount_docs_Makefile.in) = a55063e89161221cecda661039d0a62174592669
SHA1 (patch-libsmartcols_docs_Makefile.in) = aa44d1a9ffd9bf4422ed8892d91b4e0e72e50407
SHA1 (patch-libuuid_src_gen__uuid.c) = d15aa418ab497e2e3634c62633d2f3212f1b42be
SHA1 (patch-libuuid_src_gen__uuid.c) = 94d190ffca4357e62c6b0ae90fdc9a7456e10468
SHA1 (patch-misc-utils_mcookie.c) = 1456f47881552162b1ba6218c620f23648eceb6c

View file

@ -0,0 +1,15 @@
$NetBSD: patch-include_randutils.h,v 1.1 2021/07/25 04:00:34 dholland Exp $
Rename random_get_bytes to avoid symbol name conflict on Solaris.
--- include/randutils.h~ 2018-06-04 07:57:02.792445890 +0000
+++ include/randutils.h
@@ -11,7 +11,7 @@ extern int rand_get_number(int low_n, in
/* /dev/urandom based with fallback to rand() */
extern int random_get_fd(void);
-extern void random_get_bytes(void *buf, size_t nbytes);
+extern void my_random_get_bytes(void *buf, size_t nbytes);
extern const char *random_tell_source(void);
#endif

View file

@ -1,11 +1,13 @@
$NetBSD: patch-lib_randutils.c,v 1.5 2017/12/08 08:03:35 adam Exp $
$NetBSD: patch-lib_randutils.c,v 1.6 2021/07/25 04:00:34 dholland Exp $
O_CLOEXEC is not available on every platform (e.g. MacOS X < 10.7). It
was introduced in POSIX 2008.
--- lib/randutils.c.orig 2017-10-02 09:30:08.000000000 +0000
Rename random_get_bytes to avoid symbol name conflict on Solaris.
--- lib/randutils.c.orig 2018-06-21 09:58:10.352568488 +0000
+++ lib/randutils.c
@@ -72,6 +72,10 @@ static void crank_random(void)
@@ -74,6 +74,10 @@ static void crank_random(void)
rand();
}
@ -16,3 +18,30 @@ was introduced in POSIX 2008.
int random_get_fd(void)
{
int i, fd;
@@ -98,7 +102,7 @@ int random_get_fd(void)
#define UL_RAND_READ_ATTEMPTS 8
#define UL_RAND_READ_DELAY 125000 /* microseconds */
-void random_get_bytes(void *buf, size_t nbytes)
+void my_random_get_bytes(void *buf, size_t nbytes)
{
unsigned char *cp = (unsigned char *)buf;
size_t i, n = nbytes;
@@ -213,7 +217,7 @@ int main(int argc, char *argv[])
printf("Multiple random calls:\n");
for (i = 0; i < n; i++) {
- random_get_bytes(&v, sizeof(v));
+ my_random_get_bytes(&v, sizeof(v));
printf("#%02zu: %25"PRIu64"\n", i, v);
}
@@ -224,7 +228,7 @@ int main(int argc, char *argv[])
if (!buf)
err(EXIT_FAILURE, "failed to allocate buffer");
- random_get_bytes(buf, bufsz);
+ my_random_get_bytes(buf, bufsz);
for (i = 0; i < n; i++) {
vp = (int64_t *) (buf + (i * sizeof(*vp)));
printf("#%02zu: %25"PRIu64"\n", i, *vp);

View file

@ -1,9 +1,10 @@
$NetBSD: patch-libuuid_src_gen__uuid.c,v 1.1 2017/12/08 08:03:35 adam Exp $
$NetBSD: patch-libuuid_src_gen__uuid.c,v 1.2 2021/07/25 04:00:34 dholland Exp $
fcntl is portable, flock is not.
Solaris does not have ifr.ifr_hwaddr.
Rename random_get_bytes to avoid symbol name conflict on Solaris.
--- libuuid/src/gen_uuid.c.orig 2017-09-27 09:05:13.000000000 +0000
--- libuuid/src/gen_uuid.c.orig 2018-06-04 07:57:02.805445789 +0000
+++ libuuid/src/gen_uuid.c
@@ -172,7 +172,7 @@ static int get_node_id(unsigned char *no
for (i = 0; i < n; i+= ifreq_size(*ifrp) ) {
@ -42,6 +43,15 @@ Solaris does not have ifr.ifr_hwaddr.
if ((errno == EAGAIN) || (errno == EINTR))
continue;
fclose(state_f);
@@ -278,7 +284,7 @@ static int get_clock(uint32_t *clock_hig
}
if ((last.tv_sec == 0) && (last.tv_usec == 0)) {
- random_get_bytes(&clock_seq, sizeof(clock_seq));
+ my_random_get_bytes(&clock_seq, sizeof(clock_seq));
clock_seq &= 0x3FFF;
gettimeofday(&last, NULL);
last.tv_sec--;
@@ -325,7 +331,8 @@ try_again:
fflush(state_f);
}
@ -52,3 +62,21 @@ Solaris does not have ifr.ifr_hwaddr.
}
*clock_high = clock_reg >> 32;
@@ -416,7 +423,7 @@ int __uuid_generate_time(uuid_t out, int
if (!has_init) {
if (get_node_id(node_id) <= 0) {
- random_get_bytes(node_id, 6);
+ my_random_get_bytes(node_id, 6);
/*
* Set multicast bit, to prevent conflicts
* with IEEE 802 addresses obtained from
@@ -514,7 +521,7 @@ void __uuid_generate_random(uuid_t out,
n = *num;
for (i = 0; i < n; i++) {
- random_get_bytes(buf, sizeof(buf));
+ my_random_get_bytes(buf, sizeof(buf));
uuid_unpack(buf, &uu);
uu.clock_seq = (uu.clock_seq & 0x3FFF) | 0x8000;

View file

@ -0,0 +1,15 @@
$NetBSD: patch-misc-utils_mcookie.c,v 1.1 2021/07/25 04:00:34 dholland Exp $
Rename random_get_bytes to avoid symbol name conflict on Solaris.
--- misc-utils/mcookie.c~ 2018-06-04 07:57:02.810445749 +0000
+++ misc-utils/mcookie.c
@@ -180,7 +180,7 @@ int main(int argc, char **argv)
randomness_from_files(&ctl);
free(ctl.files);
- random_get_bytes(&buf, RAND_BYTES);
+ my_random_get_bytes(&buf, RAND_BYTES);
ul_MD5Update(&ctl.ctx, buf, RAND_BYTES);
if (ctl.verbose)
fprintf(stderr, P_("Got %d byte from %s\n",