1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-18 15:20:56 +03:00
Commit Graph

95 Commits

Author SHA1 Message Date
Viktor Szakats
b889b39945 docs: convert man page sources to "curldown" format
To render in Git webviews as-is, to make it easier to edit, verify,
and to sync up with curl.

- add options to not build the `.3` man pages:
  - autotools: `--disable-docs`
  - cmake: `LIBSSH2_BUILD_DOCS=OFF`
- building `.3` man pages requires Perl after this patch.
- drop `mansyntax` and the shell / `grep` / GNU `man` tool requirements with it.
- scripts and most logic were copied from curl.
- add `cd2nroff` from curl, with edits to relax curl-specific checks.
- used `nroff2cd` (from curl) to convert from `.3` to `.md`. Then
  manually fixed copyrights, inline function references and a couple
  of other things.

Credits-to: Daniel Stenberg

Ref: eefcc1bda4
Ref: https://github.com/curl/curl/pull/12730
Ref: https://github.com/libssh2/www/issues/25#issuecomment-3289431671

Closes #1660
2025-10-09 04:05:38 +02:00
Viktor Szakats
2677d3b087 build: stop detecting sys/param.h header
This header is no longer used.

Follow-up to 12427f4fb8 #1415
Closes #1418
2024-07-04 01:59:58 +02:00
Viktor Szakats
790b1178eb autotools: delete bogus square bracket from help text [ci skip]
Follow-up to 3f98bfb090 #1368
2024-04-25 17:33:27 +02:00
Viktor Szakats
3f98bfb090 wincng: add to ci/GHA, add ./configure option --enable-ecdsa-wincng
- add `./configure` option `--enable-ecdsa-wincng`

- add WinCNG autotools jobs to GHA.

- enable WinCNG ECDSA in some GHA jobs (both CMake and autotools).

Follow-up to 3e72343737 #1315
Closes #1368
2024-04-14 02:44:38 +00:00
Viktor Szakats
3ec53f3ea2 build: enable -pedantic-errors
According to the manual, this isn't the same as `-Werror -pedantic`.
Enable it together with `-Werror`.

https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-pedantic-errors-1

This option results in autotools feature detection going into crazies.
To avoid this, we add it to `CFLAGS` late. Idea copied from curl.

This option has an effect only with gcc 5.0 and newer as of this commit.
Let's enable it for clang and older versions too for simplicity. Ref:
d5c0351055
https://github.com/curl/curl/pull/2747

Closes #1286
2023-12-17 15:15:34 +00:00
Viktor Szakats
e051ae343a autotools: delete --disable-tests option, fix CI tests
Originally added to improve build performance by skipping building
tests. But, there seems to be no point in this, because autotools
doesn't build tests by default, unless explicitly invoking
`make check`.

Delete this option from Cygwin and FreeBSD CI tests, where it caused
`make check` to do nothing. Tests are built now, and runtime tests are
too, where supported.

Also disable Docker-based tests for these, and add a missing `make -j3`
for FreeBSD.

Reverts 7483edfada #715

