summaryrefslogtreecommitdiff
path: root/sal/osl/unx/uunxapi.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sal/osl/unx/uunxapi.cxx')
-rw-r--r--sal/osl/unx/uunxapi.cxx59
1 files changed, 46 insertions, 13 deletions
diff --git a/sal/osl/unx/uunxapi.cxx b/sal/osl/unx/uunxapi.cxx
index 9b40644e8b27..7eb2ed910467 100644
--- a/sal/osl/unx/uunxapi.cxx
+++ b/sal/osl/unx/uunxapi.cxx
@@ -127,7 +127,6 @@ static rtl::OString macxp_resolveAliasAndConvert(rtl::OString p)
int access_u(const rtl_uString* pustrPath, int mode)
{
rtl::OString fn = OUStringToOString(pustrPath);
-#ifndef MACOSX
#ifdef ANDROID
if (strncmp(fn.getStr(), "/assets", sizeof("/assets")-1) == 0 &&
(fn.getStr()[sizeof("/assets")-1] == '\0' ||
@@ -144,18 +143,18 @@ int access_u(const rtl_uString* pustrPath, int mode)
return 0;
}
#endif
- return access(fn.getStr(), mode);
-#else
+
+#ifdef MACOSX
+ fn = macxp_resolveAliasAndConvert(fn);
+#endif
accessFilePathState *state = prepare_to_access_file_path(fn.getStr());
- int result = access(macxp_resolveAliasAndConvert(fn).getStr(), mode);
+ int result = access(fn.getStr(), mode);
done_accessing_file_path(fn.getStr(), state);
return result;
-
-#endif
}
sal_Bool realpath_u(const rtl_uString* pustrFileName, rtl_uString** ppustrResolvedName)
@@ -176,12 +175,12 @@ sal_Bool realpath_u(const rtl_uString* pustrFileName, rtl_uString** ppustrResolv
}
#endif
- accessFilePathState *state = prepare_to_access_file_path(fn.getStr());
-
#ifdef MACOSX
fn = macxp_resolveAliasAndConvert(fn);
#endif
+ accessFilePathState *state = prepare_to_access_file_path(fn.getStr());
+
char rp[PATH_MAX];
bool bRet = realpath(fn.getStr(), rp);
@@ -205,7 +204,14 @@ int stat_c(const char* cpPath, struct stat* buf)
cpPath[sizeof("/assets")-1] == '/'))
return lo_apk_lstat(cpPath, buf);
#endif
- return stat(cpPath, buf);
+
+ accessFilePathState *state = prepare_to_access_file_path(cpPath);
+
+ int result = stat(cpPath, buf);
+
+ done_accessing_file_path(cpPath, state);
+
+ return result;
}
int lstat_c(const char* cpPath, struct stat* buf)
@@ -229,11 +235,12 @@ int lstat_c(const char* cpPath, struct stat* buf)
int lstat_u(const rtl_uString* pustrPath, struct stat* buf)
{
rtl::OString fn = OUStringToOString(pustrPath);
-#ifndef MACOSX
- return lstat_c(fn.getStr(), buf);
-#else
- return lstat(macxp_resolveAliasAndConvert(fn).getStr(), buf);
+
+#ifdef MACOSX
+ fn = macxp_resolveAliasAndConvert(fn);
#endif
+
+ return lstat_c(fn.getStr(), buf);
}
int mkdir_u(const rtl_uString* path, mode_t mode)
@@ -271,4 +278,30 @@ int utime_c(const char *cpPath, struct utimbuf *times)
return result;
}
+int ftruncate_with_name(int fd, sal_uInt64 uSize, rtl_String* path)
+{
+ /* When sandboxed on OS X, ftruncate(), even if it takes an
+ * already open file descriptor which was retuned from an open()
+ * call already checked by the sandbox, still requires a security
+ * scope bookmark for the file to be active in case the file is
+ * one that the sandbox doesn't otherwise allow access to. Luckily
+ * LibreOffice usually calls ftruncate() through the helpful C++
+ * abstraction layer that keeps the pathname around.
+ */
+
+ rtl::OString fn = rtl::OString(path);
+
+#ifdef MACOSX
+ fn = macxp_resolveAliasAndConvert(fn);
+#endif
+
+ accessFilePathState *state = prepare_to_access_file_path(fn.getStr());
+
+ int result = ftruncate(fd, uSize);
+
+ done_accessing_file_path(fn.getStr(), state);
+
+ return result;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */