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/netpgpkeys + if we're go...
details: https://anonhg.NetBSD.org/src/rev/6f17bc7333ac
branches: trunk
changeset: 757480:6f17bc7333ac
user: agc <agc%NetBSD.org@localhost>
date: Wed Sep 01 06:18:21 2010 +0000
description:
+ if we're going to the trouble of testing the return value from the
setoption() function, probably best to return one
+ check for a valid entry in the JSON array instead of trusting that
we have one
+ if there is no JSON value to print, don't print it
+ if we've set the keyring from an ssh key file, then we're using ssh
keys - no need to set that value separately. This means that
% netpgpkeys --sshkeyfile ~/.ssh/id_test.pub -l
1 key found
signature 2048/RSA (Encrypt or Sign) 8368881b3b9832ec 2010-08-26
Key fingerprint: 3abd bf38 33a5 1f87 d704 ad42 8368 881b 3b98 32ec
uid osx-vm1.crowthorne.alistaircrooks.co.uk (/home/agc/.ssh/id_test.pub) <agc%osx-vm1.crowthorne.alistaircrooks.co.uk@localhost>
%
lists ssh pubkeys properly, no need for other tautological arguments
diffstat:
crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c | 14 ++++++++++--
1 files changed, 11 insertions(+), 3 deletions(-)
diffs (59 lines):
diff -r f05685236203 -r 6f17bc7333ac crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c
--- a/crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c Wed Sep 01 06:02:58 2010 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c Wed Sep 01 06:18:21 2010 +0000
@@ -179,6 +179,10 @@
{
int i;
+ if (obj == NULL) {
+ (void) fprintf(stderr, "No object found\n");
+ return;
+ }
for (i = 0 ; i < depth ; i++) {
p(fp, " ", NULL);
}
@@ -332,7 +336,9 @@
from = to = tok = 0;
/* convert from string into an mj structure */
(void) mj_parse(&ids, json, &from, &to, &tok);
- idc = mj_arraycount(&ids);
+ if ((idc = mj_arraycount(&ids)) == 1 && strchr(json, '{') == NULL) {
+ idc = 0;
+ }
(void) fprintf(fp, "%d key%s found\n", idc, (idc == 1) ? "" : "s");
for (i = 0 ; i < idc ; i++) {
formatobj(fp, &ids.value.v[i], psigs);
@@ -474,6 +480,7 @@
netpgp_setvar(netpgp, "res", arg);
break;
case SSHKEYFILE:
+ netpgp_setvar(netpgp, "ssh keys", "1");
netpgp_setvar(netpgp, "sshkeyfile", arg);
break;
case OPS_DEBUG:
@@ -483,6 +490,7 @@
p->cmd = HELP_CMD;
break;
}
+ return 1;
}
/* we have -o option=value -- parse, and process */
@@ -548,7 +556,7 @@
if (ch >= LIST_KEYS) {
/* getopt_long returns 0 for long options */
if (!setoption(&netpgp, &p, options[optindex].val, optarg, &homeset)) {
- (void) fprintf(stderr, "Bad option\n");
+ (void) fprintf(stderr, "Bad setoption result %d\n", ch);
}
} else {
switch (ch) {
@@ -566,7 +574,7 @@
break;
case 'o':
if (!parse_option(&netpgp, &p, optarg, &homeset)) {
- (void) fprintf(stderr, "Bad option\n");
+ (void) fprintf(stderr, "Bad parse_option\n");
}
break;
case 's':
Home |
Main Index |
Thread Index |
Old Index