在設置ZOPE/ZEO設置的備份例程時,我遇到了與blob權限相同的問題。
在嘗試應用Mikko寫的猴子補丁(這並不容易)後,我想出了一個「真正的」補丁來解決這個問題。
Martijn建議的修補程序不完整,它仍然沒有在blob文件上設置正確的模式。
因此,這裏是我的解決方案:
1)創建一個包含補丁:
Index: ZODB/blob.py
===================================================================
--- ZODB/blob.py (Revision 121959)
+++ ZODB/blob.py (Arbeitskopie)
@@ -337,11 +337,11 @@
def create(self):
if not os.path.exists(self.base_dir):
- os.makedirs(self.base_dir, 0700)
+ os.makedirs(self.base_dir, 0750)
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)
+ os.makedirs(self.temp_dir, 0750)
log("Blob temporary directory '%s' does not exist. "
"Created new directory." % self.temp_dir)
@@ -359,8 +359,8 @@
(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 are 0750."""
+ return (os.stat(path).st_mode & 027) == 0
def checkSecure(self):
if not self.isSecure(self.base_dir):
@@ -385,7 +385,7 @@
if create and not os.path.exists(path):
try:
- os.makedirs(path, 0700)
+ os.makedirs(path, 0750)
except OSError:
# We might have lost a race. If so, the directory
# must exist now
@@ -891,7 +891,7 @@
file2.close()
remove_committed(f1)
if chmod:
- os.chmod(f2, stat.S_IREAD)
+ os.chmod(f2, stat.S_IRUSR | stat.S_IRGRP)
if sys.platform == 'win32':
# On Windows, you can't remove read-only files, so make the
您還可以看看這裏的補丁 - >http://pastebin.com/wNLYyXvw
2)存儲在您的buildout根目錄中名稱爲'blob.patch'的補丁
3.)擴展您的buildout配置:
parts +=
patchblob
postinstall
[patchblob]
recipe = collective.recipe.patch
egg = ZODB3
patches = blob.patch
[postinstall]
recipe = plone.recipe.command
command =
chmod -R g+r ${buildout:directory}/var
find ${buildout:directory}/var -type d | xargs chmod g+x
update-command = ${:command}
postinstall部分在已存在的斑點上設置所需的組讀取權限。請注意,還必須將執行權限授予blob文件夾,該組可以進入目錄。
我用ZODB 3.10.2和3.10.3測試了這個補丁。
正如Martijn所建議的,這應該是可配置的,並且可以直接作爲ZODB的一部分。
在ZEO設置中,我應該打補丁ZEO服務器,對吧?用服務器和客戶端做了一些測試,看起來像客戶端的猴子補丁沒有運行(嘗試上傳文件,沒有發生任何事情)。 – 2011-05-29 20:05:21
@Mikko:在ZEO設置中,您確實想要修補ZEO服務器和客戶端。據推測,你已將shared-blob-dir設置爲True,在這種情況下,客戶端和服務器都將使用blob數據目錄。 無論如何,您可能首先想要在獨立的設置上進行測試。此外,現有的blob datadir結構必須更新權限(chmod -R g + r),因爲此修補程序不會更改現有目錄,而只會更改新創建的目錄。 – 2011-05-29 20:24:35
謝謝Martjin。這裏是正在進行的工作:https://github.com/miohtama/collective.xsendfile – 2011-05-29 22:54:12