From 799c1293fcf412db64dcc8a09a6b11cc755914dc Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Tue, 20 Sep 2016 16:59:32 +0200 Subject: [PATCH] rand/randfile.c: restore fallback to $HOME for non-setuid programs. Reported in GH#1589, but solution is different from suggested. Reviewed-by: Rich Salz --- crypto/rand/randfile.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c index 7aeb871743..16cc27aa9b 100644 --- a/crypto/rand/randfile.c +++ b/crypto/rand/randfile.c @@ -316,12 +316,14 @@ const char *RAND_file_name(char *buf, size_t size) } } #else - if (OPENSSL_issetugid() == 0) { - s = getenv("RANDFILE"); - } else { + if (OPENSSL_issetugid() != 0) { use_randfile = 0; - if (OPENSSL_issetugid() == 0) + } else { + s = getenv("RANDFILE"); + if (s == NULL || *s == '\0') { + use_randfile = 0; s = getenv("HOME"); + } } #endif #ifdef DEFAULT_HOME -- 2.25.1