Skip to content

Commit

Permalink
Workaround for launch bug (#861)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Oct 24, 2022
1 parent 52f908b commit ddf7028
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions jupyter_client/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ def write_connection_file(
cfg["signature_scheme"] = signature_scheme
cfg["kernel_name"] = kernel_name

# Prevent over-writing a file that has already been written with the same
# info. This is to prevent a race condition where the process has
# already been launched but has not yet read the connection file.
if os.path.exists(fname):
with open(fname) as f:
try:
data = json.load(f)
if data == cfg:
return fname, cfg
except Exception:
pass

# Only ever write this file as user read/writeable
# This would otherwise introduce a vulnerability as a file has secrets
# which would let others execute arbitrarily code as you
Expand Down

0 comments on commit ddf7028

Please sign in to comment.