1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

server: Implement X11 requests and window-change

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Aris Adamantiadis
2013-04-02 20:32:39 +02:00
committed by Andreas Schneider
parent 37cce98f7e
commit f457080d62
2 changed files with 62 additions and 2 deletions

View File

@@ -456,6 +456,7 @@ typedef void (*ssh_channel_exit_signal_callback) (ssh_session session,
/** /**
* @brief SSH channel PTY request from a client. * @brief SSH channel PTY request from a client.
* @param channel the channel * @param channel the channel
* @param term The type of terminal emulation
* @param width width of the terminal, in characters * @param width width of the terminal, in characters
* @param height height of the terminal, in characters * @param height height of the terminal, in characters
* @param pxwidth width of the terminal, in pixels * @param pxwidth width of the terminal, in pixels
@@ -488,9 +489,41 @@ typedef int (*ssh_channel_shell_request_callback) (ssh_session session,
* @param channel the channel * @param channel the channel
* @param userdata Userdata to be passed to the callback function. * @param userdata Userdata to be passed to the callback function.
*/ */
typedef void (*channel_auth_agent_req_callback) (ssh_session session, typedef void (*ssh_channel_auth_agent_req_callback) (ssh_session session,
ssh_channel channel, ssh_channel channel,
void *userdata); void *userdata);
/**
* @brief SSH X11 request from the client. This request is
* sent by a client when X11 forwarding is requested(and available).
* Server is free to ignore this callback, no answer is expected.
* @param channel the channel
* @param userdata Userdata to be passed to the callback function.
*/
typedef void (*ssh_channel_x11_req_callback) (ssh_session session,
ssh_channel channel,
int single_connection,
const char *auth_protocol,
const char *auth_cookie,
uint32_t screen_number,
void *userdata);
/**
* @brief SSH channel PTY windows change (terminal size) from a client.
* @param channel the channel
* @param width width of the terminal, in characters
* @param height height of the terminal, in characters
* @param pxwidth width of the terminal, in pixels
* @param pxheight height of the terminal, in pixels
* @param userdata Userdata to be passed to the callback function.
* @returns 0 if the pty request is accepted
* @returns -1 if the request is denied
*/
typedef int (*ssh_channel_pty_window_change_callback) (ssh_session session,
ssh_channel channel,
int width, int height,
int pxwidth, int pwheight,
void *userdata);
struct ssh_channel_callbacks_struct { struct ssh_channel_callbacks_struct {
/** DON'T SET THIS use ssh_callbacks_init() instead. */ /** DON'T SET THIS use ssh_callbacks_init() instead. */
size_t size; size_t size;
@@ -533,7 +566,16 @@ struct ssh_channel_callbacks_struct {
/** This function will be called when a client requests agent /** This function will be called when a client requests agent
* authentication forwarding. * authentication forwarding.
*/ */
channel_auth_agent_req_callback channel_auth_agent_req_function; ssh_channel_auth_agent_req_callback channel_auth_agent_req_function;
/** This function will be called when a client requests X11
* forwarding.
*/
ssh_channel_x11_req_callback channel_x11_req_function;
/** This function will be called when a client requests a
* window change.
*/
ssh_channel_pty_window_change_callback channel_pty_window_change_function;
}; };
typedef struct ssh_channel_callbacks_struct *ssh_channel_callbacks; typedef struct ssh_channel_callbacks_struct *ssh_channel_callbacks;

View File

@@ -158,6 +158,24 @@ 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.type == SSH_CHANNEL_REQUEST_X11){
if(ssh_callbacks_exists(channel->callbacks, channel_x11_req_function)){
channel->callbacks->channel_x11_req_function(session, channel,
msg->channel_request.x11_single_connection,
msg->channel_request.x11_auth_protocol,
msg->channel_request.x11_auth_cookie,
msg->channel_request.x11_screen_number,
channel->callbacks->userdata);
ssh_message_channel_request_reply_success(msg);
return SSH_OK;
}
} else if (msg->channel_request.type == SSH_CHANNEL_REQUEST_WINDOW_CHANGE){
if(ssh_callbacks_exists(channel->callbacks, channel_pty_window_change_function)){
rc = channel->callbacks->channel_pty_window_change_function(session, channel,
msg->channel_request.height, msg->channel_request.width,
msg->channel_request.pxheight, msg->channel_request.pxwidth,
channel->callbacks->userdata);
}
} }
break; break;
case SSH_REQUEST_SERVICE: case SSH_REQUEST_SERVICE: