-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-143511: Document sys.remote_exec permissions requirements #143575
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
base: main
Are you sure you want to change the base?
Conversation
|
Wouldn't it make more sense to add this info to the remote debugging docs? 🤔 |
|
@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. |
Doc/library/sys.rst
Outdated
| The temporary script file is created with restrictive permissions (typically | ||
| ``0o600``). The target process must be able to read this file. | ||
|
|
||
| Callers should adjust permissions before calling, e.g.:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use latin abbreviations, see the devguide for more information.
| .. availability:: Unix, Windows. | ||
| .. versionadded:: 3.14 | ||
|
|
||
| The temporary script file is created with restrictive permissions (typically |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the directives (availability, versionadded) should always be at the end of a member section. Hence, I would move them to the end (or your addition above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the changes @RafaelWO, could you verify them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not at the end. versionadded should be the last section. You added your section afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@picnixz You mean even after the example I've provided?
| 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 |
There was a problem hiding this comment.
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.
sys.remote_exec(pid, script_path)creates a temporary script with restrictivepermissions (typically
0o600). The target process must be able to read thisfile, which fails in cross-user scenarios (e.g. sudo debugging).
Added documentation note with example showing how to
os.chmod()the file to0o644(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/