Skip to content

Conversation

@Yashp002
Copy link
Contributor

@Yashp002 Yashp002 commented Jan 8, 2026

sys.remote_exec(pid, script_path) creates a temporary script with restrictive
permissions (typically 0o600). The target process must be able to read this
file, which fails in cross-user scenarios (e.g. sudo debugging).

Added documentation note with example showing how to os.chmod() the file to
0o644 (readable by group/other) before calling.

Addresses the PermissionError reported in #143511.

Co-authored-by: @RafaelWO


📚 Documentation preview 📚: https://cpython-previews--143575.org.readthedocs.build/

@RafaelWO
Copy link
Contributor

RafaelWO commented Jan 8, 2026

Wouldn't it make more sense to add this info to the remote debugging docs? 🤔

@Yashp002
Copy link
Contributor Author

Yashp002 commented Jan 8, 2026

@RafaelWO Well i figured sys.rst or sys.executable here is way more used or gone through by users on a daily basis? Sys.rst is more discoverable for users hitting the error.
We could go with keeping it in both too but this one's just more discoverable imo unless I'm heavily mistaken.

@StanFromIreland StanFromIreland changed the title gh-143511: Document sys.remote_exec permissions requirements [skip news] gh-143511: Document sys.remote_exec permissions requirements Jan 9, 2026
Comment on lines 2022 to 2033
Callers should adjust permissions before calling, for example::

import os
import tempfile
import sys

with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) as f:
f.write("print('Hello from remote!')")
f.flush()
os.chmod(f.name, 0o644) # Readable by group/other
sys.remote_exec(pid, f.name)
os.unlink(f.name) # Cleanup
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be put before the audit event descriptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@picnixz Have implemented that yes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not before the audit events yet. Speaking in line numbers, your paragraph should be after line 1998 but before 2000.

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did so
accidentally named the commit the same as last one but yeah, shouldn't be a problem

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are almost there: Please move all your content above the audit-event directives - not just the first paragraph 😉

Comment on lines 1999 to 2000
The temporary script file is created with restrictive permissions (typically
``0o600``). The target process must be able to read this file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be misleading since it sounds like remote_exec creates the script (which it does not).

Example suggestion:

Note that the remote process must be able to read this file in terms of permissions. If the caller is running under a different user than the remote process, the caller should adjust permissions (...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright yeah, yours is quite better I have to say, cuz what I've inputted may be misleading.

Thanks I'll use yours:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants