cvs commit: patches/mktemp mktemp-1.5-frandom-1.patch

tushar at linuxfromscratch.org tushar at linuxfromscratch.org
Wed May 5 22:54:01 PDT 2004


tushar      04/05/05 23:54:01

  Added:       mktemp   mktemp-1.5-frandom-1.patch
  Log:
  Added: mktemp-1.5-frandom-1.patch
  
  Revision  Changes    Path
  1.1                  patches/mktemp/mktemp-1.5-frandom-1.patch
  
  Index: mktemp-1.5-frandom-1.patch
  ===================================================================
  Submitted By: Robert Connolly <robert at linuxfromscratch dot org> (ashes)
  Date: 2004-05-05
  Initial Package Version: 1.5
  Origin: None
  Description: This uses sysctl erandom instead of urandom for mktemp.
  Do not use the --with-libc configure option with this patch or it will
  not work.
  
  diff -Naur mktemp-1.5.orig/configure mktemp-1.5.frandom/configure
  --- mktemp-1.5.orig/configure	2003-03-24 01:06:43.000000000 +0000
  +++ mktemp-1.5.frandom/configure	2004-05-05 20:45:10.000000000 +0000
  @@ -3643,7 +3643,7 @@
   if test -n "$with_random"; then
       mktemp_cv_dev_urandom="with_random=$with_random"
   elif test -r /dev/urandom; then
  -    mktemp_cv_dev_urandom="with_random=/dev/urandom"
  +    mktemp_cv_dev_urandom="with_random=erandom"
   else
       mktemp_cv_dev_urandom="with_random=no"
   fi
  diff -Naur mktemp-1.5.orig/configure.in mktemp-1.5.frandom/configure.in
  --- mktemp-1.5.orig/configure.in	2003-03-24 01:04:49.000000000 +0000
  +++ mktemp-1.5.frandom/configure.in	2004-05-05 20:45:10.000000000 +0000
  @@ -172,7 +172,7 @@
   if test -n "$with_random"; then
       mktemp_cv_dev_urandom="with_random=$with_random"
   elif test -r /dev/urandom; then
  -    mktemp_cv_dev_urandom="with_random=/dev/urandom"
  +    mktemp_cv_dev_urandom="with_random=erandom"
   else
       mktemp_cv_dev_urandom="with_random=no"
   fi
  diff -Naur mktemp-1.5.orig/random.c mktemp-1.5.frandom/random.c
  --- mktemp-1.5.orig/random.c	2001-10-01 00:21:34.000000000 +0000
  +++ mktemp-1.5.frandom/random.c	2004-05-05 20:45:10.000000000 +0000
  @@ -26,6 +26,7 @@
    */
   
   #include "config.h"
  +#include <sys/sysctl.h>
   
   #include <sys/types.h>
   #if defined(TIME_WITH_SYS_TIME) || defined(HAVE_SYS_TIME_H)
  @@ -105,16 +106,17 @@
   	SEED_T seed;
   	struct timeval tv;
   
  -#ifdef _PATH_RANDOM
  -	int fd;
  +        int i, mib[3];
  +        size_t len;
  +        mib[0] = CTL_KERN;
  +        mib[1] = KERN_RANDOM;
  +        mib[2] = RANDOM_ERANDOM;
  +	len = sizeof(seed);
   
  -	if ((fd = open(_PATH_RANDOM, O_RDONLY)) != -1 &&
  -	    read_loop(fd, &seed, sizeof(seed)) == sizeof(seed)) {
  -		close(fd);
  +	if (sysctl(mib, 3, &seed, &len, NULL, 0) != -1) {
   		SRAND(seed);
  -		return;
  -	}
  -#endif /* _PATH_RANDOM */
  +                return;
  +        }
   
   	/* Don't have /dev/random */
   	/* XXX - check for gettimeofday() and use time() if none? */
  
  
  



More information about the patches mailing list