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

2997 Commits

Author SHA1 Message Date
a3ffc4221d man: fix double spaces and dash escaping
- `-  ` -> `- `
- `.  ` -> `. `
- `\- ` -> `- `
- `-1` -> `\-1`
- fold long lines along the way

This makes the minus sign come out as a Unicode minus sign
(0x2212), and title separator dashes as Unicode hyphen (0x2010),
with `groff -Tutf8` v1.23.0.

Ref: https://lwn.net/Articles/947941/

Closes #1210
2023-11-03 19:57:56 +00:00
8cca7b7752 src: fix gcc 13 -Wconversion warning on Darwin
```
src/session.c: In function 'libssh2_poll':
src/session.c:1776:22: warning: conversion from 'long int' to '__darwin_suseconds_t' {aka 'int'} may change value [-Wconversion]
 1776 |         tv.tv_usec = (timeout_remaining % 1000) * 1000;
      |                      ^
```
Ref: https://github.com/curl/curl-for-win/actions/runs/6711735060/job/18239768548#step:3:4368

Follow-up to 08354e0abb

Closes #1209
2023-11-01 10:56:55 +00:00
bf285500e6 openssl: silence -Wunused-value warnings
Seen with gcc 12.

Manual: https://www.openssl.org/docs/man3.1/man3/BIO_reset.html

```
./quictls/linux-a64-musl/usr/include/openssl/bio.h:555:34: warning: value computed is not used [-Wunused-value]
  555 | # define BIO_reset(b)            (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./libssh2/src/openssl.c:3518:5: note: in expansion of macro 'BIO_reset'
./libssh2/src/openssl.c:3884:5: note: in expansion of macro 'BIO_reset'
./libssh2/src/openssl.c:3995:5: note: in expansion of macro 'BIO_reset'
```
Ref: https://github.com/curl/curl-for-win/actions/runs/6696392318/job/18194032712#step:3:5060

Closes #1205
2023-10-30 21:17:28 +00:00
f64e6318f0 Makefile.am: fix cp to preserve attributes and timestamp 2023-10-30 11:23:50 +00:00
fc00bdd7f1 cmake: simplify showing CMake version
Move it to `CMakeLists.txt`. Drop `cmake --version` commands.

Credit to the `zlib-ng` project for the idea:
61e181c8ae/CMakeLists.txt (L7)

Closes #1203
2023-10-07 16:56:32 +00:00
5e19044282 ci: mbedtls 3.5.0
v3.5.0 needs extra compiler option for i386 to avoid:
```
#error "Must use `-mpclmul -msse2 -maes` for MBEDTLS_AESNI_C"
```

Closes #1202
2023-10-07 11:02:28 +00:00
2cd2f40e37 tests: show cmake version used in integration tests
Closes #1201
2023-10-07 11:02:23 +00:00
a9a79e7a41 readme.vms: fix typo [ci skip]
Detected by codespell 2.2.6
2023-10-03 13:46:22 +00:00
06fd721f08 appveyor: YAML/PowerShell formatting, shorten variable name
- use single-quotes in yaml and PowerShell.

- shorten a variable name.

- use indentation 2 for scripts.

- use C else-style in PowerShell.

Closes #1200
2023-10-02 12:41:22 +00:00
d468a33f62 ci: update actions, use shallow clones with appveyor
- update GitHub Actions to their latest versions.

- use shallow git clones in AppVeyor CI to save data over the wire.

Closes #1199
2023-09-30 16:05:00 +00:00
8a081fd98b appveyor: move to pure PowerShell
- replace batch commands with PowerShell.

- merge separate command entries into single PowerShell blocks.

Closes #1197
2023-09-30 06:49:35 +00:00
6fbc9505d8 windows: use built-in _WIN32 macro to detect Windows
Instead of `WIN32`.

The compiler defines `_WIN32`. Windows SDK headers or build env defines
`WIN32`, or we have to take care of it. The agreement seems to be that
`_WIN32` is the preferred practice here.

