Module Name: src
Committed By: agc
Date: Wed Sep 1 06:18:21 UTC 2010
Modified Files:
src/crypto/external/bsd/netpgp/dist/src/netpgpkeys: netpgpkeys.c
Log Message:
+ 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) <[email protected]>
%
lists ssh pubkeys properly, no need for other tautological arguments
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 \
src/crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c
diff -u src/crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c:1.16 src/crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c:1.17
--- src/crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c:1.16 Fri Aug 13 18:29:41 2010
+++ src/crypto/external/bsd/netpgp/dist/src/netpgpkeys/netpgpkeys.c Wed Sep 1 06:18:21 2010
@@ -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':