Skip to content

Commit 481af5b

Browse files
author
Justus Pendleton
committed
respect umask on filestorage backend (fixes [SF#744328])
patch from Ulrik Mikaelsson also: some trailing whitespace got removed
1 parent 9c1cfc4 commit 481af5b

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

roundup/backends/back_anydbm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.205 2007-08-31 15:44:02 jpend Exp $
18+
#$Id: back_anydbm.py,v 1.206 2007-09-11 21:33:30 jpend Exp $
1919
'''This module defines a backend that saves the hyperdatabase in a
2020
database chosen by anydbm. It is guaranteed to always be available in python
2121
versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
@@ -85,6 +85,7 @@ def __init__(self, config, journaltag=None):
8585
Class.set(), Class.retire(), and Class.restore() methods are
8686
disabled.
8787
'''
88+
FileStorage.__init__(self, config.UMASK)
8889
self.config, self.journaltag = config, journaltag
8990
self.dir = config.DATABASE
9091
self.classes = {}

roundup/backends/blobfiles.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
# FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17-
#
18-
#$Id: blobfiles.py,v 1.19 2005-06-08 03:35:18 anthonybaxter Exp $
17+
#
18+
#$Id: blobfiles.py,v 1.20 2007-09-11 21:33:30 jpend Exp $
1919
'''This module exports file storage for roundup backends.
2020
Files are stored into a directory hierarchy.
2121
'''
@@ -36,22 +36,25 @@ def files_in_dir(dir):
3636
return num_files
3737

3838
class FileStorage:
39-
"""Store files in some directory structure"""
39+
def __init__(self, umask):
40+
self.umask = umask
41+
42+
"""Store files in some directory structure"""
4043
def subdirFilename(self, classname, nodeid, property=None):
4144
"""Determine what the filename and subdir for nodeid + classname is."""
4245
if property:
4346
name = '%s%s.%s'%(classname, nodeid, property)
4447
else:
45-
# roundupdb.FileClass never specified the property name, so don't
48+
# roundupdb.FileClass never specified the property name, so don't
4649
# include it
4750
name = '%s%s'%(classname, nodeid)
48-
51+
4952
# have a separate subdir for every thousand messages
5053
subdir = str(int(nodeid) / 1000)
5154
return os.path.join(subdir, name)
52-
55+
5356
def filename(self, classname, nodeid, property=None, create=0):
54-
'''Determine what the filename for the given node and optionally
57+
'''Determine what the filename for the given node and optionally
5558
property is.
5659
5760
Try a variety of different filenames - the file could be in the
@@ -101,6 +104,10 @@ def storefile(self, classname, nodeid, property, content):
101104
# save off the rename action
102105
self.transactions.append((self.doStoreFile, (classname, nodeid,
103106
property)))
107+
# always set umask before writing to make sure we have the proper one
108+
# in multi-tracker (i.e. multi-umask) or modpython scenarios
109+
# the umask may have changed since last we set it.
110+
os.umask(self.umask)
104111
open(name, 'wb').write(content)
105112

106113
def getfile(self, classname, nodeid, property):

roundup/backends/rdbms_common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: rdbms_common.py,v 1.188 2007-08-31 15:44:02 jpend Exp $
18+
#$Id: rdbms_common.py,v 1.189 2007-09-11 21:33:30 jpend Exp $
1919
""" Relational database (SQL) backend common code.
2020
2121
Basics:
@@ -106,6 +106,7 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database):
106106
def __init__(self, config, journaltag=None):
107107
""" Open the database and load the schema from it.
108108
"""
109+
FileStorage.__init__(self, config.UMASK)
109110
self.config, self.journaltag = config, journaltag
110111
self.dir = config.DATABASE
111112
self.classes = {}

0 commit comments

Comments
 (0)