773
774
    const char *pubkeyname = "pubkey.txt";
 
774
775
    const char *seckeyname = "seckey.txt";
 
775
776
    mandos_context mc = { .simple_poll = NULL, .server = NULL,
 
776
 
                          .dh_bits = 1024, .priority = "SECURE256"
 
777
 
                          ":!CTYPE-X.509:+CTYPE-OPENPGP" };
 
 
777
                          .dh_bits = 1024, .priority = "SECURE256"};
 
778
778
    bool gnutls_initalized = false;
 
 
782
782
        { .name = "debug", .key = 128,
 
783
783
          .doc = "Debug mode", .group = 3 },
 
784
784
        { .name = "connect", .key = 'c',
 
785
 
          .arg = "ADDRESS:PORT",
 
786
 
          .doc = "Connect directly to a specific Mandos server",
 
 
786
          .doc = "Connect directly to a sepcified mandos server",
 
788
788
        { .name = "interface", .key = 'i',
 
790
 
          .doc = "Interface that will be used to search for Mandos"
 
 
790
          .doc = "Interface that Avahi will conntect through",
 
793
792
        { .name = "keydir", .key = 'd',
 
795
 
          .doc = "Directory to read the OpenPGP key files from",
 
 
794
          .doc = "Directory where the openpgp keyring is",
 
797
796
        { .name = "seckey", .key = 's',
 
799
 
          .doc = "OpenPGP secret key file base name",
 
 
798
          .doc = "Secret openpgp key for gnutls authentication",
 
801
800
        { .name = "pubkey", .key = 'p',
 
803
 
          .doc = "OpenPGP public key file base name",
 
 
802
          .doc = "Public openpgp key for gnutls authentication",
 
805
804
        { .name = "dh-bits", .key = 129,
 
807
 
          .doc = "Bit length of the prime number used in the"
 
808
 
          " Diffie-Hellman key exchange",
 
 
806
          .doc = "dh-bits to use in gnutls communication",
 
810
808
        { .name = "priority", .key = 130,
 
812
 
          .doc = "GnuTLS priority string for the TLS handshake",
 
 
810
          .doc = "GNUTLS priority", .group = 1 },
 
817
815
      error_t parse_opt (int key, char *arg,
 
818
816
                         struct argp_state *state) {
 
819
817
        /* Get the INPUT argument from `argp_parse', which we know is
 
820
818
           a pointer to our plugin list pointer. */
 
822
 
        case 128:               /* --debug */
 
825
 
        case 'c':               /* --connect */
 
826
824
          connect_to = arg;
 
828
 
        case 'i':               /* --interface */
 
831
 
        case 'd':               /* --keydir */
 
834
 
        case 's':               /* --seckey */
 
835
833
          seckeyname = arg;
 
837
 
        case 'p':               /* --pubkey */
 
838
836
          pubkeyname = arg;
 
840
 
        case 129:               /* --dh-bits */
 
842
840
          mc.dh_bits = (unsigned int) strtol(arg, NULL, 10);
 
 
861
859
      struct argp argp = { .options = options, .parser = parse_opt,
 
863
861
                           .doc = "Mandos client -- Get and decrypt"
 
864
 
                           " passwords from a Mandos server" };
 
 
862
                           " passwords from mandos server" };
 
865
863
      ret = argp_parse (&argp, argc, argv, 0, 0, NULL);
 
866
864
      if (ret == ARGP_ERR_UNKNOWN){
 
867
865
        fprintf(stderr, "Unknown error while parsing arguments\n");
 
 
990
988
      config.publish_addresses = 0;
 
991
989
      config.publish_workstation = 0;
 
992
990
      config.publish_domain = 0;
 
994
992
      /* Allocate a new server */
 
995
993
      mc.server = avahi_server_new(avahi_simple_poll_get
 
996
994
                                   (mc.simple_poll), &config, NULL,
 
999
997
      /* Free the Avahi configuration data */
 
1000
998
      avahi_server_config_free(&config);