/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 server.py

  • Committer: Teddy Hogeborn
  • Date: 2008-07-31 19:48:05 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080731194805-mseis21dxwrdfqhk
* plugins.d/mandosclient.c (start_mandos_communication): Changed
                                                        "if_index" to
                                                        be of type
                                                        "AvahiIfIndex".
                                                        All callers
                                                        changed.
 (main): Add default values to "interface" and "if_index".  Only
         change if_index from default if "interface" was given.

* server.py (IPv6_TCPServer.server_bind): Bug fix: test if interface
                                          is empty, not if equal to
                                          avahi.IF_UNSPEC.
  (if_nametoindex): Bug fix; typo: assign to _func[0], not func[0].
  (main): Bug fix: Do not set service.interface unless the interface
          setting has been given.

Show diffs side-by-side

added added

removed removed

Lines of Context:
509
509
        """This overrides the normal server_bind() function
510
510
        to bind to an interface if one was specified, and also NOT to
511
511
        bind to an address or port if they were not specified."""
512
 
        if self.settings["interface"] != avahi.IF_UNSPEC:
 
512
        if self.settings["interface"]:
513
513
            # 25 is from /usr/include/asm-i486/socket.h
514
514
            SO_BINDTODEVICE = getattr(socket, "SO_BINDTODEVICE", 25)
515
515
            try:
603
603
            try:
604
604
                libc = ctypes.cdll.LoadLibrary\
605
605
                       (ctypes.util.find_library("c"))
606
 
                func[0] = libc.if_nametoindex
 
606
                _func[0] = libc.if_nametoindex
607
607
                return _func[0](interface)
608
608
            except IOError, e:
609
609
                if e != errno.EINTR:
699
699
    server_settings["debug"] = server_config.getboolean\
700
700
                               (server_section, "debug")
701
701
    del server_config
702
 
    if not server_settings["interface"]:
703
 
        server_settings["interface"] = avahi.IF_UNSPEC
704
702
    
705
703
    # Override the settings from the config file with command line
706
704
    # options, if set.
724
722
    global service
725
723
    service = AvahiService(name = server_settings["servicename"],
726
724
                           type = "_mandos._tcp", );
 
725
    if server_settings["interface"]:
 
726
        service.interface = if_nametoindex(server_settings["interface"])
727
727
    
728
728
    global main_loop
729
729
    global bus
794
794
                                clients=clients)
795
795
    # Find out what port we got
796
796
    service.port = tcp_server.socket.getsockname()[1]
797
 
    logger.debug(u"Now listening on port %d", service.port)
 
797
    logger.debug(u"Now listening on address %r, port %d, flowinfo %d,"
 
798
                 u" scope_id %d" % tcp_server.socket.getsockname())
798
799
    
799
 
    if not server_settings["interface"]:
800
 
        service.interface = if_nametoindex\
801
 
                            (server_settings["interface"])
 
800
    #service.interface = tcp_server.socket.getsockname()[3]
802
801
    
803
802
    try:
804
803
        # From the Avahi example code