chiark / gitweb /
fishdescriptor: bugfixes, seems to get fds now!
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 19 Oct 2017 00:32:56 +0000 (01:32 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Thu, 19 Oct 2017 00:32:56 +0000 (01:32 +0100)
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
fishdescriptor/py/fishdescriptor/fish.py

index 718456a..763684b 100644 (file)
@@ -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)