Skip to content

Commit f276b10

Browse files
authored
include missing vm_sockets.h for socket.AF_VSOCK (#1133)
Include vm_sockets.h which is missing from the kernel UAPI headers in version 3.16 of the kernel. This file is missing due to a typo in the Kbuild file. The file is needed for CPython to make socket.AF_VSOCK available. closes #1050
1 parent 6905b66 commit f276b10

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

cpython-unix/build.Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
# Compression packages are needed to extract archives.
88
#
99
# Various other build tools are needed for various building.
10+
# Note linux-headers is installed to source a missing UAPI header, see below
1011
RUN ulimit -n 10000 && apt-get install \
1112
bzip2 \
1213
ca-certificates \
1314
curl \
1415
file \
1516
libc6-dev \
17+
linux-headers-3.16.0-6-common \
1618
libffi-dev \
1719
make \
1820
patch \
@@ -23,3 +25,8 @@ RUN ulimit -n 10000 && apt-get install \
2325
unzip \
2426
zip \
2527
zlib1g-dev
28+
29+
# Debian Jessie's linux-libc-dev is missing the vm_sockets header due to a typo
30+
# see https://lists.openwall.net/netdev/2014/12/01/2
31+
RUN install -m 0644 /usr/src/linux-headers-3.16.0-6-common/include/uapi/linux/vm_sockets.h \
32+
/usr/include/linux/vm_sockets.h

pythonbuild/disttests/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,18 @@ def assertPythonWorks(path: Path, argv0: Optional[str] = None):
340340
with self.subTest(msg="weird argv[0]"):
341341
assertPythonWorks(sys.executable, argv0="/dev/null")
342342

343+
@unittest.skipUnless(sys.platform == "linux", "Linux-specific socket constant")
344+
# TODO(jjh) remove when musl builds use a sysroot
345+
@unittest.skipIf(
346+
os.environ["TARGET_TRIPLE"].endswith("-musl"),
347+
"kernel headers not available in musl",
348+
)
349+
def test_socket_af_vsock(self):
350+
import socket
351+
352+
self.assertTrue(hasattr(socket, "AF_VSOCK"))
353+
self.assertEqual(socket.AF_VSOCK, 40)
354+
343355
@unittest.skipUnless(sys.platform == "linux", "Linux-specific prctl")
344356
@unittest.skipIf(
345357
"static" in os.environ["BUILD_OPTIONS"],

0 commit comments

Comments
 (0)