[Libreoffice-commits] core.git: 4 commits - sal/osl unotools/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Oct 11 14:15:45 UTC 2018


 sal/osl/unx/file_misc.cxx              |   19 +++++++++++++++----
 unotools/source/ucbhelper/tempfile.cxx |    7 +++++++
 2 files changed, 22 insertions(+), 4 deletions(-)

New commits:
commit fd41fb8392a4e9a27d9fd09071a5f1e2be4b5a0e
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Oct 11 17:00:29 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu Oct 11 17:06:15 2018 +0300

    On iOS, don't create temp files in the folder where a document being edited is
    
    That folder typically is not inside the app sandbox, and the process
    has access only to the one file that they have selected for editing
    there. Trying to create other files in that folder is doomed to fail.
    
    Change-Id: Ib4ff5c7c60aa372eb412e87dc8bbce48ec6d6b54

diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx
index 9b8d7a957c2d..c600a59f5be8 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -118,6 +118,10 @@ static bool ensuredir( const OUString& rUnqPath )
 static OUString ConstructTempDir_Impl( const OUString* pParent )
 {
     OUString aName;
+
+    // Ignore pParent on iOS. We don't want to create any temp files
+    // in the same directory where the document being edited is.
+#ifndef IOS
     if ( pParent && !pParent->isEmpty() )
     {
         // test for valid filename
@@ -136,6 +140,9 @@ static OUString ConstructTempDir_Impl( const OUString* pParent )
                 aName = aRet;
         }
     }
+#else
+    (void) pParent;
+#endif
 
     if ( aName.isEmpty() )
     {
commit cc8cd28f4f66444f8e77c350c5dc64e2dc70af17
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Oct 11 15:43:06 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu Oct 11 17:06:15 2018 +0300

    Do the SAL_INFO() also in the special 'good' ENOENT case
    
    Change-Id: I66c3fb02f4c44adec5c8f663d8845658adfe803f

diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index 60ba5088359d..307a0f81afc7 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -803,15 +803,15 @@ static oslFileError oslDoCopy(const sal_Char* pszSourceFileName, const sal_Char*
         tmpDestFile = rtl::OString(pszDestFileName) + ".osl-tmp";
         if (rename(pszDestFileName, tmpDestFile.getStr()) != 0)
         {
+            int e = errno;
+            SAL_INFO("sal.file", "rename(" << pszDestFileName << ", " << tmpDestFile
+                     << "): errno " << e << ": " << strerror(e));
             if (errno == ENOENT)
             {
                 DestFileExists = 0;
             }
             else
             {
-                int e = errno;
-                SAL_INFO("sal.file", "rename(" << pszDestFileName << ", " << tmpDestFile
-                         << "): errno " << e << ": " << strerror(e));
                 return osl_File_E_EXIST; // for want of a better error code
             }
         }
commit f340ddd7371938333092e0cca4fc035762872340
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Oct 11 15:39:25 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu Oct 11 17:06:15 2018 +0300

    Add SAL_INFO for the open() call in oslDoCopyFile()
    
    Change-Id: I1fde453d5d37481aedec152a1a4da8a85fc6c99b

diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index 2bc713dfd9c6..60ba5088359d 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -964,9 +964,12 @@ static int oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszD
     if ( DestFileFD < 0 )
     {
         nRet=errno;
+        SAL_INFO("sal.file", "open(" << pszDestFileName << ",O_WRONLY|O_CREAT," << std::oct << mode << std::dec << "): errno " << nRet << ": " << strerror(nRet));
         osl_closeFile(SourceFileFH);
         return nRet;
     }
+    else
+        SAL_INFO("sal.file", "open(" << pszDestFileName << ",O_WRONLY|O_CREAT," << std::oct << mode << std::dec << "): OK");
 
     size_t nRemains = nSourceSize;
 
commit 5f438ebe0824f04d08ddf2b39d7f5e02325f2ce3
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Oct 11 15:32:26 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Thu Oct 11 17:06:15 2018 +0300

    Tweak check for nonexistent file on iOS
    
    Calling stat() on a non-existent file outside the sandbox fails with
    EPERM on iOS, not ENOENT. (Presumably calling stat() even on an
    existing file, but one you don't have been granted access to, also
    fails, because that is after all a point of sandboxing, you shouldn't
    even be allowed to figure out whether arbitrary files exist outside
    the sandbox.)
    
    Not sure why this change hasn't been necessary also for a sandboxed
    LibreOffice on macOS.
    
    Change-Id: I67c768e9c34fd17fa35f08232284210ff4a71b98

diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index d44abb3f1c3c..2bc713dfd9c6 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -1,4 +1,4 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
 /*
  * This file is part of the LibreOffice project.
  *
@@ -762,6 +762,14 @@ static oslFileError osl_psz_copyFile( const sal_Char* pszPath, const sal_Char* p
     {
         nRet=errno;
 
+#ifdef IOS
+        // Checking for nonexistent files at least in the iCloud cache directory (like
+        // "/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/helloodt0.odt" fails
+        // with EPERM, not ENOENT.
+        if (nRet == EPERM)
+            DestFileExists=0;
+#endif
+
         if (nRet == ENOENT)
             DestFileExists=0;
     }


More information about the Libreoffice-commits mailing list