use temp files to avoid loss of files on error #26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch change easyrsa to use tempfiles for openssl output files. This prevents file destruction when openssl fails (like trying to sign a req twice will destroy the first output crt).
I'm using a little dirty approach with multiple tempfiles vars. However, I wrote a list-based alternative before and it was much more complex (see branch https://github.com/luizluca/easy-rsa/tree/temp_files for list as string sep by new line and https://github.com/luizluca/easy-rsa/compare/temp_files_simpler for fake array).
I also changed the clean_temp to be called by trap EXIT. This is POSIX compatible and avoids multiple calls of it.
I think that even EASYRSA_TEMP_FILE should use mktemp.
If mktemp is not a desired dependency (not a POSIX required command), I could implement a dummy one.