1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-08-07 08:02:56 +03:00
Commit Graph

2997 Commits

Author SHA1 Message Date
Viktor Szakats
d29eea1d29 test_sshd.test: minor cleanups 2023-06-07 15:10:01 +02:00
Daniel Stenberg
f6aa31f48f provide SPDX identifiers
- All files have prominent copyright and SPDX identifier
- If not embedded in the file, in the .reuse/dep5 file
- All used licenses are in LICENSES/ (not shipped in tarballs)
- A new REUSE CI job verify that all files are OK

Assisted-by: Viktor Szakats

Closes #1084
2023-06-07 08:18:55 +02:00
Viktor Szakats
8b92499940 src: improve MSVC C4701 warning fix
Simplify the code to avoid this warning. This might also help avoiding
it with other compilers (e.g. gcc?).

Improves 02f2700a61 #876
Might fix #1083
Closes #1086
2023-06-06 12:13:55 +00:00
Daniel Stenberg
f4f52ccc4d configure.ac: remove AB_INIT
Not used. Remove m4/autobuild.m4 as well
2023-06-05 19:33:09 +02:00
Viktor Szakats
187d89bb07 copyright: remove years from copyright headers
Also:
- uppercase `(C)`.
- add missing 'All rights reserved.' lines.
- drop duplicate 'Author' lines.
- add copyright headers where missing.
- enable copyright header check in checksrc.

Reasons for deleting years (copied as-is from curl):
- they are mostly pointless in all major jurisdictions
- many big corporations and projects already don't use them
- saves us from pointless churn
- git keeps history for us
- the year range is kept in COPYING

Closes #1082
2023-06-04 19:19:16 +00:00
Viktor Szakats
43df6a46b1 tests: cast to avoid -Wchar-subscripts with Cygwin
```
In file included from $HOME/src/cygwin/libssh2/libssh2-1.11.0-1.x86_64/src/libssh2-1.11.0/tests/openssh_fixture.c:57:
$HOME/src/cygwin/libssh2/libssh2-1.11.0-1.x86_64/src/libssh2-1.11.0/tests/openssh_fixture.c: In function 'run_command_varg':
$HOME/src/cygwin/libssh2/libssh2-1.11.0-1.x86_64/src/libssh2-1.11.0/tests/openssh_fixture.c:136:37: warning: array subscript has type 'char' [-Wchar-subscripts]
  136 |         while(end > 0 && isspace(buf[end - 1])) {
      |                                  ~~~^~~~~~~~~
```
Ref: https://github.com/libssh2/libssh2/files/11644340/cygwin-x86_64-libssh2-1.11.0-1-check.log

Reported-by: Brian Inglis
Fixes #1080
Closes #1081
2023-06-04 00:25:59 +00:00
Viktor Szakats
003fb454c3 tidy-up: avoid exclamations, prefer single quotes, in outputs
Closes #1079
2023-06-03 12:51:56 +00:00
Viktor Szakats
c89174a78b autotools: improve libz position
We repositioned crypto libs in 4f0f4bff5a
via #941 and subsequently in d4f58f0343
from d93ccf4901 via #1013.

This patch moves libz accordingly, to unbreak certain build scenarios.

Reported-by: Kenneth Davidson
Regression from 4f0f4bff5a #941
Fixes #1075
Closes #1077
2023-06-01 09:17:40 +00:00
Viktor Szakats
8b917d765f src: bump hash_len to size_t in LIBSSH2_HOSTKEY_METHOD
Follow-up to 7b8e02257f
Closes #1076
2023-05-31 23:28:09 +00:00
Viktor Szakats
c6e137f7aa ci: add non-static autotools i386 build, ignore GHA updates on AppVeyor
Add a non-static autotools build to GitHub Actions. Make this build
target i386 and libgcrypt, to test a new build combination if we are at
it.

Also:
- GHA: add necessary generic bits for i386 autotools builds.
- AppVeyor CI: teach it to ignore commits updating our GHA config.

