chiark / gitweb /
1418aa19d71c8c628d591dc1416cd0035f910178
[chiark-utils.git] / fishdescriptor / py / fishdescriptor / fish.py
1 # python 3 only
2
3 import socket
4 import subprocess
5
6 def _geteuid(pid):
7     def _shuffle_fd3():
8         dup(1,3)
9         dup(2,1)
10     sp = subprocess.Popen(preexec_fn = _suffle_fd3,
11           stdin = subprocess.DEVNULL, stdout = subprocess.PIPE,
12           close_fds = False,
13           args = ['gdb', '-p', pid, '-batch', '-ex'
14                   'python import os; os.fdopen(30,"w").write("%d\n" % '
15                   +'gdb.parse_and_eval("(uid_t)geteuid()"))'])
16     (output, dummy) = sp.communicate()
17     
18 2009
19
20 def fish(pid, fds):
21     # -> list of fds in our process
22     sockname = '/run/user/' + 
23     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
24
25 def deliver(pid, fds, path):
26     gdb -batch -p %d -ex '