mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
wks: Add special mode to --install-key.
* tools/gpg-wks-client.c (get_key_status_parm_s) (get_key_status_cb, get_key): Move to ... * tools/wks-util.c: ...here. (get_key): Rename to wks_get_key. * tools/gpg-wks-server.c: Include userids.h. (command_install_key): Allow use of a fingerprint. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
ee474856ec
commit
685a5e1558
5 changed files with 153 additions and 134 deletions
|
@ -35,6 +35,7 @@
|
|||
#include "../common/util.h"
|
||||
#include "../common/init.h"
|
||||
#include "../common/sysutils.h"
|
||||
#include "../common/userids.h"
|
||||
#include "../common/ccparray.h"
|
||||
#include "../common/exectool.h"
|
||||
#include "../common/zb32.h"
|
||||
|
@ -2002,7 +2003,8 @@ static gpg_error_t
|
|||
command_install_key (const char *fname, const char *userid)
|
||||
{
|
||||
gpg_error_t err;
|
||||
estream_t fp;
|
||||
KEYDB_SEARCH_DESC desc;
|
||||
estream_t fp = NULL;
|
||||
char *addrspec = NULL;
|
||||
char *fpr = NULL;
|
||||
uidinfo_list_t uidlist = NULL;
|
||||
|
@ -2011,14 +2013,6 @@ command_install_key (const char *fname, const char *userid)
|
|||
char *huname = NULL;
|
||||
int any;
|
||||
|
||||
fp = es_fopen (fname, "rb");
|
||||
if (!fp)
|
||||
{
|
||||
err = gpg_error_from_syserror ();
|
||||
log_error ("error reading '%s': %s\n", fname, gpg_strerror (err));
|
||||
goto leave;
|
||||
}
|
||||
|
||||
addrspec = mailbox_from_userid (userid);
|
||||
if (!addrspec)
|
||||
{
|
||||
|
@ -2027,6 +2021,31 @@ command_install_key (const char *fname, const char *userid)
|
|||
goto leave;
|
||||
}
|
||||
|
||||
if (!classify_user_id (fname, &desc, 1)
|
||||
&& (desc.mode == KEYDB_SEARCH_MODE_FPR
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR20))
|
||||
{
|
||||
/* FNAME looks like a fingerprint. Get the key from the
|
||||
* standard keyring. */
|
||||
err = wks_get_key (&fp, fname, addrspec, 0);
|
||||
if (err)
|
||||
{
|
||||
log_error ("error getting key '%s' (uid='%s'): %s\n",
|
||||
fname, addrspec, gpg_strerror (err));
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
else /* Take it from the file */
|
||||
{
|
||||
fp = es_fopen (fname, "rb");
|
||||
if (!fp)
|
||||
{
|
||||
err = gpg_error_from_syserror ();
|
||||
log_error ("error reading '%s': %s\n", fname, gpg_strerror (err));
|
||||
goto leave;
|
||||
}
|
||||
}
|
||||
|
||||
/* List the key so that we can figure out the newest UID with the
|
||||
* requested addrspec. */
|
||||
err = wks_list_key (fp, &fpr, &uidlist);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue