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

5997 Commits

Author SHA1 Message Date
Jakub Jelen
a8b7e17aa0 kex: Avoid trailing comma in cipher list
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-04-09 12:46:08 +02:00
Jakub Jelen
1bdc78d69f Reformat rest of torture_options
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-04-09 12:46:08 +02:00
Adam Kerrison
74a8d271ad Add support for more options in ssh_options_get()
Signed-off-by: Adam Kerrison <adam_kerrison@bmc.com>
Squashed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-04-09 12:46:05 +02:00
Noah Miller
d2a8a464a7 Fix mbedTLS issues
Signed-off-by: Noah Miller <mike@stealthwing.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-04-09 12:36:13 +02:00
Ajit Singh
4a83c50ce9 sftp.c: call ssh_set_error
Since sftp_init() returns 0 on success, < 0 on error with ssh error set. This
change sets the appropriate ssh error when the SSH_FXP_VERSION packet cannot be
unpacked and sftp_init() return with -1.

Signed-off-by: Ajit Singh <ajeetsinghchahar2@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-04-09 12:35:37 +02:00
Noah Miller
996037e77b cmake: fix missing includes in ConfigureChecks
Signed-off-by: Noah Miller <mike@stealthwing.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-04-02 09:37:02 +02:00
Norbert Pocs
78378291b1 ecdh_crypto.c: free secret when error happens
Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-03-24 17:27:16 +01:00
Jakub Jelen
60085debb1 ci: Remove duplicate check for sign-off trailers
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-23 12:34:47 +01:00
Jakub Jelen
07cb0be12f Do not close socket passed through options on error conditions
Fixes: #244

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-03-23 11:48:50 +01:00
Jakub Jelen
9d5c31205c Reformat ssh_silent_disconnect
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-03-23 11:48:50 +01:00
Jakub Jelen
49c61bb263 ci: Add shellcheck
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-22 12:35:07 +01:00
Jakub Jelen
b6fd4912d7 Fix shellcheck issues
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-22 12:35:07 +01:00
Jakub Jelen
45334b6736 clang-format: Note about line break after short type
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-22 12:35:07 +01:00
Jakub Jelen
2fc77d90cf Run all reviews in single job
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-22 12:35:07 +01:00
Jakub Jelen
c5a0d0fc09 ci: Move codespell to the review stage in file
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-22 12:35:07 +01:00
Andreas Schneider
46e6804c89 gitlab-ci: Check merge requests for Signed-off-by trailers
Based on Andreas work in

https://gitlab.com/libssh/libssh-mirror/-/merge_requests/104/

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-22 12:35:03 +01:00
Jakub Jelen
ed68fdaa61 Run CI in merge requests and in branches
This should avoid duplicate pipelines as suggested in (gitlab-org/gitlab!230928)

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-22 12:35:00 +01:00
Jakub Jelen
9cee4fa054 Add review stage to the CI checking formatting
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-21 11:15:14 +01:00
Gauravsingh Sisodia
a9d1cfa9e2 feat: Handle hostkeys like OpenSSH
fix: memory leak
fix: add defaults after parsing
fix: set defaults in ssh_bind_listen
tests: add test for checking default hostkey paths
remove: null check for hostkey paths, can't happen since we set defaults now
examples: ssh_server remove "no default keys", default hostkeys set in ssh_bind_listen

Signed-off-by: Gauravsingh Sisodia <xaerru@gmail.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-03-19 10:26:44 +01:00
Gauravsingh Sisodia
b9d4e11456 reformat: bind.c
reformat: remove unneeded free

