Skip to content

Commit 6687123

Browse files
committed
remotexec fix 4
1 parent fe77ba9 commit 6687123

1 file changed

Lines changed: 19 additions & 17 deletions

File tree

Doc/library/sys.rst

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,8 +1996,25 @@ always available. Unless explicitly noted otherwise, all variables are read-only
19961996
and minor version as the local process. If either the local or remote
19971997
interpreter is pre-release (alpha, beta, or release candidate) then the
19981998
local and remote interpreters must be the same exact version.
1999-
The temporary script file is created with restrictive permissions (typically
2000-
``0o600``). The target process must be able to read this file.
1999+
Note that the remote process must be able to read the temporary script file in terms
2000+
of permissions. If the caller is running under different user than the process,
2001+
the caller should grant permissions (typically ``os.fchmod(filename, 0o644)``).
2002+
2003+
Callers should adjust permissions before calling, for example::
2004+
2005+
import os
2006+
import tempfile
2007+
import sys
2008+
2009+
with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) as f:
2010+
f.write("print('Hello from remote!')")
2011+
f.flush()
2012+
os.chmod(f.name, 0o644) # Readable by group/other
2013+
sys.remote_exec(pid, f.name)
2014+
os.unlink(f.name) # Cleanup
2015+
2016+
.. availability:: Unix, Windows.
2017+
.. versionadded:: 3.14
20012018

20022019
.. audit-event:: sys.remote_exec pid script_path
20032020

@@ -2015,21 +2032,6 @@ always available. Unless explicitly noted otherwise, all variables are read-only
20152032
This event is raised in the remote process, not the one
20162033
that called :func:`sys.remote_exec`.
20172034

2018-
Callers should adjust permissions before calling, for example::
2019-
2020-
import os
2021-
import tempfile
2022-
import sys
2023-
2024-
with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) as f:
2025-
f.write("print('Hello from remote!')")
2026-
f.flush()
2027-
os.chmod(f.name, 0o644) # Readable by group/other
2028-
sys.remote_exec(pid, f.name)
2029-
os.unlink(f.name) # Cleanup
2030-
2031-
.. availability:: Unix, Windows.
2032-
.. versionadded:: 3.14
20332035

20342036
.. function:: _enablelegacywindowsfsencoding()
20352037

0 commit comments

Comments
 (0)