diff mbox series

sudo: fix build with OpenSSL 4

Message ID 20261101040943.2246656-1-chenqi_hycx@cetc.com.cn
State Under Review
Headers show
Series sudo: fix build with OpenSSL 4 | expand

Commit Message

Chen Qi Nov. 1, 2026, 4:09 a.m. UTC
From: Chen Qi <chenqi_hycx@cetc.com.cn>

OpenSSL 4 made ASN1_STRING opaque, so hostcheck.c no longer builds when
it reads ->length directly.

hostcheck.c is only compiled when OpenSSL is found by configure, and
without selinux in DISTRO_FEATURES that never happens for sudo: it only
pulls in OpenSSL indirectly through

  audit -> python3 -> openssl

which selinux pulls into the sysroot. Disabling selinux removes that
chain, HAVE_OPENSSL stays undefined, the whole file is #if'd out, and the
error goes unnoticed.

Use ASN1_STRING_length() instead of accessing the length member. This is
the upstream fix, not yet part of any release.

Assisted-by: Codewhale:deepseek-v4-flash
Signed-off-by: Chen Qi <chenqi_hycx@cetc.com.cn>
---
 ...-use-accessor-for-ASN1_STRING-length.patch | 37 +++++++++++++++++++
 meta/recipes-extended/sudo/sudo_1.9.17p2.bb   |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 meta/recipes-extended/sudo/files/0001-lib-iolog-use-accessor-for-ASN1_STRING-length.patch
diff mbox series

Patch

diff --git a/meta/recipes-extended/sudo/files/0001-lib-iolog-use-accessor-for-ASN1_STRING-length.patch b/meta/recipes-extended/sudo/files/0001-lib-iolog-use-accessor-for-ASN1_STRING-length.patch
new file mode 100644
index 0000000000..5fd98acae0
--- /dev/null
+++ b/meta/recipes-extended/sudo/files/0001-lib-iolog-use-accessor-for-ASN1_STRING-length.patch
@@ -0,0 +1,37 @@ 
+From f97a34bc7b390f185d544e21b0ef75db1275953e Mon Sep 17 00:00:00 2001
+From: Theo Buehler <tb@openbsd.org>
+Date: Sat, 22 Nov 2025 12:28:50 +0100
+Subject: [PATCH] Use accessor for getting an ASN1_STRING's length
+
+OpenSSL 4 makes ASN1_STRING opaque, so hostcheck.c can no longer read
+->length directly. Use the ASN1_STRING_length() accessor instead.
+
+Upstream-Status: Backport [https://github.com/sudo-project/sudo/commit/f97a34bc7b390f185d544e21b0ef75db1275953e]
+Signed-off-by: Chen Qi <chenqi_hycx@cetc.com.cn>
+---
+ lib/iolog/hostcheck.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/lib/iolog/hostcheck.c b/lib/iolog/hostcheck.c
+--- a/lib/iolog/hostcheck.c
++++ b/lib/iolog/hostcheck.c
+@@ -323,14 +323,14 @@
+ #endif
+ 
+             /* IPV4 address */
+-            if(current_name->d.iPAddress->length == 4) {
++            if (ASN1_STRING_length(current_name->d.iPAddress) == 4) {
+                 if (inet_ntop(AF_INET, san_ip, san_ip_str, INET_ADDRSTRLEN) == NULL) {
+                     result = MalformedCertificate;
+                     break;
+                 }
+ #if defined(HAVE_STRUCT_IN6_ADDR)
+             /* IPV6 address */
+-            } else if (current_name->d.iPAddress->length == 16) {
++            } else if (ASN1_STRING_length(current_name->d.iPAddress) == 16) {
+                 if (inet_ntop(AF_INET6, san_ip, san_ip_str, INET6_ADDRSTRLEN) == NULL) {
+                     result = MalformedCertificate;
+                     break;
+-- 
+2.43.0
+
diff --git a/meta/recipes-extended/sudo/sudo_1.9.17p2.bb b/meta/recipes-extended/sudo/sudo_1.9.17p2.bb
index 489c0db09d..2b01684ee5 100644
--- a/meta/recipes-extended/sudo/sudo_1.9.17p2.bb
+++ b/meta/recipes-extended/sudo/sudo_1.9.17p2.bb
@@ -5,6 +5,7 @@  SRC_URI = "https://www.sudo.ws/dist/sudo-${PV}.tar.gz \
            file://0001-sudo.conf.in-fix-conflict-with-multilib.patch \
 		   file://0001-m4-Backport-ax_prog_cc_for_build.m4-macros.patch \
 		   file://CVE-2026-35535.patch \
+		   file://0001-lib-iolog-use-accessor-for-ASN1_STRING-length.patch \
            "
 
 PAM_SRC_URI = "file://sudo.pam"