9
9
* "browse_callback", and parts of "main".
11
11
* Everything else is
12
* Copyright © 2008-2012 Teddy Hogeborn
13
* Copyright © 2008-2012 Björn Påhlsson
12
* Copyright © 2008-2013 Teddy Hogeborn
13
* Copyright © 2008-2013 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 TEMP_FAILURE_RETRY(vfprintf(stream, format, ap));
190
return (int)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,
662
694
ret = init_gnutls_session(&session, mc);
705
737
if(af == AF_INET6){
706
738
to.in6.sin6_port = htons(port);
740
#pragma GCC diagnostic push
741
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
707
743
if(IN6_IS_ADDR_LINKLOCAL /* Spurious warnings from */
708
(&to.in6.sin6_addr)){ /* -Wstrict-aliasing=2 or lower and
744
(&to.in6.sin6_addr)){ /* -Wstrict-aliasing=2 or lower */
746
#pragma GCC diagnostic pop
710
748
if(if_index == AVAHI_IF_UNSPEC){
711
749
fprintf_plus(stderr, "An IPv6 link-local address is"
712
750
" incomplete without a network interface\n");
2006
2042
/* Lower privileges */
2010
perror_plus("seteuid");
2015
/* Remove empty interface names */
2047
/* Remove invalid interface names (except "none") */
2017
2049
char *interface = NULL;
2018
2050
while((interface = argz_next(mc.interfaces, mc.interfaces_size,
2020
if(if_nametoindex(interface) == 0){
2021
if(interface[0] != '\0' and strcmp(interface, "none") != 0){
2052
if(strcmp(interface, "none") != 0
2053
and if_nametoindex(interface) == 0){
2054
if(interface[0] != '\0'){
2022
2055
fprintf_plus(stderr, "Not using nonexisting interface"
2023
2056
" \"%s\"\n", interface);
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)){
2191
/* Bring up interfaces which are down, and remove any "none"s */
2171
2193
char *interface = NULL;
2172
2194
while((interface = argz_next(mc.interfaces, mc.interfaces_size,
2196
/* If interface name is "none", stop bringing up interfaces.
2197
Also remove all instances of "none" from the list */
2198
if(strcmp(interface, "none") == 0){
2199
argz_delete(&mc.interfaces, &mc.interfaces_size,
2202
while((interface = argz_next(mc.interfaces,
2203
mc.interfaces_size, interface))){
2204
if(strcmp(interface, "none") == 0){
2205
argz_delete(&mc.interfaces, &mc.interfaces_size,
2174
2212
bool interface_was_up = interface_is_up(interface);
2175
2213
ret = bring_up_interface(interface, delay);
2176
2214
if(not interface_was_up){
2187
free(mc.interfaces);
2188
mc.interfaces = NULL;
2189
mc.interfaces_size = 0;
2190
2225
if(debug and (interfaces_to_take_down == NULL)){
2191
2226
fprintf_plus(stderr, "No interfaces were brought up\n");
2230
/* If we only got one interface, explicitly use only that one */
2231
if(argz_count(mc.interfaces, mc.interfaces_size) == 1){
2233
fprintf_plus(stderr, "Using only interface \"%s\"\n",
2236
if_index = (AvahiIfIndex)if_nametoindex(mc.interfaces);