bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gc.m4 and hard failure


From: Simon Josefsson
Subject: Re: gc.m4 and hard failure
Date: Wed, 08 Mar 2006 14:41:29 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Ralf Wildenhues <address@hidden> writes:

> Hi Simon,
>
> * Simon Josefsson wrote on Wed, Mar 08, 2006 at 10:36:28AM CET:
>> Ralf Wildenhues <address@hidden> writes:
>> 
>> > Better, thanks.  But
>> >   --disable-random-device  (--enable-random-devide=no)
>> > could IMVHO still be given a useful meaning, which it currently does not
>> > have.  Since I don't actually use this code in any project, I can't tell
>> > you how realistic this usage case would be.
>> 
>> I'm inclined to fix this in the source code, so that
>> --disable-random-device actually end up disabling the use of just that
>> device.  What do you think?
>
> Oh, sure, I guess that would be fine.  In the macro, you'd have to
> change the AC_ARG_ENABLE argument ACTION-IF-GIVEN though:
>   test "$enableval" != "no" && NAME_OF_RANDOM_DEVICE=$enableval
>
> to set the value in any case (so the user can override your defaults),
> and avoid the warning later that file `no' does not exist:
>     AC_CHECK_FILE($NAME_OF_RANDOM_DEVICE,,
>       AC_MSG_WARN([[device for (strong) random data `$NAME_OF_RANDOM_DEVICE' 
> does not exist]]))
>
> Or am I missing something here (untested)?

Seems good.  I installed this.  Review appreciated (untested).

2006-03-08  Simon Josefsson  <address@hidden>

        * gc-random.m4: Permit 'no' as variable values and fix warnings,
        suggested by Ralf Wildenhues <address@hidden>.

2006-03-08  Simon Josefsson  <address@hidden>

        * gc-gnulib.c (randomize): Don't open files called 'no', they
        signal that configure disabled the device.

Index: lib/gc-gnulib.c
===================================================================
RCS file: /sources/gnulib/gnulib/lib/gc-gnulib.c,v
retrieving revision 1.17
diff -u -p -r1.17 gc-gnulib.c
--- lib/gc-gnulib.c     7 Mar 2006 13:17:10 -0000       1.17
+++ lib/gc-gnulib.c     8 Mar 2006 13:38:45 -0000
@@ -109,6 +109,9 @@ randomize (int level, char *data, size_t
       break;
     }
 
+  if (strcmp (device, "no") == 0)
+    return GC_RANDOM_ERROR;
+
   fd = open (device, O_RDONLY);
   if (fd < 0)
     return GC_RANDOM_ERROR;
Index: m4/gc-random.m4
===================================================================
RCS file: /sources/gnulib/gnulib/m4/gc-random.m4,v
retrieving revision 1.2
diff -u -p -r1.2 gc-random.m4
--- m4/gc-random.m4     8 Mar 2006 09:32:40 -0000       1.2
+++ m4/gc-random.m4     8 Mar 2006 13:38:45 -0000
@@ -41,30 +41,36 @@ AC_DEFUN([gl_GC_RANDOM],
   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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]