Closes #1271
2023-12-06 00:55:15 +00:00
ren mingshuai
b1414503f5 build: add LIBSSH2_NO_DEPRECATED option (#1266)
The following APIs have been deprecated for over 10 years and
use `LIBSSH2_NO_DEPRECATED` to mark them as deprecated:

libssh2_session_startup()
libssh2_banner_set()
libssh2_channel_receive_window_adjust()
libssh2_channel_handle_extended_data()
libssh2_scp_recv()

Add these options to disable them:
- autotools: `--disable-deprecated`
- cmake: `-DLIBSSH2_NO_DEPRECATED=ON`
- `CPPFLAGS`: `-DLIBSSH2_NO_DEPRECATED`

Fixes #1259
Replaces #1260
Co-authored-by: Viktor Szakats
Closes #1267
2023-12-06 00:14:53 +01:00
Viktor Szakats
a3f5594a96 autotools: show the default for hidden-symbols option
Closes #1269
2023-12-05 02:14:23 +00:00
Viktor Szakats
e9017b1046 acinclude.m4: revert accidental edit [ci skip]
Follow-up to 8c320a93a4
2023-11-20 01:48:33 +00:00
Viktor Szakats
8c320a93a4 acinclude.m4: re-sync with curl [ci skip] 2023-11-18 16:04:53 +00:00
Viktor Szakats
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
Viktor Szakats
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
Viktor Szakats
5720dd9fe0 build: tidy-up libssh2.pc.in variable names
- prefix with `LIBSSH2_PC_`

- match with the names of `pkg-config` values.

- use the same names in autotools and CMake scripts.

- use `LIBSSH2_VERSION` for the version number in autotools scripts,
  to match the name used in CMake.

Closes #1125
2023-07-18 20:45:14 +00:00
Viktor Szakats
624abe275f libssh2.pc: re-add & extend support for static-only libssh2 builds
Adapted for libssh2 from the curl commit message by James Le Cuirot:

"A project built entirely statically will call `pkg-config` with
`--static`, which utilises the `Libs.private:` field. Conversely it will
not use `--static` when not being built entirely statically, even if
there is only a static build of libssh2 available. This will most
likely cause the build to fail due to underlinking unless we merge the
`Libs:` fields.

Consider that this is what the Meson build system does when it generates
`pkg-config` files."

This patch extends the above to `Requires:`, to mirror `Libs:` with
`pkg-config` package names.

Follow-up to 1209c16d93 #1114

Ref: https://github.com/libssh2/libssh2/pull/1114#issuecomment-1634334809
Ref: 98e5904165
Ref: https://github.com/curl/curl/pull/5373
Closes #1119
2023-07-18 15:18:50 +00:00
Viktor Szakats
7f83de14a0 autotools: use comma separator in Requires.private of libssh2.pc
In `Requires*:`, the documented name separator is comma. We already used
it in the CMake-generated `libssh2.pc`. Adjust the autotools-generated
one to use it too, instead of spaces.

Ref: https://linux.die.net/man/1/pkg-config
Ref: d97db4fae4/pkg-config.1

Closes #1124
2023-07-14 21:08:44 +00: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
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
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
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
62178a367a tests: add cmake/autotools options to disable running tests
autotools:
- `--disable-docker-tests`
- `--disable-sshd-tests`

cmake:
- `RUN_DOCKER_TESTS`
- `RUN_SSHD_TESTS`

Update automake and ci to use this new flag and delete former logic
of relying on Windows detection and `HOST_WINDOWS`. Also fix honoring
this when running `test_read_algos.test`.

This allows to disable these individually and on per-CI/local-job basis.
To run as much tests as the env allows.

Cherry-picked from #1017
2023-05-03 15:01:53 +00:00
Viktor Szakats
7aab5bd6f9 build: fix autoreconf warnings
- update `AC_HELP_STRING' to 'AS_HELP_STRING`:
  ```
  configure.ac:[...]: warning: The macro `AC_HELP_STRING' is obsolete.
  ```
  "AC_HELP_STRING is deprecated in 2.70+ and I believe AS_HELP_STRING works
  already since 2.59 so bump the minimum required version to that."

  Ref: a59f046116

- simplify to avoid:
  ```
  src/Makefile.inc:48: warning: variable 'EXTRA_DIST_SOURCES' is defined but no program or
  src/Makefile.inc:48: library has 'DIST' as canonical name (possible typo)
  ```
  Regression from 2c18b6fc8d

- `AC_TRY_LINK`/`AC_TRY_COMPILE`:
  ```
  configure.ac:335: warning: The macro `AC_TRY_COMPILE' is obsolete.
  configure.ac:335: warning: The macro `AC_TRY_LINK' is obsolete.
  ```

- `libtool`-related ones:
  ```
  configure.ac:70: warning: The macro `AC_LIBTOOL_WIN32_DLL' is obsolete.
  configure.ac:70: warning: AC_LIBTOOL_WIN32_DLL: Remove this warning and the call to _LT_SET_OPTION when you
  configure.ac:70: put the 'win32-dll' option into LT_INIT's first parameter.
  configure.ac:71: warning: The macro `AC_PROG_LIBTOOL' is obsolete.
  ```
  Using code copied from curl:
  9ce7eee070/m4/xc-lt-iface.m4 (L157-L163)

- delete commented and obsolete `AC_HEADER_STDC`.

- formatting.

Most cherry-picked from `autoupdate` updates.

Cherry-picked from #1017
Closes #1021
2023-05-03 01:09:15 +00:00
Viktor Szakats
d93ccf4901 ci: add macOS CI jobs + fix issues revealed
Add macOS CI jobs, both cmake and autotools for all supported crypto
backends (except BoringSSL), with debug, zlib enabled. Without running
tests. It also introduces OpenSSL 1.1 into the CI with a non-MSVC
compiler.

Credits to curl's `macos.yml`, that I used as a base.

Fix these issues uncovered by the new tests:

- openssl: fix warning when built with wolfSSL, or OpenSSL 1.1 and
  earlier. CI missed it because apparently the only OpenSSL 1.1 test
  we had used MSVC, which did not complain.

  ```
  ../src/openssl.c:3852:19: error: variable 'sslError' set but not used [-Werror,-Wunused-but-set-variable]
      unsigned long sslError;
                    ^
  ```

  Regression from 097c8f0dae

- pem: add hack to build without MD5 crypto-backend support.

  The Homebrew wolfSSL build comes with MD5 support disabled. We can
  expect this becoming the norm. FIPS also requires MD5 disabled.

  We deleted the same hack from `hostkey.c` a month ago:
  ad6aae302a

  A better fix would be to guard the MD5 logic with our `LIBSSH2_MD5`
  macro.

  ```
  pem.c:214:32: error: use of undeclared identifier 'MD5_DIGEST_LENGTH'; did you mean 'SHA_DIGEST_LENGTH'?
          unsigned char secret[2*MD5_DIGEST_LENGTH];
                                 ^~~~~~~~~~~~~~~~~
                                 SHA_DIGEST_LENGTH
  ```

  Regression from 386e012292

- `configure.ac`: add crypto libs late.

  Fix it by adding crypto libs to `LIBS` at the end of the configuration
  process.

  Otherwise `configure` links crypto libs while doing feature tests,
  which can cause unwanted detections. For example LibreSSL publishes
  the function `explicit_bzero()`, which masks the system alternative,
  e.g. `memset_s()` on macOS. Then when trying to compile libssh2, its
  declaration is missing:

  ```
  bcrypt_pbkdf.c:93:5: error: implicit declaration of function 'explicit_bzero' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      _libssh2_explicit_zero(ciphertext, sizeof(ciphertext));
      ^
  ../src/misc.h:50:43: note: expanded from macro '_libssh2_explicit_zero'
                                            ^
  ```

  Regression from 4f0f4bff5a

- cmake: fix to list our own include directory before the crypto libs',
  when building tests.

  Otherwise a global crypto header path, such as `/usr/local/include`,
  containing an external `libssh2.h` of a different version, could cause
  weird errors:

  ```
  cc -DHAVE_CONFIG_H -DLIBSSH2_LIBGCRYPT \
    -I../src -I../../src -I/usr/local/include -I[...]/libssh2/include \
    -g -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.1.sdk  \
    -mmacosx-version-min=12.6 -MD -MT  \
    tests/CMakeFiles/test_aa_warmup.dir/test_aa_warmup.c.o \
    -MF CMakeFiles/test_aa_warmup.dir/test_aa_warmup.c.o.d  \
    -o CMakeFiles/test_aa_warmup.dir/test_aa_warmup.c.o -c \
    [...]/libssh2/tests/test_aa_warmup.c
  ```

  ```
  [ 62%] Building C object tests/CMakeFiles/test_aa_warmup.dir/test_aa_warmup.c.o
  In file included from /Users/runner/work/libssh2/libssh2/tests/test_aa_warmup.c:4:
  In file included from /Users/runner/work/libssh2/libssh2/tests/runner.h:42:
  In file included from /Users/runner/work/libssh2/libssh2/tests/session_fixture.h:43:
  /Users/runner/work/libssh2/libssh2/tests/../src/libssh2_priv.h:649:5: error: type name requires a specifier or qualifier
      LIBSSH2_AUTHAGENT_FUNC((*authagent));
      ^
  /Users/runner/work/libssh2/libssh2/tests/../src/libssh2_priv.h:649:30: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int]
      LIBSSH2_AUTHAGENT_FUNC((*authagent));
                               ^
  /Users/runner/work/libssh2/libssh2/tests/../src/libssh2_priv.h:650:5: error: type name requires a specifier or qualifier
      LIBSSH2_ADD_IDENTITIES_FUNC((*addLocalIdentities));
      ^
  /Users/runner/work/libssh2/libssh2/tests/../src/libssh2_priv.h:650:35: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int]
      LIBSSH2_ADD_IDENTITIES_FUNC((*addLocalIdentities));
                                    ^
  /Users/runner/work/libssh2/libssh2/tests/../src/libssh2_priv.h:651:5: error: type name requires a specifier or qualifier
      LIBSSH2_AUTHAGENT_SIGN_FUNC((*agentSignCallback));
      ^
  /Users/runner/work/libssh2/libssh2/tests/../src/libssh2_priv.h:651:35: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int]
      LIBSSH2_AUTHAGENT_SIGN_FUNC((*agentSignCallback));
                                    ^
  6 errors generated.
  ```

- `tests/session_fixture.h`: delete duplicate `libssh2.h`,
  `libssh2_priv.h` already includes it.

  Follow-up to a683133dfe

CI logs with these errors:
https://github.com/libssh2/libssh2/actions/runs/4824079094
https://github.com/libssh2/libssh2/actions/runs/4824270819

curl's `macos.yml`: da2470de96/.github/workflows/macos.yml

Tidying-up while here:

- tests/session_fixture.h: delete duplicate `libssh2.h`.
  `libssh2_priv.h` includes it already.

  Follow-up to a683133dfe

- ci.yml: yamllint warnings and formatting.

- ci.yml: msvc section formatting and step-naming sync with macOS.

  Follow-up to f4a4c05dc3

- ci.yml: enable `--enable-werror` for msys2 jobs.

  Follow-up to 71cae949d5

- appveyor.yml: show OpenSSL versions, link to image content.

Closes #1013
2023-04-28 13:59:38 +00:00
Viktor Szakats
d67aaaffc4 tidy-up: text nits, English contractions [ci skip]
In input/output text and docs mostly.
2023-04-27 14:19:03 +00:00
Viktor Szakats
5db836b2a8 libssh2_priv.h: assume HAVE_LONGLONG
Unless I'm missing something, it looks like `libssh2.h` has been using
`libssh2_int64_t` unconditionally since at least 2010-04-17 when
`libssh2_scp_send64()` landed via commit
be9ee7095e.

This makes it redundant to detect `HAVE_LONGLONG` to fallback to a
32-bit `scpRecv_size` in `libssh2_priv.h`. Then deal with possible
combinations of this flag and `strtoll()` options, which was
error-prone.

Instead, assume in `libssh2_priv.h` that we have `libssh2_int64_t`, and
use it always.

For MSVC, this means `_MSC_VER` `1310` (from year 2003) is now
required. Based on the above, this was already so before this patch.

If there happens to be no 64-bit `strtoll()` detected, fall back to the
32-bit `strtol()` (this should never happen with MSVC, and probably
neither with any other reasonably modern toolchain.)

Also make sure to set `HAVE_STRTOI64` for older, non-CMake, MSVC builds
(e.g. `Makefile.mk` or `NMakefile` ones).

Closes #1002
2023-04-26 16:46:05 +00:00
Viktor Szakats
f7e889b627 build: add autotools test_read support and more
Keep a single list for mac and crypt algos that we use in both CMake
and autotools. Use the same test names across build tools.

Use the TAP protocol to track individual tests run from a single shell
script.

Also:

- enable the rest of our tests with autotools.

- set `make check` verbose to see errors in case they happen.

- silence stray 'command not found' error when running `mansyntax.sh`
  on Windows.

GitHub Actions Windows docker tests disabled due to:
```
Command: docker build --quiet -t libssh2/openssh_server ../tests/openssh_server
Error running command 'docker build --quiet -t libssh2/openssh_server ../tests/openssh_server' (exit 1): Sending build context to Docker daemon  22.02kB
Step 1/42 : FROM debian:bullseye-slim
bullseye-slim: Pulling from library/debian
no matching manifest for windows/amd64 10.0.20348 in the manifest list entries
Failed to build docker image
```

Closes #993
2023-04-21 19:11:21 +00:00
Viktor Szakats
c76b96cbe6 build: support libssh2.rc with autotools
Caveat: When building `--enable-static` and `--enable-shared` at the
same time, the compiled Windows resource is also included in the
static library. This appears to be an autotools limitation, with no
way to have different input lists (or different custom options) for
shared and static libraries, even though it builds them separately.

The workaround is to build static libraries in a separate
`./configure` + `make` pass.

Closes #944
2023-04-10 09:24:31 +00:00
Viktor Szakats
4f0f4bff5a build: unify source lists
- introduce `src/crypto.c` as an umbrella source that does nothing else
  than include the selected crypto backend source. Moving this job from
  the built-tool to the C preprocessor.

- this allows dropping the various techniques to pick the correct crypto
  backend sources in autotools, CMake and other build method. Including
  the per-backend `Makefile.<crypto-backend>.inc` makefiles.

- copy a trick from curl and instead of maintaining duplicate source
  lists for CMake, convert the GNU Makefile kept for autotools
  automatically. Do this in `docs`, `examples` and `src`.

  Ref: dfabe8bca2/CMakeLists.txt (L1399-L1413)

  Also fixes missing `libssh2_setup.h` from `src/CMakeFiles.txt` after
  59666e03f0.

- move `Makefile.inc` from root to `src`.

- reformat `src/Makefile.inc` to list each source in separate lines,
  re-align the continuation character and sort the lists alphabetically.

- update `docs/HACKING-CRYPTO` accordingly.

- autotools: update the way we add crypto-backends to `LIBS`.

- delete old CSV headers, indent, and merge two lines in
  `docs/Makefile.am` and `src/Makefile.am`.

- add `libssh2.pc` to `.gitignore`, while there.

Closes #941
2023-04-10 09:20:13 +00:00
Viktor Szakats
a7a2fcdab6 autotools: delete unused conditional HAVE_SYS_UN_H
No longer necessary after moving the disabling/enabling logic from
build tool to `example/x11.c`.

Reverts 4774d500e7
Follow-up to d245c66cc0
2023-04-02 12:12:18 +02:00
Viktor Szakats
cab599120c delete redundant HAVE_STDLIB_H
libssh2 used this standard C89 header unconditionally before this patch.

Delete the feature checks and all unnecessary header guards.

Closes #913
2023-04-01 23:41:07 +00:00
Viktor Szakats
eb236329c4 delete redundant HAVE_WINSOCK2_H
`libssh2.h` required `winsock2.h` for `_WIN32` since
81d53de4dc (2011-06-04).

Apply that to the whole codebase. This makes it unnecessary to detect
`HAVE_WINSOCK2_H` and allows to drop all its uses.

Completes TODO from b66d7317ca

TODO: Straighten out the use a mixture of `HAVE_WINDOWS_H`,
      `WIN32`, `_WIN32` to detect Windows.
2023-04-01 19:32:08 +02:00
Viktor Szakats
b66d7317ca delete redundant HAVE_WS2TCPIP_H
It was used once in `src/libssh2_priv.h`, but without any effect.
The header included `ws2tcpip.h` twice, once guarded by
`HAVE_WS2TCPIP_H` and another time by `HAVE_WINSOCK2_H`.

Dedupe these to not use `HAVE_WS2TCPIP_H`. Then delete detection
of this feature from all build methods.

TODO: Replace `HAVE_WINSOCK2_H` with `_WIN32`/`WIN32`.
2023-04-01 13:15:55 +02:00
Viktor Szakats
00005682f7 detect and use explicit_bzero() and explicit_memset() (#895)
Also skip detecting these and `memset_s()` for Windows targets in CMake,
to save detection time. On Windows we always use `SecureZeroMemory()`.
2023-03-28 17:49:38 +02:00
Viktor Szakats
1d9af00609 tidy-up: fix typos (#886)
detected by codespell 2.2.4.
2023-03-27 19:26:58 +02:00
Viktor Szakats
50c9bf868e rework how to enable insecure null-cipher/null-MAC (#873)
Null-cipher and null-MAC are security footguns we want to avoid.

Existing option names to toggle these were ambiguous and gave room for
misinterpretation. Some projects may have had these options enabled by
accident.

This patch aims to make it more difficult to enable them, and making
sure that existing methods require an update to stay enabled.

- delete CMake/autotools settings to enable the "none" cipher and MAC.

- rename existing C macros that can enable them.

  To use them, pass them as custom `CPPFLAGS` to the build.

- enable them only if `LIBSSH2DEBUG` is also enabled.

Best would be to delete them, though they may have some use while
developing libssh2 itself, or debugging.
2023-03-27 11:34:54 +02:00
Viktor Szakats
38177f18dd delete old gex (SSH2_MSG_KEX_DH_GEX_REQUEST_OLD) build option (#872)
libssh2 supports an "old" style KEX message
`SSH2_MSG_KEX_DH_GEX_REQUEST_OLD`, as an off-by-default build option.

OpenSSH deprecated/disabled this feature in v6.9 (2015-07-01):
https://www.openssh.com/releasenotes.html#6.9

This patch deletes this obsolete feature from libssh2, with no option
to enable it.

Added to libssh2 in: cf8ca63ea0 (2004-12-31)
RFC: https://datatracker.ietf.org/doc/html/rfc4419 (2006-03)
2023-03-27 11:28:51 +02:00
Viktor Szakats
a0e424a51c src: enable clear memory on all platforms
- convert `_libssh2_explicit_zero()` to macro. This allows inlining
  where supported (e.g. `SecureZeroMemory()`).

- replace `SecureZeroMemory()` (in `wincng.c`) and
  `LIBSSH2_CLEAR_MEMORY`-guarded `memset()` (in `os400qc3.c`) with
  `_libssh2_explicit_zero()` macro.

- delete `LIBSSH2_CLEAR_MEMORY` guards, which enables secure-zeroing
  universally.

- add `LIBSSH2_NO_CLEAR_MEMORY` option to disable secure-zeroing.

- while here, delete double/triple inclusion of `misc.h`.
  `libssh2_priv.h` included it already.

Closes #810
2023-03-07 14:21:46 +00:00
Viktor Szakats
4cdf785cd3 snprintf: unify fallback logic
Before this patch, the `snprintf()` fallback logic for envs not
supporting this function (i.e. Visual Studio 2013 and older) varied
depending on build tool, and used different techniques in examples,
tests and libssh2 itself.

This patch aims to apply a common logic to libssh2 and examples/tests.

- libssh2: use local `snprintf()` fallback with all build tools.

  We already had a local implementation, but only with CMake. Move that
  to the library as `_libssh2_snprintf()`, and map `snprintf()` to it
  when `HAVE_SNPRINTF` is not set.

  Also change the length type from `int` to `size_t`, and fix
  formatting.

- set or detect `HAVE_SNPRINTF` in non-CMake builds.

  Detect in autotools. Keep existing logic in `win32/libssh2_config.h`.
  Always set for OS/400, NetWare and VMS, keeping existing behaviour.
  (OS/400 builds use a different local implementation)

- examples/tests: drop the CMake-specific fallback logic and map
  `snprintf()` to `_snprintf()` for old MSVC versions, like we did
  before with other build tools. This is unsafe, but should be fine for
  these uses.

- `win32/libssh2_config.h`: make it easier to read.

Closes #812
2023-03-07 14:08:12 +00:00
Viktor Szakats
2addafb77b build fixes and improvements (mostly for Windows)
- in `hostkey.c` check the result of `libssh2_sha256_init()` and
  `libssh2_sha512_init()` calls. This avoid the warning that we're
  ignoring the return values.

- fix code using `int` (or `SOCKET`) for sockets. Use libssh2's
  dedicated `libssh2_socket_t` and `LIBSSH2_INVALID_SOCKET` instead.

- fix compiler warnings due to `STATUS_*` macro redefinitions between
  `ntstatus.h` / `winnt.h`. Solve it by manually defining the single
  `STATUS` value we need from `ntstatus.h` and stop including the whole
  header.
  Fixes #733

- improve Windows UWP/WinRT builds by detecting it with code copied
  from the curl project. Then excluding problematic libssh2 parts
  according to PR by Dmitry Kostjučenko.
  Fixes #734

- always use `SecureZeroMemory()` on Windows.

  We can tweak this if not found or not inlined by a C compiler which
  we otherwise support. Same if it causes issues with UWP apps.

  Ref: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa366877(v=vs.85)
  Ref: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlsecurezeromemory

- always enable `LIBSSH2_CLEAR_MEMORY` on Windows. CMake and
  curl-for-win builds already did that. Delete `SecureZeroMemory()`
  detection from autotools' WinCNG backend logic, that this
  setting used to depend on.

  TODO: Enable it for all platforms in a separate PR.
  TODO: For clearing buffers in WinCNG, call `_libssh2_explicit_zero()`,
        insead of a local function or explicit `SecureZeroMemory()`.

- Makefile.inc: move `os400qc3.h` to `HEADERS`. This fixes
  compilation on non-unixy platforms. Recent regression.

- `libssh2.rc`: replace copyright with plain ASCII, as in curl.

  Ref: curl/curl@1ca62bb
  Ref: curl/curl#7765
  Ref: curl/curl#7776

- CMake fixes and improvements:

  - enable warnings with llvm/clang.
  - enable more comprehensive warnings with gcc and llvm/clang.
    Logic copied from curl:
    233810bb5f/CMakeLists.txt (L131-L148)
  - fix `Policy CMP0080` CMake warning by deleting that reference.
  - add `ENABLE_WERROR` (default: `OFF`) option. Ported from curl.
  - add `PICKY_COMPILER` (default: `ON`) option, as known from curl.

    It controls both the newly added picky warnings for llvm/clang and
    gcc, and also the pre-existing ones for MSVC.

- `win32/GNUmakefile` fixes and improvements:

  - delete `_AMD64_` and add missing `-m64` for x64 builds under test.
  - add support for `ARCH=custom`.
    It disables hardcoded Intel 64-bit and Intel 32-bit options,
    allowing ARM64 builds.
  - add support for `LIBSSH2_RCFLAG_EXTRAS`.
    To pass custom options to windres, e.g. in ARM64 builds.
  - add support for `LIBSSH2_RC`. To override `windres`.
  - delete support for Metrowerks C. Last released in 2004.

- `win32/libssh2_config.h`: delete unnecessary socket #includes

  `src/libssh2_priv.h` includes `winsock2.h` and `ws2tcpip.h` further
   down the line, triggered by `HAVE_WINSOCK2_H`.

  `mswsock.h` does not seem to be necessary anymore.

  Double-including these (before `windows.h`) caused compiler failures
  when building against BoringSSL and warnings with LibreSSL. We could
  work this around by passing `-DNOCRYPT`. Deleting the duplicates
  fixes these issues.

  Timeline:
  2013: c910cd382d deleted `mswsock.h` from `src/libssh2_priv.h`
  2008: 8c43bc52b1 added `winsock2.h` and `ws2tcpip.h` to `src/libssh2_priv.h`
  2005: dc4bb1af96 added the now deleted #includes

- delete or replace `LIBSSH2_WIN32` with `WIN32`.

- replace hand-rolled `HAVE_WINDOWS_H` macro with `WIN32`. Also delete
  its detections/definitions.

- delete unused `LIBSSH2_DARWIN` macro.

- delete unused `writev()` Windows implementation

  There is no reference to `writev()` since 2007-02-02, commit
  9d55db6501.

- fix a bunch of MSVC / llvm/clang / gcc compiler warnings:

  - `warning C4100: '...': unreferenced formal parameter`
  - using value of undefined PP macro `LIBSSH2DEBUG`
  - missing void from function definition
  - `if()` block missing in non-debug builds
  - unreferenced variable in non-debug builds
  - `warning: must specify at least one argument for '...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments]`
    in `_libssh2_debug()`
  - `warning C4295: 'ciphertext' : array is too small to include a terminating null character`
  - `warning C4706: assignment within conditional expression`
  - `warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or
      define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings`
    By suppressning it. Would be best to use inet_pton() as suggested.
    On Windows this needs Vista though.
  - `warning C4152: nonstandard extension, function/data pointer conversion in expression`
    (silenced locally)
  - `warning C4068: unknown pragma`

  Ref: https://ci.appveyor.com/project/libssh2org/libssh2/builds/46354480/job/j7d0m34qgq8rag5w

Closes #808
2023-03-03 13:30:03 +00:00
Dan Fandrich
9f8e69cca0 configure.ac: check for sys/param.h
This file is required by glibc for the test suite.
2022-12-05 17:12:07 -08:00
Viktor Szakats
7483edfada configure: add --disable-tests option 2022-07-02 11:54:39 +02:00
Hayden Roche
17c9c1fcdf Add support for a wolfSSL crypto backend. (#629)
It uses wolfSSL's OpenSSL compatibility layer, so rather than introduce new
wolfssl.h/c files, the new backend just reuses openssl.h/c. Additionally,
replace EVP_Cipher() calls with EVP_CipherUpdate(), since EVP_Cipher() is not
recommended.

Credit: Hayden Roche
2022-01-06 10:25:34 -08:00
Daniel Stenberg
6eb132f159 mailing list: moved to lists.haxx.se 2021-09-03 09:17:34 +02:00
Will Cosgrove
35ac220a44 configure.ac: don't undefine scoped variable (#594)
* configure.ac: don't undefine scoped variable

To get this script to run with Autoconf 2.71 on macOS I had to remove the undefine of the backend for loop variable. It seems scoped to the for loop and also isn't referenced later in the script so it seems OK to remove it.

* configure.ac: remove cygwin specific CFLAGS #598

Notes:
Remove cygwin specific Win32 CFLAGS and treat the build like a posix build

Credit:
Will Cosgrove, Brian Inglis
2021-05-26 16:42:38 -07:00
Max Dymond
7a4b051ba4 Add support for an OSS Fuzzer fuzzing target (#392)
Files:
.travis.yml, configure.ac, ossfuzz 

Notes:
This adds support for an OSS-Fuzz fuzzing target in ssh2_client_fuzzer,
which is a cut down example of ssh2.c. Future enhancements can improve
coverage.

Credit:
Max Dymond
2020-09-01 14:20:52 -07:00
yann-morin-1998
fc5d77881e buildsystem: drop custom buildconf script, rely on autoreconf (#224)
Notes:
The buildconf script is currently required, because we need to copy a
header around, because it is used both from the library and the examples
sources.

However, having a custom 'buildconf'-like script is not needed if we can
ensure that the header exists by the time it is needed. For that, we can
just append the src/ directory to the headers search path for the
examples.

And then it means we no longer need to generate the same header twice,
so we remove the second one from configure.ac.

Now, we can just call "autoreconf -fi" to generate the autotools files,
instead of relying on the canned sequence in "buildconf", since
autoreconf has now long known what to do at the correct moment (future
versions of autotools, automake, autopoint, autoheader etc... may
require an other ordering, or other intermediate steps, etc...).

Eventually, get rid of buildconf now it is no longer needed. In fact, we
really keep it for legacy, but have it just call autoreconf (and print a
nice user-friendly warning). Don't include it in the release tarballs,
though.

Update doc, gitignore, and travis-CI jobs accordingly.

Credit:
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Sam Voss <sam.voss@rockwellcollins.com>
2020-07-01 11:44:08 -07:00
Daniel Stenberg
1a60c0111c configure: provide --enable-werror 2019-03-17 14:33:23 +01:00
Will Cosgrove
0309229259 ED25519 Key Support #39 (#248)
OpenSSH Key and ED25519 support #39
Added _libssh2_explicit_zero() to explicitly zero sensitive data in memory #120

* ED25519 Key file support - Requires OpenSSL 1.1.1 or later
* OpenSSH Key format reading support - Supports RSA/DSA/ECDSA/ED25519 types
* New string buffer reading functions - These add build-in bounds checking and convenance methods. Used for OpenSSL PEM file reading.
* Added new tests for OpenSSH formatted Keys
2018-08-02 14:00:25 -07:00
Peter Stuge
e70e71a3b1 configure.ac: Add --with-crypto= instead of many different --with-$backend
The new --with-crypto option replaces the previous backend-specific
--with-{openssl,libgcrypt,mbedtls,wincng} options and fixes some issues.

* libgcrypt or mbedtls would previously be used whenever found, even
  if configure was passed --without-libgcrypt or --without-mbedtls.

* If --with-$backend was specified then configure would not fail even
  if that library could not be found, and would instead use whichever
  crypto library was found first.

The new option defaults to `auto`, which makes configure check for all
supported crypto libraries in turn, choosing the first one found, or
exiting with an error if none can be found.
2016-11-12 10:46:06 +00:00
Peter Stuge
a68356418d configure.ac src/Makefile.am: Remove dead AM_CONDITIONAL(OS400QC3)
According to os400/README400 this backend can not be built
with configure+make, and the conditional is hard coded to false.
2016-11-05 22:18:04 +00:00