/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2009-10-02 00:34:19 UTC
  • Revision ID: teddy@fukt.bsnet.se-20091002003419-28cmxz7ls9h60l1m
* mandos (ClientDBus.ReceivedSecret): Renamed to "GotSecret".  All
                                      emitters changed.
  (DBusObjectWithProperties.Introspect): Catch any XML parsing errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
627
627
        """
628
628
        xmlstring = dbus.service.Object.Introspect(self, object_path,
629
629
                                                   connection)
630
 
        document = xml.dom.minidom.parseString(xmlstring)
631
 
        del xmlstring
632
 
        def make_tag(document, name, prop):
633
 
            e = document.createElement(u"property")
634
 
            e.setAttribute(u"name", name)
635
 
            e.setAttribute(u"type", prop._dbus_signature)
636
 
            e.setAttribute(u"access", prop._dbus_access)
637
 
            return e
638
 
        for if_tag in document.getElementsByTagName(u"interface"):
639
 
            for tag in (make_tag(document, name, prop)
640
 
                        for name, prop
641
 
                        in self._get_all_dbus_properties()
642
 
                        if prop._dbus_interface
643
 
                        == if_tag.getAttribute(u"name")):
644
 
                if_tag.appendChild(tag)
645
 
            # Add the names to the return values for the
646
 
            # "org.freedesktop.DBus.Properties" methods
647
 
            if (if_tag.getAttribute(u"name")
648
 
                == u"org.freedesktop.DBus.Properties"):
649
 
                for cn in if_tag.getElementsByTagName(u"method"):
650
 
                    if cn.getAttribute(u"name") == u"Get":
651
 
                        for arg in cn.getElementsByTagName(u"arg"):
652
 
                            if (arg.getAttribute(u"direction")
653
 
                                == u"out"):
654
 
                                arg.setAttribute(u"name", u"value")
655
 
                    elif cn.getAttribute(u"name") == u"GetAll":
656
 
                        for arg in cn.getElementsByTagName(u"arg"):
657
 
                            if (arg.getAttribute(u"direction")
658
 
                                == u"out"):
659
 
                                arg.setAttribute(u"name", u"props")
660
 
        xmlstring = document.toxml(u"utf-8")
661
 
        document.unlink()
 
630
        try:
 
631
            document = xml.dom.minidom.parseString(xmlstring)
 
632
            def make_tag(document, name, prop):
 
633
                e = document.createElement(u"property")
 
634
                e.setAttribute(u"name", name)
 
635
                e.setAttribute(u"type", prop._dbus_signature)
 
636
                e.setAttribute(u"access", prop._dbus_access)
 
637
                return e
 
638
            for if_tag in document.getElementsByTagName(u"interface"):
 
639
                for tag in (make_tag(document, name, prop)
 
640
                            for name, prop
 
641
                            in self._get_all_dbus_properties()
 
642
                            if prop._dbus_interface
 
643
                            == if_tag.getAttribute(u"name")):
 
644
                    if_tag.appendChild(tag)
 
645
                # Add the names to the return values for the
 
646
                # "org.freedesktop.DBus.Properties" methods
 
647
                if (if_tag.getAttribute(u"name")
 
648
                    == u"org.freedesktop.DBus.Properties"):
 
649
                    for cn in if_tag.getElementsByTagName(u"method"):
 
650
                        if cn.getAttribute(u"name") == u"Get":
 
651
                            for arg in cn.getElementsByTagName(u"arg"):
 
652
                                if (arg.getAttribute(u"direction")
 
653
                                    == u"out"):
 
654
                                    arg.setAttribute(u"name", u"value")
 
655
                        elif cn.getAttribute(u"name") == u"GetAll":
 
656
                            for arg in cn.getElementsByTagName(u"arg"):
 
657
                                if (arg.getAttribute(u"direction")
 
658
                                    == u"out"):
 
659
                                    arg.setAttribute(u"name", u"props")
 
660
            xmlstring = document.toxml(u"utf-8")
 
661
            document.unlink()
 
662
        except (AttributeError, xml.dom.DOMException,
 
663
                xml.parsers.expat.ExpatError), error:
 
664
            logger.error(u"Failed to override Introspection method",
 
665
                         error)
662
666
        return xmlstring
663
667
 
664
668
 
802
806
        "D-Bus signal"
803
807
        pass
804
808
    
805
 
    # ReceivedSecret - signal
 
809
    # GotSecret - signal
806
810
    @dbus.service.signal(_interface)
807
 
    def ReceivedSecret(self):
 
811
    def GotSecret(self):
808
812
        "D-Bus signal"
809
813
        pass
810
814
    
1297
1301
                    client.checked_ok()
1298
1302
                    if self.use_dbus:
1299
1303
                        # Emit D-Bus signal
1300
 
                        client.ReceivedSecret()
 
1304
                        client.GotSecret()
1301
1305
                    break
1302
1306
            else:
1303
1307
                logger.error(u"Sending secret to unknown client %s",