Make requesting data optional
This commit is contained in:
parent
f3088c5646
commit
f54a3e8036
@ -219,7 +219,8 @@ def prepare_exec_cmd(remote_args: Sequence[str], is_python: bool) -> str:
|
|||||||
def bootstrap_script(
|
def bootstrap_script(
|
||||||
script_type: str = 'sh', remote_args: Sequence[str] = (),
|
script_type: str = 'sh', remote_args: Sequence[str] = (),
|
||||||
ssh_opts_dict: Dict[str, Dict[str, Any]] = {},
|
ssh_opts_dict: Dict[str, Dict[str, Any]] = {},
|
||||||
test_script: str = '', request_id: Optional[str] = None, cli_hostname: str = '', cli_uname: str = ''
|
test_script: str = '', request_id: Optional[str] = None, cli_hostname: str = '', cli_uname: str = '',
|
||||||
|
request_data: str = '1',
|
||||||
) -> Tuple[str, Dict[str, str], SharedMemory]:
|
) -> Tuple[str, Dict[str, str], SharedMemory]:
|
||||||
if request_id is None:
|
if request_id is None:
|
||||||
request_id = os.environ['KITTY_PID'] + '-' + os.environ['KITTY_WINDOW_ID']
|
request_id = os.environ['KITTY_PID'] + '-' + os.environ['KITTY_WINDOW_ID']
|
||||||
@ -235,7 +236,7 @@ def bootstrap_script(
|
|||||||
atexit.register(shm.unlink)
|
atexit.register(shm.unlink)
|
||||||
replacements = {
|
replacements = {
|
||||||
'DATA_PASSWORD': pw, 'PASSWORD_FILENAME': shm.name, 'EXEC_CMD': exec_cmd, 'TEST_SCRIPT': test_script,
|
'DATA_PASSWORD': pw, 'PASSWORD_FILENAME': shm.name, 'EXEC_CMD': exec_cmd, 'TEST_SCRIPT': test_script,
|
||||||
'REQUEST_ID': request_id
|
'REQUEST_ID': request_id, 'REQUEST_DATA': request_data,
|
||||||
}
|
}
|
||||||
return prepare_script(ans, replacements), replacements, shm
|
return prepare_script(ans, replacements), replacements, shm
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import tty
|
|||||||
tty_fd = -1
|
tty_fd = -1
|
||||||
original_termios_state = None
|
original_termios_state = None
|
||||||
data_dir = shell_integration_dir = ''
|
data_dir = shell_integration_dir = ''
|
||||||
|
request_data = int('REQUEST_DATA')
|
||||||
leading_data = b''
|
leading_data = b''
|
||||||
HOME = os.path.expanduser('~')
|
HOME = os.path.expanduser('~')
|
||||||
login_shell = pwd.getpwuid(os.geteuid()).pw_shell or 'sh'
|
login_shell = pwd.getpwuid(os.geteuid()).pw_shell or 'sh'
|
||||||
@ -217,6 +218,7 @@ def main():
|
|||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
if request_data:
|
||||||
try:
|
try:
|
||||||
original_termios_state = termios.tcgetattr(tty_fd)
|
original_termios_state = termios.tcgetattr(tty_fd)
|
||||||
except OSError:
|
except OSError:
|
||||||
@ -228,9 +230,10 @@ def main():
|
|||||||
new_state[-1][termios.VMIN] = 1
|
new_state[-1][termios.VMIN] = 1
|
||||||
new_state[-1][termios.VTIME] = 0
|
new_state[-1][termios.VTIME] = 0
|
||||||
termios.tcsetattr(tty_fd, termios.TCSANOW, new_state)
|
termios.tcsetattr(tty_fd, termios.TCSANOW, new_state)
|
||||||
if original_termios_state is not None:
|
|
||||||
try:
|
try:
|
||||||
|
if original_termios_state is not None:
|
||||||
send_data_request()
|
send_data_request()
|
||||||
|
if tty_fd > -1:
|
||||||
get_data()
|
get_data()
|
||||||
finally:
|
finally:
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|||||||
@ -5,6 +5,8 @@
|
|||||||
saved_tty_settings=""
|
saved_tty_settings=""
|
||||||
tdir=""
|
tdir=""
|
||||||
shell_integration_dir=""
|
shell_integration_dir=""
|
||||||
|
compression="gz"
|
||||||
|
|
||||||
cleanup_on_bootstrap_exit() {
|
cleanup_on_bootstrap_exit() {
|
||||||
[ -n "$saved_tty_settings" ] && command stty "$saved_tty_settings" 2> /dev/null < /dev/tty
|
[ -n "$saved_tty_settings" ] && command stty "$saved_tty_settings" 2> /dev/null < /dev/tty
|
||||||
[ -n "$tdir" ] && command rm -rf "$tdir"
|
[ -n "$tdir" ] && command rm -rf "$tdir"
|
||||||
@ -177,9 +179,10 @@ hostname="$HOSTNAME"
|
|||||||
leading_data=""
|
leading_data=""
|
||||||
login_cwd=""
|
login_cwd=""
|
||||||
|
|
||||||
init_tty && trap "cleanup_on_bootstrap_exit" EXIT
|
request_data="REQUEST_DATA"
|
||||||
if [ "$tty_ok" = "y" ]; then
|
[ "$request_data" = "1" ] && init_tty
|
||||||
compression="gz"
|
trap "cleanup_on_bootstrap_exit" EXIT
|
||||||
|
if [ "$tty_ok" = "y" -a "$request_data" = "1" ]; then
|
||||||
command -v "bzip2" > /dev/null 2> /dev/null && compression="bz2"
|
command -v "bzip2" > /dev/null 2> /dev/null && compression="bz2"
|
||||||
dcs_to_kitty "ssh" "id="REQUEST_ID":hostname="$hostname":pwfile="PASSWORD_FILENAME":user="$USER":compression="$compression":pw="DATA_PASSWORD""
|
dcs_to_kitty "ssh" "id="REQUEST_ID":hostname="$hostname":pwfile="PASSWORD_FILENAME":user="$USER":compression="$compression":pw="DATA_PASSWORD""
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user