/mandos/release

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

« back to all changes in this revision

Viewing changes to mandos

* mandos (Client.start_checker): Bug fix: Fix race condition with
                                 short intervals.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
        SO_BINDTODEVICE = None
80
80
 
81
81
 
82
 
version = "1.0.13"
 
82
version = "1.0.12"
83
83
 
84
84
logger = logging.Logger(u'mandos')
85
85
syslogger = (logging.handlers.SysLogHandler
292
292
        elif u"secfile" in config:
293
293
            with closing(open(os.path.expanduser
294
294
                              (os.path.expandvars
295
 
                               (config[u"secfile"])),
296
 
                              "rb")) as secfile:
 
295
                               (config[u"secfile"])))) as secfile:
297
296
                self.secret = secfile.read()
298
297
        else:
299
298
            raise TypeError(u"No secret or secfile for client %s"
626
625
        """Standard D-Bus method, overloaded to insert property tags.
627
626
        """
628
627
        xmlstring = dbus.service.Object.Introspect(self, object_path,
629
 
                                                   connection)
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)
 
628
                                           connection)
 
629
        document = xml.dom.minidom.parseString(xmlstring)
 
630
        del xmlstring
 
631
        def make_tag(document, name, prop):
 
632
            e = document.createElement(u"property")
 
633
            e.setAttribute(u"name", name)
 
634
            e.setAttribute(u"type", prop._dbus_signature)
 
635
            e.setAttribute(u"access", prop._dbus_access)
 
636
            return e
 
637
        for if_tag in document.getElementsByTagName(u"interface"):
 
638
            for tag in (make_tag(document, name, prop)
 
639
                        for name, prop
 
640
                        in self._get_all_dbus_properties()
 
641
                        if prop._dbus_interface
 
642
                        == if_tag.getAttribute(u"name")):
 
643
                if_tag.appendChild(tag)
 
644
        xmlstring = document.toxml(u"utf-8")
 
645
        document.unlink()
666
646
        return xmlstring
667
647
 
668
648
 
806
786
        "D-Bus signal"
807
787
        pass
808
788
    
809
 
    # GotSecret - signal
 
789
    # ReceivedSecret - signal
810
790
    @dbus.service.signal(_interface)
811
 
    def GotSecret(self):
 
791
    def ReceivedSecret(self):
812
792
        "D-Bus signal"
813
793
        pass
814
794
    
1301
1281
                    client.checked_ok()
1302
1282
                    if self.use_dbus:
1303
1283
                        # Emit D-Bus signal
1304
 
                        client.GotSecret()
 
1284
                        client.ReceivedSecret()
1305
1285
                    break
1306
1286
            else:
1307
1287
                logger.error(u"Sending secret to unknown client %s",
1392
1372
        null = os.open(os.path.devnull, os.O_NOCTTY | os.O_RDWR)
1393
1373
        if not stat.S_ISCHR(os.fstat(null).st_mode):
1394
1374
            raise OSError(errno.ENODEV,
1395
 
                          u"%s not a character device"
1396
 
                          % os.path.devnull)
 
1375
                          u"/dev/null not a character device")
1397
1376
        os.dup2(null, sys.stdin.fileno())
1398
1377
        os.dup2(null, sys.stdout.fileno())
1399
1378
        os.dup2(null, sys.stderr.fileno())