aboutsummaryrefslogtreecommitdiff
path: root/libssh
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2010-05-09 01:05:12 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2010-05-09 01:05:12 +0200
commitaf519d73ae175e6564de2ccca4180f3e19996e96 (patch)
tree3ed580a16ef2d6c9957b33b95445aa5957e32400 /libssh
parent3a326793fd0c3c1fd3cecd46d57d367ee50db941 (diff)
downloadlibssh-af519d73ae175e6564de2ccca4180f3e19996e96.tar.gz
libssh-af519d73ae175e6564de2ccca4180f3e19996e96.tar.xz
libssh-af519d73ae175e6564de2ccca4180f3e19996e96.zip
Fix doc and actually make the test run :)
Diffstat (limited to 'libssh')
-rw-r--r--libssh/client.c4
-rw-r--r--libssh/options.c3
-rw-r--r--libssh/socket.c15
3 files changed, 17 insertions, 5 deletions
diff --git a/libssh/client.c b/libssh/client.c
index 805b144..e75ff49 100644
--- a/libssh/client.c
+++ b/libssh/client.c
@@ -685,7 +685,7 @@ int ssh_connect(ssh_session session) {
leave_function();
return SSH_ERROR;
}
- if (session->fd == -1 && session->host == NULL) {
+ if (session->fd == -1 && session->host == NULL && session->ProxyCommand == NULL) {
ssh_set_error(session, SSH_FATAL, "Hostname required");
leave_function();
return SSH_ERROR;
@@ -699,6 +699,8 @@ int ssh_connect(ssh_session session) {
if (session->fd != -1) {
ssh_socket_set_fd(session->socket, session->fd);
ret=SSH_OK;
+ } else if (session->ProxyCommand != NULL){
+ ret=ssh_socket_connect_proxycommand(session->socket, session->ProxyCommand);
} else {
ret=ssh_socket_connect(session->socket, session->host, session->port,
session->bindaddr);
diff --git a/libssh/options.c b/libssh/options.c
index df953dd..eab386d 100644
--- a/libssh/options.c
+++ b/libssh/options.c
@@ -365,6 +365,9 @@ char *dir_expand_dup(ssh_session session, const char *value, int allowsshdir) {
* - SSH_OPTIONS_HOSTKEYCHECK:
* Set the parameter StrictHostKeyChecking to avoid
* asking about a fingerprint
+ * - SSH_OPTIONS_PROXYCOMMAND:
+ * Set the command to be executed in order to connect to
+ * server.
*
* @param value The value to set. This is a generic pointer and the
* datatype which is used should be set according to the
diff --git a/libssh/socket.c b/libssh/socket.c
index af32c39..b40bf1b 100644
--- a/libssh/socket.c
+++ b/libssh/socket.c
@@ -66,6 +66,7 @@ enum ssh_socket_states_e {
struct ssh_socket_struct {
socket_t fd_in;
socket_t fd_out;
+ int fd_is_socket;
int last_errno;
int data_to_read; /* reading now on socket will
not block */
@@ -113,6 +114,7 @@ ssh_socket ssh_socket_new(ssh_session session) {
s->fd_in = -1;
s->fd_out= -1;
s->last_errno = -1;
+ s->fd_is_socket = 1;
s->session = session;
s->in_buffer = buffer_new();
if (s->in_buffer == NULL) {
@@ -391,8 +393,10 @@ static int ssh_socket_unbuffered_read(ssh_socket s, void *buffer, uint32_t len)
if (s->data_except) {
return -1;
}
-
- rc = recv(s->fd_in,buffer, len, 0);
+ if(s->fd_is_socket)
+ rc = recv(s->fd_in,buffer, len, 0);
+ else
+ rc = read(s->fd_in,buffer, len);
#ifdef _WIN32
s->last_errno = WSAGetLastError();
#else
@@ -417,8 +421,10 @@ static int ssh_socket_unbuffered_write(ssh_socket s, const void *buffer,
if (s->data_except) {
return -1;
}
-
- w = send(s->fd_out,buffer, len, 0);
+ if (s->fd_is_socket)
+ w = send(s->fd_out,buffer, len, 0);
+ else
+ w = write(s->fd_out, buffer, len);
#ifdef _WIN32
s->last_errno = WSAGetLastError();
#else
@@ -936,6 +942,7 @@ int ssh_socket_connect_proxycommand(ssh_socket s, const char *command){
ssh_socket_set_fd_in(s,in_pipe[0]);
ssh_socket_set_fd_out(s,out_pipe[1]);
s->state=SSH_SOCKET_CONNECTED;
+ s->fd_is_socket=0;
/* POLLOUT is the event to wait for in a nonblocking connect */
ssh_poll_set_events(ssh_socket_get_poll_handle_in(s),POLLIN | POLLERR);
ssh_poll_set_events(ssh_socket_get_poll_handle_out(s),POLLOUT);