summaryrefslogtreecommitdiffstats
path: root/crypto/rand/randfile.c
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:08:52 +0200
commit799c1293fcf412db64dcc8a09a6b11cc755914dc (patch)
tree2e23e6a132def85feab61f3f6ce4f3c5cb05efd2 /crypto/rand/randfile.c
parent776e15f9393a9e3083bec60a8da376ce2fe1e97e (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>
Diffstat (limited to 'crypto/rand/randfile.c')
-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