diff --git a/docs/changelog.rst b/docs/changelog.rst index 623144769..95cc3b928 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -169,6 +169,9 @@ Detailed list of changes selection destroys its window before kitty can reply. X errors no longer cause kitty to exit, they are reported instead (:iss:`9248`) +- ssh kitten: Fix directories such as :file:`~/.terminfo` being created world + writable on the remote host on first connect (:iss:`10834`) + 0.50.0 [2026-11-03] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty_tests/ssh.py b/kitty_tests/ssh.py index 8c6880a99..4cbd095f3 100644 --- a/kitty_tests/ssh.py +++ b/kitty_tests/ssh.py @@ -303,6 +303,10 @@ copy --exclude **/w.* --exclude **/r d1 self.ae(os.readlink(os.path.join(dest, 'link')), 'private/nested') self.ae(os.readlink(os.path.join(dest, 'broken')), 'missing') self.ae(glob.glob(os.path.join(remote_home, '.kitty-ssh-kitten-untar-*')), []) + # directories not present in the tarball must be created respecting the umask + # https://github.com/kovidgoyal/kitty/issues/10834 + for name in ('.terminfo', '.terminfo/x'): + self.ae(stat.S_IMODE(os.lstat(os.path.join(remote_home, name)).st_mode), 0o777 & ~int(umask, 8), (sh, umask, name)) @retry_on_failure() def test_ssh_env_vars(self): diff --git a/shell-integration/ssh/bootstrap.sh b/shell-integration/ssh/bootstrap.sh index 25418b29c..7e170f891 100644 --- a/shell-integration/ssh/bootstrap.sh +++ b/shell-integration/ssh/bootstrap.sh @@ -114,10 +114,9 @@ untar_and_read_env() { tdir=$(command mktemp -d "$HOME/.kitty-ssh-kitten-untar-XXXXXXXXXXXX") [ $? = 0 ] || die "Creating temp directory failed" # suppress STDERR for tar as tar prints various warnings if for instance, timestamps are in the future - old_umask=$(umask) - umask 000 + # -p makes tar restore the exact permissions of the entries in the tarball, + # directories not in the tarball are created respecting the user's umask read_base64_from_tty | base64_decode | command tar "xpzf" "-" "-C" "$tdir" 2> /dev/null - umask "$old_umask" . "$tdir/bootstrap-utils.sh" . "$tdir/data.sh" [ -z "$KITTY_SSH_KITTEN_DATA_DIR" ] && die "Failed to read SSH data from tty"