diff --git a/libssh-CmakeLists-Fix-multiple-digit-major-version-for-OpenSSH.patch b/libssh-CmakeLists-Fix-multiple-digit-major-version-for-OpenSSH.patch new file mode 100644 index 0000000..4e12547 --- /dev/null +++ b/libssh-CmakeLists-Fix-multiple-digit-major-version-for-OpenSSH.patch @@ -0,0 +1,47 @@ +From af10857aa3216f40c5c2e5d7116803fb03c166f9 Mon Sep 17 00:00:00 2001 +From: Norbert Pocs +Date: Fri, 11 Apr 2025 09:04:40 +0200 +Subject: [PATCH] CmakeLists: Fix multiple digit major version for OpenSSH +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Norbert Pocs +Reviewed-by: Jakub Jelen +Signed-off-by: Lucas Mülling +--- + tests/CMakeLists.txt | 13 +++---------- + 1 file changed, 3 insertions(+), 10 deletions(-) + +Index: libssh-0.11.1/tests/CMakeLists.txt +=================================================================== +--- libssh-0.11.1.orig/tests/CMakeLists.txt ++++ libssh-0.11.1/tests/CMakeLists.txt +@@ -100,9 +100,10 @@ add_subdirectory(unittests) + find_program(SSH_EXECUTABLE NAMES ssh) + if (SSH_EXECUTABLE) + execute_process(COMMAND ${SSH_EXECUTABLE} -V ERROR_VARIABLE OPENSSH_VERSION_STR) +- string(REGEX REPLACE "^.*OpenSSH_([0-9]).[0-9].*$" "\\1" OPENSSH_VERSION_MAJOR "${OPENSSH_VERSION_STR}") +- string(REGEX REPLACE "^.*OpenSSH_[0-9].([0-9]).*$" "\\1" OPENSSH_VERSION_MINOR "${OPENSSH_VERSION_STR}") ++ string(REGEX REPLACE "^.*OpenSSH_([0-9]+).[0-9].*$" "\\1" OPENSSH_VERSION_MAJOR "${OPENSSH_VERSION_STR}") ++ string(REGEX REPLACE "^.*OpenSSH_[0-9]+.([0-9]).*$" "\\1" OPENSSH_VERSION_MINOR "${OPENSSH_VERSION_STR}") + set(OPENSSH_VERSION "${OPENSSH_VERSION_MAJOR}.${OPENSSH_VERSION_MINOR}") ++ add_definitions(-DOPENSSH_VERSION_MAJOR=${OPENSSH_VERSION_MAJOR} -DOPENSSH_VERSION_MINOR=${OPENSSH_VERSION_MINOR}) + if("${OPENSSH_VERSION}" VERSION_LESS "6.3") + # ssh - Q was introduced in 6.3 + message("Version less than 6.3, hardcoding cipher list") +@@ -209,14 +210,6 @@ if (CLIENT_TESTING OR SERVER_TESTING) + endif (WITH_PKCS11_PROVIDER) + endif (WITH_PKCS11_URI) + +- find_program(SSH_EXECUTABLE NAMES ssh) +- if (SSH_EXECUTABLE) +- execute_process(COMMAND ${SSH_EXECUTABLE} -V ERROR_VARIABLE OPENSSH_VERSION_STR) +- string(REGEX REPLACE "^.*OpenSSH_([0-9]).[0-9].*$" "\\1" OPENSSH_VERSION_MAJOR "${OPENSSH_VERSION_STR}") +- string(REGEX REPLACE "^.*OpenSSH_[0-9].([0-9]).*$" "\\1" OPENSSH_VERSION_MINOR "${OPENSSH_VERSION_STR}") +- add_definitions(-DOPENSSH_VERSION_MAJOR=${OPENSSH_VERSION_MAJOR} -DOPENSSH_VERSION_MINOR=${OPENSSH_VERSION_MINOR}) +- endif() +- + set(LOCAL_USER "nobody") + set(LOCAL_UID "65533") + find_program(ID_EXECUTABLE NAMES id) diff --git a/libssh-misc-Fix-OpenSSH-banner-parsing.patch b/libssh-misc-Fix-OpenSSH-banner-parsing.patch new file mode 100644 index 0000000..5066dd2 --- /dev/null +++ b/libssh-misc-Fix-OpenSSH-banner-parsing.patch @@ -0,0 +1,61 @@ +From bf7b04b1665167e6bac527428c874150c6366df2 Mon Sep 17 00:00:00 2001 +From: Lucas Mulling +Date: Thu, 24 Apr 2025 15:48:32 -0300 +Subject: [PATCH] misc: Fix OpenSSH banner parsing + +Signed-off-by: Lucas Mulling +--- + src/misc.c | 6 ++++-- + tests/unittests/torture_misc.c | 5 +++++ + 2 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/src/misc.c b/src/misc.c +index 95512f0d..c18aac93 100644 +--- a/src/misc.c ++++ b/src/misc.c +@@ -1426,6 +1426,7 @@ int ssh_analyze_banner(ssh_session session, int server) + char *tmp = NULL; + unsigned long int major = 0UL; + unsigned long int minor = 0UL; ++ int off = 0; + + /* + * The banner is typical: +@@ -1445,8 +1446,9 @@ int ssh_analyze_banner(ssh_session session, int server) + } + + errno = 0; +- minor = strtoul(openssh + 10, &tmp, 10); +- if ((tmp == (openssh + 10)) || ++ off = major >= 10 ? 11: 10; ++ minor = strtoul(openssh + off, &tmp, 10); ++ if ((tmp == (openssh + off)) || + ((errno == ERANGE) && (major == ULONG_MAX)) || + ((errno != 0) && (major == 0)) || + (minor > 100)) { +diff --git a/tests/unittests/torture_misc.c b/tests/unittests/torture_misc.c +index bd6bf96e..b2320a94 100644 +--- a/tests/unittests/torture_misc.c ++++ b/tests/unittests/torture_misc.c +@@ -448,6 +448,7 @@ static void torture_ssh_analyze_banner(void **state) { + assert_server_banner_accepted("SSH-2.0-OpenSSH"); + assert_int_equal(0, session->openssh); + ++ + /* OpenSSH banners: big enough to extract major and minor versions */ + assert_client_banner_accepted("SSH-2.0-OpenSSH_5.9p1"); + assert_int_equal(SSH_VERSION_INT(5, 9, 0), session->openssh); +@@ -487,6 +488,10 @@ static void torture_ssh_analyze_banner(void **state) { + assert_server_banner_accepted("SSH-2.0-OpenSSH-keyscan"); + assert_int_equal(0, session->openssh); + ++ /* OpenSSH banners: Double digit in major version */ ++ assert_server_banner_accepted("SSH-2.0-OpenSSH_10.0p1"); ++ assert_int_equal(SSH_VERSION_INT(10, 0, 0), session->openssh); ++ + ssh_free(session); + } + +-- +2.49.0 + diff --git a/libssh.changes b/libssh.changes index 4bb8997..9466a83 100644 --- a/libssh.changes +++ b/libssh.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Wed Apr 23 19:59:55 UTC 2025 - Lucas Mulling + +- Fix build and tests with OpenSSH >= 10.0 + * Use %make_build instead of naked make + * Add patches: + - libssh-CmakeLists-Fix-multiple-digit-major-version-for-OpenSSH.patch + - libssh-misc-Fix-OpenSSH-banner-parsing.patch + ------------------------------------------------------------------- Tue Feb 18 19:08:10 UTC 2025 - Lucas Mulling diff --git a/libssh.spec b/libssh.spec index e85dc9a..c28ad4f 100644 --- a/libssh.spec +++ b/libssh.spec @@ -46,6 +46,10 @@ Source4: libssh_server.config Source99: baselibs.conf # PATCH-FIX-UPSTREAM: libssh tries to read config from wrong crypto-policies location (bsc#1222716) Patch0: libssh-cmake-Add-option-WITH_HERMETIC_USR.patch +# PATCH-FIX-UPSTREAM: fix build with OpenSSH >= 10.0 +Patch1: libssh-CmakeLists-Fix-multiple-digit-major-version-for-OpenSSH.patch +# PATCH-FIX-UPSTREAM: fix OpenSSH banner parsing +Patch2: libssh-misc-Fix-OpenSSH-banner-parsing.patch BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: krb5-devel @@ -124,7 +128,7 @@ Development headers for the SSH library. -DGLOBAL_CLIENT_CONFIG="%{_sysconfdir}/libssh/libssh_client.config" \ -DGLOBAL_BIND_CONFIG="%{_sysconfdir}/libssh/libssh_server.config" -make %{?_smp_mflags} +%make_build %install %if !%{with test}