New packet handler for SSH_USERAUTH_BANNER
Этот коммит содержится в:
родитель
3aae59c224
Коммит
682ed18123
28
include/libssh/auth.h
Обычный файл
28
include/libssh/auth.h
Обычный файл
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of the SSH Library
|
||||
*
|
||||
* Copyright (c) 2009 by Aris Adamantiadis
|
||||
*
|
||||
* The SSH Library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* The SSH Library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with the SSH Library; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
* MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef AUTH_H_
|
||||
#define AUTH_H_
|
||||
#include "libssh/callbacks.h"
|
||||
SSH_PACKET_CALLBACK(ssh_packet_userauth_banner);
|
||||
|
||||
|
||||
#endif /* AUTH_H_ */
|
@ -29,7 +29,7 @@ typedef struct ssh_kbdint_struct* ssh_kbdint;
|
||||
|
||||
/* These are the different states a SSH session can be into its life */
|
||||
enum ssh_session_state_e {
|
||||
SSH_SESSION_STATE_NONE,
|
||||
SSH_SESSION_STATE_NONE=0,
|
||||
SSH_SESSION_STATE_CONNECTING,
|
||||
SSH_SESSION_STATE_SOCKET_CONNECTED,
|
||||
SSH_SESSION_STATE_BANNER_RECEIVED,
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "libssh/packet.h"
|
||||
#include "libssh/session.h"
|
||||
#include "libssh/keys.h"
|
||||
#include "libssh/auth.h"
|
||||
|
||||
/** \defgroup ssh_auth SSH Authentication functions
|
||||
* \brief functions to authenticate to servers
|
||||
@ -66,6 +67,31 @@ static int ask_userauth(ssh_session session) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
/** @internal
|
||||
* @handles a SSH_USERAUTH_BANNER packet
|
||||
* This banner should be shown to user prior to authentication
|
||||
*/
|
||||
SSH_PACKET_CALLBACK(ssh_packet_userauth_banner){
|
||||
ssh_string banner;
|
||||
(void)type;
|
||||
(void)user;
|
||||
enter_function();
|
||||
banner = buffer_get_ssh_string(packet);
|
||||
if (banner == NULL) {
|
||||
ssh_log(session, SSH_LOG_RARE,
|
||||
"Invalid SSH_USERAUTH_BANNER packet");
|
||||
} else {
|
||||
ssh_log(session, SSH_LOG_PACKET,
|
||||
"Received SSH_USERAUTH_BANNER packet");
|
||||
if(session->banner != NULL)
|
||||
string_free(session->banner);
|
||||
session->banner = banner;
|
||||
}
|
||||
leave_function();
|
||||
return SSH_PACKET_USED;
|
||||
}
|
||||
|
||||
|
||||
static int wait_auth_status(ssh_session session, int kbdint) {
|
||||
char *auth_methods = NULL;
|
||||
ssh_string auth;
|
||||
@ -147,22 +173,7 @@ static int wait_auth_status(ssh_session session, int kbdint) {
|
||||
rc = SSH_AUTH_SUCCESS;
|
||||
cont = 0;
|
||||
break;
|
||||
case SSH2_MSG_USERAUTH_BANNER:
|
||||
{
|
||||
ssh_string banner;
|
||||
|
||||
banner = buffer_get_ssh_string(session->in_buffer);
|
||||
if (banner == NULL) {
|
||||
ssh_log(session, SSH_LOG_PACKET,
|
||||
"The banner message was invalid. Continuing though\n");
|
||||
break;
|
||||
}
|
||||
ssh_log(session, SSH_LOG_PACKET,
|
||||
"Received a message banner\n");
|
||||
string_free(session->banner); /* erase the older one */
|
||||
session->banner = banner;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
//packet_parse(session);
|
||||
//FIXME: broken
|
||||
@ -270,7 +281,7 @@ int ssh_userauth_none(ssh_session session, const char *username) {
|
||||
string_free(method);
|
||||
string_free(user);
|
||||
|
||||
if (packet_send(session) != SSH_OK) {
|
||||
if (packet_send(session) == SSH_ERROR) {
|
||||
leave_function();
|
||||
return rc;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "libssh/messages.h"
|
||||
#include "libssh/pcap.h"
|
||||
#include "libssh/kex.h"
|
||||
#include "libssh/auth.h"
|
||||
|
||||
ssh_packet_callback default_packet_handlers[]= {
|
||||
|
||||
@ -69,7 +70,7 @@ ssh_packet_callback default_packet_handlers[]= {
|
||||
NULL, //#define SSH2_MSG_USERAUTH_REQUEST 50
|
||||
NULL, //#define SSH2_MSG_USERAUTH_FAILURE 51
|
||||
NULL, //#define SSH2_MSG_USERAUTH_SUCCESS 52
|
||||
NULL, //#define SSH2_MSG_USERAUTH_BANNER 53
|
||||
ssh_packet_userauth_banner, //#define SSH2_MSG_USERAUTH_BANNER 53
|
||||
NULL, //#define SSH2_MSG_USERAUTH_PK_OK 60 SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ 60
|
||||
//SSH2_MSG_USERAUTH_INFO_REQUEST 60
|
||||
NULL, //#define SSH2_MSG_USERAUTH_INFO_RESPONSE 61
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user