Skip to content

Commit

Permalink
pass: Handle FileNotFoundError when pass binary is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
dmach committed Sep 22, 2022
1 parent b116c6e commit 605e55c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions salt/renderers/pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,17 @@ def _fetch_secret(pass_path):
if pass_gnupghome:
env["GNUPGHOME"] = pass_gnupghome

proc = Popen(cmd, stdout=PIPE, stderr=PIPE, env=env)
pass_data, pass_error = proc.communicate()
try:
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, env=env)
pass_data, pass_error = proc.communicate()
pass_returncode = proc.returncode
except OSError as e:
pass_data, pass_error = "", str(e)
pass_returncode = 1

# The version of pass used during development sent output to
# stdout instead of stderr even though its returncode was non zero.
if proc.returncode or not pass_data:
if pass_returncode or not pass_data:
try:
pass_error = pass_error.decode("utf-8")
except (AttributeError, ValueError):
Expand Down

0 comments on commit 605e55c

Please sign in to comment.