[CalendarServer-changes] [6383] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Tue Sep 28 14:04:55 PDT 2010
Revision: 6383
http://trac.macosforge.org/projects/calendarserver/changeset/6383
Author: sagen at apple.com
Date: 2010-09-28 14:04:54 -0700 (Tue, 28 Sep 2010)
Log Message:
-----------
Set proper ownership of attachments directory hierarchy after migration.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tap/caldav.py
CalendarServer/trunk/txdav/common/datastore/util.py
Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py 2010-09-28 20:31:05 UTC (rev 6382)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py 2010-09-28 21:04:54 UTC (rev 6383)
@@ -721,7 +721,8 @@
attachmentsRoot = dbRoot.child("attachments")
return UpgradeToDatabaseService.wrapService(
CachingFilePath(config.DocumentRoot), mainService,
- connectionFactory, attachmentsRoot
+ connectionFactory, attachmentsRoot,
+ uid=postgresUID, gid=postgresGID
)
if os.getuid() == 0: # Only override if root
postgresUID = uid
Modified: CalendarServer/trunk/txdav/common/datastore/util.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/util.py 2010-09-28 20:31:05 UTC (rev 6382)
+++ CalendarServer/trunk/txdav/common/datastore/util.py 2010-09-28 21:04:54 UTC (rev 6383)
@@ -15,6 +15,7 @@
# limitations under the License.
##
+import os
from twext.python.log import LoggingMixIn
from twisted.application.service import Service
from txdav.common.datastore.file import CommonDataStore as FileStore, TOPPATHS
@@ -32,7 +33,8 @@
@classmethod
- def wrapService(cls, path, service, connectionFactory, sqlAttachmentsPath):
+ def wrapService(cls, path, service, connectionFactory, sqlAttachmentsPath,
+ uid=None, gid=None):
"""
Create an L{UpgradeToDatabaseService} if there are still file-based
calendar or addressbook homes remaining in the given path.
@@ -64,19 +66,26 @@
FileStore(path, None, True, True),
SqlStore(connectionFactory, None, sqlAttachmentsPath,
True, True),
- service
+ service,
+ sqlAttachmentsPath=sqlAttachmentsPath,
+ uid=uid,
+ gid=gid,
)
return self
return service
- def __init__(self, fileStore, sqlStore, service):
+ def __init__(self, fileStore, sqlStore, service, sqlAttachmentsPath=None,
+ uid=None, gid=None):
"""
Initialize the service.
"""
self.wrappedService = service
self.fileStore = fileStore
self.sqlStore = sqlStore
+ self.sqlAttachmentsPath = sqlAttachmentsPath
+ self.uid = uid
+ self.gid = gid
@inlineCallbacks
@@ -128,6 +137,14 @@
homesPath = self.fileStore._path.child(homeType)
if homesPath.isdir():
homesPath.remove()
+
+ # Set attachment directory ownership
+ if self.sqlAttachmentsPath and (self.uid or self.gid):
+ uid = self.uid or -1
+ gid = self.gid or -1
+ for fp in self.sqlAttachmentsPath.walk():
+ os.chown(fp.path, uid, gid)
+
self.log_warn(
"Filesystem upgrade complete, launching database service."
)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100928/83a0d95e/attachment.html>
More information about the calendarserver-changes
mailing list