/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/password-request.c

  • Committer: Teddy Hogeborn
  • Date: 2008-08-10 20:35:01 UTC
  • mfrom: (24.1.42 mandos)
  • Revision ID: teddy@fukt.bsnet.se-20080810203501-euh3qcf1nopilksm
Merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#define _LARGEFILE_SOURCE
33
33
#define _FILE_OFFSET_BITS 64
34
34
 
35
 
#define _GNU_SOURCE             /* TEMP_FAILURE_RETRY(), asprintf() */
 
35
#define _GNU_SOURCE             /* TEMP_FAILURE_RETRY() */
36
36
 
37
 
#include <stdio.h>              /* fprintf(), stderr, fwrite(),
38
 
                                   stdout, ferror() */
 
37
#include <stdio.h>              /* fprintf(), stderr, fwrite(), stdout,
 
38
                                   ferror() */
39
39
#include <stdint.h>             /* uint16_t, uint32_t */
40
40
#include <stddef.h>             /* NULL, size_t, ssize_t */
41
41
#include <stdlib.h>             /* free(), EXIT_SUCCESS, EXIT_FAILURE,
42
42
                                   srand() */
43
43
#include <stdbool.h>            /* bool, true */
44
44
#include <string.h>             /* memset(), strcmp(), strlen(),
45
 
                                   strerror(), asprintf(), strcpy() */
 
45
                                   strerror(), memcpy(), strcpy() */
46
46
#include <sys/ioctl.h>          /* ioctl */
 
47
#include <net/if.h>             /* ifreq, SIOCGIFFLAGS, SIOCSIFFLAGS,
 
48
                                   IFF_UP */
47
49
#include <sys/types.h>          /* socket(), inet_pton(), sockaddr,
48
50
                                   sockaddr_in6, PF_INET6,
49
51
                                   SOCK_STREAM, INET6_ADDRSTRLEN,
81
83
#include <avahi-common/error.h>
82
84
 
83
85
/* GnuTLS */
84
 
#include <gnutls/gnutls.h>      /* All GnuTLS types, constants and
85
 
                                   functions:
 
86
#include <gnutls/gnutls.h>      /* All GnuTLS types, constants and functions
86
87
                                   gnutls_*
87
88
                                   init_gnutls_session(),
88
89
                                   GNUTLS_* */
90
91
                                   GNUTLS_OPENPGP_FMT_BASE64 */
91
92
 
92
93
/* GPGME */
93
 
#include <gpgme.h>              /* All GPGME types, constants and
94
 
                                   functions:
 
94
#include <gpgme.h>              /* All GPGME types, constants and functions
95
95
                                   gpgme_*
96
96
                                   GPGME_PROTOCOL_OpenPGP,
97
97
                                   GPG_ERR_NO_* */
214
214
    fprintf(stderr, "bad gpgme_op_decrypt: %s: %s\n",
215
215
            gpgme_strsource(rc), gpgme_strerror(rc));
216
216
    plaintext_length = -1;
217
 
    if (debug){
218
 
      gpgme_decrypt_result_t result;
219
 
      result = gpgme_op_decrypt_result(ctx);
220
 
      if (result == NULL){
221
 
        fprintf(stderr, "gpgme_op_decrypt_result failed\n");
222
 
      } else {
223
 
        fprintf(stderr, "Unsupported algorithm: %s\n",
224
 
                result->unsupported_algorithm);
225
 
        fprintf(stderr, "Wrong key usage: %u\n",
226
 
                result->wrong_key_usage);
227
 
        if(result->file_name != NULL){
228
 
          fprintf(stderr, "File name: %s\n", result->file_name);
229
 
        }
230
 
        gpgme_recipient_t recipient;
231
 
        recipient = result->recipients;
232
 
        if(recipient){
233
 
          while(recipient != NULL){
234
 
            fprintf(stderr, "Public key algorithm: %s\n",
235
 
                    gpgme_pubkey_algo_name(recipient->pubkey_algo));
236
 
            fprintf(stderr, "Key ID: %s\n", recipient->keyid);
237
 
            fprintf(stderr, "Secret key available: %s\n",
238
 
                    recipient->status == GPG_ERR_NO_SECKEY
239
 
                    ? "No" : "Yes");
240
 
            recipient = recipient->next;
241
 
          }
242
 
        }
243
 
      }
244
 
    }
