Jakub Jelen
6dcfa25c9b
socket: Fix the error message
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit 3a6751f3d2 )
2020-01-23 09:50:04 +01:00
Jakub Jelen
eed8d8e957
socket: Kill the proxy command if it still runs on disconnect
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
(cherry picked from commit dd64980662 )
2020-01-23 09:50:01 +01:00
Andreas Schneider
1c7efb7b46
socket: Use SSH_BUFFER_FREE()
...
Fixes T183
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
Reviewed-by: Jakub Jelen <jjelen@redhat.com >
(cherry picked from commit 476bde4d69 )
2019-12-09 16:38:37 +01:00
Andreas Schneider
4603105e0b
socket: Pass port as uint16_t to ssh_socket_connect()
...
Fixes T188
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
Reviewed-by: Jakub Jelen <jjelen@redhat.com >
(cherry picked from commit d60640cd0e )
2019-12-09 16:38:36 +01:00
Jakub Jelen
c6c7856b51
socket: Do not process stderr of proxy commands (Fixes T130)
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com >
(cherry picked from commit 6c49c41c19 )
2019-06-24 15:41:53 +02:00
Jakub Jelen
ea71af9c22
socket: Reformat the rest of the file
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com >
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com >
(cherry picked from commit bd65568749 )
2019-06-24 15:41:51 +02:00
Anderson Toshiyuki Sasaki
9fb7fb3fac
socket: Use calloc in ssh_socket_new()
...
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-05-22 15:32:41 +02:00
Tilo Eckert
eb032e0dec
socket: Use more portable PF_UNIX instead of PF_LOCAL
...
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
Reviewed-by: Jakub Jelen <jjelen@redhat.com >
2019-02-21 10:51:25 +01:00
Andreas Schneider
0170ed8883
socket: Set socket error to get better error messages
...
We do not want an error for ssh_socket_close() here.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2019-01-09 15:50:24 +01:00
Tilo Eckert
b227c12ad2
socket: Add missing braces
...
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2018-11-21 12:25:50 +01:00
Tilo Eckert
f369d02932
socket: Remove redundant code
...
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2018-11-20 07:59:32 +01:00
Tilo Eckert
0b9e07fbdc
socket: Fix potential buffer overrun
...
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-11-20 07:58:08 +01:00
Sanne Raymaekers
ced05eb6db
socket: Undouble socket fds
...
Signed-off-by: Sanne Raymaekers <sraymaek@redhat.com >
2018-10-25 18:49:29 +02:00
Andreas Schneider
1e5e09563a
socket: Pass MSG_NOSIGNAL to send()
...
This avoid that we get a SIGPIPE.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-25 14:37:25 +02:00
Andreas Schneider
35bf5334b8
socket: Return ssize_t for ssh_socket_unbuffered_write()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-25 14:37:25 +02:00
Andreas Schneider
a7604c7d6e
socket: Reformat ssh_socket_write()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-25 14:37:25 +02:00
Andreas Schneider
c5cadaa982
socket: Reformat ssh_socket_unbuffered_write()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-25 14:37:25 +02:00
Andreas Schneider
caf50270c6
socket: Return ssize_t for ssh_socket_unbuffered_read()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-25 14:37:25 +02:00
Andreas Schneider
b7a29c7ffd
socket: Reformat ssh_socket_pollcallback()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-25 14:37:25 +02:00
Andreas Schneider
491a42d046
socket: Reformat ssh_socket_unbuffered_read()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2018-09-25 14:37:25 +02:00
Andreas Schneider
c563ed636a
Remove vim modelines from all files
...
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 >
2018-06-28 08:41:08 +02:00
Andreas Schneider
f0ddde4826
Fix config.h includes
...
We need stdlib.h and string.h in priv.h for free() and memset().
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2017-10-28 14:31:37 +02:00
Aris Adamantiadis
8e42d3959c
packet: Improve logging output
...
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2016-05-02 17:27:16 +02:00
Fabiano Fidêncio
05fd0acf45
buffer: do not use ssh_buffer_get_rest_len()
...
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-19 11:31:08 +01:00
Fabiano Fidêncio
954341dd1f
buffer: rename ssh_buffer_get_rest() to ssh_buffer_get()
...
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
adc8c20ac1
cleanup: use ssh_ prefix in the buffer (non-static) functions
...
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 >
2016-01-19 11:31:07 +01:00
Andreas Schneider
1cb940c44a
socket: Cleanup ssh_socket_close() code.
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org >
2015-04-10 13:32:09 +02:00
xjoaalm
f32e5f2191
Sending EOF on Socket that received a Broken Pipe makes call to poll to hang
...
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be >
Signed-off-by: Joao Pedro Almeida Pereira <joao.almeida@blue-tc.com >
2015-02-23 22:01:15 +01:00
Alan Dunn
d5aeebe323
socket: Fix style of ssh_socket_pollcallback
...
Signed-off-by: Alan Dunn <amdunn@gmail.com >
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2014-03-27 10:54:55 +01:00
Audrius Butkevicius
a277dd9277
Add session/channel byte/packet counters
...
Signed-off-by: Audrius Butkevicius <audrius.butkevicius@elastichosts.com >
2014-02-12 18:21:16 +01:00
Jon Simons
95782ada1f
socket: fix read of non-connected socket
...
Ensure to check whether the socket at hand is indeed still connected
throughout POLLIN processing in ssh_socket_pollcallback.
Before this change, the POLLIN block in ssh_socket_pollcallback is
predicated against the condition (s->state == SSH_SOCKET_CONNECTED).
Once entered, data from the socket is consumed through the data
callback in this loop:
do {
r = s->callbacks->data(buffer_get_rest(s->in_buffer),
buffer_get_rest_len(s->in_buffer),
s->callbacks->userdata);
buffer_pass_bytes(s->in_buffer,r);
} while (r > 0);
However, it is possible for the socket data callback to change the
state of the socket (closing it, for example). Fix the loop to only
continue so long as the socket remains connected: this also entails
setting the ssh_socket state to SSH_SOCKET_CLOSED upon close.
The bug can be observed before the change by sending a bogus banner
to the server: 'echo -e "A\r\nB\r\n" | nc localhost 22'. Each of
'A' and 'B' will be processed by 'callback_receive_banner', even
though the client socket is closed after rejection of 'A'.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2014-02-02 22:19:46 +01:00
Joseph Southwell
6bbdaceaca
src: Define MAX_BUF_SIZE globally and use it.
...
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2014-02-02 22:19:46 +01:00
Andreas Schneider
cb9786b3ae
src: Rename buffer_add_data() to ssh_buffer_add_data().
2014-01-19 20:55:55 +01:00
Andreas Schneider
9c4144689d
src: Rename buffer_init to ssh_buffer_init().
2014-01-19 20:43:29 +01:00
Andreas Schneider
2fe59071b2
src: Do not use deprecated functions.
2014-01-16 15:27:46 +01:00
Aris Adamantiadis
b514957af7
socket: don't attempt reading a non-connected socket
2014-01-05 21:54:08 +01:00
Aris Adamantiadis
ccdc0f1805
sockets: null pointer check
2013-11-18 14:42:40 +01:00
Andreas Schneider
f240ecf328
socket: Fix connect if we pass in a fd.
...
BUG: https://red.libssh.org/issues/106
Thanks to Saju Panikulam.
2013-11-15 08:47:58 +01:00
Colin Walters
4cc7f4ad03
Add ssh_get_poll_flags()
...
For integration with an external mainloop, we need to know how to
replicate libssh's internal poll() calls. We originally through
ssh_get_status() was that API, but it's not really - those flags only
get updated from the *result* of a poll(), where what we really need
is to know how libssh would *start* a poll().
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2013-11-09 12:26:19 +01:00
Aris Adamantiadis
04cb94a2dd
socket: Fix check for pending data.
...
BUG: https://red.libssh.org/issues/119
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2013-11-03 12:46:27 +01:00
Andreas Schneider
c64ec43eef
src: Remove enter_function() and leave_function().
2013-07-14 13:31:24 +02:00
Andreas Schneider
ebdd0c6ac1
src: Migrate to SSH_LOG.
2013-07-14 12:44:26 +02:00
Andreas Schneider
2b68728552
socket: Check if socket (non)blocking is working.
2013-06-17 13:18:55 +02:00
Andreas Schneider
42c7bc5a21
socket: Check return value of getsockopt().
2013-06-17 13:09:50 +02:00
Johannes Krude
186116f34a
socket: Call data handler as long as handler takes data.
...
Reviewed-by: Andreas Schneider <asn@cryptomilk.org >
2013-01-29 10:56:49 +01:00
Andreas Schneider
21db70888a
socket: Check return value of buffer function.
...
Found by Coverity.
2012-10-09 11:09:34 +02:00
Andreas Schneider
43e3a8e497
socket: Add a SSH_WRITE_PENDING socket status.
2012-07-17 18:05:51 +02:00
Andreas Schneider
c2686b8feb
socket: Move socket function to right location.
2011-09-18 21:37:17 +02:00
rofl0r
563fbe4de8
channels: Fix checking for fatal errors.
...
We need this that we don't end up in and infinite poll loop.
2011-08-06 11:11:12 +02:00
Aris Adamantiadis
79434649d0
Fix "connecting to closed port" on MacosX
2011-05-20 15:13:45 +02:00