mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
agent: Fix saving with FORCE=1.
* agent/findkey.c (agent_write_private_key): Recover from an error of GPG_ERR_ENOENT when FORCE=1 and it is opened with "rb+". -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
71158d8d5f
commit
1ffd475f99
@ -152,17 +152,30 @@ agent_write_private_key (const unsigned char *grip,
|
|||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
gpg_error_t tmperr = gpg_error_from_syserror ();
|
gpg_error_t tmperr = gpg_error_from_syserror ();
|
||||||
log_error ("can't create '%s': %s\n", fname, gpg_strerror (tmperr));
|
|
||||||
xfree (fname);
|
|
||||||
return tmperr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* See if an existing key is in extended format. */
|
if (force && gpg_err_code (tmperr) == GPG_ERR_ENOENT)
|
||||||
if (force)
|
{
|
||||||
|
fp = es_fopen (fname, "wbx,mode=-rw");
|
||||||
|
if (!fp)
|
||||||
|
{
|
||||||
|
tmperr = gpg_error_from_syserror ();
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error:
|
||||||
|
log_error ("can't create '%s': %s\n", fname, gpg_strerror (tmperr));
|
||||||
|
xfree (fname);
|
||||||
|
return tmperr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (force)
|
||||||
{
|
{
|
||||||
gpg_error_t rc;
|
gpg_error_t rc;
|
||||||
char first;
|
char first;
|
||||||
|
|
||||||
|
/* See if an existing key is in extended format. */
|
||||||
if (es_fread (&first, 1, 1, fp) != 1)
|
if (es_fread (&first, 1, 1, fp) != 1)
|
||||||
{
|
{
|
||||||
rc = gpg_error_from_syserror ();
|
rc = gpg_error_from_syserror ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user