245
217
    goto decrypt_end;
246
218
  }
247
219
  
249
221
    fprintf(stderr, "Decryption of OpenPGP data succeeded\n");
250
222
  }
251
223
  
 
224
  if (debug){
 
225
    gpgme_decrypt_result_t result;
 
226
    result = gpgme_op_decrypt_result(ctx);
 
227
    if (result == NULL){
 
228
      fprintf(stderr, "gpgme_op_decrypt_result failed\n");
 
229
    } else {
 
230
      fprintf(stderr, "Unsupported algorithm: %s\n",
 
231
              result->unsupported_algorithm);
 
232
      fprintf(stderr, "Wrong key usage: %u\n",
 
233
              result->wrong_key_usage);
 
234
      if(result->file_name != NULL){
 
235
        fprintf(stderr, "File name: %s\n", result->file_name);
 
236
      }
 
237
      gpgme_recipient_t recipient;
 
238
      recipient = result->recipients;
 
239
      if(recipient){
 
240
        while(recipient != NULL){
 
241
          fprintf(stderr, "Public key algorithm: %s\n",
 
242
                  gpgme_pubkey_algo_name(recipient->pubkey_algo));
 
243
          fprintf(stderr, "Key ID: %s\n", recipient->keyid);
 
244
          fprintf(stderr, "Secret key available: %s\n",
 
245
                  recipient->status == GPG_ERR_NO_SECKEY
 
246
                  ? "No" : "Yes");
 
247
          recipient = recipient->next;
 
248
        }
 
249
      }
 
250
    }
 
251
  }
 
252
  
252
253
  /* Seek back to the beginning of the GPGME plaintext data buffer */
253
254
  if (gpgme_data_seek(dh_plain, (off_t) 0, SEEK_SET) == -1){
254
255
    perror("pgpme_data_seek");
281
282
    }
282
283
    plaintext_length += ret;
283
284
  }
284
 
  
 
285
 
285
286
  if(debug){
286
287
    fprintf(stderr, "Decrypted password is: ");
287
288
    for(ssize_t i = 0; i < plaintext_length; i++){
301
302
}
302
303
 
303
304
static const char * safer_gnutls_strerror (int value) {
304
 
  const char *ret = gnutls_strerror (value); /* Spurious warning */
 
305
  const char *ret = gnutls_strerror (value);
305
306
  if (ret == NULL)
306
307
    ret = "(unknown)";
307
308
  return ret;
314
315
}
315
316
 
316
317
static int init_gnutls_global(mandos_context *mc,
317
 
                              const char *pubkeyfilename,
318
 
                              const char *seckeyfilename){
 
318
                              const char *pubkeyfile,
 
319
                              const char *seckeyfile){
319
320
  int ret;
320
321
  
321
322
  if(debug){
340
341
  /* OpenPGP credentials */
341
342
  gnutls_certificate_allocate_credentials(&mc->cred);
342
343
  if (ret != GNUTLS_E_SUCCESS){
343
 
    fprintf (stderr, "GnuTLS memory error: %s\n", /* Spurious
344
 
                                                     warning */
 
344
    fprintf (stderr, "GnuTLS memory error: %s\n",
345
345
             safer_gnutls_strerror(ret));
346
346
    gnutls_global_deinit ();
347
347
    return -1;
349
349
  
350
350
  if(debug){
351
351
    fprintf(stderr, "Attempting to use OpenPGP certificate %s"
352
 
            " and keyfile %s as GnuTLS credentials\n", pubkeyfilename,
353
 
            seckeyfilename);
 
352
            " and keyfile %s as GnuTLS credentials\n", pubkeyfile,
 
353
            seckeyfile);
354
354
  }
355
355
  
356
356
  ret = gnutls_certificate_set_openpgp_key_file
357
 
    (mc->cred, pubkeyfilename, seckeyfilename,
358
 
     GNUTLS_OPENPGP_FMT_BASE64);
 
357
    (mc->cred, pubkeyfile, seckeyfile, GNUTLS_OPENPGP_FMT_BASE64);
359
358
  if (ret != GNUTLS_E_SUCCESS) {
360
359
    fprintf(stderr,
361
360
            "Error[%d] while reading the OpenPGP key pair ('%s',"
362
 
            " '%s')\n", ret, pubkeyfilename, seckeyfilename);
 
361
            " '%s')\n", ret, pubkeyfile, seckeyfile);
363
362
    fprintf(stdout, "The GnuTLS error is: %s\n",
364
363
            safer_gnutls_strerror(ret));
365
364
    goto globalfail;
380
379
  }
381
380
  
382
381
  gnutls_certificate_set_dh_params(mc->cred, mc->dh_params);
383
 
  
 
382
 
384
383
  return 0;
385
 
  
 
384
 
386
385
 globalfail:
387
 
  
 
386
 
388
387
  gnutls_certificate_free_credentials(mc->cred);
389
388
  gnutls_global_deinit();
390
389
  return -1;
 
390
 
391
391
}
392
392
 
393
393
static int init_gnutls_session(mandos_context *mc,
465
465
    perror("socket");
466
466
    return -1;
467
467
  }
468
 
  
 
468
 
469
469
  if(debug){
470
470
    if(if_indextoname((unsigned int)if_index, interface) == NULL){
471
471
      perror("if_indextoname");
474
474
    fprintf(stderr, "Binding to interface %s\n", interface);
475
475
  }
476
476
  
477
 
  memset(&to, 0, sizeof(to));
 
477
  memset(&to,0,sizeof(to));     /* Spurious warning */
478
478
  to.in6.sin6_family = AF_INET6;
479
479
  /* It would be nice to have a way to detect if we were passed an
480
480
     IPv4 address here.   Now we assume an IPv6 address. */
487
487
    fprintf(stderr, "Bad address: %s\n", ip);
488
488
    return -1;
489
489
  }
490
 
  to.in6.sin6_port = htons(port); /* Spurious warning */
 
490
  to.in6.sin6_port = htons(port);       /* Spurious warning */
491
491
  
492
492
  to.in6.sin6_scope_id = (uint32_t)if_index;
493
493
  
510
510
    perror("connect");
511
511
    return -1;
512
512
  }
513
 
  
 
513
 
514
514
  const char *out = mandos_protocol_version;
515
515
  written = 0;
516
516
  while (true){
534
534
      }
535
535
    }
