mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-08 12:44:23 +01:00
wks: Add command --supported to gpg-wks-client.
* tools/gpg-wks-client.c (aSupported): New. (opts): Add --supported. (parse_arguments): Ditto. (main): Call command_supported. (command_supported): New. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
95e9a97b32
commit
460568d341
@ -49,6 +49,7 @@ enum cmd_and_opt_values
|
|||||||
|
|
||||||
oDebug = 500,
|
oDebug = 500,
|
||||||
|
|
||||||
|
aSupported,
|
||||||
aCreate,
|
aCreate,
|
||||||
aReceive,
|
aReceive,
|
||||||
aRead,
|
aRead,
|
||||||
@ -64,6 +65,8 @@ enum cmd_and_opt_values
|
|||||||
static ARGPARSE_OPTS opts[] = {
|
static ARGPARSE_OPTS opts[] = {
|
||||||
ARGPARSE_group (300, ("@Commands:\n ")),
|
ARGPARSE_group (300, ("@Commands:\n ")),
|
||||||
|
|
||||||
|
ARGPARSE_c (aSupported, "supported",
|
||||||
|
("check whether provider supports WKS")),
|
||||||
ARGPARSE_c (aCreate, "create",
|
ARGPARSE_c (aCreate, "create",
|
||||||
("create a publication request")),
|
("create a publication request")),
|
||||||
ARGPARSE_c (aReceive, "receive",
|
ARGPARSE_c (aReceive, "receive",
|
||||||
@ -98,6 +101,7 @@ static struct debug_flags_s debug_flags [] =
|
|||||||
|
|
||||||
|
|
||||||
static void wrong_args (const char *text) GPGRT_ATTR_NORETURN;
|
static void wrong_args (const char *text) GPGRT_ATTR_NORETURN;
|
||||||
|
static gpg_error_t command_supported (char *userid);
|
||||||
static gpg_error_t command_send (const char *fingerprint, char *userid);
|
static gpg_error_t command_send (const char *fingerprint, char *userid);
|
||||||
static gpg_error_t process_confirmation_request (estream_t msg);
|
static gpg_error_t process_confirmation_request (estream_t msg);
|
||||||
static gpg_error_t command_receive_cb (void *opaque,
|
static gpg_error_t command_receive_cb (void *opaque,
|
||||||
@ -174,6 +178,7 @@ parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
|
|||||||
opt.output = pargs->r.ret_str;
|
opt.output = pargs->r.ret_str;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case aSupported:
|
||||||
case aCreate:
|
case aCreate:
|
||||||
case aReceive:
|
case aReceive:
|
||||||
case aRead:
|
case aRead:
|
||||||
@ -237,6 +242,14 @@ main (int argc, char **argv)
|
|||||||
/* Run the selected command. */
|
/* Run the selected command. */
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
|
case aSupported:
|
||||||
|
if (argc != 1)
|
||||||
|
wrong_args ("--supported USER-ID");
|
||||||
|
err = command_supported (argv[0]);
|
||||||
|
if (err && gpg_err_code (err) != GPG_ERR_FALSE)
|
||||||
|
log_error ("checking support failed: %s\n", gpg_strerror (err));
|
||||||
|
break;
|
||||||
|
|
||||||
case aCreate:
|
case aCreate:
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
wrong_args ("--create FINGERPRINT USER-ID");
|
wrong_args ("--create FINGERPRINT USER-ID");
|
||||||
@ -380,6 +393,48 @@ get_key (estream_t *r_key, const char *fingerprint, const char *addrspec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Check whether the provider supports the WKS protocol. */
|
||||||
|
static gpg_error_t
|
||||||
|
command_supported (char *userid)
|
||||||
|
{
|
||||||
|
gpg_error_t err;
|
||||||
|
char *addrspec = NULL;
|
||||||
|
char *submission_to = NULL;
|
||||||
|
|
||||||
|
addrspec = mailbox_from_userid (userid);
|
||||||
|
if (!addrspec)
|
||||||
|
{
|
||||||
|
log_error (_("\"%s\" is not a proper mail address\n"), userid);
|
||||||
|
err = gpg_error (GPG_ERR_INV_USER_ID);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the submission address. */
|
||||||
|
err = wkd_get_submission_address (addrspec, &submission_to);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
if (gpg_err_code (err) == GPG_ERR_NO_DATA
|
||||||
|
|| gpg_err_code (err) == GPG_ERR_UNKNOWN_HOST)
|
||||||
|
{
|
||||||
|
if (opt.verbose)
|
||||||
|
log_info ("provider for '%s' does NOT support WKS (%s)\n",
|
||||||
|
addrspec, gpg_strerror (err));
|
||||||
|
err = gpg_error (GPG_ERR_FALSE);
|
||||||
|
log_inc_errorcount ();
|
||||||
|
}
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
if (opt.verbose)
|
||||||
|
log_info ("provider for '%s' supports WKS\n", addrspec);
|
||||||
|
|
||||||
|
leave:
|
||||||
|
xfree (submission_to);
|
||||||
|
xfree (addrspec);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Locate the key by fingerprint and userid and send a publication
|
/* Locate the key by fingerprint and userid and send a publication
|
||||||
* request. */
|
* request. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user