summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/hcrypto/rand.c
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2010-08-15 18:31:28 +0400
committerAndrew Bartlett <abartlet@samba.org>2010-10-03 01:15:04 +0000
commitab6e3fce040f9ad27cbce44e9038a24f15b601c8 (patch)
treeab99a431c9610927b5d0d26335d2712b509fd6dc /source4/heimdal/lib/hcrypto/rand.c
parent197a1514d62494cc8b862d169c841a26e04b8925 (diff)
downloadsamba-ab6e3fce040f9ad27cbce44e9038a24f15b601c8.tar.gz
samba-ab6e3fce040f9ad27cbce44e9038a24f15b601c8.tar.bz2
samba-ab6e3fce040f9ad27cbce44e9038a24f15b601c8.zip
s4:heimdal: import lorikeet-heimdal-201009250123 (commit 42cabfb5b683dbcb97d583c397b897507689e382)
I based this on Matthieu's import of lorikeet-heimdal, and then updated it to this commit. Andrew Bartlett
Diffstat (limited to 'source4/heimdal/lib/hcrypto/rand.c')
-rw-r--r--source4/heimdal/lib/hcrypto/rand.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/source4/heimdal/lib/hcrypto/rand.c b/source4/heimdal/lib/hcrypto/rand.c
index d360ffcab4..d5c1f687b9 100644
--- a/source4/heimdal/lib/hcrypto/rand.c
+++ b/source4/heimdal/lib/hcrypto/rand.c
@@ -46,6 +46,10 @@
#define O_BINARY 0
#endif
+#ifdef _WIN32
+#include<shlobj.h>
+#endif
+
/**
* @page page_rand RAND - random number
*
@@ -342,7 +346,7 @@ RAND_write_file(const char *filename)
const char *
RAND_file_name(char *filename, size_t size)
{
- char *e = NULL;
+ const char *e = NULL;
int pathp = 0, ret;
if (!issuid()) {
@@ -352,6 +356,8 @@ RAND_file_name(char *filename, size_t size)
if (e)
pathp = 1;
}
+
+#ifndef _WIN32
/*
* Here we really want to call getpwuid(getuid()) but this will
* cause recursive lookups if the nss library uses
@@ -359,7 +365,6 @@ RAND_file_name(char *filename, size_t size)
*
* So at least return the unix /dev/random if we have one
*/
-#ifndef _WIN32
if (e == NULL) {
int fd;
@@ -367,7 +372,22 @@ RAND_file_name(char *filename, size_t size)
if (fd >= 0)
close(fd);
}
+#else /* Win32 */
+
+ if (e == NULL) {
+ char profile[MAX_PATH];
+
+ if (SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL,
+ SHGFP_TYPE_CURRENT, profile) == S_OK) {
+ ret = snprintf(filename, size, "%s\\.rnd", profile);
+
+ if (ret > 0 && ret < size)
+ return filename;
+ }
+ }
+
#endif
+
if (e == NULL)
return NULL;