1
0
mirror of https://github.com/libssh2/libssh2.git synced 2026-01-27 00:18:12 +03:00
Commit Graph

3010 Commits

Author SHA1 Message Date
Viktor Szakats
e590450dcc man: fixups
- 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
2023-04-11 00:38:35 +00:00
Viktor Szakats
504026262d include: indentation fixes 2023-04-11 02:33:45 +02:00
Viktor Szakats
0924632fa0 tidy-up: misc & minor cmake MSVS fix
- `libssh2.rc`: document language/codepage codes.

  Ref: https://learn.microsoft.com/windows/win32/intl/code-page-identifiers

- convert to Markdown: `docs/BINDINGS`, `docs/HACKING`

  Blind update for `vms/libssh2_make_help.dcl`. Please double-check.

- cmake: fix to recognize dash-style warning options (`-Wn`) with MSVC.

- `NMakefile`: sync `rd` command with `Makefile.mk`.

- delete a CVS header.

- cmake: simplify a `LIBSSH2_HAVE_ZLIB` macro.

- few other nits and whitespace mods.

Closes #943
2023-04-10 23:03:43 +00:00
Viktor Szakats
fe706697ed Support for direct-streamlocal@openssh.com UNIX socket connection (#945)
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 #216
Closes #632
Closes #945
2023-04-10 14:23:17 +02: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
38015f4e46 crypto: add LIBSSH2_NO_DSA to disable DSA support
See also: be31457f30

Closes #942
2023-04-10 09:21:30 +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
Zenju
e1e78e3670 sftp: always clear protocol error (#787) 2023-04-09 12:15:44 +02:00
Viktor Szakats
8017592163 cmake: add HIDE_SYMBOLS option & do symbol hiding on *nix
- 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
2023-04-09 10:13:43 +00:00
Viktor Szakats
c1ed4e99df build: make windows.h even leaner
Disable GDI and NLS features in `windows.h`. libssh2 doesn't use these.

Closes #940
2023-04-09 10:13:09 +00:00
Viktor Szakats
ff3c774e03 blowfish: build improvements
- 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
2023-04-08 22:26:47 +00:00
Viktor Szakats
279dd47247 libssh2.rc: fix debug flag, other cleanups
- 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
2023-04-08 22:26:25 +00:00
Viktor Szakats
fb9f888308 tidy-up: example, tests
- 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
2023-04-08 22:26:10 +00:00
Viktor Szakats
7e4855926e tests/mansyntax.sh: avoid if ! for portability
Ref: https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Limitations-of-Builtins.html#Limitations-of-Builtins

Fixes #704
Closes #935
2023-04-08 22:25:46 +00:00
Viktor Szakats
dfb086bfe2 tidy-up: indentation in guarded #includes [ci skip] 2023-04-08 10:56:14 +00:00
Viktor Szakats
bc0cd58e87 Makefile.mk: drop PROOT variable [ci skip] 2023-04-07 23:51:07 +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
Viktor Szakats
8774f4973f Makefile.mk: build tests and other improvements [ci skip]
- 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`
2023-04-07 23:11:59 +00:00
Viktor Szakats
72cd241239 test_warmup: re-implement as test()
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 40ac6b230a

Closes #934
2023-04-07 15:43:26 +00:00
Viktor Szakats
ed72926640 NMakefile: drop /DEBUG linker option in release mode [ci skip] 2023-04-07 14:17:38 +00:00
Viktor Szakats
17a419ba62 NMakefile: simplify [ci skip] 2023-04-07 14:16:26 +00:00
Viktor Szakats
dfbd28308e Makefile.mk: merge two rules [ci skip] 2023-04-07 14:15:11 +00:00
Viktor Szakats
2082db93b2 TODO: update item about compiler warnings [ci skip]
Follow-up to 08354e0abb
Follow-up to 2934790572
Follow-up to 5a96f494ee
Follow-up to 463449fb9e
Follow-up to 02f2700a61
2023-04-06 10:54:38 +00:00
ihsinme
4048d0ba26 example/x11: Add null-termination (#749) 2023-04-05 16:23:54 +02:00
Viktor Szakats
85582df111 crypto: fix LIBSSH2_NO_MD5 compiler warnings
Follow-up to be31457f30

Closes #933
2023-04-05 13:59:49 +00:00
Viktor Szakats
bdad217440 build: add new man pages
Follow-up to c20c81ab10
2023-04-05 13:58:36 +00:00
Daniel Silverstone
c20c81ab10 Configurable session read timeout (#892)
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
2023-04-05 15:53:53 +02:00
Viktor Szakats
a7d60c62ab cmake: whitespace fixes [ci skip] 2023-04-04 17:54:17 +00:00
Viktor Szakats
d709e3f9d0 libssh2.h: bump LIBSSH2_COPYRIGHT year [ci skip] 2023-04-04 17:52:10 +00:00
Viktor Szakats
901bf00d02 Makefile.mk: move portable GNU Make file to the root
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`
2023-04-04 02:57:29 +02:00
Viktor Szakats
d58b713687 src: include limits.h for *_MAX macros
Follow-up to 5a96f494ee

Reported-by: OldWorldOrdr on github
Fixes #928
Closes #930
2023-04-04 00:03:52 +00:00
Viktor Szakats
202a4f3f7a build: MSVS warning suppression option tidy-up
- 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
2023-04-04 00:03:33 +00:00
Viktor Szakats
8c24a3f599 win32/GNUmakefile: make it movable [ci skip]
- 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.
2023-04-04 00:01:33 +00:00
Viktor Szakats
1cd1aaefa6 win32/GNUmakefile: drop an unnecessary variable [ci skip] 2023-04-03 15:16:51 +00:00
Viktor Szakats
e387311bd6 windows: re-add libssh2.rc
Lost while moving it from the win32 directory

Follow-up to 194cfc0f84
2023-04-03 12:27:05 +00:00
Viktor Szakats
be31457f30 crypto: add LIBSSH2_NO_MD5 to disable MD5 support
Closes #927
2023-04-03 12:10:47 +00:00
Viktor Szakats
ad6aae302a hostkey: fix hash_len field constants
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 #919
Closes #926
2023-04-03 12:09:48 +00:00
Viktor Szakats
2e3e0be816 ci: add MSVS 2008/2010 build tests and fix warnings
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/08t5ktvkcgdghp7r

Closes #925
2023-04-03 12:08:50 +00:00
Viktor Szakats
d1b36efe41 transport: rename local RANDOM_PADDING macro
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 #921
Closes #924
2023-04-03 12:07:49 +00:00
Viktor Szakats
194cfc0f84 windows: move libssh2.rc to the src directory
Closes #918
2023-04-03 12:07: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
cffcae4e0d win32/GNUmakefile: update help & exit without crypto backend [ci skip]
Follow-up to: 5bcd25c4c9
Follow-up to: 68fd02fba0
2023-04-02 10:00:43 +00:00
Viktor Szakats
fb1195cf88 build: respect autotools DLL_EXPORT in libssh2.h
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
2023-04-02 03:24:39 +00:00
Viktor Szakats
185292a06b build: make HAVE_LIBCRYPT32 local to wincng.c
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-cryptdecodeobjectex

Closes #916
2023-04-02 03:24:16 +00:00
Viktor Szakats
a07ba9ee71 autotools: delete src/libssh2.pc.in reference [ci skip]
Follow-up to 06f2819219
2023-04-02 00:28:38 +00:00
Viktor Szakats
1b59e90705 tidy-up: null-mac/cipher documentation
Move documentation for these deleted build-level options from
autotools/cmake docs to the source code itself.

Follow-up to 50c9bf868e

Closes #915
2023-04-01 23:41:57 +00:00
Viktor Szakats
06f2819219 cmake: re-use existing libssh2.pc template
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
2023-04-01 23:41:42 +00: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
5f790d24ef NMakefile: drop redundant variable and assignments [ci skip] 2023-04-01 19:45:53 +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