diff options
author | Michael Meeks <michael.meeks@suse.com> | 2012-01-24 16:57:11 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-01-24 18:11:33 +0000 |
commit | 72a0b0ad0c364a92fb4872fca4bf3aaaeae0977d (patch) | |
tree | 4f06708846d97000da5c8c90d1a7acfa444b385c /sal/osl/unx | |
parent | 651803c7a5d4568ade7ca829cfce400090637e38 (diff) |
android: initialize security data, and use HOME / bootstrap key
Diffstat (limited to 'sal/osl/unx')
-rw-r--r-- | sal/osl/unx/security.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/sal/osl/unx/security.c b/sal/osl/unx/security.c index 598850658e90..d73111c8afba 100644 --- a/sal/osl/unx/security.c +++ b/sal/osl/unx/security.c @@ -38,6 +38,7 @@ #include <osl/security.h> #include <osl/diagnose.h> +#include <rtl/bootstrap.h> #include "osl/thread.h" #include "osl/file.h" @@ -105,6 +106,7 @@ static oslSecurityImpl * growSecurityImpl( n = SIZE_MAX; } p = realloc(impl, n); + memset (p, 0, n); } if (p == NULL) { free(impl); @@ -301,7 +303,6 @@ sal_Bool SAL_CALL osl_getHomeDir(oslSecurity Security, rtl_uString **pustrDirect return bRet; } - static sal_Bool SAL_CALL osl_psz_getHomeDir(oslSecurity Security, sal_Char* pszDirectory, sal_uInt32 nMax) { oslSecurityImpl *pSecImpl = (oslSecurityImpl *)Security; @@ -309,6 +310,37 @@ static sal_Bool SAL_CALL osl_psz_getHomeDir(oslSecurity Security, sal_Char* pszD if (pSecImpl == NULL) return sal_False; +#ifdef ANDROID +{ + sal_Bool bRet = sal_False; + rtl_uString *pName = 0, *pValue = 0; + + rtl_uString_newFromAscii(&pName, "HOME"); + + if (rtl_bootstrap_get(pName, &pValue, NULL)) + { + rtl_String *pStrValue = 0; + if (pValue && pValue->length > 0) + { + rtl_uString2String(&pStrValue, pValue->buffer, + pValue->length, RTL_TEXTENCODING_UTF8, + OUSTRING_TO_OSTRING_CVTFLAGS); + if (pStrValue && pStrValue->length > 0) + { + sal_Int32 nCopy = SAL_MIN ((sal_Int32)(nMax-1), pStrValue->length); + strncpy (pszDirectory, pStrValue->buffer, nCopy); + pszDirectory[nCopy] = '\0'; + bRet = (size_t)pStrValue->length < nMax; + } + rtl_string_release(pStrValue); + } + rtl_uString_release(pName); + } + if (bRet) + return bRet; +} +#endif + /* if current user, check also environment for HOME */ if (getuid() == pSecImpl->m_pPasswd.pw_uid) { |