536
536
  }
537
 
  
 
537
 
538
538
  if(debug){
539
539
    fprintf(stderr, "Establishing TLS session with %s\n", ip);
540
540
  }
541
541
  
542
542
  gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) tcp_sd);
543
 
  
 
543
 
544
544
  do{
545
545
    ret = gnutls_handshake (session);
546
546
  } while(ret == GNUTLS_E_AGAIN or ret == GNUTLS_E_INTERRUPTED);
560
560
    fprintf(stderr, "Retrieving pgp encrypted password from %s\n",
561
561
            ip);
562
562
  }
563
 
  
 
563
 
564
564
  while(true){
565
565
    buffer_capacity = adjustbuffer(&buffer, buffer_length,
566
566
                                   buffer_capacity);
634
634
    } else {
635
635
      retval = -1;
636
636
    }
637
 
  } else {
638
 
    retval = -1;
639
637
  }
640
638
  
641
639
  /* Shutdown procedure */
662
660
                             flags,
663
661
                             void* userdata) {
664
662
  mandos_context *mc = userdata;
665
 
  assert(r);
 
663
  assert(r);                    /* Spurious warning */
666
664
  
667
665
  /* Called whenever a service has been resolved successfully or
668
666
     timed out */
686
684
      }
687
685
      int ret = start_mandos_communication(ip, port, interface, mc);
688
686
      if (ret == 0){
689
 
        avahi_simple_poll_quit(mc->simple_poll);
 
687
        exit(EXIT_SUCCESS);
690
688
      }
691
689
    }
692
690
  }
704
702
                             flags,
