android/Bootstrap/src/org/libreoffice/android/Bootstrap.java | 6 android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java | 2 cppu/source/uno/lbmap.cxx | 4 sal/osl/unx/file.cxx | 78 ++++++++-- 4 files changed, 70 insertions(+), 20 deletions(-)
New commits: commit 0d5f437bf7ee3ea8cf9787ccf8bf22d67eee92b8 Author: Tor Lillqvist <tlillqv...@suse.com> Date: Thu Apr 5 20:36:08 2012 +0300 Catch attempts to open /assets files read-write. Improve debugging output diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index 5e59f7c..dbf256d 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -856,11 +856,11 @@ static int osl_file_queryLocking (sal_uInt32 uFlags) #ifdef UNX -oslFileError -SAL_CALL osl_openMemoryAsFile( void *address, size_t size, oslFileHandle *pHandle ) +static oslFileError +osl_openMemoryAsFile( void *address, size_t size, oslFileHandle *pHandle, const char *path ) { oslFileError eRet; - FileHandle_Impl * pImpl = new FileHandle_Impl (-1, FileHandle_Impl::KIND_MEM); + FileHandle_Impl * pImpl = new FileHandle_Impl (-1, FileHandle_Impl::KIND_MEM, path); if (!pImpl) { eRet = oslTranslateFileError (OSL_FET_ERROR, ENOMEM); @@ -879,6 +879,12 @@ SAL_CALL osl_openMemoryAsFile( void *address, size_t size, oslFileHandle *pHandl return osl_File_E_None; } +oslFileError +SAL_CALL osl_openMemoryAsFile( void *address, size_t size, oslFileHandle *pHandle ) +{ + return osl_openMemoryAsFile( address, size, pHandle, "<anon>" ); +} + #endif /**************************************************************************** @@ -901,20 +907,27 @@ SAL_CALL osl_openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_u /* Opening a file from /assets read-only means * we should mmap it from the .apk file */ - if (!(uFlags & osl_File_OpenFlag_Write) && - strncmp (cpFilePath, "/assets/", sizeof ("/assets/") - 1) == 0) + if (strncmp (cpFilePath, "/assets/", sizeof ("/assets/") - 1) == 0) { + if (uFlags & osl_File_OpenFlag_Write) + { + // Or should we just silently "open" it read-only and let write + // attempts, if any, fail then later? + OSL_TRACE("osl_openFile(%s, writeable), not possible!", cpFilePath); + errno = EPERM; + return osl_File_E_PERM; + } void *address; size_t size; address = lo_apkentry(cpFilePath, &size); - OSL_TRACE("osl_openFile(%s): %p", + OSL_TRACE("osl_openFile(%s) => %p", cpFilePath, address); if (address == NULL) { errno = ENOENT; return osl_File_E_NOENT; } - return osl_openMemoryAsFile(address, size, pHandle); + return osl_openMemoryAsFile(address, size, pHandle, cpFilePath); } #endif @@ -952,7 +965,14 @@ SAL_CALL osl_openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_u /* open the file */ int fd = open( cpFilePath, flags, mode ); if (-1 == fd) - return oslTranslateFileError (OSL_FET_ERROR, errno); + { + int saved_errno = errno; + OSL_TRACE("osl_openFile(%s, %s) failed: %s", + cpFilePath, + flags & O_RDWR ? "writeable":"readonly", + strerror(saved_errno)); + return oslTranslateFileError (OSL_FET_ERROR, saved_errno); + } /* reset O_NONBLOCK flag */ if (flags & O_NONBLOCK) @@ -960,13 +980,25 @@ SAL_CALL osl_openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_u int f = fcntl (fd, F_GETFL, 0); if (-1 == f) { - eRet = oslTranslateFileError (OSL_FET_ERROR, errno); + int saved_errno = errno; + OSL_TRACE("osl_openFile(%s, %s): fcntl(%d, F_GETFL) failed: %s", + cpFilePath, + flags & O_RDWR ? "writeable":"readonly", + fd, + strerror(saved_errno)); + eRet = oslTranslateFileError (OSL_FET_ERROR, saved_errno); (void) close(fd); return eRet; } if (-1 == fcntl (fd, F_SETFL, (f & ~O_NONBLOCK))) { - eRet = oslTranslateFileError (OSL_FET_ERROR, errno); + int saved_errno = errno; + OSL_TRACE("osl_openFile(%s, %s): fcntl(%d, F_SETFL) failed: %s", + cpFilePath, + flags & O_RDWR ? "writeable":"readonly", + fd, + strerror(saved_errno)); + eRet = oslTranslateFileError (OSL_FET_ERROR, saved_errno); (void) close(fd); return eRet; } @@ -976,13 +1008,21 @@ SAL_CALL osl_openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_u struct stat aFileStat; if (-1 == fstat (fd, &aFileStat)) { - eRet = oslTranslateFileError (OSL_FET_ERROR, errno); + int saved_errno = errno; + OSL_TRACE("osl_openFile(%s, %s): fstat(%d) failed: %s", + cpFilePath, + flags & O_RDWR ? "writeable":"readonly", + fd, + strerror(saved_errno)); + eRet = oslTranslateFileError (OSL_FET_ERROR, saved_errno); (void) close(fd); return eRet; } if (!S_ISREG(aFileStat.st_mode)) { /* we only open regular files here */ + OSL_TRACE("osl_openFile(%s): not a regular file", + cpFilePath); (void) close(fd); return osl_File_E_INVAL; } @@ -1011,7 +1051,13 @@ SAL_CALL osl_openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_u if (-1 == fcntl (fd, F_SETLK, &aflock)) { - eRet = oslTranslateFileError (OSL_FET_ERROR, errno); + int saved_errno = errno; + OSL_TRACE("osl_openFile(%s, %s): fcntl(%d, F_SETLK) failed: %s", + cpFilePath, + flags & O_RDWR ? "writeable":"readonly", + fd, + strerror(saved_errno)); + eRet = oslTranslateFileError (OSL_FET_ERROR, saved_errno); (void) close(fd); return eRet; } @@ -1031,9 +1077,10 @@ SAL_CALL osl_openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_u pImpl->m_state |= FileHandle_Impl::STATE_WRITEABLE; pImpl->m_size = sal::static_int_cast< sal_uInt64 >(aFileStat.st_size); - OSL_TRACE("osl_openFile(%d, %s) => %s", pImpl->m_fd, + OSL_TRACE("osl_openFile(%s, %s) => %d", + rtl_string_getStr(pImpl->m_strFilePath), flags & O_RDWR ? "writeable":"readonly", - rtl_string_getStr(pImpl->m_strFilePath)); + pImpl->m_fd); *pHandle = (oslFileHandle)(pImpl); return osl_File_E_None; @@ -1072,6 +1119,8 @@ SAL_CALL osl_closeFile( oslFileHandle Handle ) if (pImpl == 0) return osl_File_E_INVAL; + OSL_TRACE("osl_closeFile(%s:%d)", rtl_string_getStr(pImpl->m_strFilePath), pImpl->m_fd); + if (pImpl->m_kind == FileHandle_Impl::KIND_MEM) { delete pImpl; @@ -1084,7 +1133,6 @@ SAL_CALL osl_closeFile( oslFileHandle Handle ) (void) pthread_mutex_lock (&(pImpl->m_mutex)); /* close(2) implicitly (and unconditionally) unlocks */ - OSL_TRACE("osl_closeFile(%d) => %s", pImpl->m_fd, rtl_string_getStr(pImpl->m_strFilePath)); oslFileError result = pImpl->syncFile(); if (result != osl_File_E_None) { commit 694bb9f5de9128657225f3cab0baa14186c62480 Author: Tor Lillqvist <tlillqv...@suse.com> Date: Thu Apr 5 20:34:41 2012 +0300 Do two fairly useless but often emitted OSL_TRACEs only if OSL_DEBUG_LEVEL > 2 diff --git a/cppu/source/uno/lbmap.cxx b/cppu/source/uno/lbmap.cxx index 219a4bf..0dab901 100644 --- a/cppu/source/uno/lbmap.cxx +++ b/cppu/source/uno/lbmap.cxx @@ -683,7 +683,7 @@ CPPU_DLLPUBLIC void SAL_CALL uno_registerMapping( { OUString aMappingName( getMappingName( pFrom, pTo, pAddPurpose ? OUString(pAddPurpose) : OUString() ) ); -#if OSL_DEBUG_LEVEL > 1 +#if OSL_DEBUG_LEVEL > 2 OString cstr( OUStringToOString( aMappingName, RTL_TEXTENCODING_ASCII_US ) ); OSL_TRACE( "> inserting new mapping: %s", cstr.getStr() ); #endif @@ -723,7 +723,7 @@ CPPU_DLLPUBLIC void SAL_CALL uno_revokeMapping( rData.aMapping2Entry.erase( pEntry->pMapping ); rData.aName2Entry.erase( pEntry->aMappingName ); aGuard.clear(); -#if OSL_DEBUG_LEVEL > 1 +#if OSL_DEBUG_LEVEL > 2 OString cstr( OUStringToOString( pEntry->aMappingName, RTL_TEXTENCODING_ASCII_US ) ); OSL_TRACE( "> revoking mapping %s", cstr.getStr() ); #endif commit 8451dec867e8443349921c3a5a2fa7c5205a30a6 Author: Tor Lillqvist <tlillqv...@suse.com> Date: Thu Apr 5 20:32:33 2012 +0300 dlopen() also the sw and swd libs ahead of time so that they can be debugged diff --git a/android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java b/android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java index 1be2395..76b545f 100644 --- a/android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java +++ b/android/experiments/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java @@ -56,6 +56,8 @@ public class DocumentLoader // makes debugging work better, sigh Bootstrap.dlopen("libvcllo.so"); Bootstrap.dlopen("libmergedlo.so"); + Bootstrap.dlopen("libswdlo.so"); + Bootstrap.dlopen("libswlo.so"); com.sun.star.uno.XComponentContext xContext = null; commit cafcd8577480d79baa070cec3bd1cb973d06f88c Author: Tor Lillqvist <tlillqv...@suse.com> Date: Thu Apr 5 20:31:13 2012 +0300 Set TMPDIR also in non-NativeActivity apps diff --git a/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java index 98df770..b562da8 100644 --- a/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java +++ b/android/Bootstrap/src/org/libreoffice/android/Bootstrap.java @@ -139,6 +139,9 @@ public class Bootstrap extends NativeActivity } if (i != null) putenv("FONTCONFIG_FILE=" + dataDir + "/etc/fonts/fonts.conf"); + + // TMPDIR is used by osl_getTempDirURL() + putenv("TMPDIR=" + activity.getCacheDir().getAbsolutePath()); } @Override @@ -186,9 +189,6 @@ public class Bootstrap extends NativeActivity argv = Arrays.copyOfRange(argv, 1, argv.length-1); } - // TMPDIR is used by osl_getTempDirURL() - putenv("TMPDIR=" + getCacheDir().getAbsolutePath()); - // argv[0] will be replaced by android_main() in lo-bootstrap.c by the // pathname of the mainLibrary. String[] newargv = new String[argv.length + 1]; _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits