/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

merge + fallback bugg

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#     GNU General Public License for more details.
25
25
26
26
# You should have received a copy of the GNU General Public License
27
 
# along with this program.  If not, see
28
 
# <http://www.gnu.org/licenses/>.
 
27
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
29
28
30
29
# Contact the authors at <mandos@fukt.bsnet.se>.
31
30
124
123
    def rename(self):
125
124
        """Derived from the Avahi example code"""
126
125
        if self.rename_count >= self.max_renames:
127
 
            logger.critical(u"No suitable Zeroconf service name found"
128
 
                            u" after %i retries, exiting.",
129
 
                            rename_count)
 
126
            logger.critical(u"No suitable service name found after %i"
 
127
                            u" retries, exiting.", rename_count)
130
128
            raise AvahiServiceError("Too many renames")
131
129
        self.name = server.GetAlternativeServiceName(self.name)
132
 
        logger.info(u"Changing Zeroconf service name to %r ...",
133
 
                    str(self.name))
 
130
        logger.info(u"Changing name to %r ...", str(self.name))
134
131
        syslogger.setFormatter(logging.Formatter\
135
132
                               ('Mandos (%s): %%(levelname)s:'
136
133
                               ' %%(message)s' % self.name))
151
148
                     avahi.DBUS_INTERFACE_ENTRY_GROUP)
152
149
            group.connect_to_signal('StateChanged',
153
150
                                    entry_group_state_changed)
154
 
        logger.debug(u"Adding Zeroconf service '%s' of type '%s' ...",
 
151
        logger.debug(u"Adding service '%s' of type '%s' ...",
155
152
                     service.name, service.type)
156
153
        group.AddService(
157
154
                self.interface,         # interface
416
413
    # Verify the self signature in the key
417
414
    crtverify = ctypes.c_uint();
418
415
    gnutls.library.functions.gnutls_openpgp_crt_verify_self\
419
 
        (crt, 0, ctypes.byref(crtverify))
420
 
    if crtverify.value != 0:
 
416
        (crt, ctypes.c_uint(0), ctypes.byref(crtverify))
 
417
    if crtverify != 0:
421
418
        gnutls.library.functions.gnutls_openpgp_crt_deinit(crt)
422
419
        raise gnutls.errors.CertificateSecurityError("Verify failed")
423
420
    # New buffer for the fingerprint
606
603
def server_state_changed(state):
607
604
    """Derived from the Avahi example code"""
608
605
    if state == avahi.SERVER_COLLISION:
609
 
        logger.error(u"Zeroconf server name collision")
 
606
        logger.error(u"Server name collision")
610
607
        service.remove()
611
608
    elif state == avahi.SERVER_RUNNING:
612
609
        service.add()
614
611
 
615
612
def entry_group_state_changed(state, error):
616
613
    """Derived from the Avahi example code"""
617
 
    logger.debug(u"Avahi state change: %i", state)
 
614
    logger.debug(u"state change: %i", state)
618
615
    
619
616
    if state == avahi.ENTRY_GROUP_ESTABLISHED:
620
 
        logger.debug(u"Zeroconf service established.")
 
617
        logger.debug(u"Service established.")
621
618
    elif state == avahi.ENTRY_GROUP_COLLISION:
622
 
        logger.warning(u"Zeroconf service name collision.")
 
619
        logger.warning(u"Service name collision.")
623
620
        service.rename()
624
621
    elif state == avahi.ENTRY_GROUP_FAILURE:
625
 
        logger.critical(u"Avahi: Error in group state changed %s",
 
622
        logger.critical(u"Error in group state changed %s",
626
623
                        unicode(error))
627
624
        raise AvahiGroupError("State changed: %s", str(error))
628
625
 
762
759
    service = AvahiService(name = server_settings["servicename"],
763
760
                           type = "_mandos._tcp", );
764
761
    if server_settings["interface"]:
765
 
        service.interface = if_nametoindex\
766
 
                            (server_settings["interface"])
 
762
        service.interface = if_nametoindex(server_settings["interface"])
767
763
    
768
764
    global main_loop
769
765
    global bus
772
768
    DBusGMainLoop(set_as_default=True )
773
769
    main_loop = gobject.MainLoop()
774
770
    bus = dbus.SystemBus()
775
 
    server = dbus.Interface(bus.get_object(avahi.DBUS_NAME,
776
 
                                           avahi.DBUS_PATH_SERVER),
777
 
                            avahi.DBUS_INTERFACE_SERVER)
 
771
    server = dbus.Interface(
 
772
            bus.get_object( avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER ),
 
773
            avahi.DBUS_INTERFACE_SERVER )
778
774
    # End of Avahi example code
779
775
    
780
776
    clients = Set()