summaryrefslogtreecommitdiffstats
path: root/g10/keydb.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2015-08-07 15:53:56 +0200
committerWerner Koch <wk@gnupg.org>2015-08-07 15:53:56 +0200
commit5b7a80b1ab91d2f199065e5dd14e85f42918975d (patch)
tree2e4584aa37cf727cc98df2ab48c46682a7595645 /g10/keydb.c
parentagent: Add option --force to the DELETE_KEY command. (diff)
downloadgnupg2-5b7a80b1ab91d2f199065e5dd14e85f42918975d.tar.xz
gnupg2-5b7a80b1ab91d2f199065e5dd14e85f42918975d.zip
gpg: Allow gpgv to work with a trustedkeys.kbx file.
* g10/keydb.h (KEYDB_RESOURCE_FLAG_GPGVDEF): New. * g10/keydb.c (keydb_add_resource): Take care of new flag. * g10/gpgv.c (main): Use new flag. -- GnuPG-bug-id: 2025 Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g10/keydb.c')
-rw-r--r--g10/keydb.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/g10/keydb.c b/g10/keydb.c
index 3dc9ec72e..b31c6a62c 100644
--- a/g10/keydb.c
+++ b/g10/keydb.c
@@ -434,6 +434,7 @@ keydb_add_resource (const char *url, unsigned int flags)
int create;
int read_only = !!(flags&KEYDB_RESOURCE_FLAG_READONLY);
int is_default = !!(flags&KEYDB_RESOURCE_FLAG_DEFAULT);
+ int is_gpgvdef = !!(flags&KEYDB_RESOURCE_FLAG_GPGVDEF);
int rc = 0;
KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE;
void *token;
@@ -516,6 +517,23 @@ keydb_add_resource (const char *url, unsigned int flags)
strcpy (filename+filenamelen-4, ".gpg");
}
}
+ else if (!pass && is_gpgvdef
+ && filenamelen > 4 && !strcmp (filename+filenamelen-4, ".kbx"))
+ {
+ /* Not found but gpgv's default "trustedkeys.kbx" file has
+ been requested. We did not found it so now check whether
+ a "trustedkeys.gpg" file exists and use that instead. */
+ KeydbResourceType rttmp;
+
+ strcpy (filename+filenamelen-4, ".gpg");
+ rttmp = rt_from_file (filename, &found, &openpgp_flag);
+ if (found
+ && ((rttmp == KEYDB_RESOURCE_TYPE_KEYBOX && openpgp_flag)
+ || (rttmp == KEYDB_RESOURCE_TYPE_KEYRING)))
+ rt = rttmp;
+ else /* Restore filename */
+ strcpy (filename+filenamelen-4, ".kbx");
+ }
else if (!pass
&& is_default && create
&& filenamelen > 4 && !strcmp (filename+filenamelen-4, ".gpg"))