Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filepath arg to generate_and_write_*_keypair may already exist #172

Closed
lukpueh opened this issue Jul 5, 2019 · 0 comments · Fixed by #772
Closed

filepath arg to generate_and_write_*_keypair may already exist #172

lukpueh opened this issue Jul 5, 2019 · 0 comments · Fixed by #772
Labels
legacy Issues related to legacy interfaces (obsolete with #731)

Comments

@lukpueh
Copy link
Member

lukpueh commented Jul 5, 2019

Description of issue or feature request:

As pointed out by @adityasaky in #169 (review) interface.generate_and_write_spx_keypair does not check if its filepath 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 the generate_and_write_*_keypair functions in interface.

Current behavior:
filepath argument in interface.generate_and_write_*_keypair is not checked if it already exists

Expected 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy Issues related to legacy interfaces (obsolete with #731)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant