[Zodb-checkins] SVN: ZODB/branches/patricks-blob-dir-perm/ Make the blob dir permissions configurable
Patrick Strawderman
cvs-admin at zope.org
Thu Oct 11 22:08:05 UTC 2012
Log message for revision 127974:
Make the blob dir permissions configurable
Changed:
A ZODB/branches/patricks-blob-dir-perm/
U ZODB/branches/patricks-blob-dir-perm/src/ZODB/Connection.py
U ZODB/branches/patricks-blob-dir-perm/src/ZODB/FileStorage/FileStorage.py
U ZODB/branches/patricks-blob-dir-perm/src/ZODB/blob.py
-=-
Property changes on: ZODB/branches/patricks-blob-dir-perm
___________________________________________________________________
Added: svn:ignore
+ build
eggs
.installed.cfg
dist
testing.log
develop-eggs
parts
bin
Added: svn:externals
+
Added: svn:mergeinfo
+ /ZODB/branches/tseaver-persistent_as_egg:127229-127234,127294,127487,127510
Added: svk:merge
+ 62d5b8a3-27da-0310-9561-8e5933582275:/ZODB/branches/tseaver-persistent_as_egg:127510
Modified: ZODB/branches/patricks-blob-dir-perm/src/ZODB/Connection.py
===================================================================
--- ZODB/trunk/src/ZODB/Connection.py 2012-10-11 14:48:15 UTC (rev 127973)
+++ ZODB/branches/patricks-blob-dir-perm/src/ZODB/Connection.py 2012-10-11 22:08:01 UTC (rev 127974)
@@ -1301,7 +1301,7 @@
targetpath = self._getBlobPath()
if not os.path.exists(targetpath):
- os.makedirs(targetpath, 0700)
+ self.db.storage.fshelper.makedirs(path)
targetname = self._getCleanFilename(oid, serial)
rename_or_copy_blob(blobfilename, targetname, chmod=False)
Modified: ZODB/branches/patricks-blob-dir-perm/src/ZODB/FileStorage/FileStorage.py
===================================================================
--- ZODB/trunk/src/ZODB/FileStorage/FileStorage.py 2012-10-11 14:48:15 UTC (rev 127973)
+++ ZODB/branches/patricks-blob-dir-perm/src/ZODB/FileStorage/FileStorage.py 2012-10-11 22:08:01 UTC (rev 127974)
@@ -1167,7 +1167,7 @@
newpath = old+path[lblob_dir:]
dest = os.path.dirname(newpath)
if not os.path.exists(dest):
- os.makedirs(dest, 0700)
+ self.fshelper.makedirs(dest)
os.rename(path, newpath)
handle_dir = handle_file
else:
@@ -1214,7 +1214,7 @@
file_path = os.path.join(path, file_name)
dest = os.path.dirname(old+file_path[lblob_dir:])
if not os.path.exists(dest):
- os.makedirs(dest, 0700)
+ self.fshelper.makedirs(dest)
link_or_copy(file_path, old+file_path[lblob_dir:])
def iterator(self, start=None, stop=None):
Modified: ZODB/branches/patricks-blob-dir-perm/src/ZODB/blob.py
===================================================================
--- ZODB/trunk/src/ZODB/blob.py 2012-10-11 14:48:15 UTC (rev 127973)
+++ ZODB/branches/patricks-blob-dir-perm/src/ZODB/blob.py 2012-10-11 22:08:01 UTC (rev 127974)
@@ -322,7 +322,9 @@
# with blobs and storages needn't indirect through this if they
# want to perform blob storage differently.
- def __init__(self, base_dir, layout_name='automatic'):
+ blob_dir_permissions = 0700
+
+ def __init__(self, base_dir, layout_name='automatic', permissions=None):
self.base_dir = os.path.abspath(base_dir) + os.path.sep
self.temp_dir = os.path.join(base_dir, 'tmp')
@@ -334,14 +336,23 @@
'migrating to the `bushy` layout.', level=logging.WARN)
self.layout_name = layout_name
self.layout = LAYOUTS[layout_name]
+ if permissions is not None:
+ self.blob_dir_permissions = permissions
+ def makedirs(self, path):
+ umask = os.umask(0)
+ try:
+ os.makedirs(path, self.blob_dir_permissions)
+ finally:
+ os.umask(umask)
+
def create(self):
if not os.path.exists(self.base_dir):
- os.makedirs(self.base_dir, 0700)
+ self.makedirs(self.base_dir)
log("Blob directory '%s' does not exist. "
"Created new directory." % self.base_dir)
if not os.path.exists(self.temp_dir):
- os.makedirs(self.temp_dir, 0700)
+ self.makedirs(self.temp_dir)
log("Blob temporary directory '%s' does not exist. "
"Created new directory." % self.temp_dir)
@@ -359,8 +370,9 @@
(self.layout_name, self.base_dir, layout))
def isSecure(self, path):
- """Ensure that (POSIX) path mode bits are 0700."""
- return (os.stat(path).st_mode & 077) == 0
+ """Ensure that (POSIX) path mode bits for others is 0."""
+ # XXX
+ return (os.stat(path).st_mode & stat.S_IRWXO) == 0
def checkSecure(self):
if not self.isSecure(self.base_dir):
@@ -385,7 +397,7 @@
if create and not os.path.exists(path):
try:
- os.makedirs(path, 0700)
+ self.makedirs(path)
except OSError:
# We might have lost a race. If so, the directory
# must exist now
@@ -592,9 +604,10 @@
class BlobStorageMixin(object):
"""A mix-in to help storages support blobs."""
- def _blob_init(self, blob_dir, layout='automatic'):
+ def _blob_init(self, blob_dir, layout='automatic',
+ permissions=None):
# XXX Log warning if storage is ClientStorage
- self.fshelper = FilesystemHelper(blob_dir, layout)
+ self.fshelper = FilesystemHelper(blob_dir, layout, permissions)
self.fshelper.create()
self.fshelper.checkSecure()
self.dirty_oids = []
More information about the Zodb-checkins
mailing list