if using ssh keys with any of the netpgp programs, set the home
directory appropriately. add some aliases for long command options across all programs
This commit is contained in:
parent
8aede0d81f
commit
f46123a333
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
#if defined(__NetBSD__)
|
#if defined(__NetBSD__)
|
||||||
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
|
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
|
||||||
__RCSID("$NetBSD: netpgp.c,v 1.62 2010/07/01 03:52:13 agc Exp $");
|
__RCSID("$NetBSD: netpgp.c,v 1.63 2010/07/01 04:27:21 agc Exp $");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -255,7 +255,7 @@ readsshkeys(netpgp_t *netpgp, char *homedir)
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
if ((filename = netpgp_getvar(netpgp, "sshkeyfile")) == NULL) {
|
if ((filename = netpgp_getvar(netpgp, "sshkeyfile")) == NULL) {
|
||||||
(void) snprintf(f, sizeof(f), "%s/.ssh/id_rsa.pub", homedir);
|
(void) snprintf(f, sizeof(f), "%s/id_rsa.pub", homedir);
|
||||||
filename = f;
|
filename = f;
|
||||||
}
|
}
|
||||||
if ((pubring = calloc(1, sizeof(*pubring))) == NULL) {
|
if ((pubring = calloc(1, sizeof(*pubring))) == NULL) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: netpgp.c,v 1.11 2010/02/06 02:24:34 agc Exp $ */
|
/* $NetBSD: netpgp.c,v 1.12 2010/07/01 04:27:21 agc Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||||
|
@ -125,6 +125,7 @@ static struct option options[] = {
|
||||||
{"show-keys", no_argument, NULL, SHOW_KEYS},
|
{"show-keys", no_argument, NULL, SHOW_KEYS},
|
||||||
{"showkeys", no_argument, NULL, SHOW_KEYS},
|
{"showkeys", no_argument, NULL, SHOW_KEYS},
|
||||||
/* options */
|
/* options */
|
||||||
|
{"ssh", no_argument, NULL, SSHKEYS},
|
||||||
{"ssh-keys", no_argument, NULL, SSHKEYS},
|
{"ssh-keys", no_argument, NULL, SSHKEYS},
|
||||||
{"sshkeyfile", required_argument, NULL, SSHKEYFILE},
|
{"sshkeyfile", required_argument, NULL, SSHKEYFILE},
|
||||||
{"coredumps", no_argument, NULL, COREDUMPS},
|
{"coredumps", no_argument, NULL, COREDUMPS},
|
||||||
|
@ -132,6 +133,7 @@ static struct option options[] = {
|
||||||
{"userid", required_argument, NULL, USERID},
|
{"userid", required_argument, NULL, USERID},
|
||||||
{"home", required_argument, NULL, HOMEDIR},
|
{"home", required_argument, NULL, HOMEDIR},
|
||||||
{"homedir", required_argument, NULL, HOMEDIR},
|
{"homedir", required_argument, NULL, HOMEDIR},
|
||||||
|
{"ascii", no_argument, NULL, ARMOUR},
|
||||||
{"armor", no_argument, NULL, ARMOUR},
|
{"armor", no_argument, NULL, ARMOUR},
|
||||||
{"armour", no_argument, NULL, ARMOUR},
|
{"armour", no_argument, NULL, ARMOUR},
|
||||||
{"detach", no_argument, NULL, DETACHED},
|
{"detach", no_argument, NULL, DETACHED},
|
||||||
|
@ -337,6 +339,7 @@ main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
netpgp_t netpgp;
|
netpgp_t netpgp;
|
||||||
prog_t p;
|
prog_t p;
|
||||||
|
int homeset;
|
||||||
int optindex;
|
int optindex;
|
||||||
int ret;
|
int ret;
|
||||||
int ch;
|
int ch;
|
||||||
|
@ -355,7 +358,7 @@ main(int argc, char **argv)
|
||||||
netpgp_setvar(&netpgp, "hash", DEFAULT_HASH_ALG);
|
netpgp_setvar(&netpgp, "hash", DEFAULT_HASH_ALG);
|
||||||
/* 4 MiB for a memory file */
|
/* 4 MiB for a memory file */
|
||||||
netpgp_setvar(&netpgp, "max mem alloc", "4194304");
|
netpgp_setvar(&netpgp, "max mem alloc", "4194304");
|
||||||
netpgp_set_homedir(&netpgp, getenv("HOME"), "/.gnupg", 1);
|
homeset = 0;
|
||||||
optindex = 0;
|
optindex = 0;
|
||||||
while ((ch = getopt_long(argc, argv, "", options, &optindex)) != -1) {
|
while ((ch = getopt_long(argc, argv, "", options, &optindex)) != -1) {
|
||||||
switch (options[optindex].val) {
|
switch (options[optindex].val) {
|
||||||
|
@ -420,6 +423,7 @@ main(int argc, char **argv)
|
||||||
exit(EXIT_ERROR);
|
exit(EXIT_ERROR);
|
||||||
}
|
}
|
||||||
netpgp_set_homedir(&netpgp, optarg, NULL, 0);
|
netpgp_set_homedir(&netpgp, optarg, NULL, 0);
|
||||||
|
homeset = 1;
|
||||||
break;
|
break;
|
||||||
case HASH_ALG:
|
case HASH_ALG:
|
||||||
if (optarg == NULL) {
|
if (optarg == NULL) {
|
||||||
|
@ -476,6 +480,10 @@ main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!homeset) {
|
||||||
|
netpgp_set_homedir(&netpgp, getenv("HOME"),
|
||||||
|
netpgp_getvar(&netpgp, "ssh keys") ? "/.ssh" : "/.gnupg", 1);
|
||||||
|
}
|
||||||
/* initialise, and read keys from file */
|
/* initialise, and read keys from file */
|
||||||
if (!netpgp_init(&netpgp)) {
|
if (!netpgp_init(&netpgp)) {
|
||||||
printf("can't initialise\n");
|
printf("can't initialise\n");
|
||||||
|
|
|
@ -103,8 +103,13 @@ static struct option options[] = {
|
||||||
{"list-keys", no_argument, NULL, LIST_KEYS},
|
{"list-keys", no_argument, NULL, LIST_KEYS},
|
||||||
{"list-sigs", no_argument, NULL, LIST_SIGS},
|
{"list-sigs", no_argument, NULL, LIST_SIGS},
|
||||||
{"find-key", no_argument, NULL, FIND_KEY},
|
{"find-key", no_argument, NULL, FIND_KEY},
|
||||||
|
{"export", no_argument, NULL, EXPORT_KEY},
|
||||||
{"export-key", no_argument, NULL, EXPORT_KEY},
|
{"export-key", no_argument, NULL, EXPORT_KEY},
|
||||||
|
{"import", no_argument, NULL, IMPORT_KEY},
|
||||||
{"import-key", no_argument, NULL, IMPORT_KEY},
|
{"import-key", no_argument, NULL, IMPORT_KEY},
|
||||||
|
{"gen", optional_argument, NULL, GENERATE_KEY},
|
||||||
|
{"gen-key", optional_argument, NULL, GENERATE_KEY},
|
||||||
|
{"generate", optional_argument, NULL, GENERATE_KEY},
|
||||||
{"generate-key", optional_argument, NULL, GENERATE_KEY},
|
{"generate-key", optional_argument, NULL, GENERATE_KEY},
|
||||||
{"get-key", no_argument, NULL, GET_KEY},
|
{"get-key", no_argument, NULL, GET_KEY},
|
||||||
/* debugging commands */
|
/* debugging commands */
|
||||||
|
@ -121,6 +126,7 @@ static struct option options[] = {
|
||||||
{"home", required_argument, NULL, HOMEDIR},
|
{"home", required_argument, NULL, HOMEDIR},
|
||||||
{"homedir", required_argument, NULL, HOMEDIR},
|
{"homedir", required_argument, NULL, HOMEDIR},
|
||||||
{"numbits", required_argument, NULL, NUMBITS},
|
{"numbits", required_argument, NULL, NUMBITS},
|
||||||
|
{"ssh", no_argument, NULL, SSHKEYS},
|
||||||
{"ssh-keys", no_argument, NULL, SSHKEYS},
|
{"ssh-keys", no_argument, NULL, SSHKEYS},
|
||||||
{"sshkeyfile", required_argument, NULL, SSHKEYFILE},
|
{"sshkeyfile", required_argument, NULL, SSHKEYFILE},
|
||||||
{"verbose", no_argument, NULL, VERBOSE},
|
{"verbose", no_argument, NULL, VERBOSE},
|
||||||
|
@ -196,6 +202,7 @@ main(int argc, char **argv)
|
||||||
struct stat st;
|
struct stat st;
|
||||||
netpgp_t netpgp;
|
netpgp_t netpgp;
|
||||||
prog_t p;
|
prog_t p;
|
||||||
|
int homeset;
|
||||||
int optindex;
|
int optindex;
|
||||||
int ret;
|
int ret;
|
||||||
int ch;
|
int ch;
|
||||||
|
@ -203,6 +210,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
(void) memset(&p, 0x0, sizeof(p));
|
(void) memset(&p, 0x0, sizeof(p));
|
||||||
(void) memset(&netpgp, 0x0, sizeof(netpgp));
|
(void) memset(&netpgp, 0x0, sizeof(netpgp));
|
||||||
|
homeset = 0;
|
||||||
p.progname = argv[0];
|
p.progname = argv[0];
|
||||||
p.numbits = DEFAULT_NUMBITS;
|
p.numbits = DEFAULT_NUMBITS;
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
|
@ -210,7 +218,6 @@ main(int argc, char **argv)
|
||||||
exit(EXIT_ERROR);
|
exit(EXIT_ERROR);
|
||||||
}
|
}
|
||||||
/* set some defaults */
|
/* set some defaults */
|
||||||
netpgp_set_homedir(&netpgp, getenv("HOME"), "/.gnupg", 1);
|
|
||||||
netpgp_setvar(&netpgp, "sshkeydir", "/etc/ssh");
|
netpgp_setvar(&netpgp, "sshkeydir", "/etc/ssh");
|
||||||
netpgp_setvar(&netpgp, "res", "<stdout>");
|
netpgp_setvar(&netpgp, "res", "<stdout>");
|
||||||
netpgp_setvar(&netpgp, "hash", DEFAULT_HASH_ALG);
|
netpgp_setvar(&netpgp, "hash", DEFAULT_HASH_ALG);
|
||||||
|
@ -273,6 +280,7 @@ main(int argc, char **argv)
|
||||||
exit(EXIT_ERROR);
|
exit(EXIT_ERROR);
|
||||||
}
|
}
|
||||||
netpgp_set_homedir(&netpgp, optarg, NULL, 0);
|
netpgp_set_homedir(&netpgp, optarg, NULL, 0);
|
||||||
|
homeset = 1;
|
||||||
break;
|
break;
|
||||||
case NUMBITS:
|
case NUMBITS:
|
||||||
if (optarg == NULL) {
|
if (optarg == NULL) {
|
||||||
|
@ -318,6 +326,10 @@ main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!homeset) {
|
||||||
|
netpgp_set_homedir(&netpgp, getenv("HOME"),
|
||||||
|
netpgp_getvar(&netpgp, "ssh keys") ? "/.ssh" : "/.gnupg", 1);
|
||||||
|
}
|
||||||
/* initialise, and read keys from file */
|
/* initialise, and read keys from file */
|
||||||
if (!netpgp_init(&netpgp)) {
|
if (!netpgp_init(&netpgp)) {
|
||||||
if (stat(netpgp_getvar(&netpgp, "homedir"), &st) < 0) {
|
if (stat(netpgp_getvar(&netpgp, "homedir"), &st) < 0) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: verify.c,v 1.13 2010/06/01 06:07:56 agc Exp $ */
|
/* $NetBSD: verify.c,v 1.14 2010/07/01 04:27:21 agc Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2009,2010 The NetBSD Foundation, Inc.
|
* Copyright (c) 2009,2010 The NetBSD Foundation, Inc.
|
||||||
|
@ -96,6 +96,7 @@ static struct option options[] = {
|
||||||
{"help", no_argument, NULL, HELP_CMD},
|
{"help", no_argument, NULL, HELP_CMD},
|
||||||
{"version", no_argument, NULL, VERSION_CMD},
|
{"version", no_argument, NULL, VERSION_CMD},
|
||||||
/* options */
|
/* options */
|
||||||
|
{"ssh", no_argument, NULL, SSHKEYS},
|
||||||
{"ssh-keys", no_argument, NULL, SSHKEYS},
|
{"ssh-keys", no_argument, NULL, SSHKEYS},
|
||||||
{"sshkeyfile", required_argument, NULL, SSHKEYFILE},
|
{"sshkeyfile", required_argument, NULL, SSHKEYFILE},
|
||||||
{"coredumps", no_argument, NULL, COREDUMPS},
|
{"coredumps", no_argument, NULL, COREDUMPS},
|
||||||
|
@ -231,12 +232,14 @@ main(int argc, char **argv)
|
||||||
netpgp_t netpgp;
|
netpgp_t netpgp;
|
||||||
prog_t p;
|
prog_t p;
|
||||||
int optindex;
|
int optindex;
|
||||||
|
int homeset;
|
||||||
int ret;
|
int ret;
|
||||||
int ch;
|
int ch;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
(void) memset(&p, 0x0, sizeof(p));
|
(void) memset(&p, 0x0, sizeof(p));
|
||||||
(void) memset(&netpgp, 0x0, sizeof(netpgp));
|
(void) memset(&netpgp, 0x0, sizeof(netpgp));
|
||||||
|
homeset = 0;
|
||||||
p.progname = argv[0];
|
p.progname = argv[0];
|
||||||
p.overwrite = 1;
|
p.overwrite = 1;
|
||||||
p.output = NULL;
|
p.output = NULL;
|
||||||
|
@ -248,7 +251,6 @@ main(int argc, char **argv)
|
||||||
netpgp_setvar(&netpgp, "hash", DEFAULT_HASH_ALG);
|
netpgp_setvar(&netpgp, "hash", DEFAULT_HASH_ALG);
|
||||||
/* 4 MiB for a memory file */
|
/* 4 MiB for a memory file */
|
||||||
netpgp_setvar(&netpgp, "max mem alloc", "4194304");
|
netpgp_setvar(&netpgp, "max mem alloc", "4194304");
|
||||||
netpgp_set_homedir(&netpgp, getenv("HOME"), "/.gnupg", 1);
|
|
||||||
optindex = 0;
|
optindex = 0;
|
||||||
while ((ch = getopt_long(argc, argv, "", options, &optindex)) != -1) {
|
while ((ch = getopt_long(argc, argv, "", options, &optindex)) != -1) {
|
||||||
switch (options[optindex].val) {
|
switch (options[optindex].val) {
|
||||||
|
@ -299,6 +301,7 @@ main(int argc, char **argv)
|
||||||
exit(EXIT_ERROR);
|
exit(EXIT_ERROR);
|
||||||
}
|
}
|
||||||
netpgp_set_homedir(&netpgp, optarg, NULL, 0);
|
netpgp_set_homedir(&netpgp, optarg, NULL, 0);
|
||||||
|
homeset = 1;
|
||||||
break;
|
break;
|
||||||
case OUTPUT:
|
case OUTPUT:
|
||||||
if (optarg == NULL) {
|
if (optarg == NULL) {
|
||||||
|
@ -330,6 +333,10 @@ main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!homeset) {
|
||||||
|
netpgp_set_homedir(&netpgp, getenv("HOME"),
|
||||||
|
netpgp_getvar(&netpgp, "ssh keys") ? "/.ssh" : "/.gnupg", 1);
|
||||||
|
}
|
||||||
/* initialise, and read keys from file */
|
/* initialise, and read keys from file */
|
||||||
if (!netpgp_init(&netpgp)) {
|
if (!netpgp_init(&netpgp)) {
|
||||||
printf("can't initialise\n");
|
printf("can't initialise\n");
|
||||||
|
|
Loading…
Reference in New Issue