randgen.c revision 8045f6e30e98b009b85fcd6cc8d1bdc90524a556
/* Copyright (c) 2002-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "randgen.h"
#include "fd-close-on-exec.h"
#include <unistd.h>
#include <fcntl.h>
#if defined(HAVE_GETRANDOM) && HAVE_DECL_GETRANDOM != 0
# define USE_GETRANDOM
#elif defined(HAVE_ARC4RANDOM)
# if defined(HAVE_LIBBSD)
# endif
# define USE_ARC4RANDOM
#else
# define USE_RANDOM_DEV
#endif
static int init_refcount = 0;
#if defined(USE_RANDOM_DEV)
static int urandom_fd;
#endif
{
i_assert(init_refcount > 0);
#if defined(USE_ARC4RANDOM)
#else
# if defined(USE_GETRANDOM)
# else
# endif
if (ret == 0)
# if defined(USE_RANDOM_DEV)
# elif defined(USE_GETRANDOM)
i_fatal("getrandom() failed: %m");
# endif
} else {
}
}
#endif /* defined(USE_ARC4RANDOM) */
}
void random_init(void)
{
unsigned int seed;
if (init_refcount++ > 0)
return;
#if defined(USE_RANDOM_DEV)
if (urandom_fd == -1) {
"currently we require it");
} else {
}
}
#endif
}
void random_deinit(void)
{
if (--init_refcount > 0)
return;
#if defined(USE_RANDOM_DEV)
#endif
}