mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
-rc release
Ipv6 patch from Laurent Bigonville. When the ipv6 targets are unreachable, it tries all possible targets from the getaddrinfo list. Norbert: does it break anything ? it works for me but I didn't test it extensively git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@99 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
2
AUTHORS
2
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)
|
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):
|
Contributor(s):
|
||||||
|
|
||||||
|
|||||||
2
Doxyfile
2
Doxyfile
@@ -4,7 +4,7 @@
|
|||||||
# Project related configuration options
|
# Project related configuration options
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
PROJECT_NAME = libssh
|
PROJECT_NAME = libssh
|
||||||
PROJECT_NUMBER = 0.2-dev
|
PROJECT_NUMBER = 0.2rc
|
||||||
OUTPUT_DIRECTORY = doxygen/
|
OUTPUT_DIRECTORY = doxygen/
|
||||||
CREATE_SUBDIRS = NO
|
CREATE_SUBDIRS = NO
|
||||||
OUTPUT_LANGUAGE = English
|
OUTPUT_LANGUAGE = English
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ LN = @LN_S@
|
|||||||
LIBTOOL = @LIBTOOL@
|
LIBTOOL = @LIBTOOL@
|
||||||
OBJECTS = sample.o samplesshd.o
|
OBJECTS = sample.o samplesshd.o
|
||||||
APPS = samplessh samplesftp samplesshd
|
APPS = samplessh samplesftp samplesshd
|
||||||
VERSION = 0.2-dev
|
VERSION = 0.2rc
|
||||||
DISTLIB = libssh-$(VERSION)
|
DISTLIB = libssh-$(VERSION)
|
||||||
CONFIG = include/libssh/config.h
|
CONFIG = include/libssh/config.h
|
||||||
|
|
||||||
@@ -67,7 +67,8 @@ dist:
|
|||||||
include/libssh/ssh1.h include/libssh/ssh2.h \
|
include/libssh/ssh1.h include/libssh/ssh2.h \
|
||||||
include/libssh/server.h $(DISTLIB)/include/libssh/
|
include/libssh/server.h $(DISTLIB)/include/libssh/
|
||||||
cp *.c COPYING README AUTHORS CHANGELOG Doxyfile $(DISTLIB)/
|
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)/
|
tar czf $(DISTLIB).tgz $(DISTLIB)/
|
||||||
|
|
||||||
.PHONY: doc
|
.PHONY: doc
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ(2.57)
|
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_SRCDIR([sample.c])
|
||||||
AC_CONFIG_HEADER([config.h])
|
AC_CONFIG_HEADER([config.h])
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ MA 02111-1307, USA. */
|
|||||||
#include <sys/select.h> /* for fd_set * */
|
#include <sys/select.h> /* for fd_set * */
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#define LIBSSH_VERSION "libssh-0.2-dev"
|
#define LIBSSH_VERSION "libssh-0.2rc"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ MA 02111-1307, USA. */
|
|||||||
#error "Your system must have select()"
|
#error "Your system must have select()"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_GETADDRINFO
|
||||||
|
#error "Your system must have getaddrinfo()"
|
||||||
|
#endif
|
||||||
|
|
||||||
static void sock_set_nonblocking(int sock) {
|
static void sock_set_nonblocking(int sock) {
|
||||||
fcntl(sock,F_SETFL,O_NONBLOCK);
|
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));
|
memset(&hints,0,sizeof(hints));
|
||||||
hints.ai_protocol=IPPROTO_TCP;
|
hints.ai_protocol=IPPROTO_TCP;
|
||||||
|
hints.ai_family=PF_UNSPEC;
|
||||||
hints.ai_socktype=SOCK_STREAM;
|
hints.ai_socktype=SOCK_STREAM;
|
||||||
if(port==0){
|
if(port==0){
|
||||||
hints.ai_flags=AI_PASSIVE;
|
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
|
int ssh_connect_host(SSH_SESSION *session, const char *host, const char
|
||||||
*bind_addr, int port,long timeout, long usec){
|
*bind_addr, int port,long timeout, long usec){
|
||||||
int s;
|
int s=-1;
|
||||||
int my_errno;
|
int my_errno;
|
||||||
struct addrinfo *ai;
|
struct addrinfo *ai, *ai2;
|
||||||
|
|
||||||
my_errno=getai(host, port, &ai);
|
my_errno=getai(host, port, &ai);
|
||||||
if (my_errno){
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create socket */
|
for(ai2=ai;ai2!=NULL;ai2=ai2->ai_next){
|
||||||
s=socket(ai->ai_family,ai->ai_socktype,ai->ai_protocol);
|
/* create socket */
|
||||||
if(s<0){
|
s=socket(ai2->ai_family,ai2->ai_socktype,ai2->ai_protocol);
|
||||||
ssh_set_error(session,SSH_FATAL,"socket : %s",strerror(errno));
|
if(s<0){
|
||||||
freeaddrinfo(ai);
|
ssh_set_error(session,SSH_FATAL,"socket : %s",strerror(errno));
|
||||||
return s;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if(bind_addr){
|
|
||||||
struct addrinfo *bind_ai;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bind(s,bind_ai->ai_addr,bind_ai->ai_addrlen)<0){
|
if(bind_addr){
|
||||||
ssh_set_error(session,SSH_FATAL,"Binding local address : %s",strerror(errno));
|
struct addrinfo *bind_ai, *bind_ai2;
|
||||||
freeaddrinfo(ai);
|
|
||||||
freeaddrinfo(bind_ai);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
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);
|
freeaddrinfo(ai);
|
||||||
return s;
|
return s;
|
||||||
|
|||||||
Reference in New Issue
Block a user