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

age: create outfile as late as possible #169

Closed
wants to merge 1 commit into from

Conversation

codesoap
Copy link
Contributor

@codesoap codesoap commented Dec 31, 2020

age creates empty output files, when something goes wrong. Examples:

  1. With age -p -o data.age data when I enter non matching passphrases.
  2. With age -d -o data data.age when I enter the wrong passphrase.
  3. With age -d -i key -o data data.age when I provided the wrong secret key.

This pull requests ensures, that the output file is created as late as possible and thus avoids the creation of empty files for the given examples. Unfortunately this leads to some boilerplate, but I feel like it's not too bad.

One drawback is that the user is now informed later about already existing output files. Thus they may have already entered a password, only to be informed that the output file already exists and won't be overwritten. This could be prevented by checking if the file exists in advance. Let me know if you want this implemented.

This pull request should resolve #159 and to some extend #57.

FiloSottile added a commit that referenced this pull request Jan 2, 2021
This avoids leaving behind an empty file when an error occurs before we
write the header (for example, because the passphrase is invalid). Do a
best-effort check before taking user input for whether the file exists
so we don't waste user effort. An error might still happen after user
input if other kind of open errors happen (for example, a permission
issue, or disk full).

Fixes #159
Fixes #57
Closes #169
FiloSottile added a commit that referenced this pull request Jan 3, 2021
This avoids leaving behind an empty file when an error occurs before we
write the header (for example, because the passphrase is invalid). Do a
best-effort check before taking user input for whether the file exists
so we don't waste user effort. An error might still happen after user
input if other kind of open errors happen (for example, a permission
issue, or disk full).

Fixes #159
Fixes #57
Closes #169
@FiloSottile
Copy link
Owner

Thank you! I took a slightly different implementation strategy, but the examples and discussion was very useful. Let me know if the changes in #173 look good!

@codesoap
Copy link
Contributor Author

codesoap commented Jan 3, 2021

I really like the lazyOpener. I had briefly thought about something like this, but didn't think it would be implementable with so little code. I'll definitely remember this for future projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UX: Empty files created upon passphrase mismatch
2 participants