Signed-off-by: Gauravsingh Sisodia <xaerru@gmail.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-03-19 10:26:11 +01:00
Jakub Jelen
fcd63abb6a tests: Avoid hardcoding 64b arch path to pkcs11-spy
Find the path to the library using cmake and enable this sort of logging only
with TORTURE_PKCS11 environment variable.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-03-19 09:58:16 +01:00
Jakub Jelen
81f9b00005 cmake: Use -fprofile-update=atomic to avoid coverage files corruption from threads
The gcc should be able to select this automatically based on the presence of
-pthread is present on the commandline, but given that we link the tests static,
we do not have this?

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-08 13:34:23 +01:00
Jakub Jelen
64ef3fefb4 Rework the coverage build
This reworks it to avoid a need to special build type and adding the flags only
to the targets that need it (skipping testing wrappers which break with them).

It also updates the CodeCoverage module from the following URL:

https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-08 13:34:23 +01:00
Jakub Jelen
6a03f6cefe tests: Introduce chown wrapper to avoid OpenSSH touching PTY ownership
The OpenSSH as part of the new test torture_request_pty_modes attempts to chown
the pty to the faked user, which is obviously not permitted when the test does
not run as a root. But since all the permissions for SSH are faked, just
ignoring these requests should be safe enough giving expected results.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-08 11:10:16 +01:00
Jakub Jelen
9ee8d8cd20 tests: Print content of channels to investigate random failures
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-08 11:10:16 +01:00
Jakub Jelen
3b7095acbb Conditionalize TTY options that are not available on freebsd
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-03-08 11:10:16 +01:00
Abdelrahman Yossef
b2fcef3fad updated documentation of sftp_tell64
Signed-off-by: Abdelrahman Youssef <abdelrahmanyossef12@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-03-06 14:01:36 +01:00
Daniel Evers
a7d212cd7d Issue #157: Added author
Signed-off-by: Daniel Evers (daniel.evers@utimaco.com)
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-03-06 14:01:36 +01:00
Daniel Evers
6e5eb4ed2d Issue #157: Adapted documentation to the latest code changes.
Signed-off-by: Daniel Evers (daniel.evers@utimaco.com)
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-03-06 14:01:36 +01:00
Daniel Evers
cd6e84a6c3 Issue #157: Use the current TTY's settings by default.
When opening a PTY on the server, try to use the current TTY's settings
(i.e. based on STDIN). If that fails or STDIN isn't a TTY, use default
modes that avoid any character translation.

Don't rely on stdin to be a TTY (breaks CI). Instead, open a PTY and
temporarily use that as "fake" stdin.

Signed-off-by: Daniel Evers (daniel.evers@utimaco.com)
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-03-06 14:01:36 +01:00
Daniel Evers
b5daac6772 Issue #157: Added documentation
Signed-off-by: Daniel Evers (daniel.evers@utimaco.com)
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-03-06 14:01:36 +01:00
Daniel Evers
1291ceb17d Fix #157: Allow to set terminal modes for PTYs
Added the new function `ssh_channel_request_pty_size_modes` which allows
to pass additional encoded SSH terminal modes (see opcodes in RFC 4245).

Signed-off-by: Daniel Evers (daniel.evers@utimaco.com)
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-03-06 14:01:36 +01:00
Gregor Jasny
6ad455a8ac cmake: use imported targets for OpenSSL and zlib
Imported targets are highly preferred over the individual variables
for includes and libs because they will be used in a coherent way
and any spelling mistakes or unavailability won't go unnoticed.

Also it will prevent bugs like conan-io/conan-center-index#16900
or using mismatching header/libs combinations.

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-02-22 19:50:43 +01:00
Gregor Jasny
486d2289fa cmake: remove fallback for crypto lib lookup
because if a fallback happens, the WITH_(GCRYPT|MBEDTLS) variables
do not match the selection, anymore. Also a silent fallback is pretty
bad if it is unnoticed.

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2024-02-22 19:50:03 +01:00
Andreas Schneider
ff111a4a8b cmake: Use Python find_package
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-02-22 19:40:29 +01:00
renmingshuai
fbfc9b3595 Fix a syntax error
Signed-off-by: renmingshuai <renmingshuai@huawei.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-02-22 19:38:06 +01:00
Jakub Jelen
3e2bbbc96a sftp: Fix copy&paste error in the doxygen comment
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-02-13 18:19:33 +01:00
Jakub Jelen
4172752b4b sftp: Handle read/write limits in the old low-level SFTP API
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2024-02-13 18:19:31 +01:00
Andreas Schneider
172f6bfb47 tests:pkd: Add missing includes for cmocka
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-02-13 18:17:56 +01:00
Clemens Lang
2c918aad67 tests: Use /tmp for tmpdirs that contain sockets
Socket paths have a length limit, and depending on the working directory of the
source code, these tests occasionally fail if the path is too long. Avoid this
by using a template string that is absolute and in /tmp, which should avoid the
socket path length issues.

