From 959df9b7183ed581178c25d9ed6f0ae483f2b82e Mon Sep 17 00:00:00 2001 From: xinghe Date: Thu, 13 Oct 2022 03:18:58 +0000 Subject: [PATCH] backport upstream patches (cherry picked from commit e2042d2ad5c949b97d3cfa7b04536b335c6aabf2) --- backport-options-Parse-hostname-by-last.patch | 33 +++++++++++ backport-session-Initialize-pointers.patch | 31 ++++++++++ ...sure-the-mode-of-the-created-file-is.patch | 57 +++++++++++++++++++ ...e_options-Add-test-for-in-login-name.patch | 37 ++++++++++++ libssh.spec | 15 ++++- 5 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 backport-options-Parse-hostname-by-last.patch create mode 100644 backport-session-Initialize-pointers.patch create mode 100644 backport-tests-Ensure-the-mode-of-the-created-file-is.patch create mode 100644 backport-torture_options-Add-test-for-in-login-name.patch diff --git a/backport-options-Parse-hostname-by-last.patch b/backport-options-Parse-hostname-by-last.patch new file mode 100644 index 0000000..5fe977c --- /dev/null +++ b/backport-options-Parse-hostname-by-last.patch @@ -0,0 +1,33 @@ +From bb5f7e2707c1d04cd080bc64ff748ec89cf614fa Mon Sep 17 00:00:00 2001 +From: Norbert Pocs +Date: Mon, 4 Jul 2022 13:58:06 +0200 +Subject: options: Parse hostname by last '@' + +The login name can have '@' char in it + +Signed-off-by: Norbert Pocs +Reviewed-by: Jakub Jelen +Reviewed-by: Andreas Schneider + +Conflict:NA +Reference:https://git.libssh.org/projects/libssh.git/patch/?id=bb5f7e2707c1d04cd080bc64ff748ec89cf614fa +--- + src/options.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/options.c b/src/options.c +index e4c80f8..9c2ac29 100644 +--- a/src/options.c ++++ b/src/options.c +@@ -495,7 +495,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, + ssh_set_error_oom(session); + return -1; + } +- p = strchr(q, '@'); ++ p = strrchr(q, '@'); + + SAFE_FREE(session->opts.host); + +-- +2.33.0 + diff --git a/backport-session-Initialize-pointers.patch b/backport-session-Initialize-pointers.patch new file mode 100644 index 0000000..f99462d --- /dev/null +++ b/backport-session-Initialize-pointers.patch @@ -0,0 +1,31 @@ +From 355e29d881dcf2d255fbe58864ef98dc3bc5653c Mon Sep 17 00:00:00 2001 +From: Jakub Jelen +Date: Mon, 4 Jul 2022 19:22:30 +0200 +Subject: session: Initialize pointers + +Signed-off-by: Jakub Jelen +Reviewed-by: Andreas Schneider + +Conflict:NA +Reference:https://git.libssh.org/projects/libssh.git/patch/?id=355e29d881dcf2d255fbe58864ef98dc3bc5653c + +--- + src/session.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/session.c b/src/session.c +index 3199096..484fe39 100644 +--- a/src/session.c ++++ b/src/session.c +@@ -977,7 +977,7 @@ int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash) + ssh_key pubkey = NULL; + ssh_string pubkey_blob = NULL; + MD5CTX ctx; +- unsigned char *h; ++ unsigned char *h = NULL; + int rc; + + if (session == NULL || hash == NULL) { +-- +2.33.0 + diff --git a/backport-tests-Ensure-the-mode-of-the-created-file-is.patch b/backport-tests-Ensure-the-mode-of-the-created-file-is.patch new file mode 100644 index 0000000..3e048ea --- /dev/null +++ b/backport-tests-Ensure-the-mode-of-the-created-file-is.patch @@ -0,0 +1,57 @@ +From 1286a70e139fb7553dce02107cdcdf36edcf53f1 Mon Sep 17 00:00:00 2001 +From: renmingshuai +Date: Fri, 5 Aug 2022 17:08:30 +0800 +Subject: tests: Ensure the mode of the created file is ... + +what we set in open funtion by the argument mode. The mode of the +created file +is (mode & ~umask), So we set umask to typical default value(octal 022). + +Signed-off-by: renmingshuai +Reviewed-by: Jakub Jelen +Reviewed-by: Andreas Schneider + +Conflict:NA +Reference:https://git.libssh.org/projects/libssh.git/patch/?id=1286a70e139fb7553dce02107cdcdf36edcf53f1 + +--- + tests/client/torture_scp.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/tests/client/torture_scp.c b/tests/client/torture_scp.c +index 59a00ba..fe3f239 100644 +--- a/tests/client/torture_scp.c ++++ b/tests/client/torture_scp.c +@@ -39,6 +39,9 @@ + #define TEMPLATE BINARYDIR "/tests/home/alice/temp_dir_XXXXXX" + #define ALICE_HOME BINARYDIR "/tests/home/alice" + ++/* store the original umask */ ++mode_t old; ++ + struct scp_st { + struct torture_state *s; + char *tmp_dir; +@@ -99,6 +102,9 @@ static int session_setup(void **state) + + s = ts->s; + ++ /* store the original umask and set a new one */ ++ old = umask(0022); ++ + /* Create temporary directory for alice */ + tmp_dir = torture_make_temp_dir(TEMPLATE); + assert_non_null(tmp_dir); +@@ -135,6 +141,9 @@ static int session_teardown(void **state) + assert_non_null(ts->s); + s = ts->s; + ++ /* restore the umask */ ++ umask(old); ++ + ssh_disconnect(s->ssh.session); + ssh_free(s->ssh.session); + +-- +2.33.0 + diff --git a/backport-torture_options-Add-test-for-in-login-name.patch b/backport-torture_options-Add-test-for-in-login-name.patch new file mode 100644 index 0000000..7a9d0e4 --- /dev/null +++ b/backport-torture_options-Add-test-for-in-login-name.patch @@ -0,0 +1,37 @@ +From 964df4dc290c631fe2ece74600e510ca6c0a7385 Mon Sep 17 00:00:00 2001 +From: Norbert Pocs +Date: Mon, 11 Jul 2022 12:34:34 +0200 +Subject: torture_options: Add test for '@' in login name + +Signed-off-by: Norbert Pocs +Reviewed-by: Jakub Jelen +Reviewed-by: Andreas Schneider + +Conflict:Na +Reference:https://git.libssh.org/projects/libssh.git/commit?id=964df4dc290c631fe2ece74600e510ca6c0a7385 + +--- + tests/unittests/torture_options.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/tests/unittests/torture_options.c b/tests/unittests/torture_options.c +index d0fdaed..6bfd091 100644 +--- a/tests/unittests/torture_options.c ++++ b/tests/unittests/torture_options.c +@@ -65,6 +65,13 @@ static void torture_options_set_host(void **state) { + assert_string_equal(session->opts.host, "meditation"); + assert_non_null(session->opts.username); + assert_string_equal(session->opts.username, "guru"); ++ ++ rc = ssh_options_set(session, SSH_OPTIONS_HOST, "at@login@hostname"); ++ assert_true(rc == 0); ++ assert_non_null(session->opts.host); ++ assert_string_equal(session->opts.host, "hostname"); ++ assert_non_null(session->opts.username); ++ assert_string_equal(session->opts.username, "at@login"); + } + + static void torture_options_set_ciphers(void **state) { +-- +2.33.0 + diff --git a/libssh.spec b/libssh.spec index 7d9cfd3..21e10b9 100644 --- a/libssh.spec +++ b/libssh.spec @@ -1,6 +1,6 @@ Name: libssh Version: 0.9.6 -Release: 3 +Release: 4 Summary: A library implementing the SSH protocol License: LGPLv2+ URL: http://www.libssh.org @@ -14,6 +14,10 @@ Patch1: backport-auth-Fix-error-returned-in-ssh_userauth_try_publicke.pa Patch2: backport-client-Do-not-close-the-socket-if-it-was-set-via-opt.patch Patch3: backport-libsshpp-Fix-openForward-to-not-set-sourcehost-to-NU.patch Patch4: backport-sftp-fix-the-length-calculation-of-packet-in-sftp_wr.patch +Patch5: backport-options-Parse-hostname-by-last.patch +Patch6: backport-torture_options-Add-test-for-in-login-name.patch +Patch7: backport-session-Initialize-pointers.patch +Patch8: backport-tests-Ensure-the-mode-of-the-created-file-is.patch BuildRequires: cmake gcc-c++ gnupg2 openssl-devel pkgconfig zlib-devel BuildRequires: krb5-devel libcmocka-devel openssh-clients openssh-server @@ -99,6 +103,15 @@ popd %doc ChangeLog README %changelog +* Thu Oct 13 2022 xinghe - 0.9.6-4 +- Type:bugfix +- Id:NA +- SUG:NA +- DESC:options: Parse hostname by last '@' + torture_options: Add test for '@' in login name + session: Initialize pointers + tests: Ensure the mode of the created file is what we set + * Fri Sep 02 2022 zengweifeng - 0.9.6-3 - Type:bugfix - Id:NA -- Gitee