On 2024/03/03 15:21, Stuart Henderson wrote:
> On 2024/03/03 07:59, Theo de Raadt wrote:
> > Does it work if this is modified to just ask for "libc.so"?
> 
> Yes. Conservative approach just doing this for libc:

oh, we need to update the installed list-of-changes file too,
and diff updated to include 3.11 as well. I don't think I'll bother
with patching the legacy versions.

any OKs?

Index: 3.10/Makefile
===================================================================
RCS file: /cvs/ports/lang/python/3.10/Makefile,v
retrieving revision 1.37
diff -u -p -r1.37 Makefile
--- 3.10/Makefile       14 Nov 2023 12:33:56 -0000      1.37
+++ 3.10/Makefile       3 Mar 2024 15:24:58 -0000
@@ -4,7 +4,7 @@
 # Python itself.
 
 FULL_VERSION =         3.10.13
-REVISION =             0
+REVISION =             1
 SHARED_LIBS =          python3.10 0.0
 VERSION_SPEC =         >=3.10,<3.11
 PORTROACH =            limit:^3\.10
Index: 3.10/files/CHANGES.OpenBSD
===================================================================
RCS file: /cvs/ports/lang/python/3.10/files/CHANGES.OpenBSD,v
retrieving revision 1.13
diff -u -p -r1.13 CHANGES.OpenBSD
--- 3.10/files/CHANGES.OpenBSD  24 Apr 2023 11:15:43 -0000      1.13
+++ 3.10/files/CHANGES.OpenBSD  3 Mar 2024 15:24:58 -0000
@@ -19,5 +19,9 @@ compiler as passed to ports builds is /u
 6.  Use closefrom(2) instead of looping through all the file descriptors
 and calling close(2) on them.
 
+7.  ctypes' find_library is modified to pass "libc.so" to dlopen() rather
+than attempting to resolve a version number by parsing ldconfig -r output,
+which results in loading an incorrect version in some cases.
+
 These changes are available in the OpenBSD CVS repository
 <http://www.openbsd.org/anoncvs.html> in ports/lang/python/3.10.
Index: 3.10/patches/patch-Lib_ctypes_util_py
===================================================================
RCS file: 3.10/patches/patch-Lib_ctypes_util_py
diff -N 3.10/patches/patch-Lib_ctypes_util_py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ 3.10/patches/patch-Lib_ctypes_util_py       3 Mar 2024 15:24:58 -0000
@@ -0,0 +1,20 @@
+allow dlopen() to search for libc rather than parsing ldconfig -r to
+decide on a version number.
+
+(would this make sense for all libraries? I'm not sure exactly what
+parameters this might be called with, whether it's just a bare name or
+could have a path/version in it).
+
+Index: Lib/ctypes/util.py
+--- Lib/ctypes/util.py.orig
++++ Lib/ctypes/util.py
+@@ -204,6 +204,9 @@ elif os.name == "posix":
+             return nums or [sys.maxsize]
+ 
+         def find_library(name):
++            if sys.platform.startswith("openbsd") and name == "c":
++                return "libc.so"
++
+             ename = re.escape(name)
+             expr = r':-l%s\.\S+ => \S*/(lib%s\.\S+)' % (ename, ename)
+             expr = os.fsencode(expr)
Index: 3.11/Makefile
===================================================================
RCS file: /cvs/ports/lang/python/3.11/Makefile,v
retrieving revision 1.14
diff -u -p -r1.14 Makefile
--- 3.11/Makefile       12 Feb 2024 00:53:52 -0000      1.14
+++ 3.11/Makefile       3 Mar 2024 15:24:58 -0000
@@ -4,6 +4,7 @@
 # Python itself.
 
 FULL_VERSION =         3.11.8
+REVISION =             0
 SHARED_LIBS =          python3.11 0.0
 VERSION_SPEC =         >=3.11,<3.12
 PORTROACH =            limit:^3\.11
Index: 3.11/files/CHANGES.OpenBSD
===================================================================
RCS file: /cvs/ports/lang/python/3.11/files/CHANGES.OpenBSD,v
retrieving revision 1.4
diff -u -p -r1.4 CHANGES.OpenBSD
--- 3.11/files/CHANGES.OpenBSD  24 Apr 2023 11:18:57 -0000      1.4
+++ 3.11/files/CHANGES.OpenBSD  3 Mar 2024 15:24:58 -0000
@@ -19,5 +19,9 @@ compiler as passed to ports builds is /u
 6.  Use closefrom(2) instead of looping through all the file descriptors
 and calling close(2) on them.
 
+7.  ctypes' find_library is modified to pass "libc.so" to dlopen() rather
+than attempting to resolve a version number by parsing ldconfig -r output,
+which results in loading an incorrect version in some cases.
+
 These changes are available in the OpenBSD CVS repository
 <http://www.openbsd.org/anoncvs.html> in ports/lang/python/3.11.
Index: 3.11/patches/patch-Lib_ctypes_util_py
===================================================================
RCS file: 3.11/patches/patch-Lib_ctypes_util_py
diff -N 3.11/patches/patch-Lib_ctypes_util_py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ 3.11/patches/patch-Lib_ctypes_util_py       3 Mar 2024 15:24:58 -0000
@@ -0,0 +1,20 @@
+allow dlopen() to search for libc rather than parsing ldconfig -r to
+decide on a version number.
+
+(would this make sense for all libraries? I'm not sure exactly what
+parameters this might be called with, whether it's just a bare name or
+could have a path/version in it).
+
+Index: Lib/ctypes/util.py
+--- Lib/ctypes/util.py.orig
++++ Lib/ctypes/util.py
+@@ -207,6 +207,9 @@ elif os.name == "posix":
+             return nums or [sys.maxsize]
+ 
+         def find_library(name):
++            if sys.platform.startswith("openbsd") and name == "c":
++                return "libc.so"
++
+             ename = re.escape(name)
+             expr = r':-l%s\.\S+ => \S*/(lib%s\.\S+)' % (ename, ename)
+             expr = os.fsencode(expr)

Reply via email to