Only try to chmod runtime dir if actually needed

This commit is contained in:
Kovid Goyal 2022-03-13 13:45:03 +05:30
parent db00adaf69
commit f3088c5646
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 2 deletions

View File

@ -151,6 +151,8 @@ def runtime_dir() -> str:
if not os.path.isdir(candidate) or not os.access(candidate, os.X_OK | os.W_OK | os.R_OK): if not os.path.isdir(candidate) or not os.access(candidate, os.X_OK | os.W_OK | os.R_OK):
candidate = os.path.join(cache_dir(), 'run') candidate = os.path.join(cache_dir(), 'run')
os.makedirs(candidate, exist_ok=True) os.makedirs(candidate, exist_ok=True)
import stat
if stat.S_IMODE(os.stat(candidate).st_mode) != 0o700:
os.chmod(candidate, 0o700) os.chmod(candidate, 0o700)
return candidate return candidate

View File

@ -14,7 +14,7 @@ from kittens.ssh.main import (
) )
from kittens.ssh.options.utils import DELETE_ENV_VAR from kittens.ssh.options.utils import DELETE_ENV_VAR
from kittens.transfer.utils import set_paths from kittens.transfer.utils import set_paths
from kitty.constants import is_macos from kitty.constants import is_macos, runtime_dir
from kitty.fast_data_types import CURSOR_BEAM from kitty.fast_data_types import CURSOR_BEAM
from kitty.options.utils import shell_integration from kitty.options.utils import shell_integration
from kitty.utils import SSHConnectionData from kitty.utils import SSHConnectionData
@ -56,6 +56,7 @@ print(' '.join(map(str, buf)))'''), lines=13, cols=77)
t('ssh un@ip -iident -p34', host='un@ip', port=34, identity_file='ident') t('ssh un@ip -iident -p34', host='un@ip', port=34, identity_file='ident')
t('ssh -p 33 main', port=33) t('ssh -p 33 main', port=33)
t('ssh --kitten=one -p 12 --kitten two -ix main', identity_file='x', port=12, extra_args=(('--kitten', 'one'), ('--kitten', 'two'))) t('ssh --kitten=one -p 12 --kitten two -ix main', identity_file='x', port=12, extra_args=(('--kitten', 'one'), ('--kitten', 'two')))
self.assertTrue(runtime_dir())
def test_ssh_config_parsing(self): def test_ssh_config_parsing(self):
def parse(conf): def parse(conf):