aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS2
-rw-r--r--Doxyfile2
-rw-r--r--Makefile.in5
-rw-r--r--configure.in2
-rw-r--r--include/libssh/libssh.h2
-rw-r--r--libssh/connect.c82
6 files changed, 56 insertions, 39 deletions
diff --git a/AUTHORS b/AUTHORS
index bdf5fd4..8d1d550 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -5,7 +5,7 @@ Nick Zitzmann <seiryu (at) comcast (dot) net> (mostly client SFTP stuff)
Norbert Kiesel <nkiesel (at) tbdnetworks (dot) com> (getaddrinfo and other patches)
-Jean-Philippe Garcia Ballester <giga (at) le-pec (dot) org> (Port to libgcrypt and configure.in voodoo)
+Jean-Philippe Garcia Ballester <giga (at) le-pec (dot) org> (Port to libgcrypt and configure.in voodoo, debian packaging)
Contributor(s):
diff --git a/Doxyfile b/Doxyfile
index 2e82c47..6764edf 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -4,7 +4,7 @@
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = libssh
-PROJECT_NUMBER = 0.2-dev
+PROJECT_NUMBER = 0.2rc
OUTPUT_DIRECTORY = doxygen/
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
diff --git a/Makefile.in b/Makefile.in
index 8897a27..a3481e0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -23,7 +23,7 @@ LN = @LN_S@
LIBTOOL = @LIBTOOL@
OBJECTS = sample.o samplesshd.o
APPS = samplessh samplesftp samplesshd
-VERSION = 0.2-dev
+VERSION = 0.2rc
DISTLIB = libssh-$(VERSION)
CONFIG = include/libssh/config.h
@@ -67,7 +67,8 @@ dist:
include/libssh/ssh1.h include/libssh/ssh2.h \
include/libssh/server.h $(DISTLIB)/include/libssh/
cp *.c COPYING README AUTHORS CHANGELOG Doxyfile $(DISTLIB)/
- cp doc/* $(DISTLIB)/doc/
+ #cp doc/* $(DISTLIB)/doc/
+ #docs removed coz they are obsolete
tar czf $(DISTLIB).tgz $(DISTLIB)/
.PHONY: doc
diff --git a/configure.in b/configure.in
index 60bfc59..adf02dd 100644
--- a/configure.in
+++ b/configure.in
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
-AC_INIT(libssh, 0.2-dev , aris@0xbadc0de.be)
+AC_INIT(libssh, 0.2rc , aris@0xbadc0de.be)
AC_CONFIG_SRCDIR([sample.c])
AC_CONFIG_HEADER([config.h])
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index bf7877b..c75b357 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -24,7 +24,7 @@ MA 02111-1307, USA. */
#include <sys/select.h> /* for fd_set * */
#include <inttypes.h>
-#define LIBSSH_VERSION "libssh-0.2-dev"
+#define LIBSSH_VERSION "libssh-0.2rc"
#ifdef __cplusplus
extern "C" {
diff --git a/libssh/connect.c b/libssh/connect.c
index 44cb6a1..c797dc2 100644
--- a/libssh/connect.c
+++ b/libssh/connect.c
@@ -38,6 +38,10 @@ MA 02111-1307, USA. */
#error "Your system must have select()"
#endif
+#ifndef HAVE_GETADDRINFO
+#error "Your system must have getaddrinfo()"
+#endif
+
static void sock_set_nonblocking(int sock) {
fcntl(sock,F_SETFL,O_NONBLOCK);
}
@@ -53,6 +57,7 @@ static int getai(const char *host, int port, struct addrinfo **ai)
memset(&hints,0,sizeof(hints));
hints.ai_protocol=IPPROTO_TCP;
+ hints.ai_family=PF_UNSPEC;
hints.ai_socktype=SOCK_STREAM;
if(port==0){
hints.ai_flags=AI_PASSIVE;
@@ -108,51 +113,62 @@ int ssh_connect_ai_timeout(SSH_SESSION *session, const char *host, int port, str
int ssh_connect_host(SSH_SESSION *session, const char *host, const char
*bind_addr, int port,long timeout, long usec){
- int s;
+ int s=-1;
int my_errno;
- struct addrinfo *ai;
+ struct addrinfo *ai, *ai2;
my_errno=getai(host, port, &ai);
if (my_errno){
- ssh_set_error(session,SSH_FATAL,"Failed to resolve hostname %s (%d)",host,my_errno);
+ ssh_set_error(session,SSH_FATAL,"Failed to resolve hostname %s (%s)",host,gai_strerror(my_errno));
return -1;
}
- /* create socket */
- s=socket(ai->ai_family,ai->ai_socktype,ai->ai_protocol);
- if(s<0){
- ssh_set_error(session,SSH_FATAL,"socket : %s",strerror(errno));
- freeaddrinfo(ai);
- return s;
- }
+ for(ai2=ai;ai2!=NULL;ai2=ai2->ai_next){
+ /* create socket */
+ s=socket(ai2->ai_family,ai2->ai_socktype,ai2->ai_protocol);
+ if(s<0){
+ ssh_set_error(session,SSH_FATAL,"socket : %s",strerror(errno));
+ continue;
+ }
- if(bind_addr){
- struct addrinfo *bind_ai;
+ if(bind_addr){
+ struct addrinfo *bind_ai, *bind_ai2;
- ssh_say(2,"resolving %s\n",bind_addr);
- my_errno=getai(host,0,&bind_ai);
- if (my_errno){
- ssh_set_error(session,SSH_FATAL,"Failed to resolve bind address %s (%d)",bind_addr,my_errno);
- freeaddrinfo(ai);
- return -1;
- }
+ ssh_say(2,"resolving %s\n",bind_addr);
+ my_errno=getai(host,0,&bind_ai);
+ if (my_errno){
+ ssh_set_error(session,SSH_FATAL,"Failed to resolve bind address %s (%s)",bind_addr,gai_strerror(my_errno));
+ return -1;
+ }
- if(bind(s,bind_ai->ai_addr,bind_ai->ai_addrlen)<0){
- ssh_set_error(session,SSH_FATAL,"Binding local address : %s",strerror(errno));
- freeaddrinfo(ai);
- freeaddrinfo(bind_ai);
+ for(bind_ai2=bind_ai;bind_ai2!=NULL;bind_ai2=bind_ai2->ai_next){
+ if(bind(s,bind_ai2->ai_addr,bind_ai2->ai_addrlen)<0){
+ ssh_set_error(session,SSH_FATAL,"Binding local address : %s",strerror(errno));
+ continue;
+ }
+ else{
+ break;
+ }
+ }
+ freeaddrinfo(bind_ai);
+ if(bind_ai2==NULL){ /*cannot bind to any local addresses*/
+ close(s);
+ s=-1;
+ continue;
+ }
+ }
+ if(timeout||usec){
+ return ssh_connect_ai_timeout(session,host,port,ai2,timeout,usec,s);
+ }
+ if(connect(s,ai2->ai_addr,ai2->ai_addrlen)<0){
+ ssh_set_error(session,SSH_FATAL,"connect: %s",strerror(errno));
close(s);
- return -1;
+ s=-1;
+ continue;
+ }
+ else{ /*we are connected*/
+ break;
}
- freeaddrinfo(bind_ai);
- }
- if(timeout||usec){
- return ssh_connect_ai_timeout(session,host,port,ai,timeout,usec,s);
- }
- if(connect(s,ai->ai_addr,ai->ai_addrlen)<0){
- ssh_set_error(session,SSH_FATAL,"connect: %s",strerror(errno));
- close(s);
- s=-1;
}
freeaddrinfo(ai);
return s;