=== modified file 'plugins.d/password-request.c' --- plugins.d/password-request.c 2008-08-10 03:32:42 +0000 +++ plugins.d/password-request.c 2008-08-11 08:04:35 +0000 @@ -44,8 +44,6 @@ #include /* memset(), strcmp(), strlen(), strerror(), memcpy(), strcpy() */ #include /* ioctl */ -#include /* ifreq, SIOCGIFFLAGS, SIOCSIFFLAGS, - IFF_UP */ #include /* socket(), inet_pton(), sockaddr, sockaddr_in6, PF_INET6, SOCK_STREAM, INET6_ADDRSTRLEN, @@ -487,7 +485,7 @@ fprintf(stderr, "Bad address: %s\n", ip); return -1; } - to.in6.sin6_port = htons(port); /* Spurious warning */ + to.in6.sin6_port = htons(port); /* Spurious warning */ to.in6.sin6_scope_id = (uint32_t)if_index; @@ -893,10 +891,37 @@ } else { gnutls_initalized = true; } - + + /* If the interface is down, bring it up */ + { + sd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP); + if(sd < 0) { + perror("socket"); + exitcode = EXIT_FAILURE; + goto end; + } + strcpy(network.ifr_name, interface); /* Spurious warning */ + ret = ioctl(sd, SIOCGIFFLAGS, &network); + if(ret == -1){ + perror("ioctl SIOCGIFFLAGS"); + exitcode = EXIT_FAILURE; + goto end; + } + if((network.ifr_flags & IFF_UP) == 0){ + network.ifr_flags |= IFF_UP; + ret = ioctl(sd, SIOCSIFFLAGS, &network); + if(ret == -1){ + perror("ioctl SIOCSIFFLAGS"); + exitcode = EXIT_FAILURE; + goto end; + } + } + close(sd); + } + uid = getuid(); gid = getgid(); - + ret = setuid(uid); if (ret == -1){ perror("setuid"); @@ -940,33 +965,6 @@ goto end; } - /* If the interface is down, bring it up */ - { - sd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP); - if(sd < 0) { - perror("socket"); - exitcode = EXIT_FAILURE; - goto end; - } - strcpy(network.ifr_name, interface); /* Spurious warning */ - ret = ioctl(sd, SIOCGIFFLAGS, &network); - if(ret == -1){ - perror("ioctl SIOCGIFFLAGS"); - exitcode = EXIT_FAILURE; - goto end; - } - if((network.ifr_flags & IFF_UP) == 0){ - network.ifr_flags |= IFF_UP; - ret = ioctl(sd, SIOCSIFFLAGS, &network); - if(ret == -1){ - perror("ioctl SIOCSIFFLAGS"); - exitcode = EXIT_FAILURE; - goto end; - } - } - close(sd); - } - if (not debug){ avahi_set_log_function(empty_log); }