diff options
| author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2025-04-26 10:00:28 +0900 |
|---|---|---|
| committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2025-04-26 20:40:02 +0900 |
| commit | 9acef235e131d4cb2bcbeb2e7358fbf3af4ad9fe (patch) | |
| tree | 24988279dd3b3e9c84171039f7cd46a418529525 /gnu | |
| parent | 7ff20b9e94c429f1160bd8f0db86b153a03e4683 (diff) | |
gnu: libssh: Apply upstream patch and enable all tests.
* gnu/packages/patches/libssh-openssh-banner.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/ssh.scm (libssh) [source]: Apply it.
[arguments] <#:phase>: Remove disable-problematic-tests phase. Add
patch-commands and prepare-for-tests phases.
Change-Id: Iaead28f77b81fdf42b77f15dd37e6450537cba30
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/local.mk | 1 | ||||
| -rw-r--r-- | gnu/packages/patches/libssh-openssh-banner.patch | 61 | ||||
| -rw-r--r-- | gnu/packages/ssh.scm | 31 |
3 files changed, 81 insertions, 12 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index fafe69f609d..c4bc084b7e0 100644 --- a/gnu/local.mk +++ b/gnu/local.mk | |||
| @@ -1765,6 +1765,7 @@ dist_patch_DATA = \ | |||
| 1765 | %D%/packages/patches/libsecret-fix-test-paths.patch \ | 1765 | %D%/packages/patches/libsecret-fix-test-paths.patch \ |
| 1766 | %D%/packages/patches/libsepol-versioned-docbook.patch \ | 1766 | %D%/packages/patches/libsepol-versioned-docbook.patch \ |
| 1767 | %D%/packages/patches/libskk-fix-invalid-escape.patch \ | 1767 | %D%/packages/patches/libskk-fix-invalid-escape.patch \ |
| 1768 | %D%/packages/patches/libssh-openssh-banner.patch \ | ||
| 1768 | %D%/packages/patches/libtar-CVE-2013-4420.patch \ | 1769 | %D%/packages/patches/libtar-CVE-2013-4420.patch \ |
| 1769 | %D%/packages/patches/libtar-CVE-2021-33643-CVE-2021-33644.patch \ | 1770 | %D%/packages/patches/libtar-CVE-2021-33643-CVE-2021-33644.patch \ |
| 1770 | %D%/packages/patches/libtar-CVE-2021-33645-CVE-2021-33646.patch \ | 1771 | %D%/packages/patches/libtar-CVE-2021-33645-CVE-2021-33646.patch \ |
diff --git a/gnu/packages/patches/libssh-openssh-banner.patch b/gnu/packages/patches/libssh-openssh-banner.patch new file mode 100644 index 00000000000..2a05f6ec670 --- /dev/null +++ b/gnu/packages/patches/libssh-openssh-banner.patch | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | From 78d536c150bd7f327e0de45a1246bb1f03cd2f48 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Lucas Mulling <lucas.mulling@suse.com> | ||
| 3 | Date: Thu, 24 Apr 2025 15:48:32 -0300 | ||
| 4 | Subject: [PATCH] misc: Fix OpenSSH banner parsing | ||
| 5 | |||
| 6 | Signed-off-by: Lucas Mulling <lucas.mulling@suse.com> | ||
| 7 | --- | ||
| 8 | src/misc.c | 6 ++++-- | ||
| 9 | tests/unittests/torture_misc.c | 5 +++++ | ||
| 10 | 2 files changed, 9 insertions(+), 2 deletions(-) | ||
| 11 | |||
| 12 | diff --git a/src/misc.c b/src/misc.c | ||
| 13 | index 95512f0d3..b1ebc0c44 100644 | ||
| 14 | --- a/src/misc.c | ||
| 15 | +++ b/src/misc.c | ||
| 16 | @@ -1426,6 +1426,7 @@ int ssh_analyze_banner(ssh_session session, int server) | ||
| 17 | char *tmp = NULL; | ||
| 18 | unsigned long int major = 0UL; | ||
| 19 | unsigned long int minor = 0UL; | ||
| 20 | + int off = 0; | ||
| 21 | |||
| 22 | /* | ||
| 23 | * The banner is typical: | ||
| 24 | @@ -1445,8 +1446,9 @@ int ssh_analyze_banner(ssh_session session, int server) | ||
| 25 | } | ||
| 26 | |||
| 27 | errno = 0; | ||
| 28 | - minor = strtoul(openssh + 10, &tmp, 10); | ||
| 29 | - if ((tmp == (openssh + 10)) || | ||
| 30 | + off = major >= 10 ? 11 : 10; | ||
| 31 | + minor = strtoul(openssh + off, &tmp, 10); | ||
| 32 | + if ((tmp == (openssh + off)) || | ||
| 33 | ((errno == ERANGE) && (major == ULONG_MAX)) || | ||
| 34 | ((errno != 0) && (major == 0)) || | ||
| 35 | (minor > 100)) { | ||
| 36 | diff --git a/tests/unittests/torture_misc.c b/tests/unittests/torture_misc.c | ||
| 37 | index bd6bf96e8..b2320a94e 100644 | ||
| 38 | --- a/tests/unittests/torture_misc.c | ||
| 39 | +++ b/tests/unittests/torture_misc.c | ||
| 40 | @@ -448,6 +448,7 @@ static void torture_ssh_analyze_banner(void **state) { | ||
| 41 | assert_server_banner_accepted("SSH-2.0-OpenSSH"); | ||
| 42 | assert_int_equal(0, session->openssh); | ||
| 43 | |||
| 44 | + | ||
| 45 | /* OpenSSH banners: big enough to extract major and minor versions */ | ||
| 46 | assert_client_banner_accepted("SSH-2.0-OpenSSH_5.9p1"); | ||
| 47 | assert_int_equal(SSH_VERSION_INT(5, 9, 0), session->openssh); | ||
| 48 | @@ -487,6 +488,10 @@ static void torture_ssh_analyze_banner(void **state) { | ||
| 49 | assert_server_banner_accepted("SSH-2.0-OpenSSH-keyscan"); | ||
| 50 | assert_int_equal(0, session->openssh); | ||
| 51 | |||
| 52 | + /* OpenSSH banners: Double digit in major version */ | ||
| 53 | + assert_server_banner_accepted("SSH-2.0-OpenSSH_10.0p1"); | ||
| 54 | + assert_int_equal(SSH_VERSION_INT(10, 0, 0), session->openssh); | ||
| 55 | + | ||
| 56 | ssh_free(session); | ||
| 57 | } | ||
| 58 | |||
| 59 | -- | ||
| 60 | GitLab | ||
| 61 | |||
diff --git a/gnu/packages/ssh.scm b/gnu/packages/ssh.scm index 0b1ebfad56e..9fa765c2108 100644 --- a/gnu/packages/ssh.scm +++ b/gnu/packages/ssh.scm | |||
| @@ -154,7 +154,8 @@ file names. | |||
| 154 | (string-append all "\n" | 154 | (string-append all "\n" |
| 155 | "#ifndef PATH_MAX\n" | 155 | "#ifndef PATH_MAX\n" |
| 156 | "# define PATH_MAX 4096\n" | 156 | "# define PATH_MAX 4096\n" |
| 157 | "#endif\n")))))) | 157 | "#endif\n")))) |
| 158 | (patches (search-patches "libssh-openssh-banner.patch")))) | ||
| 158 | (build-system cmake-build-system) | 159 | (build-system cmake-build-system) |
| 159 | (outputs '("out" "debug")) | 160 | (outputs '("out" "debug")) |
| 160 | (arguments | 161 | (arguments |
| @@ -172,19 +173,25 @@ file names. | |||
| 172 | #~())) | 173 | #~())) |
| 173 | #:phases | 174 | #:phases |
| 174 | #~(modify-phases %standard-phases | 175 | #~(modify-phases %standard-phases |
| 175 | (add-after 'unpack 'disable-problematic-tests | 176 | (add-after 'unpack 'patch-commands |
| 177 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 178 | ;; Runtime sources. | ||
| 179 | (substitute* '("src/config.c" | ||
| 180 | "src/socket.c") | ||
| 181 | (("\"/bin/sh\"") | ||
| 182 | (format #f "~s" (search-input-file inputs "/bin/sh")))) | ||
| 183 | ;; Test sources. | ||
| 184 | (substitute* '("tests/server/test_server/default_cb.c") | ||
| 185 | (("\"/bin/sh\"") | ||
| 186 | (format #f "~s" (which "sh")))))) | ||
| 187 | (add-before 'check 'prepare-for-tests | ||
| 188 | ;; A few test rely on the assumption that HOME == user's pw_dir, | ||
| 189 | ;; which is not satisfied in Guix, where `pw_dir' is '/' while | ||
| 190 | ;; HOME is '/homeless-shelter'. | ||
| 176 | (lambda _ | 191 | (lambda _ |
| 177 | ;; XXX: There is no finer-grain control on skipping tests using | 192 | (setenv "HOME" "/")))))) |
| 178 | ;; cmocka, short of patching sources, which isn't trivial with | ||
| 179 | ;; substitute*/sed. | ||
| 180 | (substitute* "tests/unittests/CMakeLists.txt" | ||
| 181 | ;; Some torture tests fail due to assuming the user directory | ||
| 182 | ;; (from the passwd database) matches HOME, and other fail for | ||
| 183 | ;; unknown reasons (see: | ||
| 184 | ;; https://gitlab.com/libssh/libssh-mirror/-/issues/302). | ||
| 185 | (("^ torture_(config|misc|options).*$") ""))))))) | ||
| 186 | (native-inputs (list cmocka)) | 193 | (native-inputs (list cmocka)) |
| 187 | (inputs (list zlib libgcrypt mit-krb5)) | 194 | (inputs (list bash-minimal mit-krb5 libgcrypt zlib)) |
| 188 | (synopsis "SSH client library") | 195 | (synopsis "SSH client library") |
| 189 | (description | 196 | (description |
| 190 | "libssh is a C library implementing the SSHv2 and SSHv1 protocol for client | 197 | "libssh is a C library implementing the SSHv2 and SSHv1 protocol for client |
