mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
client: handle x11 channel open requests with callbacks
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
f457080d62
commit
3e7bd72f76
@@ -94,6 +94,19 @@ typedef void (*ssh_status_callback) (ssh_session session, float status,
|
|||||||
typedef void (*ssh_global_request_callback) (ssh_session session,
|
typedef void (*ssh_global_request_callback) (ssh_session session,
|
||||||
ssh_message message, void *userdata);
|
ssh_message message, void *userdata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Handles an SSH new channel open X11 request. This happens when the server
|
||||||
|
* sends back an X11 connection attempt. This is a client-side API
|
||||||
|
* @param session current session handler
|
||||||
|
* @param userdata Userdata to be passed to the callback function.
|
||||||
|
* @returns a valid ssh_channel handle if the request is to be allowed
|
||||||
|
* @returns NULL if the request should not be allowed
|
||||||
|
* @warning The channel pointer returned by this callback must be closed by the application.
|
||||||
|
*/
|
||||||
|
typedef ssh_channel (*ssh_channel_open_request_x11_callback) (ssh_session session,
|
||||||
|
const char * originator_address, int originator_port, void *userdata);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The structure to replace libssh functions with appropriate callbacks.
|
* The structure to replace libssh functions with appropriate callbacks.
|
||||||
*/
|
*/
|
||||||
@@ -121,6 +134,10 @@ struct ssh_callbacks_struct {
|
|||||||
* This function will be called each time a global request is received.
|
* This function will be called each time a global request is received.
|
||||||
*/
|
*/
|
||||||
ssh_global_request_callback global_request_function;
|
ssh_global_request_callback global_request_function;
|
||||||
|
/** This function will be called when an incoming X11 request is received.
|
||||||
|
*/
|
||||||
|
ssh_channel_open_request_x11_callback channel_open_request_x11_function;
|
||||||
|
|
||||||
};
|
};
|
||||||
typedef struct ssh_callbacks_struct *ssh_callbacks;
|
typedef struct ssh_callbacks_struct *ssh_callbacks;
|
||||||
|
|
||||||
@@ -185,7 +202,6 @@ typedef int (*ssh_service_request_callback) (ssh_session session, const char *se
|
|||||||
*/
|
*/
|
||||||
typedef ssh_channel (*ssh_channel_open_request_session_callback) (ssh_session session, void *userdata);
|
typedef ssh_channel (*ssh_channel_open_request_session_callback) (ssh_session session, void *userdata);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This structure can be used to implement a libssh server, with appropriate callbacks.
|
* This structure can be used to implement a libssh server, with appropriate callbacks.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -130,6 +130,19 @@ static int ssh_execute_server_callbacks(ssh_session session, ssh_message msg){
|
|||||||
ssh_message_reply_default(msg);
|
ssh_message_reply_default(msg);
|
||||||
}
|
}
|
||||||
return SSH_OK;
|
return SSH_OK;
|
||||||
|
} else if (msg->channel_request_open.type == SSH_CHANNEL_X11){
|
||||||
|
if(ssh_callbacks_exists(session->common.callbacks, channel_open_request_x11_function)){
|
||||||
|
channel = session->common.callbacks->channel_open_request_x11_function (session,
|
||||||
|
msg->channel_request_open.originator, msg->channel_request_open.originator_port,
|
||||||
|
session->common.callbacks->userdata);
|
||||||
|
if(channel != NULL) {
|
||||||
|
rc = ssh_message_channel_request_open_reply_accept_channel(msg, channel);
|
||||||
|
return SSH_OK;
|
||||||
|
} else {
|
||||||
|
ssh_message_reply_default(msg);
|
||||||
|
}
|
||||||
|
return SSH_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user