Minor downside is that CMake uses `WIN32` and we also adopted it in
`Makefile.mk`.

In public libssh2 headers we stick with accepting either `_WIN32` or
`WIN32` and define our own namespaced `LIBSSH2_WIN32` based on them.

grepping for `WIN32` remains useful to detect Windows-specific code.

Closes #1195
2023-09-29 19:15:08 +00:00
4c241d5c65 cmake: cleanup mbedTLS version detection more
- lowercase, underscored local variables.
- fix `find_library()` to use the multiple names passed.
- rely more on `find_package_handle_standard_args()`.
  Logic based on our `Findwolfssl.cmake`.
- delete ignored/unused `MBEDTLS_LIBRARY_DIR`.
- revert CI configuration to use `MBEDCRTYPO_LIBRARY`.
- clarify inputs/outputs in comment header.
- use variable for regex.
- formatting.

Follow-up to 4159467507 #1192

Closes #1196
2023-09-29 13:49:09 +00:00
30eef0a630 cmake: delete duplicate include() 2023-09-28 18:32:37 +00:00
4159467507 cmake: improve/fix mbedTLS detection
- libssh2 needs the crypto lib only, stop dealing with the rest.

- simplify logic.

- drop hard-wired toolchain specific options that broke with e.g. MSVC.

  Reported by: AR Visions
  Fixes #1191

- add mbedTLS version detection for recent releases.

- merge custom detection results display into a single line.

- shorten mbedTLS configuration in macOS CI job.

Used the curl mbedTLS detection logic for ideas:
a8c773845f/CMake/FindMbedTLS.cmake

