ssh kitten: Fix remote directories being created world writable

The bootstrap script extracted the tarball with umask 000, so tar
created any directories not present in the tarball, such as ~/.terminfo
and the ssh kitten data directory, with mode 0777. Since tar is run with
-p, the permissions of entries in the tarball are already restored
exactly, so the umask override is unnecessary. Remove it so that
directories not in the tarball respect the user's umask, matching the
behavior of bootstrap.py.

Fixes #10834
Closes #10835
This commit is contained in:
Kovid Goyal 2026-11-10 08:15:26 +05:30
parent d1fc36a613
commit 45cd5201e9
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 9 additions and 3 deletions

View file

@ -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]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -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):

View file

@ -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"