Skip to content

Commit

Permalink
passwordstore: Fix error detection for non-English locales (#4219)
Browse files Browse the repository at this point in the history
The passwordstore lookup plugin depends on parsing GnuPG's
error messages in English language. As a result, detection of
a specific error failes when users set a different locale.

This change corrects this by setting the `LANGUAGE` environment
variable to `C` when invoking `pass`, as this only affects
gettext translations.

See
https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html

(cherry picked from commit 77a0c13)
  • Loading branch information
grembo authored and patchback[bot] committed Feb 17, 2022
1 parent 271bafb commit d4bd2fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/4219-passwordstore-locale-fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- passwordstore lookup plugin - fix error detection for non-English locales (https://github.com/ansible-collections/community.general/pull/4219).
1 change: 1 addition & 0 deletions plugins/lookup/passwordstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def parse_params(self, term):

# Collect pass environment variables from the plugin's parameters.
self.env = os.environ.copy()
self.env['LANGUAGE'] = 'C' # make sure to get errors in English as required by check_output2

# Set PASSWORD_STORE_DIR
if os.path.isdir(self.paramvals['directory']):
Expand Down

0 comments on commit d4bd2fa

Please sign in to comment.