mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
wkd: Support option --output for command --check.
* tools/wks-util.c (write_to_file): Rename to ... (wks_write_to_file): this, make global, and support NULL for fname. * tools/gpg-wks-client.c (command_check): Write to key.
This commit is contained in:
parent
e28b6c301d
commit
33b6ee5047
@ -189,7 +189,9 @@ fields are (future versions may specify additional fields):
|
|||||||
@itemx -o
|
@itemx -o
|
||||||
@opindex output
|
@opindex output
|
||||||
Write the created mail to @var{file} instead of stdout. Note that the
|
Write the created mail to @var{file} instead of stdout. Note that the
|
||||||
value @code{-} for @var{file} is the same as writing to stdout.
|
value @code{-} for @var{file} is the same as writing to stdout. If
|
||||||
|
this option is used with the @option{--check} command and a key was
|
||||||
|
found it is written to the given file.
|
||||||
|
|
||||||
@item --status-fd @var{n}
|
@item --status-fd @var{n}
|
||||||
@opindex status-fd
|
@opindex status-fd
|
||||||
|
@ -1126,6 +1126,19 @@ command_check (char *userid)
|
|||||||
addrspec);
|
addrspec);
|
||||||
err = gpg_error (GPG_ERR_CERT_REVOKED);
|
err = gpg_error (GPG_ERR_CERT_REVOKED);
|
||||||
}
|
}
|
||||||
|
else if (opt.output)
|
||||||
|
{
|
||||||
|
/* Save to file. */
|
||||||
|
const char *fname = opt.output;
|
||||||
|
|
||||||
|
if (*fname == '-' && !fname[1])
|
||||||
|
fname = NULL;
|
||||||
|
es_rewind (key);
|
||||||
|
err = wks_write_to_file (key, fname);
|
||||||
|
if (err)
|
||||||
|
log_error ("writing key to '%s' failed: %s\n",
|
||||||
|
fname? fname : "[stdout]", gpg_strerror (err));
|
||||||
|
}
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
xfree (fpr);
|
xfree (fpr);
|
||||||
|
@ -106,6 +106,7 @@ gpg_error_t wks_send_mime (mime_maker_t mime);
|
|||||||
gpg_error_t wks_parse_policy (policy_flags_t flags, estream_t stream,
|
gpg_error_t wks_parse_policy (policy_flags_t flags, estream_t stream,
|
||||||
int ignore_unknown);
|
int ignore_unknown);
|
||||||
void wks_free_policy (policy_flags_t policy);
|
void wks_free_policy (policy_flags_t policy);
|
||||||
|
gpg_error_t wks_write_to_file (estream_t src, const char *fname);
|
||||||
|
|
||||||
gpg_error_t wks_fname_from_userid (const char *userid, int hash_only,
|
gpg_error_t wks_fname_from_userid (const char *userid, int hash_only,
|
||||||
char **r_fname, char **r_addrspec);
|
char **r_fname, char **r_addrspec);
|
||||||
|
@ -892,18 +892,27 @@ wks_free_policy (policy_flags_t policy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Write the content of SRC to the new file FNAME. */
|
/* Write the content of SRC to the new file FNAME. If FNAME is NULL
|
||||||
static gpg_error_t
|
* SRC is written to stdout. */
|
||||||
write_to_file (estream_t src, const char *fname)
|
gpg_error_t
|
||||||
|
wks_write_to_file (estream_t src, const char *fname)
|
||||||
{
|
{
|
||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
estream_t dst;
|
estream_t dst;
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
size_t nread, written;
|
size_t nread, written;
|
||||||
|
|
||||||
dst = es_fopen (fname, "wb");
|
if (!fname)
|
||||||
if (!dst)
|
{
|
||||||
return gpg_error_from_syserror ();
|
dst = es_stdout;
|
||||||
|
es_set_binary (es_stdout);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dst = es_fopen (fname, "wb");
|
||||||
|
if (!dst)
|
||||||
|
return gpg_error_from_syserror ();
|
||||||
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -918,12 +927,15 @@ write_to_file (estream_t src, const char *fname)
|
|||||||
if (!es_feof (src) || es_ferror (src) || es_ferror (dst))
|
if (!es_feof (src) || es_ferror (src) || es_ferror (dst))
|
||||||
{
|
{
|
||||||
err = gpg_error_from_syserror ();
|
err = gpg_error_from_syserror ();
|
||||||
es_fclose (dst);
|
if (dst != es_stdout)
|
||||||
gnupg_remove (fname);
|
{
|
||||||
|
es_fclose (dst);
|
||||||
|
gnupg_remove (fname);
|
||||||
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (es_fclose (dst))
|
if (dst != es_stdout && es_fclose (dst))
|
||||||
{
|
{
|
||||||
err = gpg_error_from_syserror ();
|
err = gpg_error_from_syserror ();
|
||||||
log_error ("error closing '%s': %s\n", fname, gpg_strerror (err));
|
log_error ("error closing '%s': %s\n", fname, gpg_strerror (err));
|
||||||
@ -1225,7 +1237,7 @@ wks_install_key_core (estream_t key, const char *addrspec)
|
|||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
/* Publish. */
|
/* Publish. */
|
||||||
err = write_to_file (key, huname);
|
err = wks_write_to_file (key, huname);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
log_error ("copying key to '%s' failed: %s\n", huname,gpg_strerror (err));
|
log_error ("copying key to '%s' failed: %s\n", huname,gpg_strerror (err));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user