From e879afd8023b435327d1ab687340bbb8eaa744d2 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 17 Feb 2022 22:21:06 +0100 Subject: [PATCH] passwordstore: Fix error detection for non-English locales (#4219) (#4220) 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 77a0c139c9c929fb08d3b9c7eb3409b08bdb6857) Co-authored-by: grembo --- 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 00000000000..540b475fb3a --- /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 d5ebf8b6d84..b3492745f09 100644 --- a/plugins/lookup/passwordstore.py +++ b/plugins/lookup/passwordstore.py @@ -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']):