From 77a0c139c9c929fb08d3b9c7eb3409b08bdb6857 Mon Sep 17 00:00:00 2001 From: grembo Date: Thu, 17 Feb 2022 22:00:02 +0100 Subject: [PATCH] passwordstore: Fix error detection for non-English locales (#4219) 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 --- changelogs/fragments/4219-passwordstore-locale-fix.yml | 2 ++ plugins/lookup/passwordstore.py | 1 + 2 files changed, 3 insertions(+) create mode 100644 changelogs/fragments/4219-passwordstore-locale-fix.yml diff --git a/changelogs/fragments/4219-passwordstore-locale-fix.yml b/changelogs/fragments/4219-passwordstore-locale-fix.yml new file mode 100644 index 0000000000..540b475fb3 --- /dev/null +++ b/changelogs/fragments/4219-passwordstore-locale-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - passwordstore lookup plugin - fix error detection for non-English locales (https://github.com/ansible-collections/community.general/pull/4219). diff --git a/plugins/lookup/passwordstore.py b/plugins/lookup/passwordstore.py index d5ebf8b6d8..b3492745f0 100644 --- a/plugins/lookup/passwordstore.py +++ b/plugins/lookup/passwordstore.py @@ -229,6 +229,7 @@ class LookupModule(LookupBase): # 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']):