[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    [Patch] let KSaveFile honor the umask
From:       Thorsten Zachmann <t.zachmann () zagge ! de>
Date:       2008-03-26 11:20:37
Message-ID: 200803261220.37396.t.zachmann () zagge ! de
[Download RAW message or body]

Hello all,

KSaveFile does not honor the umask for newly created files. Looks like this 
behaviour was introduces during the port to QTemporaryFile which by default 
creates file with permissions 0600. This is good for temporary files but for 
a file saved by an application it is not.
The attached patch changes the behaviour so that the KSaveFile does honor the 
umask for files that are newly created.

Ok to commit?

Thorsten

["ksavefile.diff" (text/x-diff)]

Index: ksavefile.cpp
===================================================================
--- ksavefile.cpp	(revision 789898)
+++ ksavefile.cpp	(working copy)
@@ -119,6 +119,12 @@ bool KSaveFile::open(OpenMode flags)
         if (!fchown(tempFile.handle(), fi.ownerId(), fi.groupId()))
             tempFile.setPermissions(fi.permissions());
     }
+    else {
+        mode_t tmp = 0;
+        mode_t umsk = umask(tmp);
+        umask(umsk);
+        fchmod(tempFile.handle(), 0666&(~umsk));
+    }
 
     //Open oursleves with the temporary file
     QFile::setFileName(tempFile.fileName());


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic