1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-29 13:01:14 +03:00

320 Commits

Author SHA1 Message Date
30203f167b docs: improve man page for libssh2_channel_request_auth_agent
Mention that the callback is needed for full functionality.

This is inspired/copied from the existing X11 man pages.

Closes #1503
2025-07-22 14:13:01 +02:00
992dafbc7f scp: fix NULL dereference in path arg of send/recv (#1625)
Notes:
* Error handling if path for scp is NULL

Reported-by:
Liu Xing Yu

Credit:
Ryan Kelley
2025-07-21 10:02:42 -07:00
98cd10d1c1 INSTALL_CMAKE: fixes build result directories
In the CMake installation instructions, the resulting static library,
examples and tests are actually found in `bld`, not in `bin`.

Closes #1617
2025-07-13 11:21:39 +02:00
723b701715 build: tidy up comments on Makefile.inc variables
Closes #1615
2025-07-02 12:02:09 +02:00
694b9d964b cmake: add linter, fix issues
Ref: https://cmake-format.readthedocs.io/en/latest/cmake-lint.html
Ref: https://github.com/cheshirekow/cmake_format

Closes #1610
2025-06-11 07:09:10 +02:00
e0681cdba9 build: drop crypto.c umbrella source
Instead build all crypto backend sources always, and exclude inactive
ones with guards.

To play better with code checkers and compilers that are blind to
included C sources, e.g. clang with certain compiler warnings and
clang-tidy.

We continue to include `blowfish.c`.

Follow-up to 4f0f4bff5a #941
Cherry-picked from #1561
2025-03-24 14:04:07 +01:00
d32ab16241 ci/GHA: add CI test for AWS-LC
* Adds AWS-LC (cmake, gcc, amd64) to the GitHub CI tests.
* Adds note on how to build w/ BoringSSL or AWS-LC in `INSTALL_CMAKE.md`

AWS-LC recently added CI integration tests for Libssh2 to the AWS-LC
GitHub repo to ensure that we maintain our compatibility with libssh2:
https://github.com/aws/aws-lc/pull/2222

I've verified this change by running the CI job on my fork, which
completed successfully:
https://github.com/justsmth/libssh2/actions/runs/13547314774/job/37862097664

Closes #1557
2025-03-15 03:12:38 +01:00
a751d578be tidy-up: replace exit() with return
In examples and the manual page for `libssh2_version()`.

Closes #1541
2025-02-13 13:51:49 +01:00
cf3aac1aba libssh2_base64_decode: add deprecation warning
Cherry-picked from #1484
2025-01-31 02:04:59 +01:00
7027604505 libssh2_scp_send, libssh2_scp_send_ex: add deprecation warning
Also:
- switch to non-deprecated alternative in examples.
- add pointers and deprecation warning to libssh2_scp_send man page.

Cherry-picked from #1484
2025-01-31 02:04:59 +01:00
90a686ef3a gitignore: compress rules
Cherry-picked from #1484
2025-01-31 02:00:28 +01:00
7495084b1c libssh2_trace.3: Update prototype
Return value is int, not void.

Reported-by: pyscripter on github
Bug: https://github.com/libssh2/libssh2/issues/1517#issuecomment-2608628918
Closes #1518
2025-01-29 02:55:02 +01:00
114923f1ac tidy-up: unsigned const char -> const unsigned char
For consistency with rest of the code.

Closes #1487
2024-11-02 00:37:59 +01:00
b7ab0faa70 disable DSA by default
Also:
- add `LIBSSH2_DSA_ENABLE` to enable it explicitly.
- test the above option in CI.
- say 'deprecated' in docs and public header.
- disable DSA in the CI server config.
  (OpenSSH 9.8 no longer builds with it by default)
  https://www.openssh.com/txt/release-9.8
  Patch-by: Jose Quaresma
- disable more DSA code when not enabled.

Fixes #1433
Closes #1435
2024-07-30 22:59:02 +02:00
c905bfd27c tidy-up: link updates (#1434) 2024-07-30 19:35:38 +02:00
fb6527468c sftp: implement posix-rename@openssh.com
Add a new function `libssh2_sftp_posix_rename_ex()` and
`libssh2_sftp_posix_rename()`, which implement
the posix-rename@openssh.com extension.

If the server does not support this extension, the function returns
`LIBSSH2_FX_OP_UNSUPPORTED` and it's up to the user to recover, possibly
by calling `libssh2_sftp_rename()`.

Co-authored-by: Viktor Szakats (bump to size_t)
Closes #1386
2024-06-26 19:31:34 +02:00
581b72aab7 docs: improve libssh2_userauth_publickey_from* manpages
Reported-by: Lyndon Brown
Assisted-by: Ryan Kelley
Fixes #652
Closes #1308
Closes #xxxx
2024-04-03 11:16:08 +00:00
2f0efde37a docs: update INSTALL_AUTOTOOLS (#1316)
corrected --with-libmbedtls-prefix to current option --with-libmbedcrypto-prefix
2024-03-28 23:27:52 +01:00
4718ede4e0 src: check hash update/final success
Also:
- delete unused internal macro `libssh2_md5()` where defined.
- prefix `libssh2_os400qc3_hash*()` function names with underscore.
  These are public/visible, but internal.
- add FIXMEs to OS/400 code to verify update/final calls; some OS API,
  some internal.

Ref: https://github.com/libssh2/libssh2/pull/1301#discussion_r1446861650
Reviewed-by: Michael Buckley
Reviewed-by: Patrick Monnerat
Closes #1303
2024-01-18 23:54:29 +00:00
ba27bbe7c9 HACKING-CRYPTO: more fixups [ci skip]
Follow-up to f64885b6ab #1297
2024-01-12 01:11:58 +00:00
cf5364f303 HACKING-CRYPTO: fixups [ci skip]
Follow-up to f64885b6ab #1297
2024-01-12 01:00:53 +00:00
f64885b6ab mac: handle low-level errors
- update low-level hmac functions from macros to functions.
- libgcrypt: propagate low-level hmac errors.
- libgcrypt: add error checks for hmac calls.
- os400qc3: add error checks, propagate them.
  Assisted-by: Patrick Monnerat
- mbedtls: fix propagating low-level hmac errors.
- wincng: fix propagating low-level hmac errors.
- mac: verify success of low-level hmac functions.
- knownhost: verify success of low-level hmac functions.
- transport: verify success of MAC hash call.
- minor type cleanup in wincng.
- delete unused ripemd wrapper in wincng.
- delete unused SHA384 wrapper in mbedtls.

Reported-by: Paul Howarth
Reviewed-by: Michael Buckley
Closes #1297
2024-01-10 16:32:22 +00:00
c0f69548be session: add libssh2_session_callback_set2()
Add new `libssh2_session_callback_set2()` API that deprecates
`libssh2_session_callback_set()`.

The new implementation offers the same functionality, but accepts and
returns a generic function pointer (of type `libssh2_cb_generic *`), as
opposed to the old function that used data pointers (`void *`). The new
solution thus avoids data to function (and vice versa) pointer
conversions, which has undefined behaviour in standard C.

About the name: It seems the `*2` suffix was used in the past for
replacement functions for deprecated ones. Let's stick with that.
`*_ex` was preferred for new functions that extend existing ones with
new features.

Closes #1285
2023-12-18 15:02:17 +00:00
9839ebe5e9 libssh2.h: add deprecated function warnings
With deprecated-at versions and suggested replacement function.

It's possible to silence them by defining `LIBSSH2_DISABLE_DEPRECATION`.

Also add depcreated-at versions to documentation, and unify wording.

Ref: https://github.com/libssh2/libssh2/pull/1260#issuecomment-1837017987
Closes #1289
2023-12-16 17:43:02 +00:00
afa6b86560 build: enable missing OpenSSF-recommended warnings, with fixes
Ref:
https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html
(2023-11-29)

Enable new warnings:

- replace `-Wno-sign-conversion` with `-Wsign-conversion`.

  Fix them in example, tests and wincng. There remain about 360 of these
  warnings in `src`. Add a TODO item for those and disable `-Werror` for
  this particular warning.

- enable `-Wformat=2` for clang (in both cmake and autotools).

- enable `__attribute__((format))` for `_libssh2_debug()`,
  `_libssh2_snprintf()` and in tests for `run_command()`.

  `LIBSSH2_PRINTF()` copied from `CURL_TEMP_PRINTF()` in curl.

- enable `-Wimplicit-fallthrough`.

- enable `-Wtrampolines`.

Fix them:

- src: replace obsolete fall-through-comments with
  `__attribute__((fallthrough))`.

- wincng: fix `-Wsign-conversion` warnings.

- tests: fix `-Wsign-conversion` warnings.

- example: fix `-Wsign-conversion` warnings.

- src: fix `-Wformat` issues in trace calls.

  Also, where necessary fix `int` and `unsigned char` casts to
  `unsigned int` and adjust printf format strings. These were not
  causing compiler warnings.

  Cast large types to `long` to avoid dealing with printf masks for
  `size_t` and other C99 types. Existing code often used `int` for this.
  I'll update them to `long` in an upcoming commit.

- tests: fix `-Wformat` warning.

- silence `-Wformat-nonliteral` warnings.

- mbedtls: silence `-Wsign-conversion`/`-Warith-conversion`
  in external header.

Closes #1257
2023-12-03 01:32:20 +00:00
b136c37998 tidy-up: unsigned -> unsigned int
In the `interval` argument of public `libssh2_keepalive_config()`.

Tested via #1257
2023-12-02 09:53:56 +00:00
0b4bdc856f TODO: disable or drop weak algos [ci skip]
Closes #1261
2023-12-02 08:29:49 +00:00
4348557960 Makefile.mk: delete Windows-focused raw GNU Make build
We recommend using CMake instead. Especially in unity mode, it's faster
and probably more familiar for most. It's also easily portable.

(`Makefile.mk` was also portable, but in practice only usable for
Windows. Other platforms required a manual config header.)

Also:
- migrate `LIBSSH2_NO_*` option CI tests to CMake.
- make MSYS2 CMake builds verbose to show compilation options.

Closes #1204
2023-11-06 21:41:12 +00:00
bfa00f1bd5 tidy-up: around stdint.h
- os400: delete unused `HAVE_STDINT_H`.

- fuzz: delete redundant `stdint.h` use.
  `inttypes.h` is already included via `testinput.h`.

- docs/TODO: adjust type in planned function.

Closes #1212
2023-11-06 15:00:08 +00:00
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
67e39091b2 libssh2_session_get_blocking.3: Add description (#1185) 2023-09-24 01:00:14 +02: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
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
f58f77b5c8 cmake: streamline invocation
Stop specifiying the current directory.
Simplify build instructions.

Closes #1138
2023-07-27 10:49:00 +00:00
2da13c13e1 cmake: re-add Libssh2:libssh2 for compatibiliy + lowercase namespace
- add `libssh2:libssh2` target that selects the shared lib if built,
  otherwise the static one.

- re-add `Libssh2:libssh2` target for compatibility with v1.10.0 and
  earlier. This is an alias for `libssh2:libssh2`.

- keep `libssh2:libssh2_shared` and `libssh2_libssh2_static` targets.

- allow using `find_package(libssh2)` in dependents as an alternative
  to `find_package(Libssh2)`.

Co-authored-by: Radek Brich
Suggested-by: Haowei Hsu

Fixes #1103
Fixes #731
Closes #1104
2023-06-25 19:14:18 +00:00
766bde9fb9 docs: replace SHA1 with SHA256 in CMake example 2023-06-23 16:31:16 +00:00
fe6239a11f reuse: comply with 3.1 spec and 2.0.0 checker
The checker tool was upgraded upstream to 2.0.0 and the REUSE
Specification to version 3.1 (from 3.0), causing these new errors:
```
reuse.project - WARNING - Copyright and licensing information for 'docs/INSTALL_AUTOTOOLS' have been found in 'docs/INSTALL_AUTOTOOLS' and the DEP5 file located at '.reuse/dep5'. The information in the DEP5 file has been overridden. Please ensure that this is correct.
reuse.project - WARNING - Copyright and licensing information for 'tests/openssh_server/Dockerfile' have been found in 'tests/openssh_server/Dockerfile' and the DEP5 file located at '.reuse/dep5'. The information in the DEP5 file has been overridden. Please ensure that this is correct.

The following files have no licensing information:
* docs/INSTALL_AUTOTOOLS
* tests/openssh_server/Dockerfile
```
Via: https://github.com/libssh2/libssh2/actions/runs/5333572682/jobs/9664211341?pr=1098#step:4:4

Ref: https://github.com/fsfe/reuse-tool/releases/tag/v2.0.0
Ref: https://git.fsfe.org/reuse/docs/src/branch/stable/CHANGELOG.md#3-1-2023-06-21

Original discovery: https://github.com/libssh2/libssh2/pull/1098#issuecomment-1600719575

Fixes #1101
Closes #1102
2023-06-21 17:43:42 +00:00
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
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
003fb454c3 tidy-up: avoid exclamations, prefer single quotes, in outputs
Closes #1079
2023-06-03 12:51:56 +00:00
e7a542da6a add copyright/credits
Closes #1050
2023-05-29 17:07:11 +00:00
dee8ec9270 docs: delete two stray characters
Cherry-picked from #1017
2023-05-03 01:35:16 +00:00
5ee6d0ffbc tidy-up: avoid expression 'of course'
Cherry-picked from #1017
2023-05-03 01:35:10 +00:00
31851511bf tidy-up: avoid word 'just'
Cherry-picked from #1017
2023-05-03 01:35:05 +00:00
081c04571b tidy-up: avoid word 'simply'
Cherry-picked from #1017
2023-05-03 01:34:58 +00:00
d67aaaffc4 tidy-up: text nits, English contractions [ci skip]
In input/output text and docs mostly.
2023-04-27 14:19:03 +00:00
592e2b37fa docs: simplify .TH header & other cleanups [ci skip]
- simplify `.TH` headers.
- delete empty lines before sections.
- update template with an `AVAILABILITY` section.

Left libssh2 version number in the `.TH` header for entries without an
`AVAILABILITY` section, or where there was a different version number
there.
2023-04-26 17:55:51 +00:00
d7bec41df3 tidy-up: formatting nits [ci skip] 2023-04-26 17:55:51 +00:00
bc4e619e76 Agent forwarding implementation (#752)
This PR contains a series of patches that date back many years and I
believe were discussed on the mailing list, but never merged. We have
been using these in our local copy of libssh2 without issue since 2015,
if not earlier. I believe this is the full set of changes, as we tried
to use comments to mark where our copy of libssh2 differs from the
canonical version.

This also contains changes I made earlier this year, but which were not
discussed on the mailing list, to support certificates and FIDO2 keys
with agent forwarding.

Note that this is not a complete implementation of agent forwarding, as
that is outside the scope of libssh2. Clients still need to provide
their own implementation that parses ssh-agent methods after calling
libssh2_channel_read() and calls the appropriate callback messages in
libssh2. See the man page changes in this PR for more details.

Integration-patches-by: Viktor Szakats

* prefer size_t
* prefer unsigned int over u_int in public function
* add const
* docs, indent, checksrc, debug call, compiler warning fixes
2023-04-22 10:54:20 +02:00