You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make a few changes so that the server / client processes of pyrasite-shell can be in two different docker containers.
We need a deterministic listen-back port so the connecting (debugging) container can provide it at launch.
We need to write the payload file to a temporary location and it should have others read bit set so a container that dropped permissions can still read it.
There are a few settings required in the docker run command of the debugging container process, but not other requirements for the container under inspection.
Copy file name to clipboardExpand all lines: pyrasite/tools/shell.py
+19-13Lines changed: 19 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -15,26 +15,32 @@
15
15
#
16
16
# Copyright (C) 2011-2013 Red Hat, Inc., Luke Macken <lmacken@redhat.com>
17
17
18
+
importargparse
18
19
importos
19
-
importsys
20
20
importpyrasite
21
21
22
22
23
23
defshell():
24
-
"""Open a Python shell in a running process"""
24
+
parser=argparse.ArgumentParser(description='Open a Python shell in a running process')
25
+
parser.add_argument('pid', type=int, help='PID of the running process to attach to.')
26
+
parser.add_argument('--timeout', type=int, default=5, help='IPC Timeout, applies for each command.')
27
+
parser.add_argument('--server-host', default='localhost', help='The hostname to use for the listening (server) side of the IPC communication. Sometimes, (docker), localhost does not work.')
28
+
parser.add_argument('--client-host', default='localhost', help='The hostname to use for the connecting (client) side of the IPC communication. Sometimes, (docker), localhost does not work.')
29
+
parser.add_argument('--port', type=int, default=None, help='Optionally specify a port that will be listened on for the remote process to attach back.')
30
+
parser.add_argument('--tmpdir', default=None, help='Use the following tmp directory for transferring the payload')
0 commit comments