This fixes building libssh with pkcs11 provider support in 'fedpkg mockbuild'.

Signed-off-by: Clemens Lang <cllang@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-26 14:49:01 +01:00
Gauravsingh Sisodia
1176a71d61 examples: server check all keys in authorized_keys instead of one
Fix read file with fgets and remove memory leaks

Remove use of ssh_pki_import_pubkey_file in ssh server and update max line size

Fix example server line no. and formatting

Fix check for leading whitespace in line

Reformat to avoid nesting

Remove setting sdata->authenticated to 0, the default is 0

Better error messages and handle case for fgets failing

Increment lineno at start

Signed-off-by: Gauravsingh Sisodia <xaerru@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-22 09:50:06 +01:00
Norbert Pocs
c0354c4689 misc.c: Initialize pointers and free it
Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15 10:49:59 +01:00
Norbert Pocs
2be44b4c5a torture: Add cases for username checks
Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15 10:49:58 +01:00
Norbert Pocs
d97a5930c9 Check any input username for validity
Check possible inputs of username for malicious code.

Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15 10:49:58 +01:00
Norbert Pocs
ebcd6eee3c misc: Add function to check username syntax
Malicious code can be injected using the username with metacharacters,
therefore the username must be validated before using it with any %u.

Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15 10:49:57 +01:00
Eshan Kelkar
d7f7c952f2 sftp_aio.dox: Change the sftp aio tutorial to incorporate capping
A section has been added to explain the capping applied by the
sftp aio API. Also the example codes have been changed such that
they expect sftp_aio_begin_*() functions to return an ssize_t
indicating the number of bytes it requested the server to
read/write.

Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15 10:47:59 +01:00
Eshan Kelkar
9857a5ef59 bench_sftp.c: Change sftp aio upload benchmark
Following changes have been made:

1. The benchmark now expects sftp_aio_begin_write() to
return a ssize_t indicating an error (or) the number of
bytes for which it sent a write request.

2. If the user sets the chunk size > max limit for writing
via CLI, the benchmark does not use the set chunk size and
instead uses the max limit for writing as the chunk size

3. fprintf calls have been added to print the reason for
failure if the benchmark fails.

Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15 10:47:59 +01:00
Eshan Kelkar
47d8bcf9a5 bench_sftp.c: Change sftp aio download benchmark
Following changes have been made :

1. The benchmark now expects sftp_aio_begin_read() to
return an ssize_t indicating an error (or) the number of
bytes for which it sent a read request.

2. If the user sets a chunk size > max limit for the reading
via CLI, the benchmark does not use the set chunk size and
instead uses the max limit for reading as the chunk size for
download.

3. fprintf calls have been introduced to print the reason
for the failure if the benchmark fails.

Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15 10:47:59 +01:00
Eshan Kelkar
d73a0acef7 torture_sftp_aio.c: Change the tests according to aio api changes
The tests have been changed such that the return value of
sftp_aio_begin_*() functions is expected to be a ssize_t
which indicates the number of bytes for which the function
sent a read/write request or error.

Tests for trying to read/write bytes more than the max limit
enforced by the API have also been added.

The negative tests for reading and writing have also been
seperated for the sake of clarity.

Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15 10:47:59 +01:00
Eshan Kelkar
188a9cf68f sftp_aio.c, sftp.h: Add capping to sftp aio write API
Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2024-01-15 10:47:59 +01:00