X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;ds=sidebyside;f=fishdescriptor%2Fpy%2Ffishdescriptor%2Ffish.py;h=1418aa19d71c8c628d591dc1416cd0035f910178;hb=5c2b2a5babcf6863b6d5d61c8fa1e8e2f2b5b52a;hp=a363c5e5318518b2eaeefdeeecbd8396eab2b82f;hpb=42c13be0ac6147fa4150d93225b81e6c5a928a4d;p=chiark-utils.git diff --git a/fishdescriptor/py/fishdescriptor/fish.py b/fishdescriptor/py/fishdescriptor/fish.py index a363c5e..1418aa1 100644 --- a/fishdescriptor/py/fishdescriptor/fish.py +++ b/fishdescriptor/py/fishdescriptor/fish.py @@ -1,9 +1,25 @@ # python 3 only import socket +import subprocess + +def _geteuid(pid): + def _shuffle_fd3(): + dup(1,3) + dup(2,1) + sp = subprocess.Popen(preexec_fn = _suffle_fd3, + stdin = subprocess.DEVNULL, stdout = subprocess.PIPE, + close_fds = False, + args = ['gdb', '-p', pid, '-batch', '-ex' + 'python import os; os.fdopen(30,"w").write("%d\n" % ' + +'gdb.parse_and_eval("(uid_t)geteuid()"))']) + (output, dummy) = sp.communicate() + +2009 def fish(pid, fds): # -> list of fds in our process + sockname = '/run/user/' + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def deliver(pid, fds, path):