summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2011-05-30 00:01:59 +0900
committerNoel Power <noel.power@novell.com>2011-05-31 11:27:39 +0100
commita6f56f70a4930d3f71bd9c9b90fdd0ba20e4da5f (patch)
tree04ddbae0fbcf4d876919720ad58f15083dd3e124
parente6d8b9c96ff6803bd13df453d454c9f9d9ef061b (diff)
fdo#32263
use $HOME/.config unless XDG_CONFIG_HOME is set with respect to http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html moreover, lose dot so as "$HOME/.config/libreoffice".
-rw-r--r--sal/osl/unx/security.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/sal/osl/unx/security.c b/sal/osl/unx/security.c
index 8cda0876e..f0f82eca1 100644
--- a/sal/osl/unx/security.c
+++ b/sal/osl/unx/security.c
@@ -360,18 +360,37 @@ sal_Bool SAL_CALL osl_getConfigDir(oslSecurity Security, rtl_uString **pustrDire
#ifndef MACOSX
+#define DOT_CONFIG "/.config"
+
static sal_Bool SAL_CALL osl_psz_getConfigDir(oslSecurity Security, sal_Char* pszDirectory, sal_uInt32 nMax)
{
sal_Char *pStr = getenv("XDG_CONFIG_HOME");
if ((pStr == NULL) || (strlen(pStr) == 0) ||
(access(pStr, 0) != 0))
- return (osl_psz_getHomeDir(Security, pszDirectory, nMax));
+ {
+ // a default equal to $HOME/.config should be used.
+ if (!osl_psz_getHomeDir(Security, pszDirectory, nMax))
+ return sal_False;
+ size_t n = strlen(pszDirectory);
+ if (n + sizeof(DOT_CONFIG) < nMax)
+ {
+ strncpy(pszDirectory+n, DOT_CONFIG, sizeof(DOT_CONFIG));
+ if (access(pszDirectory, 0) != 0)
+ {
+ // resort to HOME
+ pszDirectory[n] = '\0';
+ }
+ }
+ }
+ else
+ strncpy(pszDirectory, pStr, nMax);
- strncpy(pszDirectory, pStr, nMax);
return sal_True;
}
+#undef DOT_CONFIG
+
#else
/*