summaryrefslogtreecommitdiffstats
path: root/crypto/rand
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2016-09-20 16:59:32 +0200
committerAndy Polyakov <appro@openssl.org>2016-09-21 21:10:07 +0200
commit098dc9be439e5bc3625e01c4092bedc072498da9 (patch)
treecc72b73fd66a4937bc14b03111d0c90c10b5aae7 /crypto/rand
parent7b368cd6d964da817cd1de85fc0cae74372e0966 (diff)
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 <rsalz@openssl.org> (cherry picked from commit 799c1293fcf412db64dcc8a09a6b11cc755914dc)
Diffstat (limited to 'crypto/rand')
-rw-r--r--crypto/rand/randfile.c10
1 files 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