diff --git a/kittens/ssh/main.py b/kittens/ssh/main.py index 016a75fb1..8e0ab4074 100644 --- a/kittens/ssh/main.py +++ b/kittens/ssh/main.py @@ -129,7 +129,7 @@ def make_tarfile(ssh_opts: SSHOptions, base_env: Dict[str, str], compression: st if ksi: arcname = 'home/' + rd + '/shell-integration' tf.add(shell_integration_dir, arcname=arcname, filter=filter_from_globs( - f'{arcname}/ssh/bootstrap.*', # bootstrap files are sent as command line args + f'{arcname}/ssh/*', # bootstrap files are sent as command line args f'{arcname}/zsh/kitty.zsh', # present for legacy compat not needed by ssh kitten )) tf.add(terminfo_dir, arcname='home/.terminfo', filter=normalize_tarinfo) @@ -234,6 +234,7 @@ def bootstrap_script( with SharedMemory(size=len(db) + len(sz), mode=stat.S_IREAD, prefix=f'kssh-{os.getpid()}-') as shm: shm.write(sz) shm.write(db) + shm.flush() atexit.register(shm.unlink) replacements = { 'DATA_PASSWORD': pw, 'PASSWORD_FILENAME': shm.name, 'EXEC_CMD': exec_cmd, 'TEST_SCRIPT': test_script, diff --git a/kitty/shm.py b/kitty/shm.py index 530a82223..82eee46bf 100644 --- a/kitty/shm.py +++ b/kitty/shm.py @@ -46,8 +46,9 @@ class SharedMemory: def __init__( self, name: str = '', size: int = 0, readonly: bool = False, mode: int = stat.S_IREAD | stat.S_IWRITE, - prefix: str = 'kitty-' + prefix: str = 'kitty-', unlink_on_exit: bool = False ): + self.unlink_on_exit = unlink_on_exit if size < 0: raise TypeError("'size' must be a non-negative integer") if size and name: @@ -100,6 +101,9 @@ class SharedMemory: def seek(self, pos: int, whence: int = os.SEEK_SET) -> None: self.mmap.seek(pos, whence) + def flush(self) -> None: + self.mmap.flush() + def __del__(self) -> None: try: self.close() @@ -111,6 +115,8 @@ class SharedMemory: def __exit__(self, *a: object) -> None: self.close() + if self.unlink_on_exit: + self.unlink() @property def size(self) -> int: