[CalendarServer-changes] [13952] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Sep 11 13:20:50 PDT 2014


Revision: 13952
          http://trac.calendarserver.org//changeset/13952
Author:   sagen at apple.com
Date:     2014-09-11 13:20:50 -0700 (Thu, 11 Sep 2014)
Log Message:
-----------
Handle directory-based delegation to groups which don't actually exist.

Modified Paths:
--------------
    CalendarServer/trunk/requirements-stable.txt
    CalendarServer/trunk/txdav/common/datastore/sql.py
    CalendarServer/trunk/txdav/dps/server.py
    CalendarServer/trunk/txdav/who/groups.py
    CalendarServer/trunk/txdav/who/test/test_groups.py

Modified: CalendarServer/trunk/requirements-stable.txt
===================================================================
--- CalendarServer/trunk/requirements-stable.txt	2014-09-11 20:19:50 UTC (rev 13951)
+++ CalendarServer/trunk/requirements-stable.txt	2014-09-11 20:20:50 UTC (rev 13952)
@@ -5,7 +5,7 @@
 # For CalendarServer development, don't try to get these projects from PyPI; use svn.
 
 -e .
--e svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@13948#egg=twextpy
+-e svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@13951#egg=twextpy
 -e svn+http://svn.calendarserver.org/repository/calendarserver/PyKerberos/trunk@13420#egg=kerberos
 -e svn+http://svn.calendarserver.org/repository/calendarserver/PyCalendar/trunk@13802#egg=pycalendar
 

Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py	2014-09-11 20:19:50 UTC (rev 13951)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py	2014-09-11 20:20:50 UTC (rev 13952)
@@ -1099,6 +1099,10 @@
         @type name: C{unicode}
         @type membershipHash: C{str}
         """
+        record = yield self.directoryService().recordWithUID(groupUID)
+        if record is None:
+            returnValue(None)
+
         groupID = yield self._addGroupQuery.on(
             self,
             name=name.encode("utf-8"),
@@ -1106,7 +1110,6 @@
             membershipHash=membershipHash
         )
 
-        record = yield self.directoryService().recordWithUID(groupUID)
         yield self.refreshGroup(
             groupUID, record, groupID, name.encode("utf-8"), membershipHash, True
         )
@@ -1159,7 +1162,12 @@
             savepoint = SavepointAction("groupByUID")
             yield savepoint.acquire(self)
             try:
-                yield self.addGroup(groupUID, u"", "")
+                groupID = yield self.addGroup(groupUID, u"", "")
+                if groupID is None:
+                    # The record does not actually exist within the directory
+                    yield savepoint.release(self)
+                    returnValue((None, None, None, None, None))
+
             except Exception:
                 yield savepoint.rollback(self)
                 results = (

Modified: CalendarServer/trunk/txdav/dps/server.py
===================================================================
--- CalendarServer/trunk/txdav/dps/server.py	2014-09-11 20:19:50 UTC (rev 13951)
+++ CalendarServer/trunk/txdav/dps/server.py	2014-09-11 20:20:50 UTC (rev 13952)
@@ -216,6 +216,9 @@
         fields = {}
         if record is not None:
             for field, value in record.fields.iteritems():
+                # FIXME: need to sort out dealing with enormous groups
+                # if field.name == u"memberDNs":
+                #     continue
                 valueType = record.service.fieldName.valueType(field)
                 if valueType in (unicode, bool):
                     fields[field.name] = value

Modified: CalendarServer/trunk/txdav/who/groups.py
===================================================================
--- CalendarServer/trunk/txdav/who/groups.py	2014-09-11 20:19:50 UTC (rev 13951)
+++ CalendarServer/trunk/txdav/who/groups.py	2014-09-11 20:20:50 UTC (rev 13952)
@@ -385,6 +385,7 @@
             uid=delegatorUID
         )
         readDelegateGroupID = writeDelegateGroupID = None
+
         if readDelegateUID:
             (
                 readDelegateGroupID, _ignore_name, _ignore_hash,
@@ -392,6 +393,10 @@
             ) = (
                 yield txn.groupByUID(readDelegateUID)
             )
+            if readDelegateGroupID is None:
+                # The group record does not actually exist
+                readDelegateUID = None
+
         if writeDelegateUID:
             (
                 writeDelegateGroupID, _ignore_name, _ignore_hash,
@@ -399,6 +404,10 @@
             ) = (
                 yield txn.groupByUID(writeDelegateUID)
             )
+            if writeDelegateGroupID is None:
+                # The group record does not actually exist
+                writeDelegateUID = None
+
         yield txn.assignExternalDelegates(
             delegatorUID, readDelegateGroupID, writeDelegateGroupID,
             readDelegateUID, writeDelegateUID

Modified: CalendarServer/trunk/txdav/who/test/test_groups.py
===================================================================
--- CalendarServer/trunk/txdav/who/test/test_groups.py	2014-09-11 20:19:50 UTC (rev 13951)
+++ CalendarServer/trunk/txdav/who/test/test_groups.py	2014-09-11 20:20:50 UTC (rev 13952)
@@ -354,6 +354,32 @@
             )
         )
 
+        #
+        # Say somebody messed up and stuck a non-existent group UID in
+        # as a delegate
+        #
+        newAssignments = {
+            u"__wsanchez1__":
+            (
+                u"__sub_group_1__",
+                u"__non_existent_group__",
+            ),
+        }
+        yield self.groupCacher.scheduleExternalAssignments(
+            txn, newAssignments, immediately=True
+        )
+        oldExternalAssignments = (yield txn.externalDelegates())
+        self.assertEquals(
+            oldExternalAssignments,
+            {
+                u"__wsanchez1__":
+                (
+                    u"__sub_group_1__",
+                    None  # <--- (not __non_existent_group__)
+                ),
+            }
+        )
+
         yield txn.commit()
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140911/0e6efaf5/attachment-0001.html>


More information about the calendarserver-changes mailing list