/mandos/trunk

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

« back to all changes in this revision

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

  • Committer: Teddy Hogeborn
  • Date: 2009-01-13 04:35:19 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090113043519-0yr39snphoegq8l1
* plugin-runner.c: Only space changes.
* plugins.d/mandos-client.c: - '' -
* plugins.d/password-prompt.c: - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
#include <fcntl.h>              /* open() */
58
58
#include <dirent.h>             /* opendir(), struct dirent, readdir()
59
59
                                 */
60
 
#include <inttypes.h>           /* PRIu16, intmax_t, SCNdMAX */
 
60
#include <inttypes.h>           /* PRIu16, SCNu16 */
61
61
#include <assert.h>             /* assert() */
62
62
#include <errno.h>              /* perror(), errno */
63
63
#include <time.h>               /* time() */
365
365
}
366
366
 
367
367
static const char * safer_gnutls_strerror(int value) {
368
 
  const char *ret = gnutls_strerror(value); /* Spurious warning from
369
 
                                               -Wunreachable-code */
 
368
  const char *ret = gnutls_strerror(value); /* Spurious warning */
370
369
  if(ret == NULL)
371
370
    ret = "(unknown)";
372
371
  return ret;
405
404
  /* OpenPGP credentials */
406
405
  gnutls_certificate_allocate_credentials(&mc->cred);
407
406
  if(ret != GNUTLS_E_SUCCESS){
408
 
    fprintf(stderr, "GnuTLS memory error: %s\n", /* Spurious warning
409
 
                                                  * from
410
 
                                                  * -Wunreachable-code
411
 
                                                  */
 
407
    fprintf(stderr, "GnuTLS memory error: %s\n", /* Spurious
 
408
                                                    warning */
412
409
            safer_gnutls_strerror(ret));
413
410
    gnutls_global_deinit();
414
411
    return -1;
556
553
    fprintf(stderr, "Bad address: %s\n", ip);
557
554
    return -1;
558
555
  }
559
 
  to.in6.sin6_port = htons(port); /* Spurious warnings from
560
 
                                     -Wconversion and
561
 
                                     -Wunreachable-code */
 
556
  to.in6.sin6_port = htons(port); /* Spurious warning */
562
557
  
563
558
  to.in6.sin6_scope_id = (uint32_t)if_index;
564
559
  
754
749
      avahi_address_snprint(ip, sizeof(ip), address);
755
750
      if(debug){
756
751
        fprintf(stderr, "Mandos server \"%s\" found on %s (%s, %"
757
 
                PRIdMAX ") on port %" PRIu16 "\n", name, host_name,
758
 
                ip, (intmax_t)interface, port);
 
752
                PRIu16 ") on port %d\n", name, host_name, ip,
 
753
                interface, port);
759
754
      }
760
755
      int ret = start_mandos_communication(ip, port, interface, mc);
761
756
      if(ret == 0){
821
816
    AvahiSServiceBrowser *sb = NULL;
822
817
    int error;
823
818
    int ret;
824
 
    intmax_t tmpmax;
825
 
    int numchars;
826
819
    int exitcode = EXIT_SUCCESS;
827
820
    const char *interface = "eth0";
828
821
    struct ifreq network;
893
886
          pubkey = arg;
894
887
          break;
895
888
        case 129:               /* --dh-bits */
896
 
          ret = sscanf(arg, "%" SCNdMAX "%n", &tmpmax, &numchars);
897
 
          if(ret < 1 or tmpmax != (typeof(mc.dh_bits))tmpmax
898
 
             or arg[numchars] != '\0'){
 
889
          ret = sscanf(arg, "%u", &mc.dh_bits);
 
890
          if(ret != 1){
899
891
            fprintf(stderr, "Bad number of DH bits\n");
900
892
            exit(EXIT_FAILURE);
901
893
          }
902
 
          mc.dh_bits = (typeof(mc.dh_bits))tmpmax;
903
894
          break;
904
895
        case 130:               /* --priority */
905
896
          mc.priority = arg;
1008
999
        goto end;
1009
1000
      }
1010
1001
      uint16_t port;
1011
 
      ret = sscanf(address+1, "%" SCNdMAX "%n", &tmpmax, &numchars);
1012
 
      if(ret < 1 or tmpmax != (uint16_t)tmpmax
1013
 
         or address[numchars+1] != '\0'){
 
1002
      ret = sscanf(address+1, "%" SCNu16, &port);
 
1003
      if(ret != 1){
1014
1004
        fprintf(stderr, "Bad port number\n");
1015
1005
        exitcode = EXIT_FAILURE;
1016
1006
        goto end;
1017
1007
      }
1018
 
      port = (uint16_t)tmpmax;
1019
1008
      *address = '\0';
1020
1009
      address = connect_to;
1021
1010
      ret = start_mandos_communication(address, port, if_index, &mc);