client: handle agent forward open requests with callbacks

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Aris Adamantiadis <aris@badcode.be>
This commit is contained in:
Fabiano Fidêncio
2015-07-02 15:29:06 +02:00
committed by Aris Adamantiadis
parent 728c2fbd01
commit 2bf6e66ffe
4 changed files with 57 additions and 1 deletions

View File

@@ -1981,6 +1981,25 @@ ssh_channel ssh_channel_accept_x11(ssh_channel channel, int timeout_ms) {
return ssh_channel_accept(channel->session, SSH_CHANNEL_X11, timeout_ms, NULL);
}
/**
* @brief Send an "auth-agent-req" channel request over an existing session channel.
*
* This client-side request will enable forwarding the agent over an secure tunnel.
* When the server is ready to open one authentication agent channel, an
* ssh_channel_open_request_auth_agent_callback event will be generated.
*
* @param[in] channel The channel to send signal.
*
* @return SSH_OK on success, SSH_ERROR if an error occurred
*/
int ssh_channel_request_auth_agent(ssh_channel channel) {
if (channel == NULL) {
return SSH_ERROR;
}
return channel_request(channel, "auth-agent-req@openssh.com", NULL, 0);
}
/**
* @internal
*

View File

@@ -293,6 +293,21 @@ static int ssh_execute_client_request(ssh_session session, ssh_message msg)
ssh_message_reply_default(msg);
}
return SSH_OK;
} else if (msg->type == SSH_REQUEST_CHANNEL_OPEN
&& msg->channel_request_open.type == SSH_CHANNEL_AUTH_AGENT
&& ssh_callbacks_exists(session->common.callbacks, channel_open_request_auth_agent_function)) {
channel = session->common.callbacks->channel_open_request_auth_agent_function (session,
session->common.callbacks->userdata);
if (channel != NULL) {
rc = ssh_message_channel_request_open_reply_accept_channel(msg, channel);
return rc;
} else {
ssh_message_reply_default(msg);
}
return SSH_OK;
}
@@ -1070,6 +1085,11 @@ SSH_PACKET_CALLBACK(ssh_packet_channel_open){
goto end;
}
if (strcmp(type_c,"auth-agent@openssh.com") == 0) {
msg->channel_request_open.type = SSH_CHANNEL_AUTH_AGENT;
goto end;
}
msg->channel_request_open.type = SSH_CHANNEL_UNKNOWN;
goto end;