- add missing `.fi` tags.
- fix misplaced `.nf` tags.
- add `.nf`/`.fi` tags `SYNOPSIS` where missing.
- fix missing/wrong function name from `SH NAME`.
- fix wrong function name in `TH`.
- keep return values in a separate line.
- indent.
- fold long lines.
- deleted `libssh2_channel_direct_streamlocal()`, there is no such function.
- add missing types.
- add missing headers.
Closes#949
This patch allow to use direct-streamlocal service from OpenSSH 6.7,
that allows UNIX socket connections.
Mods:
- delete unrelated condition:
Ref: https://github.com/libssh2/libssh2/pull/216#discussion_r374748111
- rebase on master, whitespace updates.
Patch-by: @gjalves Gustavo Junior Alves
Closes#216Closes#632Closes#945
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
- 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
- implement symbol hiding on non-Windows platforms.
The essence of the detection logic was copied from:
dfabe8bca2/CMake/CurlSymbolHiding.cmake
Then simplified and shortened. This method doesn't require a recent
CMake version, nor an external, auto-generated C header.
Move `configure_file()` after `set(LIBSSH2_API ...)`, for the config
file to pick up `LIBSSH2_API`s value.
Closes#602
- add CMake option `HIDE_SYMBOLS`.
This setting means to hide non-public functions from the libssh2
dynamic library when set to `ON`. The default.
When set to `OFF`, make all non-static/internal functions visible
in the dynamic library.
This setting requires `BUILD_SHARED_LIBS=ON`.
- honor this setting on Windows.
By setting the `LIBSSH2_EXPORTS` manual macro again, and stop
recognizing the automatic CMake macro for this purpose:
`libssh2_shared_EXPORT`.
Closes#939
- include `blowfish.c` into `bcrypt_pbkdf.c`, instead of
compiling it as a distinct object.
- make low-level blowfish functions static. This prevents this symbols
to pollute the public namespace of libssh2. It also allows the
compiler to inline these functions.
- integrate `blf.h` header into `bcrypt_pbkdf.c` as well.
- use `_DEBUG_BLOWFISH` instead of `#if 0`.
- fix `_DEBUG_BLOWFISH` compiler warnings and other nits.
- `#undef` `inline` before redefining it in `libssh2_priv.h`.
(copied from `blowfish.c`)
- delete unused `inline` redefinitions from `blowfish.c`.
- disable unused low-level blowfish functions.
- formatting, header order.
Closes#938
- fix to use `LIBSSH2DEBUG` macro to set the debug flag.
(was `DEBUGBUILD`, a curl-specific macro)
- use manifest constants instead of literals
- change language to neutral
Closes#937
- drop unnecessary `WIN32`-specific branches.
- add `static`.
- sync header inclusion order.
- sync some common code between examples/tests.
- fix formatting/indentation.
- fix some `checksrc` errors not caught by `checksrc`.
Closes#936
- 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
- use `example` target for building examples (was: `test`).
- add support for building tests via the `test` target.
- accept lib-only options in a new `LIBSSH2_CPPFLAGS_LIB` variable.
Useful to pass `-DLIBSSH2_EXPORTS` for correct `dllexport` in
`libssh2.dll`.
- fix to put dynamic library in lib directory for non-Windows builds
- fix to not delete lib objects on `testclean`
Instead of overriding `main()`. To align with the other tests.
Overriding `main()` can cause duplicate symbols without using a lib for
the `runner` code.
Follow-up to 40ac6b230aCloses#934
This set of changes provides a mechanism to runtime-configure the
previously #define'd timeout for reading packets from a session. The
intention here is to also extend libcurl to be able to use this
interface so that when fetching from sftp servers which are very slow
to return directory listings, connections do not time-out so much.
* Add new field to session to hold configurable read timeout
* Updated `_libssh2_packet_require()`, `_libssh2_packet_requirev()`,
and `sftp_packet_requirev()` to use new field in session structure
* Updated docs for API functions to set/get read timeout field in
session structure
* Updated `libssh2.h` to declare the get/set read timeout functions
Co-authored-by: Jon Axtell <jon.axtell@codethink.co.uk>
Credit: Daniel Silverstone
Move the GNU Make file formerly known as `win32/GNUmakefile` to the
root directory from `win32`. It now supports any platform with a
GCC-like toolchain, while also keeping support for win32.
For non-Windows platforms it's necessary to provide a hand-crafted
`libssh2_config.h` header for now.
Usage: `make -f Makefile.mk`
- in `win32/libssh2_config.h` replace `_CRT_SECURE_NO_DEPRECATE` with
`_CRT_SECURE_NO_WARNINGS`, to use the official macro for this, like
in CMake.
Also, it's now safe to move it back under `_MSC_VER`.
Suppressing:
`warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead.`
`warning C4996: 'getenv': This function or variable may be unsafe. Consider using _dupenv_s instead.`
- move `_CRT_NONSTDC_NO_DEPRECATE` to `example` and `tests`.
Not needed for `src`.
Suppressing:
`warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strdup.`
`warning C4996: 'write': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _write.`
- move `_WINSOCK_DEPRECATED_NO_WARNINGS` from source files to
CMake files, in `example` and `tests`. Also limit this to MSVC.
Suppressing:
`warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead`
TODO: try fixing these instead of suppressing.
Closes#929
- add `BLD_DIR` to customize the output directory (where libs, .zip,
obj subdir will go). This directory must exist.
It remains `./win32` for Windows builds.
- add `CONFIG_H_DIR` option to customize `libssh2_config.h` location.
It remains `./win32` for Windows builds.
- include `.def` in distro zip for Windows.
- ready to move to the root directory.
Replace incorrect `MD5_DIGEST_LENGTH` with `SHA_DIGEST_LENGTH` for these
hostkey algos:
- `ssh-rsa` and `ssh-dss`
Ref: 7a5ffc8cee (2004-12-07 Initial)
- `ssh-rsa-cert-v01@openssh.com`
Ref: 4b21e49d9d (2022-07-28)
Ref: #710
Also delete local fall-back definition of `MD5_DIGEST_LENGTH` (added
in 9af7eb48dc). Macro is no longer used.
Reported-by: Markus-Schmidt on github
Fixes#919Closes#926
Also:
- fix newly surfaced (bogus) warnings in examples with MSVS 2010:
```
..\..\example\direct_tcpip.c(262): warning C4127: conditional expression is constant
```
Happens for every `FD_SET()` macro reference.
Ref: https://ci.appveyor.com/project/libssh2org/libssh2/builds/46677835/job/ni4hs97bh18c14ap
- silence MSVS 2010 predefined Windows macro warnings:
```
..\..\src\wincng.c(867): warning C4306: 'type cast' : conversion from 'int' to 'LPCSTR' of greater size
..\..\src\wincng.c(897): warning C4306: 'type cast' : conversion from 'int' to 'LPCSTR' of greater size
..\..\src\wincng.c(1132): warning C4306: 'type cast' : conversion from 'int' to 'LPCSTR' of greater size
```
Ref: https://ci.appveyor.com/project/libssh2org/libssh2/builds/46678071/job/08t5ktvkcgdghp7rCloses#925
Rename `RANDOM_PADDING` macro used internally to enable some code.
Committed in the initial version of `transport.c` in
9d55db6501 (2007-02-02). libssh2 code
never defined it.
The name happens to collide with a Windows macro in `wincrypt.h`.
`transport.c` doesn't include this header, but it includes `winsock2.h`,
and it turns out it can also define this macro in some cases, e.g.
when `WIN32_LEAN_AND_MEAN` is not set.
To be on the safe side, prefix the name with `LIBSSH2_` to avoid
enabling it by accident.
Q: Maybe it'd be best to delete it with the guarded code?
Reported-by: Markus-Schmidt on github
Fixes#921Closes#924
The `DLL_EXPORT` macro is automatically set by autotools when building
the libssh2 DLL. Certain toolchains might require this to correctly
export symbols, so make sure to respect it in `libssh2.h` to enable
`declspec(dllexport)`.
With this patch we have a manual macro for that (`LIBSSH2_EXPORT`),
this autotools one, the CMake one, and `_WINDLL` (added in
c355d31ff9), possibly defined by Visual
Studio.
Closes#917
libssh2 uses `wincrypt.h` aka the `crypt32` Windows system library
for the function `CryptDecodeObjectEx()` [1]. This function has been
available for Win32 (and UWP/WinRT apps) for a long while. Even old
MinGW supports it, and also Watcom 1.9, of the rare/old compilers
I checked.
CMake had it permanently enabled, while it also did an extra check
for the header to add the lib to the lib list. Autotools did the
detection proper. Other builds had it permanently enabled.
It seems safe to assume this function/header/lib is available in all
environments we support.
In this patch we simplify by deleting these detections and feature
flags from all build tools.
Keep the feature flag internal to `wincng.h`, and for extra safety add
the new macro `LIBSSH2_WINCNG_DISABLE_WINCRYPT` do disable it via
custom `CPPFLAGS`.
WinCNG's other requirement is `bcrypt`. That also has been universally
available for a long time. Here the only known outlier is old/legacy
MinGW, which is missing support.
[1] https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptdecodeobjectexCloses#916
Instead of maintaining a second copy of `libssh2.pc.in` in `src` just
for CMake, teach CMake to use the existing template in the root dir,
that we already use with autotools.
Closes#914
`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.