Pass configured GPG paths to PHP GnuPG extension #560
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 pull request is a (multiple allowed):
Checklist
The bug
If a system doesn't have GnuPG v2 installed using with the name
gpgon thePATH, Passbolt doesn't work.(In my case, my Unix system already had GnuPG v1 installed under the
gpgname, and the correct binary name that should be used wasgpg2.)There is a setting for the path to the GPG binary:
passbolt.gpg.program. This setting was not being passed to thePhpGnupg()constructor, thus it did not do anything.What I did
The
PhpGnupg()constructor (documentation) supports passing an array of options for setting the paths it should use. I added this array, populated with all options that were configured in the configuration.Note the keyring path was already passed via a environment variable, so it did work before, but explicitly passing it seemed like a clearer solution than skipping it.
How I tested it
I didn't see any relevant tests to update, and was not quite sure how to best test this in a unit test. Potentially we could set the path to something non-existent and observe that it doesn't work anymore, but that doesn't seem like a very useful test. This fix might be straightforward enough to not need a specific test.
I did test it in my a self-hosted version which needed this fix to run. With the correct path inserted here everything seems to work.
Note: The health check in
GpgHealthCheck.phpis also broken because it uses a hardcoded command instead of using thepassbolt.gpg.programsetting, thus claiming it cannot findgpg. I was less sure how to correctly fix this. Prepending the setting to a hardcoded command is possible, but looks a bit risky to me for command injection (even if the source is a relatively trusted config file).Uncommited change