705
703
                             void* userdata) {
706
704
  mandos_context *mc = userdata;
707
 
  assert(b);
 
705
  assert(b);                    /* Spurious warning */
708
706
  
709
707
  /* Called whenever a new services becomes available on the LAN or
710
708
     is removed from the LAN */
746
744
 
747
745
/* Combines file name and path and returns the malloced new
748
746
   string. some sane checks could/should be added */
749
 
static char *combinepath(const char *first, const char *second){
750
 
  char *tmp;
751
 
  int ret = asprintf(&tmp, "%s/%s", first, second);
752
 
  if(ret < 0){
 
747
static const char *combinepath(const char *first, const char *second){
 
748
  size_t f_len = strlen(first);
 
749
  size_t s_len = strlen(second);
 
750
  char *tmp = malloc(f_len + s_len + 2);
 
751
  if (tmp == NULL){
753
752
    return NULL;
754
753
  }
 
754
  if(f_len > 0){
 
755
    memcpy(tmp, first, f_len);  /* Spurious warning */
 
756
  }
 
757
  tmp[f_len] = '/';
 
758
  if(s_len > 0){
 
759
    memcpy(tmp + f_len + 1, second, s_len); /* Spurious warning */
 
760
  }
 
761
  tmp[f_len + 1 + s_len] = '\0';
755
762
  return tmp;
756
763
}
757
764
 
768
775
    gid_t gid;
769
776
    char *connect_to = NULL;
770
777
    AvahiIfIndex if_index = AVAHI_IF_UNSPEC;
771
 
    char *pubkeyfilename = NULL;
772
 
    char *seckeyfilename = NULL;
773
 
    const char *pubkeyname = "pubkey.txt";
774
 
    const char *seckeyname = "seckey.txt";
 
778
    const char *pubkeyfile = "pubkey.txt";
 
779
    const char *seckeyfile = "seckey.txt";
775
780
    mandos_context mc = { .simple_poll = NULL, .server = NULL,
776
 
                          .dh_bits = 1024, .priority = "SECURE256"
777
 
                          ":!CTYPE-X.509:+CTYPE-OPENPGP" };
 
781
                          .dh_bits = 1024, .priority = "SECURE256"};
778
782
    bool gnutls_initalized = false;
779
783
    
780
784
    {
782
786
        { .name = "debug", .key = 128,
783
787
          .doc = "Debug mode", .group = 3 },
784
788
        { .name = "connect", .key = 'c',
785
 
          .arg = "ADDRESS:PORT",
786
 
          .doc = "Connect directly to a specific Mandos server",
 
789
          .arg = "IP",
 
790
          .doc = "Connect directly to a sepcified mandos server",
787
791
          .group = 1 },
788
792
        { .name = "interface", .key = 'i',
789
 
          .arg = "NAME",
790
 
          .doc = "Interface that will be used to search for Mandos"
791
 
          " servers",
 
793
          .arg = "INTERFACE",
 
794
          .doc = "Interface that Avahi will conntect through",
792
795
          .group = 1 },
793
796
        { .name = "keydir", .key = 'd',
794
 
          .arg = "DIRECTORY",
795
 
          .doc = "Directory to read the OpenPGP key files from",
 
797
          .arg = "KEYDIR",
 
798
          .doc = "Directory where the openpgp keyring is",
796
799
          .group = 1 },
797
800
        { .name = "seckey", .key = 's',
798
 
          .arg = "FILE",
799
 
          .doc = "OpenPGP secret key file base name",
 
801
          .arg = "SECKEY",
 
802
          .doc = "Secret openpgp key for gnutls authentication",
800
803
          .group = 1 },
801
804
        { .name = "pubkey", .key = 'p',
802
 
          .arg = "FILE",
803
 
          .doc = "OpenPGP public key file base name",
 
805
          .arg = "PUBKEY",
 
806
          .doc = "Public openpgp key for gnutls authentication",
804
807
          .group = 2 },
805
808
        { .name = "dh-bits", .key = 129,
806
809
          .arg = "BITS",
807
 
          .doc = "Bit length of the prime number used in the"
808
 
          " Diffie-Hellman key exchange",
 
810
          .doc = "dh-bits to use in gnutls communication",
809
811
          .group = 2 },
810
812
        { .name = "priority", .key = 130,
811
 
          .arg = "STRING",
812
 
          .doc = "GnuTLS priority string for the TLS handshake",
813
 
          .group = 1 },
 
813
          .arg = "PRIORITY",
 
814
          .doc = "GNUTLS priority", .group = 1 },
814
815
        { .name = NULL }
815
816
      };
 
817
 
816
818
      
817
819
      error_t parse_opt (int key, char *arg,
818
820
                         struct argp_state *state) {
819
821
        /* Get the INPUT argument from `argp_parse', which we know is
820
822
           a pointer to our plugin list pointer. */
821
823
        switch (key) {
822
 
        case 128:               /* --debug */
 
824
        case 128:
823
825
          debug = true;
824
826
          break;
825
 
        case 'c':               /* --connect */
 
827
        case 'c':
826
828
          connect_to = arg;
827
829
          break;
828
 
        case 'i':               /* --interface */
 
830
        case 'i':
829
831
          interface = arg;
830
832
          break;
831
 
        case 'd':               /* --keydir */
 
833
        case 'd':
832
834
          keydir = arg;
833
835
          break;
834
 
        case 's':               /* --seckey */
835
 
          seckeyname = arg;
836
 
          break;
837
 
        case 'p':               /* --pubkey */
838
 
          pubkeyname = arg;
839
 
          break;
840
 
        case 129:               /* --dh-bits */
 
836
        case 's':
 
837
          seckeyfile = arg;
 
838
          break;
 
839
        case 'p':
 
840
          pubkeyfile = arg;
 
841
          break;
 
842
        case 129:
841
843
          errno = 0;
842
844
          mc.dh_bits = (unsigned int) strtol(arg, NULL, 10);
843
845
          if (errno){
845
847
            exit(EXIT_FAILURE);
846
848
          }
847
849
          break;
848
 
        case 130:               /* --priority */
 
850
        case 130:
849
851
          mc.priority = arg;
850
852
          break;
851
853
        case ARGP_KEY_ARG:
852
854
          argp_usage (state);
853
 
        case ARGP_KEY_END:
854
855
          break;
 
856
          case ARGP_KEY_END:
 
857
            break;
855
858
        default:
856
859
          return ARGP_ERR_UNKNOWN;
857
860
        }
858
861
        return 0;
859
862
      }
860
 
      
 
863
 
861
864
      struct argp argp = { .options = options, .parser = parse_opt,
862
865
                           .args_doc = "",
863
866
                           .doc = "Mandos client -- Get and decrypt"
864
 
                           " passwords from a Mandos server" };
 
867
                           " passwords from mandos server" };
