1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-08 19:02:06 +03:00

server: Fix compilation without WITH_SERVER

This commit is contained in:
Aris Adamantiadis
2013-07-14 09:30:59 +02:00
parent bf5e5eebd7
commit ad92740dc3
7 changed files with 49 additions and 14 deletions

View File

@@ -31,13 +31,14 @@ typedef struct ssh_gssapi_struct *ssh_gssapi;
#ifdef WITH_SERVER #ifdef WITH_SERVER
int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n_oid, ssh_string *oids); int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n_oid, ssh_string *oids);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server); SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_client);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_mic); SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_mic);
#endif /* WITH_SERVER */
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_client);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_response); SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_response);
#endif /* WITH_SERVER */
int ssh_gssapi_auth_mic(ssh_session session); int ssh_gssapi_auth_mic(ssh_session session);

View File

@@ -92,9 +92,12 @@ struct ssh_message_struct {
}; };
SSH_PACKET_CALLBACK(ssh_packet_channel_open); SSH_PACKET_CALLBACK(ssh_packet_channel_open);
SSH_PACKET_CALLBACK(ssh_packet_global_request);
#ifdef WITH_SERVER
SSH_PACKET_CALLBACK(ssh_packet_service_request); SSH_PACKET_CALLBACK(ssh_packet_service_request);
SSH_PACKET_CALLBACK(ssh_packet_userauth_request); SSH_PACKET_CALLBACK(ssh_packet_userauth_request);
SSH_PACKET_CALLBACK(ssh_packet_global_request); #endif /* WITH_SERVER */
int ssh_message_handle_channel_request(ssh_session session, ssh_channel channel, ssh_buffer packet, int ssh_message_handle_channel_request(ssh_session session, ssh_channel channel, ssh_buffer packet,
const char *request, uint8_t want_reply); const char *request, uint8_t want_reply);

View File

@@ -180,9 +180,10 @@ void _ssh_set_error_invalid(void *error, const char *function);
/* server.c */ /* server.c */
#ifdef WITH_SERVER
int ssh_auth_reply_default(ssh_session session,int partial); int ssh_auth_reply_default(ssh_session session,int partial);
int ssh_auth_reply_success(ssh_session session, int partial); int ssh_auth_reply_success(ssh_session session, int partial);
#endif
/* client.c */ /* client.c */
int ssh_send_banner(ssh_session session, int is_server); int ssh_send_banner(ssh_session session, int is_server);

View File

@@ -843,11 +843,15 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
leave_function(); leave_function();
return SSH_PACKET_USED; return SSH_PACKET_USED;
} }
#ifdef WITH_SERVER
/* If we are here, that means we have a request that is not in the understood /* If we are here, that means we have a request that is not in the understood
* client requests. That means we need to create a ssh message to be passed * client requests. That means we need to create a ssh message to be passed
* to the user code handling ssh messages * to the user code handling ssh messages
*/ */
ssh_message_handle_channel_request(session,channel,packet,request,status); ssh_message_handle_channel_request(session,channel,packet,request,status);
#else
SSH_LOG(session,SSH_LOG_WARNING, "Unhandled channel request %s", request);
#endif
SAFE_FREE(request); SAFE_FREE(request);

View File

