1
0
mirror of https://github.com/libssh2/libssh2.git synced 2026-10-24 03:48:58 +03:00
Commit Graph

16 Commits

Author SHA1 Message Date
Viktor Szakats
2233bf95ed tests: retry '(-43): Failed getting banner' flaky failures
Example:
```
1: libssh2_session_handshake failed (-43): Failed getting banner
1: ---- sshd log ----
1: No matching private key for certificate: /etc/ssh/ssh_host_mldsa44-ed25519_key-cert.pub
1: debug1: Set /proc/self/oom_score_adj from 0 to -1000
1: debug2: fd 6 setting O_NONBLOCK
1: debug1: Bind to port 22 on 0.0.0.0.
1: Server listening on 0.0.0.0 port 22.
1: debug2: fd 7 setting O_NONBLOCK
1: debug1: Bind to port 22 on ::.
1: Server listening on :: port 22.
1: ------------------
1: Command: docker image pull ghcr.io/libssh2/ci_tests_openssh_server:8d1fde1834077fddb9f9
1: Command: docker image tag ghcr.io/libssh2/ci_tests_openssh_server:8d1fde1834077fddb9f9 libssh2/openssh_server
1: Command: docker run --rm -d -p 22 libssh2/openssh_server
1: Command: docker inspect --format "{{ (index (index .NetworkSettings.Ports \"22/tcp\") 0).HostIp }}" a1f1a209001852fa7e3aba87c0f1198661c4fe07c34ddcbf2e76e264ef64b7b8
1: Command: docker inspect --format "{{ (index (index .NetworkSettings.Ports \"22/tcp\") 0).HostPort }}" a1f1a209001852fa7e3aba87c0f1198661c4fe07c34ddcbf2e76e264ef64b7b8
1: Command: docker logs a1f1a209001852fa7e3aba87c0f1198661c4fe07c34ddcbf2e76e264ef64b7b8
1: Command: docker stop a1f1a209001852fa7e3aba87c0f1198661c4fe07c34ddcbf2e76e264ef64b7b8
 1/61 Test  #1: test_aa_warmup .......................................***Failed    6.08 sec
libssh2_session_handshake failed (-43): Failed getting banner
```
Ref: https://github.com/libssh2/libssh2/actions/runs/37613324059/job/112765610280?pr=2659#step:25:133

Ref: 5bfa574460 #2603

Closes #2662
2026-10-07 15:35:05 +02:00
Viktor Szakats
45aa5c5fa4 tests: dump container sshd log for test failures
To help debugging issues.

Also:
- bump sshd LogLevel to DEBUG1, for essential details.
- bump command output buffer in `run_command_varg()`
- drop redundant condition in `run_command_varg()`
- replace `BUFSIZ` with literal sizes in `run_command_varg()`.

After this patch it's showing this in the CI log for the libgcrypt
fallout that previously needed a long time to diagnose:
```
61: ---- sshd log ----
61: No matching private key for certificate: /etc/ssh/ssh_host_mldsa44-ed25519_key-cert.pub
61: Server listening on 0.0.0.0 port 22.
61: Server listening on :: port 22.
61: debug1: sshd-session version OpenSSH_10.5, OpenSSL 3.6.3 9 Jun 2026
61: Connection from 172.17.0.1 port 51878 on 172.17.0.2 port 22 rdomain ""
61: debug1: sshd-auth version OpenSSH_10.5, OpenSSL 3.6.3 9 Jun 2026 [preauth]
61: debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256,ssh-rsa,rsa-sha2-512-cert-v01@openssh.com,
rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp256,
ecdsa-sha2-nistp256-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com [preauth]
61: debug1: Local version string SSH-2.0-OpenSSH_10.5p1 Debian-1 [preauth]
61: debug1: Remote protocol version 2.0, remote software version libssh2_1.11.2_DEV [preauth]
61: debug1: compat_banner: no match: libssh2_1.11.2_DEV [preauth]
61: debug1: SSH2_MSG_KEXINIT sent [preauth]
61: debug1: SSH2_MSG_KEXINIT received [preauth]
61: debug1: kex: algorithm: (no match) [preauth]
61: Unable to negotiate with 172.17.0.1 port 51878: no matching key exchange method found.
Their offer: diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,
diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,
diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1,ext-info-c,
kex-strict-c-v00@openssh.com [preauth]
[...]
61: ------------------
```

Follow-up to 1d0b86ac84 #2484
Follow-up to 8be5716437 #2174
Follow-up to 51f6259d18 #1720

Closes #2621
2026-09-13 21:20:56 +02:00
Viktor Szakats
967a24b3bb tidy-up: miscellaneous
- wincng: add version comments.
  Follow-up to 7a26697ede #397
- wincng: fix two version support comments.
- tests/keys-generate.sh: add comment, newlines.
- mbedtls: casing in comment.
- wording: use `null-terminator` more.
- typos: `ssh-dss`.
- knownhost: drop obsolete comment.
- include/libssh2.h: clarify comments.
- include/libssh2.h: drop empty lines.
- libssh2_knownhost_writeline.md: fix grammar.
- GHA: reorder Cygwin settings, improve package search URL.
- fixup newlines.

Closes #2617
2026-09-13 16:12:32 +02:00
Viktor Szakats
5bfa574460 tests: drop WinCNG retry workarounds
Should no longer be necessary after fixing the root cause.
(Though we do not run these tests in CI at the moment.)

Ref: #804
Follow-up to f216bbe3aa #2583
Follow-up to bc120a343b #1023

Closes #2603
2026-09-12 00:47:41 +02:00
Viktor Szakats
bcef4a03ee tidy-up: fixup and reflow copyright headers
Also:
- sync with canonical `BSD-3-Clause.txt`:
  - number the clauses.
  - wording in the 3rd clause.