865
868
      ret = argp_parse (&argp, argc, argv, 0, 0, NULL);
866
869
      if (ret == ARGP_ERR_UNKNOWN){
867
 
        fprintf(stderr, "Unknown error while parsing arguments\n");
 
870
        fprintf(stderr, "Unkown error while parsing arguments\n");
868
871
        exitcode = EXIT_FAILURE;
869
872
        goto end;
870
873
      }
871
874
    }
872
 
    
873
 
    pubkeyfilename = combinepath(keydir, pubkeyname);
874
 
    if (pubkeyfilename == NULL){
875
 
      perror("combinepath");
876
 
      exitcode = EXIT_FAILURE;
877
 
      goto end;
878
 
    }
879
 
    
880
 
    seckeyfilename = combinepath(keydir, seckeyname);
881
 
    if (seckeyfilename == NULL){
882
 
      perror("combinepath");
883
 
      exitcode = EXIT_FAILURE;
884
 
      goto end;
885
 
    }
886
 
    
887
 
    ret = init_gnutls_global(&mc, pubkeyfilename, seckeyfilename);
 
875
      
 
876
    pubkeyfile = combinepath(keydir, pubkeyfile);
 
877
    if (pubkeyfile == NULL){
 
878
      perror("combinepath");
 
879
      exitcode = EXIT_FAILURE;
 
880
      goto end;
 
881
    }
 
882
    
 
883
    seckeyfile = combinepath(keydir, seckeyfile);
 
884
    if (seckeyfile == NULL){
 
885
      perror("combinepath");
 
886
      goto end;
 
887
    }
 
888
 
 
889
    ret = init_gnutls_global(&mc, pubkeyfile, seckeyfile);
888
890
    if (ret == -1){
889
 
      fprintf(stderr, "init_gnutls_global failed\n");
890
 
      exitcode = EXIT_FAILURE;
 
891
      fprintf(stderr, "init_gnutls_global\n");
891
892
      goto end;
892
893
    } else {
893
894
      gnutls_initalized = true;
894
895
    }
895
 
    
896
 
    /* If the interface is down, bring it up */
897
 
    {
898
 
      sd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP);
899
 
      if(sd < 0) {
900
 
        perror("socket");
901
 
        exitcode = EXIT_FAILURE;
902
 
        goto end;
903
 
      }
