Compare commits

...

16 Commits

Author SHA1 Message Date
Aris Adamantiadis
75dc5939ed Workaround ssh_get_user_home_dir on LDAP accounts 2011-07-13 11:59:40 +02:00
Andreas Schneider
4d85f7b1e5 cmake: Fixed a typo.
(cherry picked from commit 7150cabafa)
2011-04-08 11:06:07 +02:00
Andreas Schneider
b7db87c817 doc: Fixed callbacks documentation. 2011-01-28 13:09:02 +01:00
Aris Adamantiadis
eb49bf4bfd SSH1: fix a few bugs that stopped the samplessh to work 2011-01-26 22:37:04 +01:00
Aris Adamantiadis
f6c31db3fc Allow SSH-1 only if compiled in 2011-01-26 22:14:48 +01:00
Aris Adamantiadis
bef014b7a9 Knownhosts: fix missing leave_function() 2011-01-26 22:08:13 +01:00
Andreas Schneider
e6d17ccc15 build: Updated the ChangeLog. 2011-01-15 09:57:00 +01:00
Andreas Schneider
0b0a2d85d0 build: Updated version number to 0.4.8 2011-01-10 14:52:25 +01:00
Andreas Schneider
8d7245f54b keys: Fixed memory leaks in session signing.
Found by cppcheck - http://test.libssh.org/cppcheck-analyzer/
2011-01-07 15:48:39 +01:00
Andreas Schneider
0b1f8a2b0c dh: Fixed a memory leak in ssh_print_hexa.
Found by cppcheck - http://test.libssh.org/cppcheck-analyzer/
(cherry picked from commit a016d356fa)
2011-01-07 15:47:18 +01:00
Aris Adamantiadis
8d676c77b1 Fix release number 2011-01-07 12:07:09 +01:00
Aris Adamantiadis
b1a65dd25f Fix problem with ssh_connect w/ timeout &fd > 1024
Convert that code to ssh_poll
2011-01-03 22:51:23 +01:00
Andreas Schneider
e78cc89b52 cmake: Added ssl libraries for OS/2. 2010-12-31 14:56:29 +01:00
Andreas Schneider
f6586576fb cmake: Fixed a warning on OS/2 if the compiler version is empty.
(cherry picked from commit 98b5f07631)
2010-12-31 14:42:34 +01:00
Andreas Schneider
3797ca0ec6 libssh: Don't use the visibility flag on OS/2. 2010-12-31 14:36:27 +01:00
Andreas Schneider
bfe59d0cdd cmake: Fixed installation path for OS/2. 2010-12-31 14:10:59 +01:00
20 changed files with 1010 additions and 698 deletions

View File

@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
set(APPLICATION_VERSION_MAJOR "0")
set(APPLICATION_VERSION_MINOR "4")
set(APPLICATION_VERSION_PATCH "7")
set(APPLICATION_VERSION_PATCH "8")
set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
@@ -30,6 +30,7 @@ set(CMAKE_MODULE_PATH
# add definitions
include(DefineCMakeDefaults)
include(DefineCompilerFlags)
include(DefinePlatformDefaults)
include(DefineInstallationPaths)
include(DefineOptions.cmake)
include(CPackConfig.cmake)

View File

@@ -13,7 +13,7 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
### versions
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "4")
set(CPACK_PACKAGE_VERSION_PATCH "7")
set(CPACK_PACKAGE_VERSION_PATCH "8")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")

View File

@@ -1,6 +1,13 @@
ChangeLog
==========
version 0.4.8 (released 2011-01-15)
* Fixed memory leaks in session signing.
* Fixed memory leak in ssh_print_hexa.
* Fixed problem with ssh_connect w/ timeout and fd > 1024.
* Fixed some warnings on OS/2.
* Fixed installation path for OS/2.
version 0.4.7 (released 2010-12-28)
* Fixed a possible memory leak in ssh_get_user_home().
* Fixed a memory leak in sftp_xstat.

View File

@@ -25,22 +25,23 @@ function(COMPILER_DUMPVERSION _OUTPUT_VERSION)
)
string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
_COMPILER_VERSION ${_COMPILER_VERSION})
_COMPILER_VERSION "${_COMPILER_VERSION}")
set(${_OUTPUT_VERSION} ${_COMPILER_VERSION} PARENT_SCOPE)
endfunction()
if(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
if(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW AND NOT OS2)
compiler_dumpversion(GNUCC_VERSION)
if (NOT GNUCC_VERSION EQUAL 34)
check_c_compiler_flag("-fvisibility=hidden" WITH_VISIBILITY_HIDDEN)
endif (NOT GNUCC_VERSION EQUAL 34)
endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW AND NOT OS2)
# HEADER FILES
check_include_file(argp.h HAVE_ARGP_H)
check_include_file(pty.h HAVE_PTY_H)
check_include_file(terminos.h HAVE_TERMIOS_H)
check_include_file(termios.h HAVE_TERMIOS_H)
if (WIN32)
check_include_files("winsock2.h;ws2tcpip.h;wspiapi.h" HAVE_WSPIAPI_H)
if (NOT HAVE_WSPIAPI_H)

