[CalendarServer-changes] [11549] CalendarServer/trunk/txdav/common/datastore/upgrade/sql/others/ attachment_migration.py

source_changes at macosforge.org source_changes at macosforge.org
Tue Jul 23 13:20:41 PDT 2013


Revision: 11549
          http://trac.calendarserver.org//changeset/11549
Author:   cdaboo at apple.com
Date:     2013-07-23 13:20:41 -0700 (Tue, 23 Jul 2013)
Log Message:
-----------
Make sure permissions are properly set on managed attachment files after upgrade from dropbox.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/common/datastore/upgrade/sql/others/attachment_migration.py

Modified: CalendarServer/trunk/txdav/common/datastore/upgrade/sql/others/attachment_migration.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/upgrade/sql/others/attachment_migration.py	2013-07-23 15:25:36 UTC (rev 11548)
+++ CalendarServer/trunk/txdav/common/datastore/upgrade/sql/others/attachment_migration.py	2013-07-23 20:20:41 UTC (rev 11549)
@@ -17,6 +17,8 @@
 from twisted.internet.defer import inlineCallbacks, returnValue
 from txdav.caldav.datastore.sql import CalendarStoreFeatures
 
+import os
+
 """
 Upgrader that checks for any dropbox attachments, and upgrades them all to managed attachments.
 
@@ -54,6 +56,18 @@
             upgrader.log.warn("No dropbox migration needed")
         if managed is None:
             yield txn.setCalendarserverValue(statusKey, "1")
+
+        # Set attachment directory ownership as upgrade runs as root
+        # but child processes running as something else need to manipulate
+        # the attachment files
+        sqlAttachmentsPath = upgrader.sqlStore.attachmentsPath
+        if (sqlAttachmentsPath and sqlAttachmentsPath.exists() and
+            (upgrader.uid or upgrader.gid)):
+            uid = upgrader.uid or -1
+            gid = upgrader.gid or -1
+            for fp in sqlAttachmentsPath.walk():
+                os.chown(fp.path, uid, gid)
+
     except RuntimeError:
         yield txn.abort()
         raise
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130723/c8a2d112/attachment.html>


More information about the calendarserver-changes mailing list