changeset 1898:b5e94fec8669

caching: mkstemp uses 0600 to create files, we need chmod to change them to our preferred file mode
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 18 Mar 2007 23:06:11 +0100
parents 5ae7a098f6e4
children 55617b3b1ac9
files MoinMoin/caching.py MoinMoin/util/filesys.py
diffstat 2 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/caching.py	Sun Mar 18 20:31:42 2007 +0100
+++ b/MoinMoin/caching.py	Sun Mar 18 23:06:11 2007 +0100
@@ -9,6 +9,7 @@
 import os
 import tempfile
 
+from MoinMoin import config
 from MoinMoin.util import filesys, lock, pickle, PICKLE_PROTOCOL
 
 
@@ -118,6 +119,7 @@
                     os.close(tmp_handle)
                     # this is either atomic or happening with real locks set:
                     filesys.rename(tmp_fname, fname)
+                    filesys.chmod(fname, 0666 & config.umask) # fix mode that mkstemp chose
                 finally:
                     if self.locking:
                         self.wlock.release()
--- a/MoinMoin/util/filesys.py	Sun Mar 18 20:31:42 2007 +0100
+++ b/MoinMoin/util/filesys.py	Sun Mar 18 23:06:11 2007 +0100
@@ -13,6 +13,18 @@
 ### Misc Helpers
 #############################################################################
 
+def chmod(name, mode, catchexception=True):
+    """ change mode of some file/dir on platforms that support it.
+        usually you don't need this because we use os.umask() when importing
+        request.py
+    """
+    try:
+        os.chmod(name, mode)
+    except OSError:
+        if not catchexception:
+            raise
+
+
 def rename(oldname, newname):
     """ Multiplatform rename