Bug report
The implementation of socket.send_fds does not pass flags and address down to sock.sendmsg:
|
def send_fds(sock, buffers, fds, flags=0, address=None): |
|
""" send_fds(sock, buffers, fds[, flags[, address]]) -> integer |
|
|
|
Send the list of file descriptors fds over an AF_UNIX socket. |
|
""" |
|
return sock.sendmsg(buffers, [(_socket.SOL_SOCKET, |
|
_socket.SCM_RIGHTS, array.array("i", fds))]) |
The fix seems trivial, I can submit a PR.
Checklist
A clear and concise description of the bug
import os
import socket
sock = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_DGRAM)
fd = os.memfd_create("journal_entry")
socket.send_fds(sock=sock, buffers=[], fds=[fd], address="/run/systemd/journal/socket")
fails with
return sock.sendmsg(buffers, [(_socket.SOL_SOCKET,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 107] Transport endpoint is not connected
Your environment
- CPython versions tested on: 3.11.3
- Operating system and architecture: Linux-6.1.43-1-rpi-ARCH-armv7l-with-glibc2.35
Linked PRs
Bug report
The implementation of
socket.send_fdsdoes not passflagsandaddressdown tosock.sendmsg:cpython/Lib/socket.py
Lines 553 to 559 in bf70774
The fix seems trivial, I can submit a PR.
Checklist
A clear and concise description of the bug
fails with
Your environment
Linked PRs
socket.send_fdsandsocket.recv_fdshonour optional arguments. #108243addressandflagsparameters insocket.{send,recv}_fds#128882