View File

@@ -1,4 +1,15 @@
if (UNIX)
if (WIN32)
# Same same
set(BIN_INSTALL_DIR "bin" CACHE PATH "-")
set(SBIN_INSTALL_DIR "." CACHE PATH "-")
set(LIB_INSTALL_DIR "lib" CACHE PATH "-")
set(INCLUDE_INSTALL_DIR "include" CACHE PATH "-")
set(PLUGIN_INSTALL_DIR "plugins" CACHE PATH "-")
set(HTML_INSTALL_DIR "doc/HTML" CACHE PATH "-")
set(ICON_INSTALL_DIR "." CACHE PATH "-")
set(SOUND_INSTALL_DIR "." CACHE PATH "-")
set(LOCALE_INSTALL_DIR "lang" CACHE PATH "-")
elseif (UNIX OR OS2)
IF (NOT APPLICATION_NAME)
MESSAGE(STATUS "${PROJECT_NAME} is used as APPLICATION_NAME")
SET(APPLICATION_NAME ${PROJECT_NAME})
@@ -90,18 +101,4 @@ if (UNIX)
"${SHARE_INSTALL_PREFIX}/info"
CACHE PATH "The ${APPLICATION_NAME} info install dir (default prefix/info)"
)
endif (UNIX)
if (WIN32)
# Same same
set(BIN_INSTALL_DIR "bin" CACHE PATH "-")
set(SBIN_INSTALL_DIR "." CACHE PATH "-")
set(LIB_INSTALL_DIR "lib" CACHE PATH "-")
set(INCLUDE_INSTALL_DIR "include" CACHE PATH "-")
set(PLUGIN_INSTALL_DIR "plugins" CACHE PATH "-")
set(HTML_INSTALL_DIR "doc/HTML" CACHE PATH "-")
set(ICON_INSTALL_DIR "." CACHE PATH "-")
set(SOUND_INSTALL_DIR "." CACHE PATH "-")
set(LOCALE_INSTALL_DIR "lang" CACHE PATH "-")
endif (WIN32)
endif ()

View File