- add 'All rights reserved.' where missing.
- agent: sync with rest of files.
- agent: merge two, identical, embedded headers.
- fix comments nits found nearby.

Closes #2247
2026-07-08 04:22:55 +02:00
Viktor Szakats
33f6508a58 tidy-up: drop most {} blocks around single-statements
Follow-up to b171deefde #2077
Follow-up to 28824712fe #2004

Closes #2087
2026-06-21 04:59:48 +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
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
003fb454c3 tidy-up: avoid exclamations, prefer single quotes, in outputs
Closes #1079
2023-06-03 12:51:56 +00:00
Viktor Szakats
bc120a343b tests: retry KEX failures when using the WinCNG backend
Twice. This tests are flaky and we haven't figured out why. In the
meantime use this workaround to test and log these issues, but also
ensure that CI run aren't flagged red because of it.

Also:
- kex: add debug message when hostkey `sig_verify` fails,
  to help tracking WinCNG KEX failures.
- test_ssh2: also add retry logic.
  I'm not quite sure this is correct. Please let me know.
- session_fixture: bump up `src_path` slots to fit retries and show
  message when hitting the limit.
- session_fixture: clear `kbd_password` static variable after use.
- session_fixture: close and deinit socket after use.
- session_fixture: deinit libssh2 after use.

Ref: #804 #846 #979 #1012 #1015

Cherry-picked from #1017
Closes #1023
2023-05-03 12:30:38 +00:00
Viktor Szakats
9ecb22daab tests: build improvements and more
- rename tests to have more succint names and a more useful natural
  order.

- rename `simple` and `ssh2` in tests to have the `test_` prefix.

  This avoids a name collisions with `ssh2` in examples.

- cmake: drop the `example-` prefix for generated examples.

  Bringing their names in sync with other build tools, like autotools.

- move common auth test code into the fixture and simplify tests by
  using that.

- move feature guards from CMake to preprocessor for auth tests.

  Now it works with all build tools and it's easier to keep it in sync
  with the lib itself.

  For this we need to include `libssh2_priv.h` in tests, which in turn
  needs tweaking on the trick we use to suppress extra MSVS warnings
  when building tests and examples.

- move mbedTLS blocklist for crypto tests from CMake to the test
  fixture.

- add ed25519 hostkey tests to `test_hostkey` and `test_hostkey_hash`.

- add shell script to regenerate all test keys used for our tests.

- alpha-sort tests.

- rename `signed_*` keys to begin with `key` like the rest of the keys
  do.

- whitespace fixes.

Closes #969
2023-04-16 22:50:01 +00:00
Viktor Szakats
2efdb6747a tidy-up: example, tests continued
- fix skip auth if `userauthlist` is NULL.
  Closes #836 (Reported-by: @sudipm-mukherjee on github)
- fix most silenced `checksrc` warnings.
- sync examples/tests code between each other.
  (output messages, error handling, declaration order, comments)
- stop including unnecessary headers.
- always deinitialize in case of error.
- drop some redundant variables.
- add error handling where missing.
- show more error codes.
- switch `perror()` to `fprintf()`.
- fix some `printf()`s to be `fprintf()`.
- formatting.

Closes #960
2023-04-14 11:07:53 +00:00
Viktor Szakats
59666e03f0 build: hand-crafted config rework & header tidy-up
- introduce the concept of a project level setup header
  `src/libssh2_setup.h`, that is used by `src`, `example` and `tests`
  alike. Move there all common platform/compiler configuration from
  `src/libssh2_priv.h`, individual sources and `CMakeFiles.txt` files.
  Also move there our hand-crafted (= not auto-generated by CMake or
  autotools) configuration `win32/libssh2-config.h`.

- `win32` directory is empty now, delete it.

- `Makefile.mk`: adapt to the above. Build-directory is the target
  triplet, or any custom name set via `BLD_DIR`.

- sync header path order between build systems:
  build/src -> source/src -> source/include

- delete redundant references to `windows.h`, `winsock2.h`,
  `ws2tcpip.h`.

- delete unnecessary #includes, update order (`libssh2_setup.h` first,
  `winsock2.h` first), simplify where possible.

  This makes the code warning-free without `WIN32_LEAN_AND_MEAN`.
  At the same time this patch applies this macro globally, to avoid
  header bloat.

- example: add missing *nix header guards.

- example: fix misindented `HAVE_UNISTD_H` `#ifdef`s.

- set `WIN32` with all build-tools.

- set `HAVE_SYS_PARAM_H` in the hand-crafted config for MinGW.
  To match auto-detection.

- move a source-specific macro to `misc.c` from `libssh2_priv.h`.

See the PR's individual commits for step-by-step updates.

Closes #932
2023-04-07 23:44:43 +00:00
Dan Fandrich
e3ce906caf tests: Fix gcc compile warnings
These were mostly due to missing and non-ANSI prototypes.
2023-01-06 10:47:32 -08:00
Viktor Szakats
42cf29101e tests: fix checksrc warnings
Also:
* add 'static' qualifier to file-wide const buffers
* fix a non-ANSI C89 comment
* silence a mismatched fprintf() mask warning by adding a cast
2018-03-13 21:32:41 +00:00
Alexander Lamaison
cf80f2f4b5 Basic dockerised test suite.
This introduces a test suite for libssh2. It runs OpenSSH in a Docker
container because that works well on Windows (via docker-machine) as
well as Linux. Presumably it works on Mac too with docker-machine, but
I've not tested that.

Because the test suite is docker-machine aware, you can also run it
against a cloud provider, for more realistic network testing, by setting
your cloud provider as your active docker machine. The Appveyor CI setup
in this commit does that because Appveyor doesn't support docker
locally.
2016-08-14 16:03:25 +01:00