@@ -121,6 +121,8 @@ static int ssh_gssapi_send_response(ssh_session session, ssh_string oid){
return SSH_OK; return SSH_OK;
} }
#endif /* WITH_SERVER */
static void ssh_gssapi_log_error(ssh_session session, int verb, const char *msg, int maj_stat){ static void ssh_gssapi_log_error(ssh_session session, int verb, const char *msg, int maj_stat){
gss_buffer_desc buffer; gss_buffer_desc buffer;
OM_uint32 dummy, message_context; OM_uint32 dummy, message_context;
@@ -128,6 +130,8 @@ static void ssh_gssapi_log_error(ssh_session session, int verb, const char *msg,
ssh_log(session, verb, "GSSAPI(%s): %s", msg, (const char *)buffer.value); ssh_log(session, verb, "GSSAPI(%s): %s", msg, (const char *)buffer.value);
} }
#ifdef WITH_SERVER
/** @internal /** @internal
* @brief handles an user authentication using GSSAPI * @brief handles an user authentication using GSSAPI
*/ */
@@ -251,6 +255,8 @@ int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n
return ssh_gssapi_send_response(session, oids[i]); return ssh_gssapi_send_response(session, oids[i]);
} }
#endif /* WITH_SERVER */
static char * ssh_gssapi_name_to_char(ssh_session session, gss_name_t name){ static char * ssh_gssapi_name_to_char(ssh_session session, gss_name_t name){
gss_buffer_desc buffer; gss_buffer_desc buffer;
OM_uint32 maj_stat, min_stat; OM_uint32 maj_stat, min_stat;
@@ -265,6 +271,8 @@ static char * ssh_gssapi_name_to_char(ssh_session session, gss_name_t name){
} }
#ifdef WITH_SERVER
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server){ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server){
ssh_string token; ssh_string token;
char *hexa; char *hexa;
@@ -349,6 +357,8 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server){
return SSH_PACKET_USED; return SSH_PACKET_USED;
} }
#endif /* WITH_SERVER */
static ssh_buffer ssh_gssapi_build_mic(ssh_session session){ static ssh_buffer ssh_gssapi_build_mic(ssh_session session){
ssh_buffer mic_buffer = ssh_buffer_new(); ssh_buffer mic_buffer = ssh_buffer_new();
ssh_string str; ssh_string str;
@@ -377,6 +387,8 @@ static ssh_buffer ssh_gssapi_build_mic(ssh_session session){
return mic_buffer; return mic_buffer;
} }
#ifdef WITH_SERVER
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_mic){ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_mic){
ssh_string mic_token; ssh_string mic_token;
OM_uint32 maj_stat, min_stat; OM_uint32 maj_stat, min_stat;
@@ -824,7 +836,6 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_client){
} }
if (GSS_ERROR(maj_stat)){ if (GSS_ERROR(maj_stat)){
ssh_gssapi_log_error(session, SSH_LOG_PROTOCOL, "Gssapi error", maj_stat); ssh_gssapi_log_error(session, SSH_LOG_PROTOCOL, "Gssapi error", maj_stat);
ssh_auth_reply_default(session,0);
ssh_gssapi_free(session); ssh_gssapi_free(session);
session->gssapi=NULL; session->gssapi=NULL;
return SSH_PACKET_USED; return SSH_PACKET_USED;

View File

@@ -93,6 +93,7 @@ static int ssh_message_reply_default(ssh_message msg) {
#endif #endif
#ifdef WITH_SERVER
/** @internal /** @internal
* Executes the callbacks defined in session->server_callbacks, out of an ssh_message * Executes the callbacks defined in session->server_callbacks, out of an ssh_message
* I don't like ssh_message interface but it works. * I don't like ssh_message interface but it works.
@@ -258,6 +259,8 @@ static int ssh_execute_server_callbacks(ssh_session session, ssh_message msg){
return SSH_AGAIN; return SSH_AGAIN;
} }
#endif /* WITH_SERVER */
static int ssh_execute_message_callback(ssh_session session, ssh_message msg) { static int ssh_execute_message_callback(ssh_session session, ssh_message msg) {
int ret; int ret;
if(session->ssh_message_callback != NULL) { if(session->ssh_message_callback != NULL) {
@@ -282,7 +285,6 @@ static int ssh_execute_message_callback(ssh_session session, ssh_message msg) {
return SSH_OK; return SSH_OK;
} }
/** /**
* @internal * @internal
* *
@@ -294,8 +296,9 @@ static int ssh_execute_message_callback(ssh_session session, ssh_message msg) {
* @param[in] message The message to add to the queue. * @param[in] message The message to add to the queue.
*/ */
void ssh_message_queue(ssh_session session, ssh_message message){ void ssh_message_queue(ssh_session session, ssh_message message){
int ret;
if (message != NULL) { if (message != NULL) {
#ifdef WITH_SERVER
int ret;
/* probably not the best place to execute server callbacks, but still better /* probably not the best place to execute server callbacks, but still better
* than nothing. * than nothing.
*/ */
@@ -304,6 +307,7 @@ void ssh_message_queue(ssh_session session, ssh_message message){
ssh_message_free(message); ssh_message_free(message);
return; return;
} }
#endif /* WITH_SERVER */
if(session->ssh_message_callback != NULL) { if(session->ssh_message_callback != NULL) {
ssh_execute_message_callback(session, message); ssh_execute_message_callback(session, message);
return; return;
@@ -477,6 +481,8 @@ void ssh_message_free(ssh_message msg){
SAFE_FREE(msg); SAFE_FREE(msg);
} }
#ifdef WITH_SERVER
SSH_PACKET_CALLBACK(ssh_packet_service_request){ SSH_PACKET_CALLBACK(ssh_packet_service_request){
ssh_string service = NULL; ssh_string service = NULL;
char *service_c = NULL; char *service_c = NULL;
@@ -888,6 +894,7 @@ end:
return SSH_PACKET_USED; return SSH_PACKET_USED;
} }
#endif /* WITH_SERVER */
/** /**
* @internal * @internal
* *
@@ -902,7 +909,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
(void)user; (void)user;
return SSH_PACKET_USED; return SSH_PACKET_USED;
} }
#else #else /* WITH_SERVER */
SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
uint32_t nanswers; uint32_t nanswers;
uint32_t i; uint32_t i;
@@ -1011,7 +1018,7 @@ error:
leave_function(); leave_function();
return SSH_PACKET_USED; return SSH_PACKET_USED;
} }
#endif #endif /* WITH_SERVER */
SSH_PACKET_CALLBACK(ssh_packet_channel_open){ SSH_PACKET_CALLBACK(ssh_packet_channel_open){
ssh_message msg = NULL; ssh_message msg = NULL;

View File

@@ -55,7 +55,11 @@ static ssh_packet_callback default_packet_handlers[]= {
ssh_packet_ignore_callback, // SSH2_MSG_IGNORE 2 ssh_packet_ignore_callback, // SSH2_MSG_IGNORE 2
ssh_packet_unimplemented, // SSH2_MSG_UNIMPLEMENTED 3 ssh_packet_unimplemented, // SSH2_MSG_UNIMPLEMENTED 3
ssh_packet_ignore_callback, // SSH2_MSG_DEBUG 4 ssh_packet_ignore_callback, // SSH2_MSG_DEBUG 4
#if WITH_SERVER
ssh_packet_service_request, // SSH2_MSG_SERVICE_REQUEST 5 ssh_packet_service_request, // SSH2_MSG_SERVICE_REQUEST 5
#else
NULL,
#endif
ssh_packet_service_accept, // SSH2_MSG_SERVICE_ACCEPT 6 ssh_packet_service_accept, // SSH2_MSG_SERVICE_ACCEPT 6
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, // 7-19 NULL, NULL, NULL, NULL, NULL, NULL, // 7-19
@@ -77,7 +81,11 @@ static ssh_packet_callback default_packet_handlers[]= {
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, // 35-49 NULL, // 35-49
#if WITH_SERVER
ssh_packet_userauth_request, // SSH2_MSG_USERAUTH_REQUEST 50 ssh_packet_userauth_request, // SSH2_MSG_USERAUTH_REQUEST 50
#else
NULL,
#endif
ssh_packet_userauth_failure, // SSH2_MSG_USERAUTH_FAILURE 51 ssh_packet_userauth_failure, // SSH2_MSG_USERAUTH_FAILURE 51
ssh_packet_userauth_success, // SSH2_MSG_USERAUTH_SUCCESS 52 ssh_packet_userauth_success, // SSH2_MSG_USERAUTH_SUCCESS 52
ssh_packet_userauth_banner, // SSH2_MSG_USERAUTH_BANNER 53 ssh_packet_userauth_banner, // SSH2_MSG_USERAUTH_BANNER 53
@@ -92,11 +100,11 @@ static ssh_packet_callback default_packet_handlers[]= {
NULL, // SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63 NULL, // SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63
NULL, // SSH2_MSG_USERAUTH_GSSAPI_ERROR 64 NULL, // SSH2_MSG_USERAUTH_GSSAPI_ERROR 64
NULL, // SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65 NULL, // SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65
#ifdef WITH_GSSAPI #if WITH_GSSAPI && WITH_SERVER
ssh_packet_userauth_gssapi_mic, // SSH2_MSG_USERAUTH_GSSAPI_MIC 66 ssh_packet_userauth_gssapi_mic, // SSH2_MSG_USERAUTH_GSSAPI_MIC 66
#else /* WITH_GSSAPI */ #else /* WITH_GSSAPI && WITH_SERVER */
NULL, NULL,
#endif /* WITH_GSSAPI */ #endif /* WITH_GSSAPI && WITH_SERVER */
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, // 67-79 NULL, NULL, NULL, NULL, // 67-79