shell-integration/ssh/bootstrap.py: suppress getpwuid() exceptions

Reference: 89e5ae28bb60d5bf3aaadf25d62ea0864e5136bb
This commit is contained in:
Samuel Tam 2023-03-19 19:09:14 +08:00 committed by usertam
parent 31319f0b65
commit 8a7491722f
No known key found for this signature in database
GPG Key ID: C35F5FF3A6C5AC43

View File

@ -20,7 +20,12 @@ echo_on = int('ECHO_ON')
data_dir = shell_integration_dir = '' data_dir = shell_integration_dir = ''
request_data = int('REQUEST_DATA') request_data = int('REQUEST_DATA')
leading_data = b'' leading_data = b''
login_shell = pwd.getpwuid(os.geteuid()).pw_shell or os.environ.get('SHELL') or 'sh' try:
login_shell = pwd.getpwuid(os.geteuid()).pw_shell or os.environ.get('SHELL') or '/bin/sh'
except KeyError:
login_shell = os.environ.get('SHELL') or '/bin/sh'
with suppress(Exception):
print('Failed to read login shell via getpwuid() for current user, falling back to', login_shell, file=sys.stderr)
export_home_cmd = b'EXPORT_HOME_CMD' export_home_cmd = b'EXPORT_HOME_CMD'
if export_home_cmd: if export_home_cmd:
HOME = base64.standard_b64decode(export_home_cmd).decode('utf-8') HOME = base64.standard_b64decode(export_home_cmd).decode('utf-8')