preserve environment variables when calling pass show
This commit is contained in:
parent
c814b8c103
commit
d1277326df
1 changed files with 7 additions and 4 deletions
11
bwpass.py
11
bwpass.py
|
@ -4,14 +4,19 @@ from subprocess import check_output, CalledProcessError
|
|||
|
||||
from bundlewrap.exceptions import FaultUnavailable
|
||||
from bundlewrap.utils import Fault
|
||||
from bundlewrap.utils.dict import merge_dict
|
||||
from bundlewrap.utils.text import bold, yellow
|
||||
from bundlewrap.utils.ui import io
|
||||
|
||||
PASSWORD_STORE_DIR = expanduser(environ.get('BW_PASS_DIR', '~/.password-store'))
|
||||
ENVIRONMENT = merge_dict(environ, {
|
||||
'PASSWORD_STORE_DIR': expanduser(environ.get('BW_PASS_DIR', '~/.password-store')).
|
||||
})
|
||||
|
||||
DUMMY_MODE = environ.get('BW_PASS_DUMMY_MODE', '0') == '1'
|
||||
|
||||
cache = {}
|
||||
|
||||
|
||||
def _get_contents_from_pass(identifier: str):
|
||||
try:
|
||||
return cache[identifier]
|
||||
|
@ -26,9 +31,7 @@ def _get_contents_from_pass(identifier: str):
|
|||
try:
|
||||
pass_output = check_output(
|
||||
['pass', 'show', identifier],
|
||||
env={
|
||||
'PASSWORD_STORE_DIR': PASSWORD_STORE_DIR,
|
||||
}
|
||||
env=ENVIRONMENT,
|
||||
).decode('UTF-8').splitlines()
|
||||
except FileNotFoundError:
|
||||
raise FaultUnavailable('pass not found')
|
||||
|
|
Loading…
Reference in a new issue