904
 
      strcpy(network.ifr_name, interface);
905
 
      ret = ioctl(sd, SIOCGIFFLAGS, &network);
906
 
      if(ret == -1){
907
 
        perror("ioctl SIOCGIFFLAGS");
908
 
        exitcode = EXIT_FAILURE;
909
 
        goto end;
910
 
      }
911
 
      if((network.ifr_flags & IFF_UP) == 0){
912
 
        network.ifr_flags |= IFF_UP;
913
 
        ret = ioctl(sd, SIOCSIFFLAGS, &network);
914
 
        if(ret == -1){
915
 
          perror("ioctl SIOCSIFFLAGS");
916
 
          exitcode = EXIT_FAILURE;
917
 
          goto end;
918
 
        }
919
 
      }
920
 
      close(sd);
921
 
    }
922
 
    
 
896
 
923
897
    uid = getuid();
924
898
    gid = getgid();
925
 
    
 
899
 
926
900
    ret = setuid(uid);
927
901
    if (ret == -1){
928
902
      perror("setuid");
966
940
      goto end;
967
941
    }
968
942
    
 
943
    /* If the interface is down, bring it up */
 
944
    {
 
945
      sd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP);
 
946
      if(sd < 0) {
 
947
        perror("socket");
 
948
        exitcode = EXIT_FAILURE;
 
949
        goto end;
 
950
      }
 
951
      strcpy(network.ifr_name, interface); /* Spurious warning */
 
952
      ret = ioctl(sd, SIOCGIFFLAGS, &network);
 
953
      if(ret == -1){
 
954
        perror("ioctl SIOCGIFFLAGS");
 
955
        exitcode = EXIT_FAILURE;
 
956
        goto end;
 
957
      }
 
958
      if((network.ifr_flags & IFF_UP) == 0){
 
959
        network.ifr_flags |= IFF_UP;
 
960
        ret = ioctl(sd, SIOCSIFFLAGS, &network);
 
961
        if(ret == -1){
 
962
          perror("ioctl SIOCSIFFLAGS");
 
963
          exitcode = EXIT_FAILURE;
 
964
          goto end;
 
965
        }
 
966
      }
 
967
      close(sd);
 
968
    }
 
969
    
969
970
    if (not debug){
970
971
      avahi_set_log_function(empty_log);
971
972
    }
981
982
        exitcode = EXIT_FAILURE;
982
983
        goto end;
983
984
    }
984
 
    
 
985
 
985
986
    {
986
987
      AvahiServerConfig config;
987
988
      /* Do not publish any local Zeroconf records */
990
991
      config.publish_addresses = 0;
991
992
      config.publish_workstation = 0;
992
993
      config.publish_domain = 0;
993
 
      
 
994
 
994
995
      /* Allocate a new server */
995
996
      mc.server = avahi_server_new(avahi_simple_poll_get
996
997
                                   (mc.simple_poll), &config, NULL,
997
998
                                   NULL, &error);
998
 
      
 
999
    
999
1000
      /* Free the Avahi configuration data */
1000
1001
      avahi_server_config_free(&config);
1001
1002
    }
1021
1022
    }
1022
1023
    
1023
1024
    /* Run the main loop */
1024
 
    
 
1025
 
1025
1026
    if (debug){
1026
1027
      fprintf(stderr, "Starting Avahi loop search\n");
1027
1028
    }
1029
1030
    avahi_simple_poll_loop(mc.simple_poll);
1030
1031
    
1031
1032
 end:
1032
 
    
 
1033
 
1033
1034
    if (debug){
1034
1035
      fprintf(stderr, "%s exiting\n", argv[0]);
1035
1036
    }
1040
1041
    
1041
1042
    if (mc.server != NULL)
1042
1043
        avahi_server_free(mc.server);
1043
 
    
 
1044
 
1044
1045
    if (mc.simple_poll != NULL)
1045
1046
        avahi_simple_poll_free(mc.simple_poll);
1046
 
    free(pubkeyfilename);
1047
 
    free(seckeyfilename);
1048
 
    
 
1047
    free(pubkeyfile);
 
1048
    free(seckeyfile);
 
1049
 
1049
1050
    if (gnutls_initalized){
1050
1051
      gnutls_certificate_free_credentials(mc.cred);
1051
1052
      gnutls_global_deinit ();