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

Stephan Bergmann sbergman at redhat.com
Thu Nov 20 02:10:22 PST 2014


 sal/osl/unx/file_misc.cxx |   26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

New commits:
commit 6dbaf74eea8ffeaeeaed3f84e95bff9a7a5fbe5d
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Nov 20 11:09:25 2014 +0100

    Let attemptChangeMetadata work on symlink itself
    
    Change-Id: I42a81e70e76cb4699052815cfd415a8efd902b03

diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index 6972f36..fd1d902 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -868,31 +868,37 @@ void attemptChangeMetadata( const sal_Char* pszFileName, mode_t nMode, time_t nA
 {
     struct utimbuf aTimeBuffer;
 
-    if ( chmod(pszFileName,nMode) < 0 )
+    if ( fchmodat(AT_FDCWD, pszFileName, nMode, AT_SYMLINK_NOFOLLOW) < 0 )
     {
         int e = errno;
         SAL_INFO(
-            "sal.osl", "chmod(" << pszFileName << ") failed with errno " << e);
+            "sal.osl",
+            "fchmodat(" << pszFileName << ") failed with errno " << e);
     }
 
-    aTimeBuffer.actime=nAcTime;
-    aTimeBuffer.modtime=nModTime;
-    if ( utime(pszFileName,&aTimeBuffer) < 0 )
+    // No way to change utime of a symlink itself:
+    if (!S_ISLNK(nMode))
     {
-        int e = errno;
-        SAL_INFO(
-            "sal.osl", "utime(" << pszFileName << ") failed with errno " << e);
+        aTimeBuffer.actime=nAcTime;
+        aTimeBuffer.modtime=nModTime;
+        if ( utime(pszFileName,&aTimeBuffer) < 0 )
+        {
+            int e = errno;
+            SAL_INFO(
+                "sal.osl",
+                "utime(" << pszFileName << ") failed with errno " << e);
+        }
     }
 
     if ( nUID != getuid() )
     {
         nUID=getuid();
     }
-    if ( chown(pszFileName,nUID,nGID) < 0 )
+    if ( lchown(pszFileName,nUID,nGID) < 0 )
     {
         int e = errno;
         SAL_INFO(
-            "sal.osl", "chown(" << pszFileName << ") failed with errno " << e);
+            "sal.osl", "lchown(" << pszFileName << ") failed with errno " << e);
     }
 }
 


More information about the Libreoffice-commits mailing list