1
1
Not tested, probably not working correctly yet
Этот коммит содержится в:
Aris Adamantiadis 2010-01-10 21:05:46 +01:00
родитель 0c47227144
Коммит 94d1112c55
3 изменённых файлов: 23 добавлений и 99 удалений

Просмотреть файл

@ -62,7 +62,9 @@ enum ssh_auth_service_state_e {
/** Service accepted */
SSH_AUTH_SERVICE_ACCEPTED,
/** Access to service denied (fatal) */
SSH_AUTH_SERVICE_DENIED
SSH_AUTH_SERVICE_DENIED,
/** Specific to SSH1 */
SSH_AUTH_SERVICE_USER_SENT
};
#endif /* AUTH_H_ */

Просмотреть файл

@ -60,14 +60,18 @@ static int wait_auth1_status(ssh_session session) {
static int send_username(ssh_session session, const char *username) {
ssh_string user = NULL;
/* returns SSH_AUTH_SUCCESS or SSH_AUTH_DENIED */
if(session->auth_service_asked) {
return session->auth_service_asked;
if(session->auth_service_state == SSH_AUTH_SERVICE_USER_SENT) {
return SSH_OK;
}
if(session->auth_service_state == SSH_AUTH_SERVICE_DENIED) {
return SSH_ERROR;
}
if (!username) {
if(!(username = session->username)) {
if (ssh_options_set(session, SSH_OPTIONS_USER, NULL) < 0) {
return session->auth_service_asked = SSH_AUTH_ERROR;
session->auth_service_state = SSH_AUTH_SERVICE_DENIED;
return SSH_ERROR;
} else {
username = session->username;
}
@ -91,9 +95,14 @@ static int send_username(ssh_session session, const char *username) {
return SSH_AUTH_ERROR;
}
session->auth_service_asked = wait_auth1_status(session);
if(wait_auth1_status(session) == SSH_AUTH_SUCCESS){
session->auth_state=SSH_AUTH_SERVICE_USER_SENT;
return SSH_AUTH_SUCCESS;
} else {
session->auth_state=SSH_AUTH_SERVICE_DENIED;
return SSH_AUTH_ERROR;
}
return session->auth_service_asked;
}
/* use the "none" authentication question */
@ -101,44 +110,6 @@ int ssh_userauth1_none(ssh_session session, const char *username){
return send_username(session, username);
}
/*
int ssh_userauth_offer_pubkey(ssh_session session, char *username,int type, ssh_string publickey){
ssh_string user;
ssh_string service;
ssh_string method;
ssh_string algo;
int err=SSH_AUTH_ERROR;
if(!username)
if(!(username=session->options->username)){
if(options_default_username(session->options))
return SSH_AUTH_ERROR;
else
username=session->options->username;
}
if(ask_userauth(session))
return SSH_AUTH_ERROR;
user=string_from_char(username);
service=string_from_char("ssh-connection");
method=string_from_char("publickey");
algo=string_from_char(ssh_type_to_char(type));
packet_clear_out(session);
buffer_add_u8(session->out_buffer,SSH2_MSG_USERAUTH_REQUEST);
buffer_add_ssh_string(session->out_buffer,user);
buffer_add_ssh_string(session->out_buffer,service);
buffer_add_ssh_string(session->out_buffer,method);
buffer_add_u8(session->out_buffer,0);
buffer_add_ssh_string(session->out_buffer,algo);
buffer_add_ssh_string(session->out_buffer,publickey);
packet_send(session);
err=wait_auth_status(session,0);
free(user);
free(method);
free(service);
free(algo);
return err;
}
*/
/** \internal
* \todo implement ssh1 public key
*/
@ -151,53 +122,6 @@ int ssh_userauth1_offer_pubkey(ssh_session session, const char *username,
return SSH_AUTH_DENIED;
}
/*
int ssh_userauth_pubkey(ssh_session session, char *username, ssh_string publickey, ssh_private_key privatekey){
ssh_string user;
ssh_string service;
ssh_string method;
ssh_string algo;
ssh_string sign;
int err=SSH_AUTH_ERROR;
if(!username)
if(!(username=session->options->username)){
if(options_default_username(session->options))
return err;
else
username=session->options->username;
}
if(ask_userauth(session))
return err;
user=string_from_char(username);
service=string_from_char("ssh-connection");
method=string_from_char("publickey");
algo=string_from_char(ssh_type_to_char(privatekey->type));
*/ /* we said previously the public key was accepted */
/* packet_clear_out(session);
buffer_add_u8(session->out_buffer,SSH2_MSG_USERAUTH_REQUEST);
buffer_add_ssh_string(session->out_buffer,user);
buffer_add_ssh_string(session->out_buffer,service);
buffer_add_ssh_string(session->out_buffer,method);
buffer_add_u8(session->out_buffer,1);
buffer_add_ssh_string(session->out_buffer,algo);
buffer_add_ssh_string(session->out_buffer,publickey);
sign=ssh_do_sign(session,session->out_buffer,privatekey);
if(sign){
buffer_add_ssh_string(session->out_buffer,sign);
free(sign);
packet_send(session);
err=wait_auth_status(session,0);
}
free(user);
free(service);
free(method);
free(algo);
return err;
}
*/
int ssh_userauth1_password(ssh_session session, const char *username,
const char *password) {
ssh_string pwd = NULL;

Просмотреть файл

@ -391,7 +391,7 @@ int packet_read(ssh_session session) {
}
}
rc = ssh_socket_read(session->ssh_socket_struct, &len, sizeof(uint32_t));
rc = ssh_socket_read(session->socket, &len, sizeof(uint32_t));
if (rc != SSH_OK) {
goto error;
}
@ -423,7 +423,7 @@ int packet_read(ssh_session session) {
goto error;
}
rc = ssh_socket_read(session->ssh_socket_struct, packet, to_be_read);
rc = ssh_socket_read(session->socket, packet, to_be_read);
if(rc != SSH_OK) {
SAFE_FREE(packet);
goto error;
@ -706,7 +706,7 @@ static int packet_send1(ssh_session session) {
ssh_print_hexa("encrypted packet",buffer_get(session->out_buffer),
buffer_get_len(session->out_buffer));
#endif
if (ssh_socket_write(session->ssh_socket_struct, buffer_get(session->out_buffer),
if (ssh_socket_write(session->socket, buffer_get(session->out_buffer),
buffer_get_len(session->out_buffer)) == SSH_ERROR) {
goto error;
}
@ -734,7 +734,7 @@ int packet_send(ssh_session session) {
}
#ifdef WITH_SSH1
void packet_parse(ssh_session session) {
static void packet_parse(ssh_session session) {
uint8_t type = session->in_packet.type;
if (session->version == 1) {
@ -744,7 +744,7 @@ void packet_parse(ssh_session session) {
ssh_log(session, SSH_LOG_PACKET, "Received SSH_MSG_DISCONNECT");
ssh_set_error(session, SSH_FATAL, "Received SSH_MSG_DISCONNECT");
ssh_socket_close(session->ssh_socket_struct);
ssh_socket_close(session->socket);
session->alive = 0;
return;
case SSH_SMSG_STDOUT_DATA:
@ -763,9 +763,7 @@ void packet_parse(ssh_session session) {
} else {
}
}
#endif
#ifdef WITH_SSH1
int packet_wait(ssh_session session, int type, int blocking) {
enter_function();
@ -773,7 +771,7 @@ int packet_wait(ssh_session session, int type, int blocking) {
ssh_log(session, SSH_LOG_PROTOCOL, "packet_wait1 waiting for %d", type);
do {
if ((packet_read1(session) != SSH_OK) ||
if ((packet_read(session) != SSH_OK) ||
(packet_translate(session) != SSH_OK)) {
leave_function();
return SSH_ERROR;