From: Ian Jackson Date: Thu, 19 Oct 2017 00:32:56 +0000 (+0100) Subject: fishdescriptor: bugfixes, seems to get fds now! X-Git-Tag: archive/debian/6.0.0~1^2~24 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=4f14a54c421cdc7799582c76d0f34eee7a86f3e7;hp=86b1fb55b995449d859fb13d925f66eb1fb12445 fishdescriptor: bugfixes, seems to get fds now! Signed-off-by: Ian Jackson --- 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)