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

Stephan Bergmann sbergman at redhat.com
Mon May 19 02:44:57 PDT 2014


 include/osl/detail/file.h              |    3 ++-
 sal/osl/unx/file.cxx                   |    9 ++++++---
 unotools/source/ucbhelper/tempfile.cxx |   12 ++++--------
 3 files changed, 12 insertions(+), 12 deletions(-)

New commits:
commit f67702e709a9049042fdd456d2456d35055a935d
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon May 19 11:44:24 2014 +0200

    fdo#60338: Add osl_File_OpenFlag_Private to avoid umask
    
    Change-Id: I293295244d1b089d747548c5025cb73b8ec428a4

diff --git a/include/osl/detail/file.h b/include/osl/detail/file.h
index 96d8807..ee5a172 100644
--- a/include/osl/detail/file.h
+++ b/include/osl/detail/file.h
@@ -19,10 +19,11 @@
  */
 
 /* More flags needed for semantics that match the open() call that
-   used to be in SvFileStream::Open().
+   used to be in SvFileStream::Open(), and for temp files:
 */
 #define osl_File_OpenFlag_Trunc     0x00000010L
 #define osl_File_OpenFlag_NoExcl    0x00000020L
+#define osl_File_OpenFlag_Private   0x00000040L
 
 /** @endcond */
 
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index e781574..a7eaac1 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -853,16 +853,19 @@ openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_uInt32 uFlags,
 #endif
 
     /* set mode and flags */
-    int defmode  = S_IRUSR | S_IRGRP | S_IROTH;
+    int defmode = uFlags & osl_File_OpenFlag_Private
+        ? S_IRUSR : S_IRUSR | S_IRGRP | S_IROTH;
     int flags = O_RDONLY;
     if (uFlags & osl_File_OpenFlag_Write)
     {
-        defmode |= S_IWUSR | S_IWGRP | S_IWOTH;
+        defmode |= uFlags & osl_File_OpenFlag_Private
+            ? S_IWUSR : S_IWUSR | S_IWGRP | S_IWOTH;
         flags = OPEN_WRITE_FLAGS;
     }
     if (uFlags & osl_File_OpenFlag_Create)
     {
-        defmode |= S_IWUSR | S_IWGRP | S_IWOTH;
+        defmode |= uFlags & osl_File_OpenFlag_Private
+            ? S_IWUSR : S_IWUSR | S_IWGRP | S_IWOTH;
         flags = OPEN_CREATE_FLAGS;
     }
     if (mode == mode_t(-1))
diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx
index 8d4152c..5b9cae7 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -29,6 +29,7 @@
 #include <ucbhelper/fileidentifierconverter.hxx>
 #include <rtl/ustring.hxx>
 #include <rtl/instance.hxx>
+#include <osl/detail/file.h>
 #include <osl/file.hxx>
 #include <tools/time.hxx>
 #include <tools/debug.hxx>
@@ -258,14 +259,9 @@ OUString lcl_createName(
         {
             DBG_ASSERT( bKeep, "Too expensive, use directory for creating name!" );
             File aFile( aTmp );
-#ifdef UNX
-            /* RW permission for the user only! */
-            mode_t old_mode = umask(077);
-#endif
-            FileBase::RC err = aFile.open(osl_File_OpenFlag_Create | (bLock ? 0 : osl_File_OpenFlag_NoLock));
-#ifdef UNX
-            umask(old_mode);
-#endif
+            FileBase::RC err = aFile.open(
+                osl_File_OpenFlag_Create | osl_File_OpenFlag_Private
+                | (bLock ? 0 : osl_File_OpenFlag_NoLock));
             if ( err == FileBase::E_None || (bLock && err == FileBase::E_NOLCK) )
             {
                 aFile.close();


More information about the Libreoffice-commits mailing list