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 Add the --trusted-keys a...



details:   https://anonhg.NetBSD.org/src/rev/30384c86f289
branches:  trunk
changeset: 777531:30384c86f289
user:      agc <agc%NetBSD.org@localhost>
date:      Wed Feb 22 06:58:54 2012 +0000

description:
Add the --trusted-keys argument to netpgpkeys(1) to print out PGP ids in a
machine-readable manner.

diffstat:

 crypto/external/bsd/netpgp/dist/src/lib/netpgp.c            |  20 +++---------
 crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.1 |  15 ++++++++-
 crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c |   7 ++++
 3 files changed, 25 insertions(+), 17 deletions(-)

diffs (136 lines):

diff -r a90193258538 -r 30384c86f289 crypto/external/bsd/netpgp/dist/src/lib/netpgp.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c  Wed Feb 22 06:29:40 2012 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c  Wed Feb 22 06:58:54 2012 +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.95 2012/02/22 06:29:40 agc Exp $");
+__RCSID("$NetBSD: netpgp.c,v 1.96 2012/02/22 06:58:54 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -1077,31 +1077,21 @@
 {
        const pgp_key_t *key;
        unsigned         k;
-       strings_t        pubs;
        ssize_t          cc;
+       char             out[1024 * 64];
        FILE            *fp = (FILE *)vp;
 
-       (void) memset(&pubs, 0x0, sizeof(pubs));
+       k = 0;
        do {
                key = pgp_getnextkeybyname(netpgp->io, netpgp->pubring,
                                                name, &k);
                if (key != NULL) {
-                       char    out[1024 * 64];
-
-                       ALLOC(char *, pubs.v, pubs.size, pubs.c, 10, 10,
-                                       "netpgp_match_pubkeys", return 0);
                        cc = pgp_sprint_pubkey(key, out, sizeof(out));
-                       pubs.v[pubs.c++] = netpgp_strdup(out);
+                       (void) fprintf(fp, "%.*s", (int)cc, out);
                        k += 1;
                }
        } while (key != NULL);
-       (void) fprintf(fp, "info:%d:%d\n", HKP_VERSION, pubs.c);
-       for (k = 0 ; k < pubs.c ; k++) {
-               (void) fprintf(fp, "%s", pubs.v[k]);
-               free(pubs.v[k]);
-       }
-       free(pubs.v);
-       return pubs.c;
+       return k;
 }
 
 /* find a key in a keyring */
diff -r a90193258538 -r 30384c86f289 crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.1
--- a/crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.1       Wed Feb 22 06:29:40 2012 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.1       Wed Feb 22 06:58:54 2012 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: netpgpkeys.1,v 1.17 2010/11/04 09:30:33 wiz Exp $
+.\" $NetBSD: netpgpkeys.1,v 1.18 2012/02/22 06:58:54 agc Exp $
 .\"
 .\" Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd November 4, 2010
+.Dd February 21, 2012
 .Dt NETPGPKEYS 1
 .Os
 .Sh NAME
@@ -59,6 +59,10 @@
 .Op options
 .Ar file ...
 .Nm
+.Fl Fl trusted\-keys
+.Op options
+.Ar key ...
+.Nm
 .Fl Fl version
 .Nm
 .Op Fl Vgls
@@ -189,6 +193,13 @@
 List all the public keys in the current keyring, along with
 the sub-key signatures which provide the key with trust.
 If no keyring is provided, the user's public keyring is used.
+.It Fl Fl trusted\-keys
+Prints a list of keys in a more machine-readble format than is
+normally used, which can be used as input to other parsing
+engines.
+The output from this command is sent to
+.Dv stdout .
+Normal key-matching rules apply.
 .It Fl Fl version
 Print the version information from the
 .Xr libnetpgp 3
diff -r a90193258538 -r 30384c86f289 crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c
--- a/crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c       Wed Feb 22 06:29:40 2012 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c       Wed Feb 22 06:58:54 2012 +0000
@@ -59,6 +59,7 @@
        "\t--import-key [options] OR\n"
        "\t--list-keys [options] OR\n"
        "\t--list-sigs [options] OR\n"
+       "\t--trusted-keys [options] OR\n"
        "\t--get-key keyid [options] OR\n"
        "\t--version\n"
        "where options are:\n"
@@ -81,6 +82,7 @@
        VERSION_CMD,
        HELP_CMD,
        GET_KEY,
+       TRUSTED_KEYS,
 
        /* options */
        SSHKEYS,
@@ -118,6 +120,8 @@
        {"generate",    optional_argument,      NULL,   GENERATE_KEY},
        {"generate-key", optional_argument,     NULL,   GENERATE_KEY},
        {"get-key",     no_argument,            NULL,   GET_KEY},
+       {"trusted-keys",optional_argument,      NULL,   TRUSTED_KEYS},
+       {"trusted",     optional_argument,      NULL,   TRUSTED_KEYS},
        /* debugging commands */
        {"help",        no_argument,            NULL,   HELP_CMD},
        {"version",     no_argument,            NULL,   VERSION_CMD},
@@ -224,6 +228,8 @@
                }
                (void) fprintf(stderr, "key '%s' not found\n", f);
                return 0;
+       case TRUSTED_KEYS:
+               return netpgp_match_pubkeys(netpgp, f, stdout);
        case HELP_CMD:
        default:
                print_usage(usage, p->progname);
@@ -249,6 +255,7 @@
        case EXPORT_KEY:
        case IMPORT_KEY:
        case GET_KEY:
+       case TRUSTED_KEYS:
        case HELP_CMD:
                p->cmd = val;
                break;



Home | Main Index | Thread Index | Old Index