diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2019-08-18 11:45:23 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2019-08-18 11:45:23 +0200 |
commit | 70197e23c9b3905987596d70b5fd72d5ec9e7652 (patch) | |
tree | 0fcab65ce792a95ea1ba64f1c2c558ed0f19e1db | |
parent | 9f2cf5f50a337d73058c43e88453cb2926b49fb3 (diff) |
Revert "added fallback random source ("/dev/urandom") for systems with low entropy available and "/dev/random" activated"
This reverts commit 9f2cf5f50a337d73058c43e88453cb2926b49fb3.
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/utils.c | 28 |
3 files changed, 5 insertions, 31 deletions
diff --git a/configure.ac b/configure.ac index 80050d3..239a78b 100644 --- a/configure.ac +++ b/configure.ac @@ -160,14 +160,13 @@ esac dnl `--with-randomdev`: Default value /dev/random use_customrng=no -use_rngfallback=no AC_MSG_CHECKING([for random device]) AC_ARG_WITH([rngdev], [AS_HELP_STRING([--with-rngdev], [Set an alternative random device. (default: /dev/random)])], [use_customrng=yes], [with_rngdev="/dev/random"]) case ${with_rngdev} in yes) with_rngdev="/dev/random" ;; - /dev/random) use_rngfallback=yes ;; + /dev/random) ;; /dev/urandom) ;; *) AC_MSG_ERROR([Unknown random device \`${with_rngdev}\` for --with-rngdev: Only \`/dev/random\` xor \`/dev/urandom\` allowed. This option is unused on Windows targets.]) ;; esac @@ -237,7 +236,6 @@ AM_CONDITIONAL([IS_WINDOWS], [test x"${use_msw}" = xyes]) AM_CONDITIONAL([HAVE_ICMPFILTER], [test x"${with_icmp_filter}" = xyes]) AM_CONDITIONAL([HAVE_ARC4RANDOM], [test x"${arc4random_enabled}" = xyes]) AM_CONDITIONAL([USE_CUSTOMRNG], [test x"${use_customrng}" = xyes]) -AM_CONDITIONAL([USE_RNGFALLBACK], [test x"${use_rngfallback}" = xyes]) dnl output config headers AC_CONFIG_HEADERS([src/config.h:src/config.h.in]) diff --git a/src/Makefile.am b/src/Makefile.am index 97b4545..6f9ca23 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,10 +30,6 @@ if USE_CUSTOMRNG ptunnel_ng_CFLAGS += -DUSE_CUSTOMRNG=1 endif -if USE_RNGFALLBACK -ptunnel_ng_CFLAGS += -DUSE_RNGFALLBACK=1 -endif - ptunnel_ng_SOURCES = \ md5.c \ challenge.c \ diff --git a/src/utils.c b/src/utils.c index 6752890..64f6f88 100644 --- a/src/utils.c +++ b/src/utils.c @@ -174,32 +174,12 @@ int pt_random(void) { } bytes_read = read(rng_fd, &rnd_val, sizeof rnd_val); if (bytes_read != sizeof rnd_val) { - if (bytes_read < 0) { - pt_log(kLog_error, "Read from random device failed: %s\n", + if (bytes_read < 0) + pt_log(kLog_error, "FATAL: Read from random device failed: %s\n", strerror(errno)); - } else { - pt_log(kLog_info, "Read only %zd random bytes (wanted %zd bytes)\n", + else + pt_log(kLog_error, "FATAL: Read only %zd bytes (wanted %zd bytes)\n", bytes_read, sizeof rnd_val); - } -#ifdef USE_RNGFALLBACK - /* use /dev/urandom if previous random device failed */ - static int fallback_rng_fd = -1; - if (fallback_rng_fd < 0) { - fallback_rng_fd = open("/dev/urandom", O_RDONLY); - if (fallback_rng_fd < 0) { - pt_log(kLog_error, "FATAL: Could not open fallback random device '%s': %s\n", - "/dev/urandom", strerror(errno)); - exit(EXIT_FAILURE); - } - } - if (bytes_read < 0) { - bytes_read = 0; - } - if (read(fallback_rng_fd, &rnd_val + bytes_read, sizeof rnd_val - bytes_read) == sizeof rnd_val - bytes_read) { - return rnd_val; - } -#endif - pt_log(kLog_error, "FATAL: No more RNG sources available\n"); exit(EXIT_FAILURE); } return rnd_val; |