diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-01-08 21:09:40 +0100 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2010-01-08 21:09:40 +0100 |
commit | db3ef37771888a4760840f03feea3f0128df548a (patch) | |
tree | 19e94c1da0d8d5255362f02f120870b707713f55 /libssh | |
parent | 7f32558e08e7b09eb1f98ac035e1f313f8bad1fa (diff) | |
download | libssh-db3ef37771888a4760840f03feea3f0128df548a.tar.gz libssh-db3ef37771888a4760840f03feea3f0128df548a.tar.xz libssh-db3ef37771888a4760840f03feea3f0128df548a.zip |
ssh_packet_userauth_request with new system
Diffstat (limited to 'libssh')
-rw-r--r-- | libssh/messages.c | 50 | ||||
-rw-r--r-- | libssh/packet.c | 2 |
2 files changed, 29 insertions, 23 deletions
diff --git a/libssh/messages.c b/libssh/messages.c index ecfb5e2f..307fd069 100644 --- a/libssh/messages.c +++ b/libssh/messages.c @@ -108,8 +108,12 @@ static int handle_unimplemented(ssh_session session) { return 0; } -static ssh_message handle_userauth_request(ssh_session session){ - ssh_string user = NULL; +/** @internal + * @brief Handle a SSH_MSG_MSG_USERAUTH_REQUEST packet and queue a + * SSH Message + */ +SSH_PACKET_CALLBACK(ssh_packet_userauth_request){ + ssh_string user_s = NULL; ssh_string service = NULL; ssh_string method = NULL; ssh_message msg = NULL; @@ -119,31 +123,34 @@ static ssh_message handle_userauth_request(ssh_session session){ enter_function(); + (void)user; + (void)type; msg = message_new(session); if (msg == NULL) { - return NULL; + ssh_set_error_oom(session); + goto error; } - user = buffer_get_ssh_string(session->in_buffer); - if (user == NULL) { + user_s = buffer_get_ssh_string(packet); + if (user_s == NULL) { goto error; } - service = buffer_get_ssh_string(session->in_buffer); + service = buffer_get_ssh_string(packet); if (service == NULL) { goto error; } - method = buffer_get_ssh_string(session->in_buffer); + method = buffer_get_ssh_string(packet); if (method == NULL) { goto error; } msg->type = SSH_REQUEST_AUTH; - msg->auth_request.username = string_to_char(user); + msg->auth_request.username = string_to_char(user_s); if (msg->auth_request.username == NULL) { goto error; } - string_free(user); - user = NULL; + string_free(user_s); + user_s = NULL; service_c = string_to_char(service); if (service_c == NULL) { @@ -170,8 +177,7 @@ static ssh_message handle_userauth_request(ssh_session session){ msg->auth_request.method = SSH_AUTH_METHOD_NONE; SAFE_FREE(service_c); SAFE_FREE(method_c); - leave_function(); - return msg; + goto end; } if (strncmp(method_c, "password", method_size) == 0) { @@ -193,8 +199,7 @@ static ssh_message handle_userauth_request(ssh_session session){ if (msg->auth_request.password == NULL) { goto error; } - leave_function(); - return msg; + goto end; } if (strncmp(method_c, "publickey", method_size) == 0) { @@ -269,17 +274,14 @@ static ssh_message handle_userauth_request(ssh_session session){ msg->auth_request.signature_state = SSH_PUBLICKEY_STATE_VALID; } SAFE_FREE(service_c); - leave_function(); - return msg; + goto end; } msg->auth_request.method = SSH_AUTH_METHOD_UNKNOWN; SAFE_FREE(method_c); - - leave_function(); - return msg; + goto end; error: - string_free(user); + string_free(user_s); string_free(service); string_free(method); @@ -289,7 +291,11 @@ error: ssh_message_free(msg); leave_function(); - return NULL; + return SSH_PACKET_USED; +end: + message_queue(session,msg); + leave_function(); + return SSH_PACKET_USED; } SSH_PACKET_CALLBACK(ssh_packet_channel_open){ @@ -754,7 +760,7 @@ ssh_message ssh_message_retrieve(ssh_session session, uint32_t packettype){ // msg=handle_service_request(session); break; case SSH2_MSG_USERAUTH_REQUEST: - msg = handle_userauth_request(session); +// msg = handle_userauth_request(session); break; case SSH2_MSG_CHANNEL_OPEN: // msg = handle_channel_request_open(session); diff --git a/libssh/packet.c b/libssh/packet.c index 33512358..15f4ddfd 100644 --- a/libssh/packet.c +++ b/libssh/packet.c @@ -67,7 +67,7 @@ ssh_packet_callback default_packet_handlers[]= { NULL, //#define SSH2_MSG_KEX_DH_GEX_REQUEST 34 NULL, NULL, NULL, NULL, NULL, // 35-49 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, //#define SSH2_MSG_USERAUTH_REQUEST 50 + ssh_packet_userauth_request, //#define SSH2_MSG_USERAUTH_REQUEST 50 ssh_packet_userauth_failure, //#define SSH2_MSG_USERAUTH_FAILURE 51 ssh_packet_userauth_success, //#define SSH2_MSG_USERAUTH_SUCCESS 52 ssh_packet_userauth_banner, //#define SSH2_MSG_USERAUTH_BANNER 53 |