Change password input for gpg operations #585
Draft
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.
Creating as draft, as this needs to be thoroughly tested and checked and isn't finished/cleaned up yet.
If finished the commit messages will be updated to include the issues it closes (if any...).
Background of this PR is the issue that
tombhas issues with passwords that try to use characters in a combination so they create control sequences for the shell. For example newline\n, form feed\fand tabulator\t.This is due how the password is provided for the
gpgcall.gpgis used with--passphrase-fd 0which reads the password from STDIN until it encounters a newline. Unfortunately this means the shell interprets those character sequences in the password itself. Especially fatal in case of\nas this will reduce the password to this point. Example: you want to set passwordtest\ntest. gpg, while readingSTDIN, will stop at\nand the resulting password will be onlytest.Not sure yet what happens with the rest, but it does seem to be discarded in general and not added to or used as
TOMBSECRET.Two ways to avoid interpreting control sequences:
--passphrase-fdto a dedicated descriptor above 2 (like--passphrase-fd 3and input password like3<<<"$password"--passphrase-fileand use an anonymous pipe (how it is done with this PR)In general the first option is similar to the current solution. But is untested if the redirect isn't visible while tracing. But I will also create a draft with that solution. Makes it easier to compare and check by others.
The second option uses an option which is discouraged. But the anonymous pipe should address concerns in regard to that.