changeset 6696:6a7edbad1cdf

Fix gc-random module.
author Simon Josefsson <simon@josefsson.org>
date Wed, 08 Mar 2006 13:40:30 +0000
parents 9afb952794ee
children 1aa169f681e6
files lib/ChangeLog lib/gc-gnulib.c m4/ChangeLog m4/gc-random.m4
diffstat 4 files changed, 28 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,8 @@
+2006-03-08  Simon Josefsson  <jas@extundo.com>
+
+	* gc-gnulib.c (randomize): Don't open files called 'no', they
+	signal that configure disabled the device.
+
 2006-03-07  Paul Eggert  <eggert@cs.ucla.edu>
 
 	* c-stack.c: Include unistd.h unconditionally, since we now assume
--- a/lib/gc-gnulib.c
+++ b/lib/gc-gnulib.c
@@ -109,6 +109,9 @@
       break;
     }
 
+  if (strcmp (device, "no") == 0)
+    return GC_RANDOM_ERROR;
+
   fd = open (device, O_RDONLY);
   if (fd < 0)
     return GC_RANDOM_ERROR;
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,3 +1,8 @@
+2006-03-08  Simon Josefsson  <jas@extundo.com>
+
+	* gc-random.m4: Permit 'no' as variable values and fix warnings,
+	suggested by Ralf Wildenhues <Ralf.Wildenhues@gmx.de>.
+
 2006-03-08  Simon Josefsson  <jas@extundo.com>
 
 	* gc-random.m4: Call AC_CANONICAL_HOST and use $host_os instead of
--- a/m4/gc-random.m4
+++ b/m4/gc-random.m4
@@ -41,30 +41,36 @@
   AC_ARG_ENABLE(random-device,
 	AC_HELP_STRING([--enable-random-device],
 		[device with (strong) randomness (for Nettle)]),
-	test "$enableval" != "no" && NAME_OF_RANDOM_DEVICE=$enableval)
+	NAME_OF_RANDOM_DEVICE=$enableval)
   AC_MSG_RESULT($NAME_OF_RANDOM_DEVICE)
 
   AC_MSG_CHECKING([device with pseudo random data...])
   AC_ARG_ENABLE(pseudo-random-device,
 	AC_HELP_STRING([--enable-pseudo-random-device],
 		[device with pseudo randomness (for Nettle)]),
-	test "$enableval" != "no" && NAME_OF_PSEUDO_RANDOM_DEVICE=$enableval)
+	NAME_OF_PSEUDO_RANDOM_DEVICE=$enableval)
   AC_MSG_RESULT($NAME_OF_PSEUDO_RANDOM_DEVICE)
 
   AC_MSG_CHECKING([device with unpredictable data for nonces...])
   AC_ARG_ENABLE(nonce-device,
 	AC_HELP_STRING([--enable-nonce-device],
 		[device with unpredictable nonces (for Nettle)]),
-	test "$enableval" != "no" && NAME_OF_NONCE_DEVICE=$enableval)
+	NAME_OF_NONCE_DEVICE=$enableval)
   AC_MSG_RESULT($NAME_OF_NONCE_DEVICE)
 
   if test "$cross_compiling" != yes; then
-    AC_CHECK_FILE($NAME_OF_RANDOM_DEVICE,,
-      AC_MSG_WARN([[device for (strong) random data `$NAME_OF_RANDOM_DEVICE' does not exist]]))
-    AC_CHECK_FILE($NAME_OF_PSEUDO_RANDOM_DEVICE,,
-      AC_MSG_WARN([[device for pseudo-random data `$NAME_OF_PSEUDO_RANDOM_DEVICE' does not exist]]))
-    AC_CHECK_FILE($NAME_OF_NONCE_DEVICE,,
-      AC_MSG_WARN([[device for unpredictable nonces `$NAME_OF_NONCE_DEVICE' does not exist]]))
+    if test "$NAME_OF_RANDOM_DEVICE" != "no"; then
+      AC_CHECK_FILE($NAME_OF_RANDOM_DEVICE,,
+        AC_MSG_WARN([[Device `$NAME_OF_RANDOM_DEVICE' does not exist, consider to use --enable-random-device]]))
+    fi
+    if test "$NAME_OF_PSEUDO_RANDOM_DEVICE" != "no"; then
+      AC_CHECK_FILE($NAME_OF_PSEUDO_RANDOM_DEVICE,,
+        AC_MSG_WARN([[Device `$NAME_OF_PSEUDO_RANDOM_DEVICE' does not exist, consider to use --enable-pseudo-random-device]]))
+    fi
+    if test "$NAME_OF_NONCE_RANDOM_DEVICE" != "no"; then
+      AC_CHECK_FILE($NAME_OF_NONCE_DEVICE,,
+        AC_MSG_WARN([[Device `$NAME_OF_NONCE_RANDOM_DEVICE' does not exist, consider to use --enable-nonce-device]]))
+    fi
   else
     AC_MSG_NOTICE([[Cross compiling, assuming random devices exists on the target host...]])  
   fi