[CalendarServer-changes] [5278] CalendarServer/trunk/twistedcaldav/directory/augment.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 10 09:31:32 PST 2010


Revision: 5278
          http://trac.macosforge.org/projects/calendarserver/changeset/5278
Author:   sagen at apple.com
Date:     2010-03-10 09:31:29 -0800 (Wed, 10 Mar 2010)
Log Message:
-----------
Create augments.xml with the correct ownership.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory/augment.py

Modified: CalendarServer/trunk/twistedcaldav/directory/augment.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/augment.py	2010-03-10 15:31:47 UTC (rev 5277)
+++ CalendarServer/trunk/twistedcaldav/directory/augment.py	2010-03-10 17:31:29 UTC (rev 5278)
@@ -15,6 +15,9 @@
 ##
 
 import copy
+import grp
+import os
+import pwd
 import time
 
 from twisted.internet.defer import inlineCallbacks, returnValue, succeed
@@ -28,7 +31,6 @@
 from twistedcaldav.directory.xmlaugmentsparser import XMLAugmentsParser
 from twistedcaldav.xmlutil import newElementTreeWithRoot, addSubElement,\
     writeXML, readXML
-import os
 
 
 log = Logger()
@@ -183,6 +185,22 @@
                     addSubElement(record, xmlaugmentsparser.ELEMENT_ENABLEADDRESSBOOK, "true")
                     doDefault = False
                 writeXML(missedFile, root)
+
+                # Set permissions
+                uid = -1
+                if config.UserName:
+                    try:
+                        uid = pwd.getpwnam(config.UserName).pw_uid
+                    except KeyError:
+                        self.log_error("User not found: %s" % (config.UserName,))
+                gid = -1
+                if config.GroupName:
+                    try:
+                        gid = grp.getgrnam(config.GroupName).gr_gid
+                    except KeyError:
+                        self.log_error("Group not found: %s" % (config.GroupName,))
+                if uid != -1 and gid != -1:
+                    os.chown(missedFile, uid, gid)
             
         try:
             self.db = self._parseXML()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100310/e7125185/attachment.html>


More information about the calendarserver-changes mailing list