/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

Support not using IPv6 in server:

* mandos (AvahiService.__init__): Take new "protocol" parameter.  All
                                  callers changed.
  (IPv6_TCPServer.__init__): Take new "use_ipv6" parameter.  All
                             callers changed.
  (IPv6_TCPServer.server_bind): Create IPv4 socket if not using IPv6.
  (main): New "--no-ipv6" command line option.  New "use_ipv6" config
          option.
* mandos-options.xml ([@id="address"]): Document conditional IPv4
                                        address support.
  ([@id="ipv6"]): New paragraph.
* mandos.conf (use_ipv6): New config option.
* mandos.conf.xml (OPTIONS): Document new "use_dbus" option.
  (EXAMPLE): Changed to use IPv6 link-local address.  Added "use_ipv6"
             option.
* mandos.xml (SYNOPSIS): New "--no-ipv6" option.
  (OPTIONS): Document new "--no-ipv6" option.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 */
31
31
 
32
32
/* Needed by GPGME, specifically gpgme_data_seek() */
33
 
#ifndef _LARGEFILE_SOURCE
34
33
#define _LARGEFILE_SOURCE
35
 
#endif
36
 
#ifndef _FILE_OFFSET_BITS
37
34
#define _FILE_OFFSET_BITS 64
38
 
#endif
39
35
 
40
36
#define _GNU_SOURCE             /* TEMP_FAILURE_RETRY(), asprintf() */
41
37
 
309
305
        }
310
306
        gpgme_recipient_t recipient;
311
307
        recipient = result->recipients;
312
 
        while(recipient != NULL){
313
 
          fprintf(stderr, "Public key algorithm: %s\n",
314
 
                  gpgme_pubkey_algo_name(recipient->pubkey_algo));
315
 
          fprintf(stderr, "Key ID: %s\n", recipient->keyid);
316
 
          fprintf(stderr, "Secret key available: %s\n",
317
 
                  recipient->status == GPG_ERR_NO_SECKEY
318
 
                  ? "No" : "Yes");
319
 
          recipient = recipient->next;
 
308
        if(recipient){
 
309
          while(recipient != NULL){
 
310
            fprintf(stderr, "Public key algorithm: %s\n",
 
311
                    gpgme_pubkey_algo_name(recipient->pubkey_algo));
 
312
            fprintf(stderr, "Key ID: %s\n", recipient->keyid);
 
313
            fprintf(stderr, "Secret key available: %s\n",
 
314
                    recipient->status == GPG_ERR_NO_SECKEY
 
315
                    ? "No" : "Yes");
 
316
            recipient = recipient->next;
 
317
          }
320
318
        }
321
319
      }
322
320
    }
564
562
  
565
563
  memset(&to, 0, sizeof(to));
566
564
  if(af == AF_INET6){
567
 
    to.in6.sin6_family = (sa_family_t)af;
 
565
    to.in6.sin6_family = (uint16_t)af;
568
566
    ret = inet_pton(af, ip, &to.in6.sin6_addr);
569
567
  } else {                      /* IPv4 */
570
568
    to.in.sin_family = (sa_family_t)af;
899
897
  int exitcode = EXIT_SUCCESS;
900
898
  const char *interface = "eth0";
901
899
  struct ifreq network;
902
 
  int sd = -1;
903
 
  bool interface_taken_up = false;
 
900
  int sd;
904
901
  uid_t uid;
905
902
  gid_t gid;
906
903
  char *connect_to = NULL;
1114
1111
#endif  /* __linux__ */
1115
1112
        goto end;
1116
1113
      }
1117
 
      interface_taken_up = true;
1118
1114
    }
1119
1115
    /* sleep checking until interface is running */
1120
1116
    for(int i=0; i < delay * 4; i++){
1130
1126
        perror("nanosleep");
1131
1127
      }
1132
1128
    }
1133
 
    if(not interface_taken_up){
1134
 
      ret = (int)TEMP_FAILURE_RETRY(close(sd));
1135
 
      if(ret == -1){
1136
 
        perror("close");
1137
 
      }
 
1129
    ret = (int)TEMP_FAILURE_RETRY(close(sd));
 
1130
    if(ret == -1){
 
1131
      perror("close");
1138
1132
    }
1139
1133
#ifdef __linux__
1140
1134
    if(restore_loglevel){
1301
1295
    gpgme_release(mc.ctx);
1302
1296
  }
1303
1297
  
1304
 
  /* Take down the network interface */
1305
 
  if(interface_taken_up){
1306
 
    ret = ioctl(sd, SIOCGIFFLAGS, &network);
1307
 
    if(ret == -1){
1308
 
      perror("ioctl SIOCGIFFLAGS");
1309
 
    } else if(network.ifr_flags & IFF_UP) {
1310
 
      network.ifr_flags &= ~IFF_UP; /* clear flag */
1311
 
      ret = ioctl(sd, SIOCSIFFLAGS, &network);
1312
 
      if(ret == -1){
1313
 
        perror("ioctl SIOCSIFFLAGS");
1314
 
      }
1315
 
    }
1316
 
    ret = (int)TEMP_FAILURE_RETRY(close(sd));
1317
 
    if(ret == -1){
1318
 
      perror("close");
1319
 
    }
1320
 
  }
1321
 
  
1322
1298
  /* Removes the temp directory used by GPGME */
1323
1299
  if(tempdir_created){
1324
1300
    DIR *d;