/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"
398
399
        # is as it should be.
399
400
        
400
401
        # If a checker exists, make sure it is not a zombie
401
 
        if self.checker is not None:
 
402
        try:
402
403
            pid, status = os.waitpid(self.checker.pid, os.WNOHANG)
 
404
        except (AttributeError, OSError), error:
 
405
            if (isinstance(error, OSError)
 
406
                and error.errno != errno.ECHILD):
 
407
                raise error
 
408
        else:
403
409
            if pid:
404
410
                logger.warning(u"Checker was a zombie")
405
411
                gobject.source_remove(self.checker_callback_tag)
620
626
        """Standard D-Bus method, overloaded to insert property tags.
621
627
        """
622
628
        xmlstring = dbus.service.Object.Introspect(self, object_path,
623
 
                                           connection)
624
 
        document = xml.dom.minidom.parseString(xmlstring)
625
 
        del xmlstring
626
 
        def make_tag(document, name, prop):
627
 
            e = document.createElement(u"property")
628
 
            e.setAttribute(u"name", name)
629
 
            e.setAttribute(u"type", prop._dbus_signature)
630
 
            e.setAttribute(u"access", prop._dbus_access)
631
 
            return e
632
 
        for if_tag in document.getElementsByTagName(u"interface"):
633
 
            for tag in (make_tag(document, name, prop)
634
 
                        for name, prop
635
 
                        in self._get_all_dbus_properties()
636
 
                        if prop._dbus_interface
637
 
                        == if_tag.getAttribute(u"name")):
638
 
                if_tag.appendChild(tag)
639
 
        xmlstring = document.toxml(u"utf-8")
640
 
        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)
641
666
        return xmlstring
642
667
 
643
668
 
781
806
        "D-Bus signal"
782
807
        pass
783
808
    
784
 
    # ReceivedSecret - signal
 
809
    # GotSecret - signal
785
810
    @dbus.service.signal(_interface)
786
 
    def ReceivedSecret(self):
 
811
    def GotSecret(self):
787
812
        "D-Bus signal"
788
813
        pass
789
814
    
1276
1301
                    client.checked_ok()
1277
1302
                    if self.use_dbus:
1278
1303
                        # Emit D-Bus signal
1279
 
                        client.ReceivedSecret()
 
1304
                        client.GotSecret()
1280
1305
                    break
1281
1306
            else:
1282
1307
                logger.error(u"Sending secret to unknown client %s",
1367
1392
        null = os.open(os.path.devnull, os.O_NOCTTY | os.O_RDWR)
1368
1393
        if not stat.S_ISCHR(os.fstat(null).st_mode):
1369
1394
            raise OSError(errno.ENODEV,
1370
 
                          u"/dev/null not a character device")
 
1395
                          u"%s not a character device"
 
1396
                          % os.path.devnull)
1371
1397
        os.dup2(null, sys.stdin.fileno())
1372
1398
        os.dup2(null, sys.stdout.fileno())
1373
1399
        os.dup2(null, sys.stderr.fileno())