filepath
arg to generate_and_write_*_keypair
may already exist
#172
Labels
legacy
Issues related to legacy interfaces (obsolete with #731)
Description of issue or feature request:
As pointed out by @adityasaky in #169 (review)
interface.generate_and_write_spx_keypair
does not check if itsfilepath
argument already exists. In the case of an existing directory we get an error (IOError
on py2,IsADirectoryError
on py3), in case of a file we silently override it. Moreover, since the function writes two files, i.e.<filepath>
and<filepath>.pub
, it might succeed writing one but not the other. The same applies to the rest of thegenerate_and_write_*_keypair
functions ininterface
.Current behavior:
filepath
argument ininterface.generate_and_write_*_keypair
is not checked if it already existsExpected behavior:
Check if
<filepath>
or<filepath>.pub
already exist and act accordingly (unsurprisingly).@adityasaky suggests to warn and/or create the keys under
<filepath>/<keyid>
and<filepath>/<keyid>.pub
. However, these could too already exist.I suggest to just fail if
<filepath>
or<filepath>.pub
exist.OTOH, and given that there are many other reasons why the write operations might fail, we could just leave it as it is now, and maybe update the function docstrings (EAFP-style).
The text was updated successfully, but these errors were encountered: