Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/crypto/external/bsd/netpgp/dist/src if using ssh keys with a...



details:   https://anonhg.NetBSD.org/src/rev/c2688487b1fe
branches:  trunk
changeset: 755975:c2688487b1fe
user:      agc <agc%NetBSD.org@localhost>
date:      Thu Jul 01 04:27:21 2010 +0000

description:
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

diffstat:

 crypto/external/bsd/netpgp/dist/src/lib/netpgp.c            |   4 +-
 crypto/external/bsd/netpgp/dist/src/netpgp/netpgp.c         |  12 +++++++++-
 crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c |  14 ++++++++++++-
 crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.c   |  11 ++++++++-
 4 files changed, 34 insertions(+), 7 deletions(-)

diffs (209 lines):

diff -r b29f66bedb90 -r c2688487b1fe crypto/external/bsd/netpgp/dist/src/lib/netpgp.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c  Thu Jul 01 03:52:13 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c  Thu Jul 01 04:27:21 2010 +0000
@@ -34,7 +34,7 @@
 
 #if defined(__NetBSD__)
 __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
 
 #include <sys/types.h>
@@ -255,7 +255,7 @@
        char            *filename;
 
        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;
        }
        if ((pubring = calloc(1, sizeof(*pubring))) == NULL) {
diff -r b29f66bedb90 -r c2688487b1fe crypto/external/bsd/netpgp/dist/src/netpgp/netpgp.c
--- a/crypto/external/bsd/netpgp/dist/src/netpgp/netpgp.c       Thu Jul 01 03:52:13 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgp/netpgp.c       Thu Jul 01 04:27:21 2010 +0000
@@ -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.
@@ -125,6 +125,7 @@
        {"show-keys",   no_argument,            NULL,   SHOW_KEYS},
        {"showkeys",    no_argument,            NULL,   SHOW_KEYS},
        /* options */
+       {"ssh",         no_argument,            NULL,   SSHKEYS},
        {"ssh-keys",    no_argument,            NULL,   SSHKEYS},
        {"sshkeyfile",  required_argument,      NULL,   SSHKEYFILE},
        {"coredumps",   no_argument,            NULL,   COREDUMPS},
@@ -132,6 +133,7 @@
        {"userid",      required_argument,      NULL,   USERID},
        {"home",        required_argument,      NULL,   HOMEDIR},
        {"homedir",     required_argument,      NULL,   HOMEDIR},
+       {"ascii",       no_argument,            NULL,   ARMOUR},
        {"armor",       no_argument,            NULL,   ARMOUR},
        {"armour",      no_argument,            NULL,   ARMOUR},
        {"detach",      no_argument,            NULL,   DETACHED},
@@ -337,6 +339,7 @@
 {
        netpgp_t        netpgp;
        prog_t          p;
+       int             homeset;
        int             optindex;
        int             ret;
        int             ch;
@@ -355,7 +358,7 @@
        netpgp_setvar(&netpgp, "hash", DEFAULT_HASH_ALG);
        /* 4 MiB for a memory file */
        netpgp_setvar(&netpgp, "max mem alloc", "4194304");
-       netpgp_set_homedir(&netpgp, getenv("HOME"), "/.gnupg", 1);
+       homeset = 0;
        optindex = 0;
        while ((ch = getopt_long(argc, argv, "", options, &optindex)) != -1) {
                switch (options[optindex].val) {
@@ -420,6 +423,7 @@
                                exit(EXIT_ERROR);
                        }
                        netpgp_set_homedir(&netpgp, optarg, NULL, 0);
+                       homeset = 1;
                        break;
                case HASH_ALG:
                        if (optarg == NULL) {
@@ -476,6 +480,10 @@
                        break;
                }
        }
+       if (!homeset) {
+               netpgp_set_homedir(&netpgp, getenv("HOME"),
+                       netpgp_getvar(&netpgp, "ssh keys") ? "/.ssh" : "/.gnupg", 1);
+       }
        /* initialise, and read keys from file */
        if (!netpgp_init(&netpgp)) {
                printf("can't initialise\n");
diff -r b29f66bedb90 -r c2688487b1fe crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c
--- a/crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c       Thu Jul 01 03:52:13 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c       Thu Jul 01 04:27:21 2010 +0000
@@ -103,8 +103,13 @@
        {"list-keys",   no_argument,            NULL,   LIST_KEYS},
        {"list-sigs",   no_argument,            NULL,   LIST_SIGS},
        {"find-key",    no_argument,            NULL,   FIND_KEY},
+       {"export",      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},
+       {"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},
        {"get-key",     no_argument,            NULL,   GET_KEY},
        /* debugging commands */
@@ -121,6 +126,7 @@
        {"home",        required_argument,      NULL,   HOMEDIR},
        {"homedir",     required_argument,      NULL,   HOMEDIR},
        {"numbits",     required_argument,      NULL,   NUMBITS},
+       {"ssh",         no_argument,            NULL,   SSHKEYS},
        {"ssh-keys",    no_argument,            NULL,   SSHKEYS},
        {"sshkeyfile",  required_argument,      NULL,   SSHKEYFILE},
        {"verbose",     no_argument,            NULL,   VERBOSE},
@@ -196,6 +202,7 @@
        struct stat     st;
        netpgp_t        netpgp;
        prog_t          p;
+       int             homeset;
        int             optindex;
        int             ret;
        int             ch;
@@ -203,6 +210,7 @@
 
        (void) memset(&p, 0x0, sizeof(p));
        (void) memset(&netpgp, 0x0, sizeof(netpgp));
+       homeset = 0;
        p.progname = argv[0];
        p.numbits = DEFAULT_NUMBITS;
        if (argc < 2) {
@@ -210,7 +218,6 @@
                exit(EXIT_ERROR);
        }
        /* set some defaults */
-       netpgp_set_homedir(&netpgp, getenv("HOME"), "/.gnupg", 1);
        netpgp_setvar(&netpgp, "sshkeydir", "/etc/ssh");
        netpgp_setvar(&netpgp, "res", "<stdout>");
        netpgp_setvar(&netpgp, "hash", DEFAULT_HASH_ALG);
@@ -273,6 +280,7 @@
                                exit(EXIT_ERROR);
                        }
                        netpgp_set_homedir(&netpgp, optarg, NULL, 0);
+                       homeset = 1;
                        break;
                case NUMBITS:
                        if (optarg == NULL) {
@@ -318,6 +326,10 @@
                        break;
                }
        }
+       if (!homeset) {
+               netpgp_set_homedir(&netpgp, getenv("HOME"),
+                       netpgp_getvar(&netpgp, "ssh keys") ? "/.ssh" : "/.gnupg", 1);
+       }
        /* initialise, and read keys from file */
        if (!netpgp_init(&netpgp)) {
                if (stat(netpgp_getvar(&netpgp, "homedir"), &st) < 0) {
diff -r b29f66bedb90 -r c2688487b1fe crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.c
--- a/crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.c Thu Jul 01 03:52:13 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpverify/verify.c Thu Jul 01 04:27:21 2010 +0000
@@ -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.
@@ -96,6 +96,7 @@
        {"help",        no_argument,            NULL,   HELP_CMD},
        {"version",     no_argument,            NULL,   VERSION_CMD},
        /* options */
+       {"ssh",         no_argument,            NULL,   SSHKEYS},
        {"ssh-keys",    no_argument,            NULL,   SSHKEYS},
        {"sshkeyfile",  required_argument,      NULL,   SSHKEYFILE},
        {"coredumps",   no_argument,            NULL,   COREDUMPS},
@@ -231,12 +232,14 @@
        netpgp_t        netpgp;
        prog_t          p;
        int             optindex;
+       int             homeset;
        int             ret;
        int             ch;
        int             i;
 
        (void) memset(&p, 0x0, sizeof(p));
        (void) memset(&netpgp, 0x0, sizeof(netpgp));
+       homeset = 0;
        p.progname = argv[0];
        p.overwrite = 1;
        p.output = NULL;
@@ -248,7 +251,6 @@
        netpgp_setvar(&netpgp, "hash", DEFAULT_HASH_ALG);
        /* 4 MiB for a memory file */
        netpgp_setvar(&netpgp, "max mem alloc", "4194304");
-       netpgp_set_homedir(&netpgp, getenv("HOME"), "/.gnupg", 1);
        optindex = 0;
        while ((ch = getopt_long(argc, argv, "", options, &optindex)) != -1) {
                switch (options[optindex].val) {
@@ -299,6 +301,7 @@
                                exit(EXIT_ERROR);
                        }
                        netpgp_set_homedir(&netpgp, optarg, NULL, 0);
+                       homeset = 1;
                        break;
                case OUTPUT:
                        if (optarg == NULL) {
@@ -330,6 +333,10 @@
                        break;
                }
        }
+       if (!homeset) {
+               netpgp_set_homedir(&netpgp, getenv("HOME"),
+                       netpgp_getvar(&netpgp, "ssh keys") ? "/.ssh" : "/.gnupg", 1);
+       }
        /* initialise, and read keys from file */
        if (!netpgp_init(&netpgp)) {
                printf("can't initialise\n");



Home | Main Index | Thread Index | Old Index