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