Home GnuPG
Diffusion GnuPG b28d9ff865a0

agent: Do not overwrite a key file by a shadow key file.

Description

agent: Do not overwrite a key file by a shadow key file.

* agent/findkey.c: Remove assert.h and use log_assert all over the
file.
(fname_from_keygrip): Add arg for_new.
(is_shadowed_key): New.
(agent_write_private_key): Rewrite to use read, write to new file,
rename pattern.  Ignore attempts to overwrite a regular key file by a
shadow key file.
(read_key_file): Move all cleanup code to the end of the function.

I am not shure whether we should allow overwriting with FORCE set.