Implement RAND_file_name.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20067 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2007-01-30 19:41:35 +00:00
parent b73c455908
commit 040695a3bd

View File

@@ -182,5 +182,34 @@ RAND_write_file(const char *filename)
const char *
RAND_file_name(char *filename, size_t size)
{
return NULL;
const char *e = NULL;
int pathp = 0, ret;
if (!issuid()) {
e = getenv("RANDFILE");
if (e == NULL) {
e = getenv("HOME");
if (e)
pathp = 1;
}
}
if (e == NULL) {
struct passwd *pw = getpwuid(getuid());
if (pw) {
e = pw->pw_dir;
pathp = 1;
}
}
if (e == NULL)
return NULL;
if (pathp)
ret = snprintf(filename, size, "%s/.randfile", e);
else
ret = snprintf(filename, size, "%s", e);
if (ret <= 0 || ret >= size)
return NULL;
return filename;
}