[CalendarServer-changes] [6679] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Dec 9 14:24:37 PST 2010


Revision: 6679
          http://trac.macosforge.org/projects/calendarserver/changeset/6679
Author:   sagen at apple.com
Date:     2010-12-09 14:24:31 -0800 (Thu, 09 Dec 2010)
Log Message:
-----------
Fixing the attachment directory permissions problem when using system postgres.

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-12-09 17:59:29 UTC (rev 6678)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py	2010-12-09 22:24:31 UTC (rev 6679)
@@ -879,11 +879,11 @@
             and returns L{IService}
 
         @param uid: the user ID to run the backend as, if this process is
-            running as root.
+            running as root (also the uid to chown Attachments to).
         @type uid: C{int}
 
         @param gid: the user ID to run the backend as, if this process is
-            running as root.
+            running as root (also the gid to chown Attachments to).
         @type gid: C{int}
 
         @return: the appropriate a service to start.
@@ -891,25 +891,29 @@
         @rtype: L{IService}
         """
         if config.UseDatabase:
+
+            if os.getuid() == 0: # Only override if root
+                overrideUID = uid
+                overrideGID = gid
+            else:
+                overrideUID = None
+                overrideGID = None
+
             if config.DBType == '':
                 # Spawn our own database as an inferior process, then connect
                 # to it.
-                if os.getuid() == 0: # Only override if root
-                    postgresUID = uid
-                    postgresGID = gid
-                else:
-                    postgresUID = None
-                    postgresGID = None
                 pgserv = pgServiceFromConfig(
                     config,
-                    self.subServiceFactoryFactory(createMainService, postgresUID, postgresGID),
-                    postgresUID, postgresGID
+                    self.subServiceFactoryFactory(createMainService,
+                        uid=overrideUID, gid=overrideGID),
+                    uid=overrideUID, gid=overrideGID
                 )
                 return pgserv
             elif config.DBType == 'postgres':
                 # Connect to a postgres database that is already running.
                 import pgdb
-                return self.subServiceFactoryFactory(createMainService)(
+                return self.subServiceFactoryFactory(createMainService,
+                    uid=overrideUID, gid=overrideGID)(
                     DBAPIConnector(
                         pgdb, postgresPreflight, config.DSN).connect)
             else:
@@ -920,7 +924,7 @@
 
 
     def subServiceFactoryFactory(self, createMainService,
-                                 postgresUID=None, postgresGID=None):
+                                 uid=None, gid=None):
         def subServiceFactory(connectionFactory):
             ms = MultiService()
             cp = ConnectionPool(connectionFactory)
@@ -929,7 +933,7 @@
             mainService = createMainService(cp, store)
             maybeUpgradeSvc = UpgradeToDatabaseService.wrapService(
                 CachingFilePath(config.DocumentRoot), mainService,
-                store, uid=postgresUID, gid=postgresGID
+                store, uid=uid, gid=gid
             )
             maybeUpgradeSvc.setServiceParent(ms)
             return ms

Modified: CalendarServer/trunk/txdav/common/datastore/util.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/util.py	2010-12-09 17:59:29 UTC (rev 6678)
+++ CalendarServer/trunk/txdav/common/datastore/util.py	2010-12-09 22:24:31 UTC (rev 6679)
@@ -140,7 +140,7 @@
             (self.uid or self.gid)):
             uid = self.uid or -1
             gid = self.gid or -1
-            for fp in self.sqlAttachmentsPath.walk():
+            for fp in sqlAttachmentsPath.walk():
                 os.chown(fp.path, uid, gid)
 
         self.log_warn(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101209/7e7d2713/attachment.html>


More information about the calendarserver-changes mailing list