=== modified file 'plugins.d/mandosclient.c' --- plugins.d/mandosclient.c 2008-07-29 03:35:39 +0000 +++ plugins.d/mandosclient.c 2008-07-31 19:48:05 +0000 @@ -343,7 +343,7 @@ __attribute__((unused)) const char *txt){} int start_mandos_communication(const char *ip, uint16_t port, - unsigned int if_index){ + AvahiIfIndex if_index){ int ret, tcp_sd; struct sockaddr_in6 to; encrypted_session es; @@ -367,7 +367,7 @@ return -1; } - if(if_indextoname(if_index, interface) == NULL){ + if(if_indextoname((unsigned int)if_index, interface) == NULL){ if(debug){ perror("if_indextoname"); } @@ -564,8 +564,7 @@ fprintf(stderr, "Mandos server \"%s\" found on %s (%s) on" " port %d\n", name, host_name, ip, port); } - int ret = start_mandos_communication(ip, port, - (unsigned int) interface); + int ret = start_mandos_communication(ip, port, interface); if (ret == 0){ exit(EXIT_SUCCESS); } @@ -629,8 +628,8 @@ int error; int ret; int returncode = EXIT_SUCCESS; - const char *interface = "eth0"; - unsigned int if_index; + const char *interface = NULL; + AvahiIfIndex if_index = AVAHI_IF_UNSPEC; char *connect_to = NULL; while (true){ @@ -662,10 +661,12 @@ } } - if_index = if_nametoindex(interface); - if(if_index == 0){ - fprintf(stderr, "No such interface: \"%s\"\n", interface); - exit(EXIT_FAILURE); + if(interface != NULL){ + if_index = (AvahiIfIndex) if_nametoindex(interface); + if(if_index == 0){ + fprintf(stderr, "No such interface: \"%s\"\n", interface); + exit(EXIT_FAILURE); + } } if(connect_to != NULL){ @@ -729,7 +730,7 @@ } /* Create the service browser */ - sb = avahi_s_service_browser_new(server, (AvahiIfIndex)if_index, + sb = avahi_s_service_browser_new(server, if_index, AVAHI_PROTO_INET6, "_mandos._tcp", NULL, 0, browse_callback, server); === modified file 'server.py' --- server.py 2008-07-29 03:35:39 +0000 +++ server.py 2008-07-31 19:48:05 +0000 @@ -509,7 +509,7 @@ """This overrides the normal server_bind() function to bind to an interface if one was specified, and also NOT to bind to an address or port if they were not specified.""" - if self.settings["interface"] != avahi.IF_UNSPEC: + if self.settings["interface"]: # 25 is from /usr/include/asm-i486/socket.h SO_BINDTODEVICE = getattr(socket, "SO_BINDTODEVICE", 25) try: @@ -603,7 +603,7 @@ try: libc = ctypes.cdll.LoadLibrary\ (ctypes.util.find_library("c")) - func[0] = libc.if_nametoindex + _func[0] = libc.if_nametoindex return _func[0](interface) except IOError, e: if e != errno.EINTR: @@ -699,8 +699,6 @@ server_settings["debug"] = server_config.getboolean\ (server_section, "debug") del server_config - if not server_settings["interface"]: - server_settings["interface"] = avahi.IF_UNSPEC # Override the settings from the config file with command line # options, if set. @@ -724,6 +722,8 @@ global service service = AvahiService(name = server_settings["servicename"], type = "_mandos._tcp", ); + if server_settings["interface"]: + service.interface = if_nametoindex(server_settings["interface"]) global main_loop global bus @@ -794,11 +794,10 @@ clients=clients) # Find out what port we got service.port = tcp_server.socket.getsockname()[1] - logger.debug(u"Now listening on port %d", service.port) + logger.debug(u"Now listening on address %r, port %d, flowinfo %d," + u" scope_id %d" % tcp_server.socket.getsockname()) - if not server_settings["interface"]: - service.interface = if_nametoindex\ - (server_settings["interface"]) + #service.interface = tcp_server.socket.getsockname()[3] try: # From the Avahi example code