Everyone has urandom
If you don't have urandom, please just add a fallback to /dev/random, rather than building our own random generator.
This commit is contained in:
parent
446fe9eecd
commit
711720650c
13
configure.ac
13
configure.ac
|
@ -176,19 +176,6 @@ dnl has it in libc), or if libdl is needed to get it.
|
||||||
AC_CHECK_FUNC([dlopen], [],
|
AC_CHECK_FUNC([dlopen], [],
|
||||||
AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
|
AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
|
||||||
|
|
||||||
case $host_os in
|
|
||||||
linux*|darwin*)
|
|
||||||
AC_DEFINE(HAVE_URANDOM, 1, [Has /dev/urandom]) ;;
|
|
||||||
freebsd*|netbsd*|openbsd*|dragonfly*)
|
|
||||||
AC_DEFINE(HAVE_URANDOM, 1, [Has /dev/urandom]) ;;
|
|
||||||
solaris*)
|
|
||||||
# Solaris 8 with patches, or Solaris 9 or later have /dev/urandom
|
|
||||||
if test -r /dev/urandom ; then
|
|
||||||
AC_DEFINE(HAVE_URANDOM, 1, [Has /dev/urandom])
|
|
||||||
fi ;;
|
|
||||||
*) ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
dnl Checks for library functions.
|
dnl Checks for library functions.
|
||||||
AC_FUNC_VPRINTF
|
AC_FUNC_VPRINTF
|
||||||
AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \
|
AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \
|
||||||
|
|
43
os/auth.c
43
os/auth.c
|
@ -314,8 +314,6 @@ GenerateAuthorization(
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_URANDOM
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GenerateRandomData (int len, char *buf)
|
GenerateRandomData (int len, char *buf)
|
||||||
{
|
{
|
||||||
|
@ -326,45 +324,4 @@ GenerateRandomData (int len, char *buf)
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* !HAVE_URANDOM */
|
|
||||||
|
|
||||||
/* A random number generator that is more unpredictable
|
|
||||||
than that shipped with some systems.
|
|
||||||
This code is taken from the C standard. */
|
|
||||||
|
|
||||||
static unsigned long int next = 1;
|
|
||||||
|
|
||||||
static int
|
|
||||||
xdm_rand(void)
|
|
||||||
{
|
|
||||||
next = next * 1103515245 + 12345;
|
|
||||||
return (unsigned int)(next/65536) % 32768;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
xdm_srand(unsigned int seed)
|
|
||||||
{
|
|
||||||
next = seed;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
GenerateRandomData (int len, char *buf)
|
|
||||||
{
|
|
||||||
static int seed;
|
|
||||||
int value;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
seed += GetTimeInMillis();
|
|
||||||
xdm_srand (seed);
|
|
||||||
for (i = 0; i < len; i++)
|
|
||||||
{
|
|
||||||
value = xdm_rand ();
|
|
||||||
buf[i] ^= (value & 0xff00) >> 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX add getrusage, popen("ps -ale") */
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* HAVE_URANDOM */
|
|
||||||
|
|
||||||
#endif /* XCSECURITY */
|
#endif /* XCSECURITY */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user