From 4f14a54c421cdc7799582c76d0f34eee7a86f3e7 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 19 Oct 2017 01:32:56 +0100 Subject: [PATCH] fishdescriptor: bugfixes, seems to get fds now! Signed-off-by: Ian Jackson --- fishdescriptor/py/fishdescriptor/fish.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fishdescriptor/py/fishdescriptor/fish.py b/fishdescriptor/py/fishdescriptor/fish.py index 718456a..763684b 100644 --- a/fishdescriptor/py/fishdescriptor/fish.py +++ b/fishdescriptor/py/fishdescriptor/fish.py @@ -4,6 +4,7 @@ import socket import subprocess import os import pwd +import struct def _shuffle_fd3(): os.dup2(1,3) @@ -119,11 +120,13 @@ class Donor(): (s2, dummy) = s.accept() (msg, ancil, flags, sender) = s2.recvmsg(1, ancil_len) - got_fds = [ ] + got_fds = None + unpack_fmt = '%di' % len(fds) for clvl, ctype, cdata in ancil: if clvl == socket.SOL_SOCKET and ctype == socket.SCM_RIGHTS: - got_fds += cdata # need to trim any surplus, and unpack + assert(got_fds is None) + got_fds = struct.unpack_from(unpack_fmt, cdata) finally: if s is not None: s.close() @@ -131,3 +134,5 @@ class Donor(): try: os.remove(our_sockname) except FileNotFoundError: pass + + return list(got_fds) -- 2.30.2