aboutsummaryrefslogtreecommitdiff
path: root/src/socket.c
AgeCommit message (Collapse)AuthorFilesLines
2023-07-11priv.h : Add compatibility code for WindowsEshan Kelkar1-11/+0
Compatibility code for mapping open, read, write, close and unlink to _open, _read, _write, _close and _unlink respectively on Windows was repeated in a lot of .c files. This commit adds that compatibility code to include/libssh/priv.h and removes it from the .c files (while ensuring that those .c files include priv.h) so that the compatibility code stays in one place, can be maintained easily and can be added easily to another source file by including priv.h in that file. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-06-01socket.c: Remove bug from documentation as it was solvedNorbert Pocs1-2/+0
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-04-25Add tests for run ssh_execute_commandRan Park1-2/+2
Signed-off-by: Ran Park <bagayonghuming@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-04-25solve incorrect parsing of the ProxyCommand configuration optionRan Park1-1/+6
Signed-off-by: Ran Park <bagayonghuming@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-03-15doc: Fix doxygen errors when QUIET=yes EXTRACT_ALL=yesNorbert Pocs1-2/+0
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-03-09socket: ReformatJakub Jelen1-10/+17
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-02-01documentation: Fix Missing param doxygen warningsNorbert Pocs1-1/+1
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-02bind: Set socket connected after accepting connectionJakub Jelen1-8/+17
Also factor out the operation to the single place. Original patch drafted by Zekun Ni in the following issue: https://gitlab.com/libssh/libssh-mirror/-/issues/155 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-11-02Reformat and initialize pointersJakub Jelen1-3/+9
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-10-12change the format specifier of uint32_t from PRId32 to PRIu32Xiang Xiao1-1/+1
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-10-12fix printf format warningXiang Xiao1-1/+1
uint32_t should be formated by PRI?32 Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Change-Id: I811cfd764010f9e8bb599b370155ac065ee1905c
2022-10-07SSH_LOG_DEBUG: Recategorize loglevelsNorbert Pocs1-3/+3
Loglevel INFO is the default openssh configuration setting which does not print redundant information. On a system using openssh with loglevels set by the terms of openssh will cause unwanted log lines in the output. recategorized based on - SSH_LOG_DEBUG are informational debug logs (no error) Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-10-07SSH_LOG_TRACE: Recategorize loglevelsNorbert Pocs1-3/+3
Do not print out logs when no fatal error happens. This approach is similiar to openssh, when Error/Fatal does not print recoverable error logs. recategorized based on - SSH_LOG_TRACE are debug logs when error happens Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-08-30socket: Remove needless typedefJakub Jelen1-1/+1
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-08-29socket: Add a comment about shellsAndreas Schneider1-1/+4
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-08-29socket: Add error message if execv failsAndreas Schneider1-1/+8
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04Rewrite strerror to ssh_strerrorNorbert Pocs1-6/+11
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-22add support for identityagent ssh_config optionWez Furlong1-1/+2
This commit adds an `agent_socket` field to the session options and connects the config parser to that option. `SSH_OPTIONS_IDENTITY_AGENT` is added to allow applications to set this option for themselves. agent.c is updated to take the `agent_socket` value in preference to the `SSH_AUTH_SOCK` environment variable. Signed-off-by: Wez Furlong <wez@fb.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-22Enable ssh agent authentication on WindowsWez Furlong1-4/+13
Windows has supported unix domain sockets for a couple of years now; see this article for more information about that: <https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/> This commit allows libssh to consider using agent authentication on Windows systems. It is mostly removing `#ifndef _WIN32` that prevented the unix domain socket code from being compiled in, and adjusting the use of `read(2)` and `write(2)` to `recv(2)` and `send(2)`, as the former functions are not compatible with sockets on Windows systems. For mingw systems, afunix.h isn't available so we use the technique as was used to resolve building with mingw as used by the curl project in: https://github.com/curl/curl/pull/5170 Signed-off-by: Wez Furlong <wez@fb.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-15Fix type mismatch warningsNorbert Pocs1-1/+1
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-05-02Fix multiple spelling and grammar mistakesJunda Ai1-3/+3
Signed-off-by: Junda Ai <aijunda29@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-04-19trivial fix: Fixes some spelling errorsDhanuka Warusadura1-2/+2
Signed-off-by: Dhanuka Warusadura <csx@tuta.io> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-05-31socket: Read the data directly into in_bufferXiang Xiao1-8/+12
to avoid allocate 4KB buffer from stack Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Change-Id: Id144ff764ee1ae98f87aee36793a9f0e4fce21b7
2019-12-23socket: Use the users shell for running proxy commandJakub Jelen1-2/+14
Fixes T200 and tests on ubuntu, which is using dash Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23socket: Fix the error messageJakub Jelen1-1/+1
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23socket: Kill the proxy command if it still runs on disconnectJakub Jelen1-1/+33
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-09socket: Use SSH_BUFFER_FREE()Andreas Schneider1-3/+3
Fixes T183 Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09socket: Pass port as uint16_t to ssh_socket_connect()Andreas Schneider1-3/+4
Fixes T188 Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-19socket: Do not process stderr of proxy commands (Fixes T130)Jakub Jelen1-2/+9
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-19socket: Reformat the rest of the fileJakub Jelen1-241/+274
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-05-22socket: Use calloc in ssh_socket_new()Anderson Toshiyuki Sasaki1-1/+1
This makes sure the content will be zero after successful allocation. Resolves T134 Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-21socket: Use more portable PF_UNIX instead of PF_LOCALTilo Eckert1-1/+1
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-01-09socket: Set socket error to get better error messagesAndreas Schneider1-1/+4
We do not want an error for ssh_socket_close() here. Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-21socket: Add missing bracesTilo Eckert1-1/+1
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-20socket: Remove redundant codeTilo Eckert1-3/+0
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-20socket: Fix potential buffer overrunTilo Eckert1-10/+2
If nread is < 0 and no exception callback is set, the following code block would cause a buffer overrun. Signed-off-by: Tilo Eckert <tilo.eckert@flam.de> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-25socket: Undouble socket fdsSanne Raymaekers1-127/+62
Signed-off-by: Sanne Raymaekers <sraymaek@redhat.com>
2018-09-25socket: Pass MSG_NOSIGNAL to send()Andreas Schneider1-1/+6
This avoid that we get a SIGPIPE. Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25socket: Return ssize_t for ssh_socket_unbuffered_write()Andreas Schneider1-10/+16
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25socket: Reformat ssh_socket_write()Andreas Schneider1-53/+61
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25socket: Reformat ssh_socket_unbuffered_write()Andreas Schneider1-21/+23
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25socket: Return ssize_t for ssh_socket_unbuffered_read()Andreas Schneider1-14/+19
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25socket: Reformat ssh_socket_pollcallback()Andreas Schneider1-36/+61
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25socket: Reformat ssh_socket_unbuffered_read()Andreas Schneider1-16/+18
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28Remove vim modelines from all filesAndreas Schneider1-2/+0
If you want modelines use my vim plugin: https://github.com/cryptomilk/git-modeline.vim git config --add vim.modeline "ts=4 sw=4 et" Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-10-28Fix config.h includesAndreas Schneider1-2/+2
We need stdlib.h and string.h in priv.h for free() and memset(). Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02packet: Improve logging outputAris Adamantiadis1-0/+6
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19buffer: do not use ssh_buffer_get_rest_len()Fabiano Fidêncio1-5/+5
As ssh_buffer_get_len() actually calls ssh_buffer_get_rest_len(), let's just use the first one. This is a preparatory step for removing ssh_buffer_get_rest_len(). Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19buffer: rename ssh_buffer_get_rest() to ssh_buffer_get()Fabiano Fidêncio1-2/+2
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19cleanup: use ssh_ prefix in the buffer (non-static) functionsFabiano Fidêncio1-9/+9
Having "ssh_" prefix in the functions' name will avoid possible clashes when compiling libssh statically. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>