Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for launch bug #861

Merged
merged 1 commit into from
Oct 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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