Closes #1192
2023-09-28 18:06:13 +00:00
67e39091b2 libssh2_session_get_blocking.3: Add description (#1185) 2023-09-24 01:00:14 +02:00
00a3b88c51 autotools: fix selecting wincng in cross-builds (and more)
- Fix explicitly selecting WinCNG in autotools cross-builds by moving
  `windows.h` header check before the WinCNG availability check.
  Follow-up to d43b8d9b0b

  Reported-by: Jack L
  Fixes #1186

- Add Linux -> mingw-w64 cross-builds for autotools and CMake. This
  doesn't detect #1186, because that happened when explicitly specifying
  WinCNG via `--with-crypto=wincng`, but not when falling back to WinCNG
  by default.

- autotools: fix to strip suffix from gcc version

  Before this patch we expected `n.n` `-dumpversion` output, but Ubuntu
  may return `n-win32` (also with `-dumpfullversion`). Causing these
  errors and failing to enable picky warnings:
  ```
  ../configure: line 23845: test: : integer expression expected
  ```
  Ref: https://github.com/libssh2/libssh2/actions/runs/6263453828/job/17007893718#step:5:143

  Fix that by stripping any dash-suffix.

  gcc version detection is still half broken because we translate '10'
  to '10.10' because `cut -d. -f2` returns the first word if the
  delimiter missing.

  More possible `-dumpversion` output: `10-posix`, `10-win32`,
  `9.3-posix`, `9.3-win32`, `6`, `9.3.0`, `11`, `11.2`, `11.2.0`
  Ref: https://github.com/mamedev/mame/pull/9767

Closes #1187
2023-09-21 15:21:15 +00:00
88a960a86b Properly bounds check packet_authagent_open() (#1179)
* Properly bounds check packet_authagent_open
* packet.c: use strlen instead of sizeof for strings
* Make LIBSSH_CHANNEL's channel_type_len a size_t
* packet_authagent_open: use size_t for offset

Credit:
Michael Buckley, signed off by Will Cosgrove
2023-08-28 16:47:21 -07:00
a790d3784e os400qc3: move FIXME comment [ci skip]
Follow-up to eb9f9de2c1
2023-08-28 23:21:34 +00:00
eb9f9de2c1 md5: allow disabling old-style encrypted private keys at build-time
Before this patch, this happened at runtime when using an old (pre-3.0),
FIPS-enabled OpenSSL backend.

This patch makes it possible to disable this via the build-time option
`LIBSSH2_NO_MD5_PEM`.

Also:
- make sure to exclude all MD5 internal APIs when both the above and
  `LIBSSH2_NO_MD5` are enabled.
- fix tests to support build with`LIBSSH2_NO_MD5`, `LIBSSH2_NO_MD5_PEM`
  and `LIBSSH2_NO_3DES`.
- add FIXME to apply this change to `os400qc3.*`.

Old-style encrypted private keys require MD5 and they look like this:
```
-----BEGIN RSA PRIVATE KEY-----
 Proc-Type: 4,ENCRYPTED
 DEK-Info: AES-128-CBC,<MD5-hex>

 <base64>
 -----END RSA PRIVATE KEY-----
```

E.g.: `tests/key_rsa_encrypted`

Ref: https://github.com/libssh2/www/issues/20
Closes #1181
2023-08-28 22:57:26 +00:00
4a64ca1430 cmake: tidy-up foreach() syntax
Use `IN LISTS` and `IN ITEMS`. This appears to be the preferred way
within CMake's own source code and possibly improves readability.

Fixup a side-effect of `IN LISTS`, where it retains empty values at
the end of the list, as opposed to the syntax used before, which
dropped it. In our case this happened with lines read from a text
file via `file(READ)`.

https://cmake.org/cmake/help/v3.7/command/foreach.html

Closes #1180
2023-08-28 22:57:02 +00:00
5754fed686 ci: replace mv + chmod with install in Dockerfile
Cherry-picked from #1175
Closes #1175
2023-08-23 11:05:56 +00:00
633db55f50 ci: set file mode early in appveyor_docker.yml
Also:
- replace tab with spaces in generated config file
- formatting

Cherry-picked from #1175
2023-08-23 11:05:39 +00:00
a79218d3a0 ci: add spellcheck (codespell)
Also rename a variable in `src/os400qc3.c` to avoid a false positive.

Cherry-picked from #1175
2023-08-23 10:55:51 +00:00
a20572e9af cmake: also test for libssh2_VERSION
Cherry-picked from #1175
2023-08-23 10:54:23 +00:00
87f5769b51 cmake: show cmake versions in ci
Cherry-picked from #1175
2023-08-23 10:54:17 +00:00
e61987a3bf tests: formatting and tidy-ups
- Dockerfile: use standard sep with `sed`
- Dockerfile: use single quotes in shell command
- appveyor.yml: use long-form option with `choco`
- tests/cmake: add language to test project
- reuse.yml: fix indentation
  ```
  $ yamllint reuse.yml
  reuse.yml
    [...]
    11:5      error    wrong indentation: expected 6 but found 4  (indentation)
    15:5      error    wrong indentation: expected 6 but found 4  (indentation)
    [...]
    27:5      error    wrong indentation: expected 6 but found 4  (indentation)
  ```

Cherry-picked from #1175
2023-08-23 10:53:53 +00:00
1676a17814 openssl.c: whitespace fixes
Cherry-picked from #1175
2023-08-23 10:53:45 +00:00
a95d401f1f checksrc: fix spelling in comment [ci skip] 2023-08-20 00:24:59 +00:00
e9c7d3afa0 cmake: quote more strings
Follow-up to 3fa5282d62

Closes #1173
2023-08-18 16:42:32 +00:00
6e3e883994 drop www. from www.libssh2.org
<https://www.libssh2.org/*> is now a 301 permanent redirect to
<https://libssh2.org/*>.

Update all references to point directly to the new destination.

Ref: ccf4a7de7f

Closes #1172
2023-08-18 11:20:58 +00:00
aeaefaf6cc cmake: add ExternalProject integration test
- via `ExternalProject_Add()`:
  https://cmake.org/cmake/help/latest/module/ExternalProject.html
  (as documented in `docs/INSTALL_CMAKE.md`)

- also make `FetchContent` fetch from local repo instead of live master.

Closes #1171
2023-08-18 09:47:09 +00:00
8715c3d51b cmake: add integration tests
Add a small project to test dependent/downstream CMake build using
libssh2. Also added to the GHA CI, and you can also run it locally with
`tests/cmake/test.sh`.

Test three methods of integrating libssh2 into a project:
- via `find_package()`:
  https://cmake.org/cmake/help/latest/command/find_package.html
- via `add_subdirectory()`:
  https://cmake.org/cmake/help/latest/command/add_subdirectory.html
- via `FetchContent`:
  https://cmake.org/cmake/help/latest/module/FetchContent.html

Closes #1170
2023-08-17 09:01:08 +00:00
4ff64ae3ca cmake: (re-)add aliases for add_subdirectory() builds
Add internal libssh2 library aliases to make these available for
downstream/dependent projects building libssh2 via `add_subdirectory()`:

- `libssh2:libssh2_static`
- `libssh2:libssh2_shared`
- `libssh2:libssh2` (shared, or static when not building shared)
- `libssh2` (shared, or static when not building shared)

Of these, `libssh2` was present in v1.10.0 and earlier releases, but
missing from v1.11.0.

Closes #1169
2023-08-16 07:10:51 +00:00
8eade0c9b7 cmake: delete empty line [ci skip]
Follow-up to 3fa5282d62
2023-08-16 06:36:16 +00:00
6eda1ee433 cmake: reflect minimum version in docs [ci skip]
Follow-up to 9cd18f4578
2023-08-15 21:58:56 +00:00
3fa5282d62 cmake: style tidy up
- quote text literals to improve readability.
  (exceptions: `FILES` items, `add_subdirectory` names, `find_package`
  names, literal target names, version numbers, 0/1, built-in CMake
  values and CMake keywords, list items in `cmake/max_warnings.cmake`)
- quote standalone variables that could break syntax on empty values.
- replace `libssh2_SOURCE_DIR` with `PROJECT_SOURCE_DIR`.
- add missing mode to `message()` call.
- `TRUE`/`FALSE` → `ON`/`OFF`.
- add missing default value `OFF` to `option()` for clarity.
- unfold some lines.
- `INSTALL_CMAKE.md` fixes and updates. Show defaults.

Closes #1166
2023-08-15 15:08:30 +00:00
186c1d6394 wincng: prefer ULONG/DWORD over unsigned long
To match with the types used by the `Crypt*()` (uses `DWORD`) and
`BCrypt*()` (uses `ULONG`) Windows APIs.

This patch doesn't change data width or signedness.

Closes #1165
2023-08-15 10:42:00 +00:00
7bb669b52a wincng: tidy-ups
- make `_libssh2_wincng_key_sha_verify` static.

- prefer `unsigned long` over `size_t` in two static functions.

- prefer `ULONG` over `DWORD` to match `BCryptImportKeyPair()`
  and `BCryptGenerateKeyPair()`.

- add a newline.

Closes #1164
2023-08-15 01:31:19 +00:00
d43b8d9b0b ci: add MSYS builds (autotools and cmake)
Use existing MSYS2 section and extend it with builds for the MSYS
environment with both autotools and cmake.

MSYS builds resemble Cygwin ones: The env is Unixy, where Windows
headers are all available but we don't use them.

Also:

- extend existing autotools logic for Cygwin to skip detecting
  `windows.h` for MSYS targets too.

- require `windows.h` for the WinCNG backend in autotools. Before this
  patch, autotools allowed selecting WinCNG on the Cygwin and MSYS
  platforms, but the builds then fell apart due to the resulting mixed
  Unixy + Windowsy environment. The general expectation for Cygwin/MSYS
  builds is not to use the Windows API directly in them.

- stop manually selecting the `MSYS Makefiles` CMake generator for
  MSYS2-based GHA CI builds. mingw-w64 builds work fine without it, but
  it broke MSYS build which use `Unix Makefiles`. Deleting this setting
  fixes all build flavours.

Closes #1162
2023-08-14 23:10:15 +00:00
84912e2ed8 ci: cygwin job tidy-ups
`CMAKE_C_COMPILER=gcc` not necessary, delete it.

Follow-up to f1e96e733f

Cherry-picked from #1163
Closes #1163
2023-08-14 23:09:54 +00:00
f1e96e733f ci: add Cygwin builds (autotools and cmake)
To avoid builds picking up non-Cygwin components coming by default with
the CI machine, I used the solution recommended by Cygwin [1] and set
`PATH` manually. To avoid repeating this for each step, I merged steps
into a single one. Let us know if there is a more elegant way.

Cygwin's Github Action uses cleartext HTTP. We upgrade this to HTTPS.

autotools build seemed to take slightly longer than other jobs. To save
turnaround time I disabled building tests.

Cygwin package search: https://cygwin.com/cgi-bin2/package-grep.cgi

[1] https://github.com/cygwin/cygwin-install-action/tree/v4#path

Closes #1161
2023-08-14 21:54:43 +00:00
5453fc8035 cmake: add LIB_NAME variable
It holds the name `libssh2`. Mainly to document its uses, and also
syncing up with the same variable in libcurl.

Closes #1159
2023-08-13 10:20:57 +00:00
c705ff3f37 cmake: add one missed PROJECT_NAME variable
Follow-up to 72fd25958a

Closes #1158
2023-08-11 23:09:52 +00:00
ae7d51085e cmake: tidy-up concatenation in CMAKE_MODULE_PATH
Former solution was appending an empty element to the array if
`CMAKE_MODULE_PATH` was originally empty. The new syntax doesn't have
this side-effect.

There is no known issue caused by this. Fixing it for good measure.

Closes #1157
2023-08-11 20:10:23 +00:00
1215aa5f46 ci: add mingw-w64 UWP build
Add a CI test for Windows UWP builds using mingw-w64. Before this patch
we had UWP builds tested with MSVC only.

Alike existing UWP jobs, it's not possible to run the binaries due to
the missing UWP runtime DLL:
https://github.com/libssh2/libssh2/actions/runs/5821297010/job/15783475118#step:11:42

We could install `winstorecompat-git` in the setup-msys2 step, but opted
to do it manually to avoid the overhead for every matrix job.

All this would work smoother with llvm-mingw, which features an UWP
toolchain prefix and provides all necessary implibs by default.

This also hit a CMake bug (with v3.26.4), where CMake gets confused and
sets up `windres.exe` to use the MSVC rc.exe-style command-line:
https://github.com/libssh2/libssh2/actions/runs/5819232677/job/15777236773#step:9:126

Notice that MS "sunset" UWP in 2021:
https://github.com/microsoft/WindowsAppSDK/discussions/1615

If this particular CI job turns out to be not worth the maintenance
burden or CPU time, or too much of a hack, feel free to delete it.

Ref: https://github.com/libssh2/libssh2/pull/1147#issuecomment-1670850890
Closes #1155
2023-08-10 22:56:47 +00:00
72fd25958a cmake: replace libssh2 literals with PROJECT_NAME variable
Where applicable.

This also makes it more obvious which `libssh2` uses were referring
to the project itself.

Closes #1152
2023-08-09 15:47:49 +00:00
42d3bf1348 cmake: fix STREQUAL check in error branch
This caused a CMake error instead of our custom error when manually
selecting the `WinCNG` crypto-backend for a non-Windows target.

Also cleanup `STREQUAL` checks to use variable name without `${}` on
the left side and quoted string literals on the right.

Closes #1151
2023-08-09 15:47:49 +00:00
74e742887c misc: flatten _libssh2_explicit_zero if tree
Closes #1149
2023-08-09 15:47:49 +00:00
1f0174d0df src: drop a redundant #include
We include `misc.h` via `libssh2_priv.h` already.

Closes #1153
2023-08-09 15:47:49 +00:00