/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-18 08:47:40 UTC
  • Revision ID: teddy@fukt.bsnet.se-20091018084740-fa1qgm22lg125r10
* plugins.d/splashy.c: Use exit codes from <sysexits.h>.

Show diffs side-by-side

added added

removed removed

Lines of Context:
292
292
        elif u"secfile" in config:
293
293
            with closing(open(os.path.expanduser
294
294
                              (os.path.expandvars
295
 
                               (config[u"secfile"])))) as secfile:
 
295
                               (config[u"secfile"])),
 
296
                              "rb")) as secfile:
296
297
                self.secret = secfile.read()
297
298
        else:
298
299
            raise TypeError(u"No secret or secfile for client %s"
625
626
        """Standard D-Bus method, overloaded to insert property tags.
626
627
        """
627
628
        xmlstring = dbus.service.Object.Introspect(self, object_path,
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()
 
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)
646
666
        return xmlstring
647
667
 
648
668
 
786
806
        "D-Bus signal"
787
807
        pass
788
808
    
789
 
    # ReceivedSecret - signal
 
809
    # GotSecret - signal
790
810
    @dbus.service.signal(_interface)
791
 
    def ReceivedSecret(self):
 
811
    def GotSecret(self):
792
812
        "D-Bus signal"
793
813
        pass
794
814
    
1281
1301
                    client.checked_ok()
1282
1302
                    if self.use_dbus:
1283
1303
                        # Emit D-Bus signal
1284
 
                        client.ReceivedSecret()
 
1304
                        client.GotSecret()
1285
1305
                    break
1286
1306
            else:
1287
1307
                logger.error(u"Sending secret to unknown client %s",
1372
1392
        null = os.open(os.path.devnull, os.O_NOCTTY | os.O_RDWR)
1373
1393
        if not stat.S_ISCHR(os.fstat(null).st_mode):
1374
1394
            raise OSError(errno.ENODEV,
1375
 
                          u"/dev/null not a character device")
 
1395
                          u"%s not a character device"
 
1396
                          % os.path.devnull)
1376
1397
        os.dup2(null, sys.stdin.fileno())
1377
1398
        os.dup2(null, sys.stdout.fileno())
1378
1399
        os.dup2(null, sys.stderr.fileno())