[CalendarServer-changes] [5059] CalendarServer/branches/users/sagen/locations-resources-2

source_changes at macosforge.org source_changes at macosforge.org
Mon Feb 8 14:00:36 PST 2010


Revision: 5059
          http://trac.macosforge.org/projects/calendarserver/changeset/5059
Author:   sagen at apple.com
Date:     2010-02-08 14:00:36 -0800 (Mon, 08 Feb 2010)
Log Message:
-----------
Generate an empty resources.xml file if it doesn't exist

Modified Paths:
--------------
    CalendarServer/branches/users/sagen/locations-resources-2/twistedcaldav/directory/xmlfile.py
    CalendarServer/branches/users/sagen/locations-resources-2/twistedcaldav/stdconfig.py

Added Paths:
-----------
    CalendarServer/branches/users/sagen/locations-resources-2/conf/resources.xml

Added: CalendarServer/branches/users/sagen/locations-resources-2/conf/resources.xml
===================================================================
--- CalendarServer/branches/users/sagen/locations-resources-2/conf/resources.xml	                        (rev 0)
+++ CalendarServer/branches/users/sagen/locations-resources-2/conf/resources.xml	2010-02-08 22:00:36 UTC (rev 5059)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+Copyright (c) 2006-2010 Apple Inc. All rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+ -->
+
+<!DOCTYPE accounts SYSTEM "accounts.dtd">
+
+<accounts realm="/Search">
+</accounts>

Modified: CalendarServer/branches/users/sagen/locations-resources-2/twistedcaldav/directory/xmlfile.py
===================================================================
--- CalendarServer/branches/users/sagen/locations-resources-2/twistedcaldav/directory/xmlfile.py	2010-02-08 21:16:23 UTC (rev 5058)
+++ CalendarServer/branches/users/sagen/locations-resources-2/twistedcaldav/directory/xmlfile.py	2010-02-08 22:00:36 UTC (rev 5059)
@@ -24,10 +24,12 @@
 
 from time import time
 import types
+import os, pwd, grp
 
 from twisted.cred.credentials import UsernamePassword
 from twisted.web2.auth.digest import DigestedCredentials
 from twisted.python.filepath import FilePath
+from twistedcaldav.config import config
 
 from twistedcaldav.directory import augment
 from twistedcaldav.directory.directory import DirectoryService, DirectoryError
@@ -60,11 +62,13 @@
                 self.recordType_resources,
             ),
             'cacheTimeout' : 30,
+            'realmName' : '/Search',
         }
         ignored = None
         params = self.getParams(params, defaults, ignored)
 
         self._recordTypes = params['recordTypes']
+        self.realmName = params['realmName']
 
         super(XMLDirectoryService, self).__init__(params['cacheTimeout'])
 
@@ -72,6 +76,31 @@
         if type(xmlFile) is str:
             xmlFile = FilePath(xmlFile)
 
+        if not xmlFile.exists():
+            xmlFile.setContent("""<?xml version="1.0" encoding="utf-8"?>
+
+<accounts realm="%s">
+</accounts>
+""" % (self.realmName,))
+
+        uid = -1
+        if config.UserName:
+            try:
+                uid = pwd.getpwnam(config.UserName).pw_uid
+            except KeyError:
+                log.error("User not found: %s" % (config.UserName,))
+
+        gid = -1
+        if config.GroupName:
+            try:
+                gid = grp.getgrnam(config.GroupName).gr_gid
+            except KeyError:
+                log.error("Group not found: %s" % (config.GroupName,))
+
+        if uid != -1 and gid != -1:
+            os.chown(xmlFile.path, uid, gid)
+
+
         self.xmlFile = xmlFile
         self._fileInfo = None
         self._lastCheck = 0

Modified: CalendarServer/branches/users/sagen/locations-resources-2/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/users/sagen/locations-resources-2/twistedcaldav/stdconfig.py	2010-02-08 21:16:23 UTC (rev 5058)
+++ CalendarServer/branches/users/sagen/locations-resources-2/twistedcaldav/stdconfig.py	2010-02-08 22:00:36 UTC (rev 5059)
@@ -53,6 +53,7 @@
     "twistedcaldav.directory.xmlfile.XMLDirectoryService": {
         "xmlFile": "/etc/caldavd/resources.xml",
         "cacheTimeout": 30,
+        "realmName": "/Search",
         "recordTypes" : ("locations", "resources"),
     },
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100208/3d41fd13/attachment.html>


More information about the calendarserver-changes mailing list