fs/StandardDirectory: no /etc/passwd lookups on Android
This doesn't make sense on Android; there is no home directory for users.
This commit is contained in:
parent
ba181ae9df
commit
2f2b394d72
@ -54,7 +54,7 @@
|
|||||||
#include "Main.hxx"
|
#include "Main.hxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WIN32
|
#if !defined(WIN32) && !defined(ANDROID)
|
||||||
class PasswdEntry
|
class PasswdEntry
|
||||||
{
|
{
|
||||||
#if defined(HAVE_GETPWNAM_R) || defined(HAVE_GETPWUID_R)
|
#if defined(HAVE_GETPWNAM_R) || defined(HAVE_GETPWUID_R)
|
||||||
@ -91,6 +91,7 @@ public:
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef ANDROID
|
||||||
static inline bool
|
static inline bool
|
||||||
IsValidPathString(PathTraitsFS::const_pointer_type path)
|
IsValidPathString(PathTraitsFS::const_pointer_type path)
|
||||||
{
|
{
|
||||||
@ -111,6 +112,7 @@ SafePathFromFS(PathTraitsFS::const_pointer_type dir)
|
|||||||
return AllocatedPath::FromFS(dir);
|
return AllocatedPath::FromFS(dir);
|
||||||
return AllocatedPath::Null();
|
return AllocatedPath::Null();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
static AllocatedPath GetStandardDir(int folder_id)
|
static AllocatedPath GetStandardDir(int folder_id)
|
||||||
@ -310,21 +312,27 @@ AllocatedPath GetAppBaseDir()
|
|||||||
|
|
||||||
AllocatedPath GetHomeDir()
|
AllocatedPath GetHomeDir()
|
||||||
{
|
{
|
||||||
|
#ifndef ANDROID
|
||||||
auto home = getenv("HOME");
|
auto home = getenv("HOME");
|
||||||
if (IsValidPathString(home) && IsValidDir(home))
|
if (IsValidPathString(home) && IsValidDir(home))
|
||||||
return AllocatedPath::FromFS(home);
|
return AllocatedPath::FromFS(home);
|
||||||
PasswdEntry pw;
|
PasswdEntry pw;
|
||||||
if (pw.ReadByUid(getuid()))
|
if (pw.ReadByUid(getuid()))
|
||||||
return SafePathFromFS(pw->pw_dir);
|
return SafePathFromFS(pw->pw_dir);
|
||||||
|
#endif
|
||||||
return AllocatedPath::Null();
|
return AllocatedPath::Null();
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocatedPath GetHomeDir(const char *user_name)
|
AllocatedPath GetHomeDir(const char *user_name)
|
||||||
{
|
{
|
||||||
|
#ifdef ANDROID
|
||||||
|
(void)user_name;
|
||||||
|
#else
|
||||||
assert(user_name != nullptr);
|
assert(user_name != nullptr);
|
||||||
PasswdEntry pw;
|
PasswdEntry pw;
|
||||||
if (pw.ReadByName(user_name))
|
if (pw.ReadByName(user_name))
|
||||||
return SafePathFromFS(pw->pw_dir);
|
return SafePathFromFS(pw->pw_dir);
|
||||||
|
#endif
|
||||||
return AllocatedPath::Null();
|
return AllocatedPath::Null();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user