Compare commits

..

6 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
10 changed files with 931 additions and 662 deletions

View File

@@ -40,7 +40,8 @@ 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)

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

@@ -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

@@ -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

@@ -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).