Follow-up to 572c57c9d8 #1072
Closes #1074
2023-05-31 15:04:51 +00:00
Xi Ruoyao
572c57c9d8 autotools: skip tests requiring static lib if --disable-static (#1072)
Co-authored-by: Viktor Szakats
Regression from 83853f8aea #663
Fixes #1056
2023-05-31 15:03:11 +02:00
Viktor Szakats
e5c0304333 ci: prefer = operator in shell snippets
Closes #1073
2023-05-31 09:21:21 +00:00
Viktor Szakats
7b8e02257f src: bump DSA and ECDSA sign hash_len to size_t
Closes #1055
2023-05-31 08:29:03 +00:00
Viktor Szakats
c317e06faa scp: fix missing cast for targets without large file support
E.g. on 32-bit Linux. Issue revealed after adding i386 Linux CI build
in abdf40c741 #1057.

```
/home/runner/work/libssh2/libssh2/src/scp.c: In function 'scp_recv':
/home/runner/work/libssh2/libssh2/src/scp.c:765:23: error: conversion from 'libssh2_int64_t' {aka 'long long int'} to '__off_t' {aka 'long int'} may change value [-Werror=conversion]
  765 |         sb->st_size = session->scpRecv_size;
      |                       ^~~~~~~
```
Ref: https://github.com/libssh2/libssh2/actions/runs/5126803482/jobs/9221746299?pr=1054#step:12:51

Regression from 5db836b2a8 #1002
Closes #1060
2023-05-31 02:05:28 +00:00
Viktor Szakats
bc69ac232a mbedtls.h: formatting [ci skip]
For consistency with `mbedtls.c`.

Follow-up to 1153ebdeba
2023-05-30 23:40:27 +00:00
Viktor Szakats
e800038cb9 libssh2.h: bump to 1.11.1_DEV [ci skip] 2023-05-30 23:12:40 +00:00
Viktor Szakats
1153ebdeba mbedtls: use more size_t to sync up with crypto.h
Ref: 5a96f494ee #846 #879

Fixes #1053
Closes #1054
2023-05-30 23:00:53 +00:00
Viktor Szakats
ab8e95bcfc ci: drop redundant/unused vars, sync var names
Closes #1059
2023-05-30 23:00:51 +00:00
Viktor Szakats
abdf40c741 ci: add i386 Linux build (with mbedTLS)
Also:
- reorder Linux build matrix to make build tool more visible.
- hide apt-get progress bar.
- prepare package install step for i386 builds.

Detects bug #1053
Closes #1057
2023-05-30 22:19:35 +00:00
Viktor Szakats
d67a91aa10 checksrc: switch to dot file
Closes #1052
2023-05-30 17:24:28 +00:00
Daniel Stenberg
1c3f1b7da5 libssh2.h: bump to 1.11.0 for release libssh2-1.11.0 2023-05-30 17:58:13 +02:00
Will Cosgrove
1a186f1ead Libssh2 1.11 release notes, copyright (#1048)
* Libssh2 1.11 release notes, copyright
2023-05-30 08:57:13 -07:00
Viktor Szakats
e7a542da6a add copyright/credits
Closes #1050
2023-05-29 17:07:11 +00:00
Viktor Szakats
3f4ea939b4 ci: add LIBSSH2_NO_AES_CBC to GNU Make build
Closes #1049
2023-05-28 00:05:01 +00:00
Viktor Szakats
801aebc6a0 ci: add wolfSSL Linux builds
Exclude wolfSSL builds from tests. All fail:

```
2/43 Test  #2: test_aa_warmup ............................***Failed    5.59 sec
libssh2_session_handshake failed (-44): Unable to ask for ssh-userauth service
```
Ref: https://github.com/libssh2/libssh2/actions/runs/5085775952/jobs/9139583212#step:12:942 (with logging)
Ref: https://github.com/libssh2/libssh2/actions/runs/5085586301/jobs/9139192562#step:12:225

wolfSSL version:
```
Get:1 http://azure.archive.ubuntu.com/ubuntu jammy/universe amd64 libwolfssl32 amd64 5.2.0-2 [818 kB]
Get:2 http://azure.archive.ubuntu.com/ubuntu jammy/universe amd64 libwolfssl-dev amd64 5.2.0-2 [1194 kB]
```

Cherry-picked from #1046
Closes #1046
2023-05-26 01:45:36 +00:00
Viktor Szakats
8e3bbd80eb ci: mbedTLS build config tidy-up
Cherry-picked from #1046
2023-05-26 00:27:54 +00:00
Viktor Szakats
4beb7a3a12 wolfssl: fix detection of AES-GCM feature
Follow-up to df513c0128

Ref: https://github.com/libssh2/libssh2/issues/1020#issuecomment-1562069241
Closes #1045
2023-05-25 22:30:13 +00:00
Viktor Szakats
ddb3be7dad build: fix 'unused' compiler warnings with all NO options set
- add `LIBSSH2_NO_ED25519` build-time option to force-disable ED25519
  support. Useful to replicate crypto-backend builds without ED25519,
  such as wolfSSL.

- openssl: fix unused variable and function warnings with all supported
  `LIBSSH2_NO_*` options enabled.

- mbedtls: fix misplaced `#endif` leaving out the required internal
  public function `libssh2_supported_key_sign_algorithms()`.

- mbedtls: add missing prototype for two internal public functions.

- delete a redundant block.

All `NO` options:
```shell
CPPFLAGS='
-DLIBSSH2_NO_MD5 -DLIBSSH2_NO_HMAC_RIPEMD -DLIBSSH2_NO_DSA
-DLIBSSH2_NO_RSA -DLIBSSH2_NO_RSA_SHA1
-DLIBSSH2_NO_ECDSA -DLIBSSH2_NO_ED25519 -DLIBSSH2_NO_AES_CTR
-DLIBSSH2_NO_BLOWFISH -DLIBSSH2_NO_RC4 -DLIBSSH2_NO_CAST
-DLIBSSH2_NO_3DES'
```

Closes #1044
2023-05-19 10:27:39 +00:00
Viktor Szakats
e692c55bc0 cmake: avoid list(PREPEND) for compatibility
`list(PREPEND)` requires CMake v3.15, our minimum is v3.1. `APPEND`
should work fine for headers anyway.

Also fix a wrongly placed comment.

Ref: https://cmake.org/cmake/help/latest/command/list.html#prepend

Regression from 1e3319a167d2f32d295603167486e9e88af9bb4e

Closes #1043
2023-05-18 23:36:58 +00:00
Viktor Szakats
1c9323416c checksrc: verify label indent, fix fallouts
Also update two labels to match the rest of the source.

checksrc update credit: Emanuele Torre @emanuele6

Ref: https://github.com/curl/curl/pull/11134

Closes #1042
2023-05-18 14:07:01 +00:00
Viktor Szakats
bfcf796c17 tidy-up: minor nits 2023-05-15 22:37:50 +02:00
Viktor Szakats
c7074ccc9d ci: drop default shared/static configuration options
Both autotools and cmake build both shared and static lib by default.

Ref: 896154bc17

Delete configuration enabling these explicitly in CI jobs.

Cherry-picked from #1036
Closes #1036
2023-05-09 08:14:05 +00:00
Viktor Szakats
896154bc17 cmake: enable shared libssh2 library by default
This brings default behaviour in sync with autotools, which builds both
lib flavours by default.

(Notice that on Windows, autotools includes the Windows Resource in the
static library, when building both at the same time. CMake doesn't have
this issue.)

Enabling both lib flavours has a side-effect when using non-MinGW
toolchains (e.g. MSVC): to resolve the filename conflict between import
and static libraries, we add a suffix to the static lib, naming it
`libssh2_static.lib`. This can break dependent builds relying on
`libssh2.lib` for linking the static libssh2.

Workarounds:

- disable either shared or static libssh2 via
  `-DBUILD_STATIC_LIBS=OFF` or
  `-DBUILD_SHARED_LIBS=OFF`. This results in a libssh2 library (either
  static or shared) without a prefix: `libssh2.lib`.

- set a custom static library suffix via:
  `-DSTATIC_LIB_SUFFIX=_my_static`. Resulting in
  `libssh2_my_static.lib`, and import library
  `libssh2.lib`.

- set a custom import library suffix via:
  `-DIMPORT_LIB_SUFFIX=_my_implib`. Resulting in
  `libssh2_my_implib.lib` import library, and static library
  `libssh2.lib`.

- customize the default static/import library suffix (incl. extension)
  via
  `-DCMAKE_STATIC_LIBRARY_SUFFIX=_my_static_suffix.lib` or
  `-DCMAKE_IMPORT_LIBRARY_SUFFIX=_my_import_suffix.lib`.

Cherry-picked from #1036
2023-05-09 08:12:52 +00:00
Viktor Szakats
837fa4b8b7 cmake: tweak static/import lib name collision avoidance logic
The collision issue affects (typically) MSVC, when building both shared
and static libssh2 in one go.

Ref: https://stackoverflow.com/questions/2140129/what-is-proper-naming-convention-for-msvc-dlls-static-libraries-and-import-libr

Initially we handled this by appending the `_imp` suffix to the import
library filename. This is how curl tackles this, but on a second look,
this solution seem to be accidental and has no widespread use.

It seems more widely accepted to use the '_static' suffix for the static
library. This patch implements this.

(MinGW, Cygwin and unixy platforms are not affected by this issue.)

Follow-up to 4e2580628d

Cherry-picked from #1036
2023-05-09 08:12:45 +00:00
Viktor Szakats
a791c0b26a cmake: add IMPORT_LIB_SUFFIX (like STATIC_LIB_SUFFIX)
Allow resolving the import/static library name collision also by setting
a custom _import_ library name suffix.

Follow-up to 4e2580628d

Cherry-picked from #1036
2023-05-09 08:12:39 +00:00
Viktor Szakats
9bd4d94a0c ci: do not disable shared lib with msys2/autotools in GHA
Cherry-picked from #1036
2023-05-09 08:12:33 +00:00
Viktor Szakats
4fcb97bde5 Makefile.mk: fix DYN=1 test by skipping tests needing static lib
`DYN=1` means to build examples/tests against the shared libssh2.

Before this patch this was broken for building tests. This patch skips
building tests that require the static libssh2 library, so the build now
succeeds.

Also move the list of tests that require static lib from
`CMakeLists.txt` to `Makefile.inc`, so that we can reuse it in
`Makefile.mk`.

Couldn't find a way to also reuse it in `Makefile.am`. Move the
`Makefile.am` specific definitions close to the shared list, to make it
easier to keep them synced.

Cherry-picked from #1036
2023-05-09 08:12:25 +00:00
Viktor Szakats
86eaec4a1e ci: make one of the AppVeyor CMake jobs shared-only
This build combination did not have a CI test before.

Cherry-picked from #1036
2023-05-08 13:51:06 +00:00
Viktor Szakats
bc2445e56e cmake: allow tests with BUILD_STATIC_LIBS=OFF
Before this patch, the CMake build did not allow to disable static
libssh2 library while also building tests.

This patch removes this constraint, and makes this combination possible.
In this case the 3 (at the moment) tests that require a static libssh2
library, are skipped from the build and test runs.

Cherry-picked from #1036
2023-05-08 13:48:31 +00:00
Viktor Szakats
4296fccd1a build: fix to set -DLIBSSH2DEBUG for tests
Required for tests using libssh2 internals. These are the ones
requiring the libssh2 _static_ lib.

Before this patch, `src` and `tests` declared the `session` structure
differently, due to extra struct members added with the `LIBSSH2DEBUG`
macro set. But, the macro was only set for `src` when using CMake. At
runtime this caused struct members to be at different offsets between
lib and test code, resulting in the test failures below.

Due to another bug in the affected test, these failures did not reflect
in the exit code, which always returned success, so this went unnoticed
for a good while. Fixed in: 84d31d0ca7

```
     Start  5: test_auth_keyboard_info_request
[...]
5: Test case 1 passed
5: Test case 2 passed
5: Test case 3: expected return code to be 0 got -1
5: Test case 4: expected last error code to be "-6" got "-38"
5: Test case 5: expected last error code to be "-6" got "-38"
5: Test case 6: expected last error code to be "-6" got "-38"
5: Test case 7: expected last error message to be "Unable to decode keyboard-interactive number of keyboard prompts" got "userauth keyboard data buffer too small to get l
5: Test case 8: expected last error code to be "-41" got "-38"
5: Test case 9: expected return code to be 0 got -1
5: Test case 10: expected return code to be 0 got -1
5: Test case 11: expected last error code to be "-6" got "-38"
5: Test case 12: expected last error message to be "Unable to decode user auth keyboard prompt echo" got "userauth keyboard data buffer too small to get length"
5: Test case 13: expected return code to be 0 got -1
5: Test case 14: expected return code to be 0 got -1
5: Test case 15: expected last error code to be "-6" got "-38"
5: Test case 16: expected last error code to be "-6" got "-38"
5: Test case 17: expected last error code to be "-6" got "-38"
5: Test case 18: expected last error code to be "-6" got "-38"
```
Ref: https://ci.appveyor.com/project/libssh2org/libssh2/builds/46925869/job/i9uasceu3coss0i2#L440
Ref: https://ci.appveyor.com/project/libssh2org/libssh2/builds/46983040/job/c3vag25c26a77lyr#L485

Cherry-picked from #1037
Closes #1037
2023-05-08 13:02:25 +00:00
Viktor Szakats
84d31d0ca7 test_auth_keyboard_info_request: fix to return failure
Before this patch, this test returned success even when one of its tests
failed. Fix it by returning 1 in case any of the tests fails.

This issue masked a CMake build bug with logging enabled. Subject to an
upcoming patch.

Cherry-picked from #1037
2023-05-08 12:59:33 +00:00
Viktor Szakats
731e74e26b test_auth_keyboard_info_request: fix indentation
Cherry-picked from #1037
2023-05-08 12:58:54 +00:00
Viktor Szakats
b48ae2db9f tidy-up: move comment off from copyright header
Cherry-picked from #1037
2023-05-08 12:58:45 +00:00
Viktor Szakats
231bd8fae7 ci: enable shared libs in msys2/macOS cmake builds
Shared libs improve example/tests build times. For "unity"
builds the overhead of building shared lib is negligible, so
this even reduced the overall build-time.

Follow-up to 3d64a3f510
Follow-up to d93ccf4901

Tests:
https://github.com/libssh2/libssh2/actions/runs/4906586658: unity builds enabled
https://github.com/libssh2/libssh2/actions/runs/4906925743: unity builds enabled + parallel msys2 builds
https://github.com/libssh2/libssh2/actions/runs/4906777629: unity + shared lib (this commit)
https://github.com/libssh2/libssh2/actions/runs/4906927190: unity + shared lib (this commit) + parallel msys2 builds

Consider making shared libs enabled by default also in CMake, to sync it with autotools?

Closes #1035
2023-05-07 17:29:49 +00:00
Viktor Szakats
34b6549fe7 ci: add missed --parallel 3 from msys2 cmake builds
Follow-up to 3d64a3f510
2023-05-07 11:28:19 +00:00
Viktor Szakats
7129ea9ca8 cmake: add and test "unity" builds
"Unity" (aka "jumbo", aka "amalgamation" builds concatenate source files
before compiling. It has these benefits for example: faster builds,
improved code optimization, cleaner code. Let's support and test this.

- enable unity builds for some existing CI builds to test this build
  scenario.
- tune `UNITY_BUILD_BATCH_SIZE` size.
- disable unity build for example and test programs (they use one source
  each already).

You can enable it by passing `-DCMAKE_UNITY_BUILD=ON` to cmake.
Supported by CMake 3.16 and newer.

Ref: https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html

Closes #1034
2023-05-07 10:03:20 +00:00
Viktor Szakats
cdd7fc009d tests: simplify passing srcdir to tests
Before this patch libssh2 used a variety of solutions to pass the source
directory to tests: `FIXTURE_WORKDIR` build-time macro (cmake),
`FIXTURE_WORKDIR` envvar (unused), setting `srcdir` manually
(autotools), setting current directory (cmake), and also `builddir`
envvar (autotools) for passing current working dir to `mansyntax.sh`.

This patch reduces this to using existing `srcdir` with autotools and
setting it ourselves in CMake. This was mostly enabled by this recent
patch: 4c9ed51f96

Details:

- cmake: replace baked-in `FIXTURE_WORKDIR` macro with env.

  Added in 54bef4c5da #198 (2018-03-21)

- rename `FIXTURE_WORKDIR` to `srcdir`, to match autotools.

- cmake: add missing `srcdir` for algo and sshd tests.

- session_fixture: stop `chdir()`-ing, rely on prefixing with `srcdir`.

  Changing current directory should be unnecessary after
    4c9ed51f96 #801 (2023-02-24),
  that prefixes referenced input filenames with the `srcdir` envvar.

  The `srcdir` envvar was already exported by autotools, and now we're
  also setting it from CMake.

- cmake: stop setting `WORKING_DIRECTORY`, rely on `srcdir` env.

  `WORKING_DIRECTORY` is no longer necessary, after passing `srcdir` to
  all tests, so they can find our source tree and keys/etc in it
  regardless of the current directory.

  Also this past commit hints that `WORKING_DIRECTORY` wasn't always
  working for this purpose as expected:
    "tests: Xcode doesn't obey CMake's test working directory"
  Ref: 10a5cbf945

- autotools: delete explicit `srcdir` for test env.

  Added in 13f8addd1b (2015-07-02)

  automake documents `srcdir` as exported to the test environment:
  c04c4e8856/doc/automake.texi (L9302-L9304)
  https://www.gnu.org/software/automake/manual/html_node/Scripts_002dbased-Testsuites.html
  It's mentioned in the docs back in 1997 and got a regression test in
  2012. We can safely assume it to be available without setting it
  ourselves.

- autotools: delete explicit `builddir`.

  Added in 13f8addd1b (2015-07-02)

  It seems this wasn't necessary to make the above fix work, and
  `mansyntax.sh` is able to figure out the build workdir by reading
  `$PWD`. Our out-of-tree and `make distcheck` CI builds also work
  without it.

  Let us know if there is a scenario we're missing and needs this.

Closes #1032
2023-05-05 20:39:58 +00:00
Viktor Szakats
ebf644fb6a src: fix libssh2_store_*() for >u32 inputs
`_libssh2_store_str()` and `_libssh2_store_bignum2_bytes()` accept
inputs of `size_t` max, store the size as 32-bit unsigned integer, then
store the complete input buffer.

With inputs larger than `UINT_MAX` this means the stored size is smaller
than the data that follows it.

This patch truncates the stored data to the stored size, and now returns
a boolean with false if the stored length differs from the requested
one. Also add `assert()`s for this condition.

This is still not a correct fix, as we now dump consistent, but still
truncated data which is not what the caller wants. In future steps we'll
need to update all callers that might pass large data to this function
to check the return value and handle an error, or make sure to not call
this function with more than UINT_MAX bytes of data.

Ref: c3bcdd88a4 (2010-04-17)
Ref: ed439a29bb (2022-09-29)

Closes #1025
2023-05-05 19:52:30 +00:00
Viktor Szakats
e36b21df91 cmake: limit WinCNG to Windows
After deleting the `bcrypt.h` check, no check remained. Restore
a `WIN32` check here to ensure WinCNG is not enabled outside Windows.

Follow-up to 1289033598

Tested-in #1032
2023-05-05 16:05:28 +00:00
Viktor Szakats
1458e28f36 cmake: move CMAKE_VS_GLOBALS setting to CI configs
To not force this setting for local builds where they might serve
a good purpose.

It makes our CI runs slightly faster and we don't need to track
file changes in unattended, single, CI runs.

Cherry-picked from #1031
2023-05-05 01:21:00 +00:00