/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to plugins.d/mandos-client.c

  • Committer: Teddy Hogeborn
  • Date: 2017-02-22 21:45:35 UTC
  • mto: (237.7.594 trunk)
  • mto: This revision was merged to the branch mainline in revision 358.
  • Revision ID: teddy@recompile.se-20170222214535-milf6w0b1krwpaex
Server bug fix: Use the mandos.conf "zeroconf" and "restore" options

Allow the "zeroconf" and "restore" options to actually work from the
mandos.conf file, in addition to command line options.

Closes: 855589
Reported-by: Pablo Abelenda <pabelenda@igalia.com>
Suggested-by: Pablo Abelenda <pabelenda@igalia.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
                                   strtof(), abort() */
48
48
#include <stdbool.h>            /* bool, false, true */
49
49
#include <string.h>             /* strcmp(), strlen(), strerror(),
50
 
                                   asprintf(), strncpy() */
 
50
                                   asprintf(), strncpy(), strsignal()
 
51
                                */
51
52
#include <sys/ioctl.h>          /* ioctl */
52
53
#include <sys/types.h>          /* socket(), inet_pton(), sockaddr,
53
54
                                   sockaddr_in6, PF_INET6,
625
626
                     safer_gnutls_strerror(ret));
626
627
        dhparamsfilename = NULL;
627
628
      }
 
629
      free(params.data);
628
630
    } while(false);
629
631
  }
630
632
  if(dhparamsfilename == NULL){
1077
1079
    bool match = false;
1078
1080
    {
1079
1081
      char *interface = NULL;
1080
 
      while((interface=argz_next(mc->interfaces, mc->interfaces_size,
1081
 
                                 interface))){
 
1082
      while((interface = argz_next(mc->interfaces,
 
1083
                                   mc->interfaces_size,
 
1084
                                   interface))){
1082
1085
        if(if_nametoindex(interface) == (unsigned int)if_index){
1083
1086
          match = true;
1084
1087
          break;
1237
1240
           with an explicit route added with the server's address.
1238
1241
           
1239
1242
           Avahi bug reference:
1240
 
           http://lists.freedesktop.org/archives/avahi/2010-February/001833.html
 
1243
           https://lists.freedesktop.org/archives/avahi/2010-February/001833.html
1241
1244
           https://bugs.debian.org/587961
1242
1245
        */
1243
1246
        if(debug){
1423
1426
                                               &decrypted_buffer, mc);
1424
1427
    if(decrypted_buffer_size >= 0){
1425
1428
      
 
1429
      clearerr(stdout);
1426
1430
      written = 0;
1427
1431
      while(written < (size_t) decrypted_buffer_size){
1428
1432
        if(quit_now){
1444
1448
        }
1445
1449
        written += (size_t)ret;
1446
1450
      }
 
1451
      ret = fflush(stdout);
 
1452
      if(ret != 0){
 
1453
        int e = errno;
 
1454
        if(debug){
 
1455
          fprintf_plus(stderr, "Error writing encrypted data: %s\n",
 
1456
                       strerror(errno));
 
1457
        }
 
1458
        errno = e;
 
1459
        goto mandos_end;
 
1460
      }
1447
1461
      retval = 0;
1448
1462
    }
1449
1463
  }
1480
1494
  return retval;
1481
1495
}
1482
1496
 
1483
 
__attribute__((nonnull))
1484
1497
static void resolve_callback(AvahiSServiceResolver *r,
1485
1498
                             AvahiIfIndex interface,
1486
1499
                             AvahiProtocol proto,
2183
2196
  
2184
2197
  /* Sleep checking until interface is running.
2185
2198
     Check every 0.25s, up to total time of delay */
2186
 
  for(int i=0; i < delay * 4; i++){
 
2199
  for(int i = 0; i < delay * 4; i++){
2187
2200
    if(interface_is_running(interface)){
2188
2201
      break;
2189
2202
    }
2485
2498
  
2486
2499
  {
2487
2500
    /* Work around Debian bug #633582:
2488
 
       <http://bugs.debian.org/633582> */
 
2501
       <https://bugs.debian.org/633582> */
2489
2502
    
2490
2503
    /* Re-raise privileges */
2491
2504
    ret = raise_privileges();
2946
2959
 end:
2947
2960
  
2948
2961
  if(debug){
2949
 
    fprintf_plus(stderr, "%s exiting\n", argv[0]);
 
2962
    if(signal_received){
 
2963
      fprintf_plus(stderr, "%s exiting due to signal %d: %s\n",
 
2964
                   argv[0], signal_received,
 
2965
                   strsignal(signal_received));
 
2966
    } else {
 
2967
      fprintf_plus(stderr, "%s exiting\n", argv[0]);
 
2968
    }
2950
2969
  }
2951
2970
  
2952
2971
  /* Cleanup things */
3004
3023
      /* Take down the network interfaces which were brought up */
3005
3024
      {
3006
3025
        char *interface = NULL;
3007
 
        while((interface=argz_next(interfaces_to_take_down,
3008
 
                                   interfaces_to_take_down_size,
3009
 
                                   interface))){
 
3026
        while((interface = argz_next(interfaces_to_take_down,
 
3027
                                     interfaces_to_take_down_size,
 
3028
                                     interface))){
3010
3029
          ret = take_down_interface(interface);
3011
3030
          if(ret != 0){
3012
3031
            errno = ret;