@@ -0,0 +1,25 @@
# Set system vars
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
set(LINUX TRUE)
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(FREEBSD TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
set(OPENBSD TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
set(NETBSD TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
if (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
set(SOLARIS TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
if (CMAKE_SYSTEM_NAME MATCHES "OS2")
set(OS2 TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "OS2")

View File

@@ -52,6 +52,7 @@ else (OPENSSL_LIBRARIES AND OPENSSL_INCLUDE_DIRS)
find_library(SSL_LIBRARY
NAMES
ssl
ssl_dl
libssl
PATHS
${_OPENSSL_DIR}/lib
@@ -101,6 +102,7 @@ else (OPENSSL_LIBRARIES AND OPENSSL_INCLUDE_DIRS)
find_library(CRYPTO_LIBRARY
NAMES
crypto
crypto_dl
libcrypto
eay
eay32

File diff suppressed because it is too large Load Diff

View File

@@ -33,6 +33,11 @@
extern "C" {
#endif
/**
* @addtogroup ssh_session
* @{
*/
/**
* @brief SSH authentication callback.
*
@@ -110,4 +115,6 @@ LIBSSH_API int ssh_set_callbacks(ssh_session session, ssh_callbacks cb);
}
#endif
/** @} */
#endif /*_SSH_CALLBACK_H */

View File

@@ -40,7 +40,7 @@
#endif
#endif
#else
#if __GNUC__ >= 4
#if __GNUC__ >= 4 && !defined(__OS2__)
#define LIBSSH_API __attribute__((visibility("default")))
#else
#define LIBSSH_API
@@ -79,7 +79,7 @@
/* libssh version */
#define LIBSSH_VERSION_MAJOR 0
#define LIBSSH_VERSION_MINOR 4
#define LIBSSH_VERSION_MICRO 6
#define LIBSSH_VERSION_MICRO 8
#define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \
LIBSSH_VERSION_MINOR, \

View File

@@ -226,7 +226,7 @@ int ssh_userauth_none(ssh_session session, const char *username) {
#ifdef WITH_SSH1
if (session->version == 1) {
ssh_userauth1_none(session, username);
rc = ssh_userauth1_none(session, username);
leave_function();
return rc;
}
@@ -332,7 +332,7 @@ int ssh_userauth_offer_pubkey(ssh_session session, const char *username,
#ifdef WITH_SSH1
if (session->version == 1) {
ssh_userauth1_offer_pubkey(session, username, type, publickey);
rc = ssh_userauth1_offer_pubkey(session, username, type, publickey);
leave_function();
return rc;
}

View File

@@ -35,38 +35,46 @@
#ifdef WITH_SSH1
static int wait_auth1_status(ssh_session session) {
enter_function();
/* wait for a packet */
if (packet_read(session) != SSH_OK) {
leave_function();
return SSH_AUTH_ERROR;
}
if(packet_translate(session) != SSH_OK) {
leave_function();
return SSH_AUTH_ERROR;
}
switch(session->in_packet.type) {
case SSH_SMSG_SUCCESS:
leave_function();
return SSH_AUTH_SUCCESS;
case SSH_SMSG_FAILURE:
leave_function();
return SSH_AUTH_DENIED;
}
ssh_set_error(session, SSH_FATAL, "Was waiting for a SUCCESS or "
"FAILURE, got %d", session->in_packet.type);
leave_function();
return SSH_AUTH_ERROR;
}
static int send_username(ssh_session session, const char *username) {
ssh_string user = NULL;
/* returns SSH_AUTH_SUCCESS or SSH_AUTH_DENIED */
enter_function();
if(session->auth_service_asked) {
leave_function();
return session->auth_service_asked;
}
if (!username) {
if(!(username = session->username)) {
if (ssh_options_set(session, SSH_OPTIONS_USER, NULL) < 0) {
leave_function();
return session->auth_service_asked = SSH_AUTH_ERROR;
} else {
username = session->username;
@@ -75,24 +83,30 @@ static int send_username(ssh_session session, const char *username) {
}
user = string_from_char(username);
if (user == NULL) {
leave_function();
return SSH_AUTH_ERROR;
}
if (buffer_add_u8(session->out_buffer, SSH_CMSG_USER) < 0) {
string_free(user);
leave_function();
return SSH_AUTH_ERROR;
}
if (buffer_add_ssh_string(session->out_buffer, user) < 0) {
string_free(user);
leave_function();
return SSH_AUTH_ERROR;
}
string_free(user);
if (packet_send(session) != SSH_OK) {
leave_function();
return SSH_AUTH_ERROR;
}
session->auth_service_asked = wait_auth1_status(session);
if(session->auth_service_asked != SSH_AUTH_ERROR)
session->auth_methods=SSH_AUTH_METHOD_PASSWORD;
leave_function();
return session->auth_service_asked;
}

View File

@@ -573,8 +573,10 @@ int ssh_connect(ssh_session session) {
/* Here we decide which version of the protocol to use. */
if (ssh2 && session->ssh2) {
session->version = 2;
#ifdef WITH_SSH1
} else if(ssh1 && session->ssh1) {
session->version = 1;
#endif
} else {
ssh_set_error(session, SSH_FATAL,
"No version of SSH protocol usable (banner: %s)",
@@ -629,6 +631,7 @@ int ssh_connect(ssh_session session) {
session->connected = 1;
break;
#ifdef WITH_SSH1
case 1:
if (ssh_get_kex1(session) < 0) {
ssh_socket_close(session->socket);
@@ -640,6 +643,7 @@ int ssh_connect(ssh_session session) {
session->connected = 1;
break;
#endif
}
leave_function();

View File

@@ -67,10 +67,7 @@
#include "libssh/socket.h"
#include "libssh/channels.h"
#include "libssh/session.h"
#ifndef HAVE_SELECT
#error "Your system must have select()"
#endif
#include "libssh/poll.h"
#ifndef HAVE_GETADDRINFO
#error "Your system must have getaddrinfo()"
@@ -202,29 +199,35 @@ static int getai(ssh_session session, const char *host, int port, struct addrinf
static int ssh_connect_ai_timeout(ssh_session session, const char *host,
int port, struct addrinfo *ai, long timeout, long usec, socket_t s) {
struct timeval to;
fd_set set;
int timeout_ms;
ssh_pollfd_t fds;
int rc = 0;
unsigned int len = sizeof(rc);
enter_function();
to.tv_sec = timeout;
to.tv_usec = usec;
/* I know we're losing some precision. But it's not like poll-like family
* type of mechanisms are precise up to the microsecond.
*/
timeout_ms=timeout * 1000 + usec / 1000;
sock_set_nonblocking(s);
ssh_log(session, SSH_LOG_RARE, "Trying to connect to host: %s:%d with "
"timeout %ld.%ld", host, port, timeout, usec);
"timeout %d ms", host, port, timeout_ms);
/* The return value is checked later */
connect(s, ai->ai_addr, ai->ai_addrlen);
freeaddrinfo(ai);
FD_ZERO(&set);
FD_SET(s, &set);
fds.fd=s;
fds.revents=0;
fds.events=POLLOUT;
#ifdef _WIN32
fds.events |= POLLWRNORM;
#endif
rc = ssh_poll(&fds,1,timeout_ms);
rc = select(s + 1, NULL, &set, NULL, &to);
if (rc == 0) {
/* timeout */
ssh_set_error(session, SSH_FATAL,
@@ -236,7 +239,7 @@ static int ssh_connect_ai_timeout(ssh_session session, const char *host,
if (rc < 0) {
ssh_set_error(session, SSH_FATAL,
"Select error: %s", strerror(errno));
"poll error: %s", strerror(errno));
ssh_connect_socket_close(s);
leave_function();
return -1;

View File

@@ -222,6 +222,8 @@ void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len) {
return;
}
printf("%s: %s\n", descr, hexa);
free(hexa);
}
int dh_generate_x(ssh_session session) {

View File

@@ -450,6 +450,8 @@ int verify_existing_algo(int algo, const char *name){
return 0;
}
#ifdef WITH_SSH1
/* makes a STRING contating 3 strings : ssh-rsa1,e and n */
/* this is a public key in openssh's format */
static ssh_string make_rsa1_string(ssh_string e, ssh_string n){
@@ -507,6 +509,7 @@ static int build_session_id1(ssh_session session, ssh_string servern,
return 0;
}
/* returns 1 if the modulus of k1 is < than the one of k2 */
static int modulus_smaller(ssh_public_key k1, ssh_public_key k2){
bignum n1;
@@ -796,4 +799,6 @@ error:
return rc;
}
#endif /* WITH_SSH1 */
/* vim: set ts=2 sw=2 et cindent: */

View File

@@ -1457,6 +1457,7 @@ static int match_hashed_host(ssh_session session, const char *host,
enter_function();
if (strncmp(sourcehash, "|1|", 3) != 0) {
leave_function();
return 0;
}

View File

@@ -1308,6 +1308,9 @@ ssh_string ssh_do_sign(ssh_session session, ssh_buffer sigbuf,
#endif
sign->dsa_sign = NULL;
break;
default:
signature_free(sign);
return NULL;
}
#ifdef HAVE_LIBGCRYPT
gcry_sexp_release(gcryhash);
@@ -1463,6 +1466,9 @@ ssh_string ssh_sign_session_id(ssh_session session, ssh_private_key privatekey)
#endif
sign->dsa_sign = NULL;
break;
default:
signature_free(sign);
return NULL;
}
#ifdef HAVE_LIBGCRYPT

View File

@@ -129,9 +129,11 @@ char *ssh_get_user_home_dir(void) {
rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf);
if (rc != 0) {
return NULL;
szPath = getenv("HOME");
return szPath ? strdup(szPath) : NULL;
}
szPath = strdup(pwd.pw_dir);
return szPath;

View File

@@ -266,33 +266,6 @@ int ssh_options_set_algo(ssh_session session, int algo,
* \n
* See the corresponding numbers in libssh.h.
*
* - SSH_OPTTIONS_AUTH_CALLBACK:
* Set a callback to use your own authentication function
* (function pointer).
*
* - SSH_OPTTIONS_AUTH_USERDATA:
* Set the user data passed to the authentication
* function (generic pointer).
*
* - SSH_OPTTIONS_LOG_CALLBACK:
* Set a callback to use your own logging function
* (function pointer).
*
* - SSH_OPTTIONS_LOG_USERDATA:
* Set the user data passed to the logging function
* (generic pointer).
*
* - SSH_OPTTIONS_STATUS_CALLBACK:
* Set a callback to show connection status in realtime
* (function pointer).\n
* \n
* @code
* fn(void *arg, float status)
* @endcode
* \n
* During ssh_connect(), libssh will call the callback
* with status from 0.0 to 1.0.
*
* - SSH_OPTTIONS_STATUS_ARG:
* Set the status argument which should be passed to the
* status callback (generic pointer).