ssh kitten: Allow using absolute paths for the location of transferred data
Fixes #5607
This commit is contained in:
parent
90e80477e9
commit
1747bbbbcb
@ -38,6 +38,8 @@ Detailed list of changes
|
|||||||
0.26.5 [future]
|
0.26.5 [future]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
- ssh kitten: Allow using absolute paths for the location of transferred data (:iss:`5607`)
|
||||||
|
|
||||||
- Fix a regression in the previous release that caused a :opt:`resize_draw_strategy` of ``static`` to not work (:iss:`5601`)
|
- Fix a regression in the previous release that caused a :opt:`resize_draw_strategy` of ``static`` to not work (:iss:`5601`)
|
||||||
|
|
||||||
- Wayland KDE: Fix abort when pasting into Firefox (:iss:`5603`)
|
- Wayland KDE: Fix abort when pasting into Firefox (:iss:`5603`)
|
||||||
|
|||||||
@ -40,10 +40,9 @@ shell or a :program:`python` executable. If the default :program:`sh` is not
|
|||||||
available or broken, using an alternate interpreter can be useful.
|
available or broken, using an alternate interpreter can be useful.
|
||||||
''')
|
''')
|
||||||
|
|
||||||
opt('remote_dir', '.local/share/kitty-ssh-kitten', option_type='relative_dir', long_text='''
|
opt('remote_dir', '.local/share/kitty-ssh-kitten', long_text='''
|
||||||
The location on the remote host where the files needed for this kitten are
|
The location on the remote host where the files needed for this kitten are
|
||||||
installed. The location is relative to the HOME directory. Absolute paths or
|
installed. Relative paths are resolved with respect to :code:`$HOME`.
|
||||||
paths that resolve to a location outside the HOME are not allowed.
|
|
||||||
''')
|
''')
|
||||||
|
|
||||||
opt('+copy', '', option_type='copy', add_to_default=False, long_text=f'''
|
opt('+copy', '', option_type='copy', add_to_default=False, long_text=f'''
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2022, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
import posixpath
|
|
||||||
from typing import Any, Dict, Iterable, Optional, Tuple
|
from typing import Any, Dict, Iterable, Optional, Tuple
|
||||||
|
|
||||||
from ..copy import CopyInstruction, parse_copy_instructions
|
from ..copy import CopyInstruction, parse_copy_instructions
|
||||||
@ -9,16 +8,6 @@ from ..copy import CopyInstruction, parse_copy_instructions
|
|||||||
DELETE_ENV_VAR = '_delete_this_env_var_'
|
DELETE_ENV_VAR = '_delete_this_env_var_'
|
||||||
|
|
||||||
|
|
||||||
def relative_dir(val: str) -> str:
|
|
||||||
if posixpath.isabs(val):
|
|
||||||
raise ValueError(f'Absolute paths not allowed. {val} is invalid.')
|
|
||||||
base = '/ffjdg'
|
|
||||||
q = posixpath.normpath(posixpath.join(base, val))
|
|
||||||
if q == base or not q.startswith(base):
|
|
||||||
raise ValueError(f'Paths that escape their parent dir are not allowed. {val} is not valid')
|
|
||||||
return posixpath.normpath(val)
|
|
||||||
|
|
||||||
|
|
||||||
def env(val: str, current_val: Dict[str, str]) -> Iterable[Tuple[str, str]]:
|
def env(val: str, current_val: Dict[str, str]) -> Iterable[Tuple[str, str]]:
|
||||||
val = val.strip()
|
val = val.strip()
|
||||||
if val:
|
if val:
|
||||||
|
|||||||
@ -205,7 +205,10 @@ def get_data():
|
|||||||
with open(tdir + '/data.sh') as f:
|
with open(tdir + '/data.sh') as f:
|
||||||
env_vars = f.read()
|
env_vars = f.read()
|
||||||
apply_env_vars(env_vars)
|
apply_env_vars(env_vars)
|
||||||
data_dir = os.path.join(HOME, os.environ.pop('KITTY_SSH_KITTEN_DATA_DIR'))
|
data_dir = os.environ.pop('KITTY_SSH_KITTEN_DATA_DIR')
|
||||||
|
if not os.path.isabs(data_dir):
|
||||||
|
data_dir = os.path.join(HOME, data_dir)
|
||||||
|
data_dir = os.path.abspath(data_dir)
|
||||||
shell_integration_dir = os.path.join(data_dir, 'shell-integration')
|
shell_integration_dir = os.path.join(data_dir, 'shell-integration')
|
||||||
compile_terminfo(tdir + '/home')
|
compile_terminfo(tdir + '/home')
|
||||||
move(tdir + '/home', HOME)
|
move(tdir + '/home', HOME)
|
||||||
|
|||||||
@ -103,7 +103,10 @@ untar_and_read_env() {
|
|||||||
. "$tdir/bootstrap-utils.sh"
|
. "$tdir/bootstrap-utils.sh"
|
||||||
. "$tdir/data.sh"
|
. "$tdir/data.sh"
|
||||||
[ -z "$KITTY_SSH_KITTEN_DATA_DIR" ] && die "Failed to read SSH data from tty"
|
[ -z "$KITTY_SSH_KITTEN_DATA_DIR" ] && die "Failed to read SSH data from tty"
|
||||||
data_dir="$HOME/$KITTY_SSH_KITTEN_DATA_DIR"
|
case "$KITTY_SSH_KITTEN_DATA_DIR" in
|
||||||
|
/*) data_dir="$KITTY_SSH_KITTEN_DATA_DIR" ;;
|
||||||
|
*) data_dir="$HOME/$KITTY_SSH_KITTEN_DATA_DIR"
|
||||||
|
esac
|
||||||
shell_integration_dir="$data_dir/shell-integration"
|
shell_integration_dir="$data_dir/shell-integration"
|
||||||
unset KITTY_SSH_KITTEN_DATA_DIR
|
unset KITTY_SSH_KITTEN_DATA_DIR
|
||||||
login_shell="$KITTY_LOGIN_SHELL"
|
login_shell="$KITTY_LOGIN_SHELL"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user