9
9
* "browse_callback", and parts of "main".
11
11
* Everything else is
12
* Copyright © 2008-2013 Teddy Hogeborn
13
* Copyright © 2008-2013 Björn Påhlsson
12
* Copyright © 2008-2012 Teddy Hogeborn
13
* Copyright © 2008-2012 Björn Påhlsson
15
15
* This program is free software: you can redistribute it and/or
16
16
* modify it under the terms of the GNU General Public License as
188
188
TEMP_FAILURE_RETRY(fprintf(stream, "Mandos plugin %s: ",
189
189
program_invocation_short_name));
190
return (int)TEMP_FAILURE_RETRY(vfprintf(stream, format, ap));
190
return TEMP_FAILURE_RETRY(vfprintf(stream, format, ap));
662
/* If the interface is specified and we have a list of interfaces */
663
if(if_index != AVAHI_IF_UNSPEC and mc->interfaces != NULL){
664
/* Check if the interface is one of the interfaces we are using */
667
char *interface = NULL;
668
while((interface=argz_next(mc->interfaces, mc->interfaces_size,
670
if(if_nametoindex(interface) == (unsigned int)if_index){
677
/* This interface does not match any in the list, so we don't
678
connect to the server */
680
char interface[IF_NAMESIZE];
681
if(if_indextoname((unsigned int)if_index, interface) == NULL){
682
perror_plus("if_indextoname");
684
fprintf_plus(stderr, "Skipping server on non-used interface"
686
if_indextoname((unsigned int)if_index,
694
662
ret = init_gnutls_session(&session, mc);
2038
2006
/* Lower privileges */
2010
perror_plus("seteuid");
2043
/* Remove invalid interface names (except "none") */
2015
/* Remove empty interface names */
2045
2017
char *interface = NULL;
2046
2018
while((interface = argz_next(mc.interfaces, mc.interfaces_size,
2048
if(strcmp(interface, "none") != 0
2049
and if_nametoindex(interface) == 0){
2050
if(interface[0] != '\0'){
2020
if(if_nametoindex(interface) == 0){
2021
if(interface[0] != '\0' and strcmp(interface, "none") != 0){
2051
2022
fprintf_plus(stderr, "Not using nonexisting interface"
2052
2023
" \"%s\"\n", interface);
2187
/* Bring up interfaces which are down, and remove any "none"s */
2159
/* If we only got one interface, explicitly use only that one */
2160
if(argz_count(mc.interfaces, mc.interfaces_size) == 1){
2162
fprintf_plus(stderr, "Using only interface \"%s\"\n",
2165
if_index = (AvahiIfIndex)if_nametoindex(mc.interfaces);
2168
/* Bring up interfaces which are down */
2169
if(not (argz_count(mc.interfaces, mc.interfaces_size) == 1
2170
and strcmp(mc.interfaces, "none") == 0)){
2189
2171
char *interface = NULL;
2190
2172
while((interface = argz_next(mc.interfaces, mc.interfaces_size,
2192
/* If interface name is "none", stop bringing up interfaces.
2193
Also remove all instances of "none" from the list */
2194
if(strcmp(interface, "none") == 0){
2195
argz_delete(&mc.interfaces, &mc.interfaces_size,
2198
while((interface = argz_next(mc.interfaces,
2199
mc.interfaces_size, interface))){
2200
if(strcmp(interface, "none") == 0){
2201
argz_delete(&mc.interfaces, &mc.interfaces_size,
2208
2174
bool interface_was_up = interface_is_up(interface);
2209
2175
ret = bring_up_interface(interface, delay);
2210
2176
if(not interface_was_up){
2187
free(mc.interfaces);
2188
mc.interfaces = NULL;
2189
mc.interfaces_size = 0;
2221
2190
if(debug and (interfaces_to_take_down == NULL)){
2222
2191
fprintf_plus(stderr, "No interfaces were brought up\n");
2226
/* If we only got one interface, explicitly use only that one */
2227
if(argz_count(mc.interfaces, mc.interfaces_size) == 1){
2229
fprintf_plus(stderr, "Using only interface \"%s\"\n",
2232
if_index = (AvahiIfIndex)if_nametoindex(mc.interfaces);