wks: Add option --fake-submission-addr to gpg-wks-client.

* tools/gpg-wks-client.c (oFakeSubmissionAddr): New.
(opts): Add option --fake-submission-addr.
(fake_submission_addr): New variable.
(parse_arguments): Set it.
(command_send): Use --fake-submission-addr.
--

This option is useful for testing.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-10-05 11:51:32 +02:00
parent 1cedc32c95
commit e514a5b725
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
1 changed files with 33 additions and 16 deletions

View File

@ -56,6 +56,7 @@ enum cmd_and_opt_values
oGpgProgram,
oSend,
oFakeSubmissionAddr,
oDummy
};
@ -83,6 +84,7 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_s_n (oSend, "send", "send the mail using sendmail"),
ARGPARSE_s_s (oOutput, "output", "|FILE|write the mail to FILE"),
ARGPARSE_s_s (oFakeSubmissionAddr, "fake-submission-addr", "@"),
ARGPARSE_end ()
};
@ -102,6 +104,11 @@ static struct debug_flags_s debug_flags [] =
};
/* Value of the option --fake-submission-addr. */
const char *fake_submission_addr;
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);
@ -180,6 +187,9 @@ parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
case oOutput:
opt.output = pargs->r.ret_str;
break;
case oFakeSubmissionAddr:
fake_submission_addr = pargs->r.ret_str;
break;
case aSupported:
case aCreate:
@ -551,30 +561,37 @@ command_send (const char *fingerprint, char *userid)
goto leave;
/* Get the submission address. */
err = wkd_get_submission_address (addrspec, &submission_to);
if (fake_submission_addr)
{
submission_to = xstrdup (fake_submission_addr);
err = 0;
}
else
err = wkd_get_submission_address (addrspec, &submission_to);
if (err)
goto leave;
log_info ("submitting request to '%s'\n", submission_to);
/* Get the policy flags. */
{
estream_t mbuf;
if (!fake_submission_addr)
{
estream_t mbuf;
err = wkd_get_policy_flags (addrspec, &mbuf);
if (err)
{
log_error ("error reading policy flags for '%s': %s\n",
submission_to, gpg_strerror (err));
goto leave;
}
if (mbuf)
{
err = wks_parse_policy (&policy, mbuf, 1);
es_fclose (mbuf);
if (err)
err = wkd_get_policy_flags (addrspec, &mbuf);
if (err)
{
log_error ("error reading policy flags for '%s': %s\n",
submission_to, gpg_strerror (err));
goto leave;
}
}
if (mbuf)
{
err = wks_parse_policy (&policy, mbuf, 1);
es_fclose (mbuf);
if (err)
goto leave;
}
}
if (policy.auth_submit)
log_info ("no confirmation required for '%s'\n", addrspec);