[CalendarServer-changes] [7059] CalendarServer/trunk/twistedcaldav/directory/xmlfile.py
source_changes at macosforge.org
source_changes at macosforge.org
Sun Feb 20 13:17:21 PST 2011
Revision: 7059
http://trac.macosforge.org/projects/calendarserver/changeset/7059
Author: sagen at apple.com
Date: 2011-02-20 13:17:21 -0800 (Sun, 20 Feb 2011)
Log Message:
-----------
Fixes the root-owned resources.xml after a migration (FilePath.setContent doesn't maintain file ownership)
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/xmlfile.py
Modified: CalendarServer/trunk/twistedcaldav/directory/xmlfile.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/xmlfile.py 2011-02-20 20:35:12 UTC (rev 7058)
+++ CalendarServer/trunk/twistedcaldav/directory/xmlfile.py 2011-02-20 21:17:21 UTC (rev 7059)
@@ -397,7 +397,25 @@
self.xmlFile.setContent(elementToXML(element))
+ # Fix up the file ownership because setContent doesn't maintain it
+ 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(self.xmlFile.path, uid, gid)
+
+
def createRecord(self, recordType, guid=None, shortNames=(), authIDs=set(),
fullName=None, firstName=None, lastName=None, emailAddresses=set(),
uid=None, password=None, **kwargs):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110220/2fb970ee/attachment.html>
More information about the calendarserver-changes
mailing list