rand/randfile.c: restore fallback to $HOME for non-setuid programs.
authorAndy Polyakov <appro@openssl.org>
Tue, 20 Sep 2016 14:59:32 +0000 (16:59 +0200)
committerAndy Polyakov <appro@openssl.org>
Wed, 21 Sep 2016 19:10:07 +0000 (21:10 +0200)
Reported in GH#1589, but solution is different from suggested.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 799c1293fcf412db64dcc8a09a6b11cc755914dc)

crypto/rand/randfile.c

index 7aeb87174370ddf0db39bfe990a7c0e731d4997b..16cc27aa9b08f88dc90cac5334d02db8942278cc 100644 (file)
@@ -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