1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-11 03:42:35 +03:00
Commit Graph

6080 Commits

Author SHA1 Message Date
Jakub Jelen
6d34718f89 ci: Update OpenSSL versions in the CI target names
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
31073780d1 ci: Drop fedora/fips combination as it looks broken
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
1eb3df5254 Get rid of the deprecated OpenSSL API
It turns out there is a way to get the uncompressed format from the low-level
API, which is not (yet?) deprecated so this removes all of the TODO's for ECDSA
keys and moves the EC_KEY structure in the high-level EVP_PKEY.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
02fda2ef80 Remove needless ifdefs for Ed25519 support ...
... through bundled code with OpenSSL. These were needed with older OpenSSL
versions before 1.1.1.
After removal in 358ce46551 these were just static
ifdef so this will simplify the code.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
2187c3feae token: Avoid warnings with extraneous parentheses
The FreeBSD builder complains like this:

/home/gitlab-runner/builds/jtxr_hfi/0/jjelen/libssh-mirror/src/token.c:438:15: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
    if ((list == NULL)) {
         ~~~~~^~~~~~~
/home/gitlab-runner/builds/jtxr_hfi/0/jjelen/libssh-mirror/src/token.c:438:15: note: remove extraneous parentheses around the comparison to silence this warning
    if ((list == NULL)) {
        ~     ^      ~
/home/gitlab-runner/builds/jtxr_hfi/0/jjelen/libssh-mirror/src/token.c:438:15: note: use '=' to turn this equality comparison into an assignment
    if ((list == NULL)) {
              ^~
              =
1 warning generated.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
b231562858 tests: Use assert_return_code instead of assert_true
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
b2cd025fcb bignum: Reformat long line
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
bb9c3245c4 tests: Avoid needless free and fix formatting
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
dcfc8a2c5d tests: Use assert_string_equal instead of assert_true
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
cc1b021153 kex: Fix typo
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
aeb60fcf28 tests: Refactor the PKCS#11 URI tests
This avoids a lot of long and hard to read constants by replacing them with
dynamic snprintf()s and a bit or reformatting

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
e97cd2d02e tests: Reformat unittests/torture_pki_rsa_uri
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
10296dbc76 tests: Use temporary variable to set test environment
avoids also long lines and code duplication

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
492f5d82b8 Clean up usage of HAVE_ECC and HAVE_ECDH
they might be turned off and on independenty and each of them affects different
part of libssh, authentication and key exchange respectively. But only HAVE_ECC
is defined by the cmake.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
dac62e7439 pki: Initialize pointers and avoid double-free with OSSL 3.0
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
ab24110ae0 Do not build the PKCS#11 when disabled
This prevents building the pkcs11-related functions and printing pkcs11-related
log messages when the libssh is built without PKCS#11 support.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25 16:53:19 +01:00
Jakub Jelen
96ee1c62dd Enable code coverage also for client testing
This adds the priv_wrapper options to skip the OpenSSH server sandbox, which
prevented in the past writing any debug information or coverage files causing
SIGSYS/crashes.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-17 14:33:50 +01:00
Jakub Jelen
c52f40bcb2 tests: Reproducer for delayed compression rekey
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-09 22:40:10 +01:00
Jakub Jelen
98b81ebcad wrapper: Correctly handle rekey with delayed compression
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-09 22:40:10 +01:00
Jakub Jelen
342b69246c wrapper: Reformat compression algorithms handling
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-09 22:40:10 +01:00
Jakub Jelen
c784bf345c Reformat gzip.c
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-09 22:40:10 +01:00
Jakub Jelen
6b4c2a21bc examples: Support more options in the sftp client
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-09 22:40:10 +01:00
Jakub Jelen
834603c96b packet: Log at least names of unknown extensions
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-09 22:40:10 +01:00
Jakub Jelen
a54d2377d6 examples: Change variable names and logs to english
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-09 22:40:10 +01:00
Jakub Jelen
8f237bde15 cmake: Check for Argp also on Linux to fix alpine build
This adjusts also usage of ARGP_LIBRARY to use ARGP_LIBRARIES which is defined
by the FindArgp module, unlike the former one in case it is provided by libc
directly.

Fixes: #167

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-09 22:40:10 +01:00
Jakub Jelen
d54d45871a cmake: Document the consequences of enabling benchmarks
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-09 22:40:10 +01:00
Jakub Jelen
a5631280a9 include: Document the need to free the returned buffer
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-09 22:40:10 +01:00
Jakub Jelen
8c1b159a3a examples: Avoid memory leak from sftp
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-09 22:40:10 +01:00
Norbert Pocs
96ad1b380d Add support for sk-keys through configuration
To be able to enable sk-ecdsa, sk-edd25519 key usage from the config file
the algorithms are needed to be listed in the algorithm lists.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-01-09 17:02:30 +01:00
Andreas Schneider
edcce095e0 Happy new year 2023!
And happy anniversary libssh (20 years).

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-01-09 09:06:38 +01:00
Tom Deseyn
f297dc6ab8 Add callbacks for channel open response, and channel request response.
Signed-off-by: Tom Deseyn <tom.deseyn@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-01-02 16:29:55 +01:00
Norbert Pocs
54c1703cb2 Move old DSA and RSA structs into EVP_PKEY
For code simplification and less ifdefs removing DSA and RSA
structures of the old openssl api and using the new EVP_PKEY
api to store the legacy keys.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-12-20 10:07:27 +01:00
Andreas Schneider
9a3e218b6f token: Fix possible resource leak
CID 1501160
CID 1501161

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-30 13:09:22 +01:00
Norbert Pocs
df48ddd895 torture_options.c: Add test for ssh_options_apply
Test that ssh_options_apply can be called multiple times without expanding
escape characters more than once. If the options are updated after calling
ssh_options_apply keep the last options.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-29 14:58:07 +01:00
Norbert Pocs
c0c063f94c torture_options.c: Add identity test for ssh_options_copy
Test if the ssh_options_apply is called on session before ssh_options_copy,
then `opts.identity` ssh_list will be copied

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-29 14:58:06 +01:00
Norbert Pocs
1bd499febb Add flags for escape expand operation
Calling `ssh_options_apply` more times can result in an unwanted behaviour of
expanding the escape characters more times. Adding flags to check if the
expansion was already done on the current string variables.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-29 14:58:05 +01:00
Norbert Pocs
87d694d5ad tests: Use opts.identites_non_exp not opts.identities
The configuration of identities are first saved to `opts.identities_non_exp`,
then moved to `opts.identities` after calling ssh_options_apply and expanding
the identity strings. These tests are testing against the proper configuration

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-29 14:58:04 +01:00
Norbert Pocs
1ff893c914 Add a placehohlder for non-expanded identities
Expanding a string twice could lead to unwanted behaviour.
This solution creates a ssh_list (`opts.identites_non_exp`) to store the strings
before expansion and by using ssh_apply it moves the string to the
`opts.identities`. This way the expanded strings are separated.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-29 14:58:03 +01:00
Norbert Pocs
435f1549f1 misc.c: Fix typo in docstring
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-29 14:58:00 +01:00
Norbert Pocs
4cd58350a8 Fix memory leaks of bignums when openssl >= 3.0
The openssl 3.0 support has introduced some memory leaks at key build as
OSSL_PARAM_BLD_push_BN duplicates the bignum and does not save the pointer
itself.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-29 14:16:01 +01:00
Pavel Filipenský
7f742680c2 replace chroot() from chroot_wrapper internal library with chroot() from priv_wrapper package
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-11-29 14:12:23 +01:00
Andreas Schneider
c8373e652c tests: Fix test with ssh as proxy command
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-25 15:34:02 +01:00
Andreas Schneider
da357b1cb4 Add missing includes for fprintf()
src/init.c:118:9: warning: incompatible implicit declaration of built-in
function 'fprintf' [enabled by default]
         fprintf(stderr, "Error in auto_init()\n");
         ^

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Norbert Pocs <npocs@redhat.com>
2022-11-23 15:29:29 +01:00
Andreas Schneider
9941e89f30 dh: Add missing include for fprintf()
src/dh.c:824:5: warning: incompatible implicit declaration of built-in
function 'fprintf' [enabled by default]
     fprintf(stderr, "%s\n", fingerprint);
     ^

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-23 10:01:49 +01:00
Jon Simons
0fa215e2ac tests/pkd: adjust usage of argv strings
Adjust some subtle usage of argv string handling in the pkd
test options: rather than conditionally overwrite the two
mkdtemp strings with a newly-allocated buffer to be later
freed, keep the original const argv pointer around in its
own dedicated field.

See also these changes in the same area that were due to the
previous arrangement, which was a bit too subtle:
 - 61ce3310b864802a101cb01ff103f0bc2da936e6
 - e1a8b359c1

Addresses:
 - https://gitlab.com/libssh/libssh-mirror/-/merge_requests/320#note_1173911211

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-22 10:20:59 +01:00
Jon Simons
44f60d878a tests/pkd/pkd_hello.c: change fprintf indentation
Although previously consistent with itself, change the fprintf
indentation to bring second lines "to the left" to line up with
the first fprintf argument instead of formatter string.

Addresses:
 - https://gitlab.com/libssh/libssh-mirror/-/merge_requests/320#note_1173911235

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-22 10:20:57 +01:00
Jon Simons
4f6aa53b16 tests/pkd: use -L in CMakeLists.txt
Use the new `-L` flag for the pkd tests so that they use a
unique temporary directory for scratch space while running.

Note the choice of `pkd_scratch_XXXXXX` in contrast to a
path living under `/tmp`: by using a relative path, one can
gather the full set of log artifacts from the GitLab CI jobs
in the event that there is a test failure.  The logs contain
lots of information to help pinpoint what went wrong.

Resolves https://gitlab.com/libssh/libssh-mirror/-/issues/143.

Testing notes:
 - In the GitLab CI jobs I can see the flag being used, and
   can observe that I am able to gather the full set of
   detailed `pkd` logs in the event of a legitimate test
   failure.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-22 10:20:56 +01:00
Jon Simons
b610757e63 tests/pkd: support -L, --temp-dir=<mkdtemp-template>
Teach `pkd` a new flag `-L, --temp-dir=<mkdtemp-template>` to enable
behavior whereby `pkd` creates a new temporary directory and uses it
for a workspace while running.

The original design of `pkd` assumed that it could freely use the
current working directory from wherever it happened to be invoked.
But, this could pose a problem when multiple `pkd` instances are run
in parallel from the same working directory, due to the usage of
various temporary files within that directory.

To avoid the problem of multiple `pkd` instances interfering with
each other, expose a `-L` flag for optionally specifying a `mkdtemp`
template string such that a temporary scratch space is used instead.

Testing notes:
 - I ran handfuls of iterations locally using the new flag
   and observed `pkd` is indeed using scratch space as desired.

Resolves https://gitlab.com/libssh/libssh-mirror/-/issues/143.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-22 10:20:55 +01:00
Jon Simons
aa206cbfe5 tests/pkd: relax pthread_kill assert in pkd_stop
Relax the `pthread_kill` result assertion in `pkd_stop` to tolerate
`ESRCH`, and guard against only `EINVAL` and `ENOTSUP`.

On macOS what can happen is that the `pthread_kill` returns `ESRCH` due
to the accept thread being already terminated.  For that case, the
teardown path should proceed to `pthread_join`.

Testing notes:
 - On my macOS setup I consistently encountered `ESRCH` in this
   codepath, causing pkd tests to fail unnecessarily.  With the
   change, I observe the tests passing.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-22 10:20:54 +01:00
Jon Simons
a2aefeb1ab cmake/Modules/FindArgp.cmake: fix ARGP warning
Fix this warning generated by cmake 3.24.3 on macOS:

    CMake Warning (dev) at /opt/homebrew/Cellar/cmake/3.24.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
      The package name passed to `find_package_handle_standard_args` (ARGP) does
      not match the name of the calling package (Argp).  This can lead to
      problems in calling code that expects `find_package` result variables
      (e.g., `_FOUND`) to follow a certain pattern.
    Call Stack (most recent call first):
      cmake/Modules/FindArgp.cmake:63 (find_package_handle_standard_args)
      CMakeLists.txt:107 (find_package)
    This warning is for project developers.  Use -Wno-dev to suppress it.

Testing notes:
 - With this change, the warning is gone on my macOS setup.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-22 10:20:53 +01:00