dont use $HOME when checking for default data dir

This commit is contained in:
Jeff Becker 2020-06-16 10:04:30 -04:00
parent b6a7b5ccfb
commit 2371e416bd
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
1 changed files with 17 additions and 1 deletions

View File

@ -4,6 +4,10 @@
#include <stdlib.h>
#ifndef _WIN32
#include <pwd.h>
#endif
namespace llarp
{
constexpr auto our_rc_filename = "self.signed";
@ -19,7 +23,19 @@ namespace llarp
#ifdef _WIN32
const fs::path homedir = getenv("APPDATA");
#else
const fs::path homedir = getenv("HOME");
fs::path homedir;
auto pw = getpwuid(getuid());
if (pw)
{
homedir = pw->pw_dir;
}
else
{
// no home dir specified yea idk
homedir = "/var/lib/lokinet";
return homedir;
}
#endif
return homedir / ".lokinet";
}