Skip to content

Commit bff9c92

Browse files
committed
Document seccomp=unconfined; make the Mac commands shorter
1 parent 3219f21 commit bff9c92

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

Doc/howto/remote_debugging.rst

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ This can also be configured persistently, usually in ``/etc/sysctl.d``.
4040
in low-security environments.
4141

4242
It is also possible that the ``ptrace`` system call is disabled because of a
43-
security filter. In particular, this was common with older versions of Docker.
44-
Docker 19.03 or higher (released 2019) running on Linux kernel 4.8 or higher
45-
(released 2016) allow usage of the ``ptrace`` system call inside containers.
43+
security filter. In particular, this was common with older versions of some
44+
container software. Docker 19.03 or newer (released 2019) and containerd 1.6.7
45+
or newer (released 2022) will automatically allow usage of the ``ptrace``
46+
system call inside containers, when running on Linux kernel 4.8 or higher. If
47+
you cannot upgrade to these versions, you can create your container with an
48+
option like ``--security-opt seccomp=unconfined`` to disable the system call
49+
security filter for that container.
4650

4751
If you need to trace a process that you *do not* own, you will need superuser
4852
access or equivalent. This also applies to processes that have changed their
@@ -68,29 +72,23 @@ get around this restriction.)
6872
By default, macOS disables the ability to debug other processes.
6973

7074
You can modify your Python binary to opt in to being debugged by giving it an
71-
**ad-hoc code signature**. (An ad-hoc "signature" is just a configuration
72-
without any actual cryptographic signature or a need for a certificate or
73-
anything else such as an Apple developer program membership.)
75+
**ad-hoc code signature** with an **entitlement** enabling it to be debugged.
76+
(An ad-hoc "signature" is just a configuration without any actual cryptographic
77+
signature or a need for a certificate or anything else such as an Apple
78+
developer program membership.)
7479

75-
Create an entitlement property list file with the following contents:
80+
The following commands will create a file ``get-task-allow.plist`` with the
81+
necessary entitlement and add it to the Python binary:
7682

77-
.. code-block:: xml
83+
.. code-block:: sh
7884
79-
<?xml version="1.0" encoding="UTF-8"?>
80-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
81-
<plist version="1.0">
82-
<dict>
83-
<key>com.apple.security.get-task-allow</key>
84-
<true/>
85-
</dict>
86-
</plist>
85+
echo '{"com.apple.security.get-task-allow": true}' | plutil -convert xml1 -o get-task-allow.plist -
86+
codesign --sign - --entitlements get-task-allow.plist path/to/bin/python3
8787
88-
Save it to a file e.g. ``get-task-allow.plist``, and then run
89-
90-
``codesign --sign - --entitlements get-task-allow.plist path/to/bin/python3``
91-
92-
(These instructions are for a non-framework build of Python. Framework builds
93-
may need to be configured differently.)
88+
where ``path/to/bin/python3`` is the path to your Python binary, which you can
89+
find by e.g. running ``which python3`` or evaluating ``sys.base_executable`` at
90+
the Python REPL. (These instructions are for a non-framework build of Python.
91+
Framework builds may need to be configured differently.)
9492

9593
You should then be able to debug your own Python processes started with that
9694
binary.

0 commit comments

Comments
 (0)