mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 17:27:39 +02:00
Avoid a race in creating the idiotic_design symlink
This commit is contained in:
@@ -451,9 +451,16 @@ def connection_sharing_args(opts: SSHOptions, kitty_pid: int) -> List[str]:
|
|||||||
# /Users/WHY_DOES_ANYONE_USE_MACOS/Library/Caches/APPLE_ARE_IDIOTIC
|
# /Users/WHY_DOES_ANYONE_USE_MACOS/Library/Caches/APPLE_ARE_IDIOTIC
|
||||||
if len(rd) > 35 and os.path.isdir('/tmp'):
|
if len(rd) > 35 and os.path.isdir('/tmp'):
|
||||||
idiotic_design = '/tmp/kssh-rdir'
|
idiotic_design = '/tmp/kssh-rdir'
|
||||||
with suppress(FileNotFoundError):
|
try:
|
||||||
os.unlink(idiotic_design)
|
os.symlink(rd, idiotic_design)
|
||||||
os.symlink(rd, idiotic_design)
|
except FileExistsError:
|
||||||
|
try:
|
||||||
|
dest = os.readlink(idiotic_design)
|
||||||
|
except OSError as e:
|
||||||
|
raise ValueError(f'The {idiotic_design} symlink could not be created as something with that name exists already') from e
|
||||||
|
else:
|
||||||
|
if dest != rd:
|
||||||
|
raise ValueError(f'The {idiotic_design} symlink exists and points to the incorrect location: {dest}')
|
||||||
rd = idiotic_design
|
rd = idiotic_design
|
||||||
|
|
||||||
cp = os.path.join(rd, ssh_control_master_template.format(kitty_pid=kitty_pid, ssh_placeholder='%C'))
|
cp = os.path.join(rd, ssh_control_master_template.format(kitty_pid=kitty_pid, ssh_placeholder='%C'))
|
||||||
|
|||||||
Reference in New Issue
Block a user