aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Cross <jcross@beyondtrust.com>2021-05-19 14:39:25 -0700
committerJakub Jelen <jjelen@redhat.com>2021-07-07 14:17:07 +0200
commitd1abe26be3d61156976ab9bd679a9faee6afe8fc (patch)
tree1a4c7e99b0cc3619f1d848e0c6a3a4a7a227b297 /src
parent0bee5d5e9756d8b30b47acceff6b546f194c94b1 (diff)
downloadlibssh-master.tar.gz
libssh-master.tar.xz
libssh-master.zip
[#48/T22] Added missing server reply on auth-agent-req when a reply was requested by the client. PuTTY for Windows chokes without this reply if "Allow agent forwarding" is enabled. Reply will be successful if channel_auth_agent_req_function callback is defined. Based on an unmerged patch by Jon Simons.HEADmaster
Signed-off-by: Jeremy Cross <jcross@beyondtrust.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/channels.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/channels.c b/src/channels.c
index 112a38f9..8d812477 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -717,7 +717,7 @@ SSH_PACKET_CALLBACK(channel_rcv_close) {
SSH_PACKET_CALLBACK(channel_rcv_request) {
ssh_channel channel;
char *request=NULL;
- uint8_t status;
+ uint8_t want_reply;
int rc;
(void)user;
(void)type;
@@ -730,7 +730,7 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
rc = ssh_buffer_unpack(packet, "sb",
&request,
- &status);
+ &want_reply);
if (rc != SSH_OK) {
SSH_LOG(SSH_LOG_PACKET, "Invalid MSG_CHANNEL_REQUEST");
return SSH_PACKET_USED;
@@ -838,13 +838,34 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
}
if (strcmp(request, "auth-agent-req@openssh.com") == 0) {
+ int status;
+
SAFE_FREE(request);
SSH_LOG(SSH_LOG_PROTOCOL, "Received an auth-agent-req request");
- ssh_callbacks_execute_list(channel->callbacks,
- ssh_channel_callbacks,
- channel_auth_agent_req_function,
- channel->session,
- channel);
+
+ status = SSH2_MSG_CHANNEL_FAILURE;
+ ssh_callbacks_iterate(channel->callbacks,
+ ssh_channel_callbacks,
+ channel_auth_agent_req_function) {
+ ssh_callbacks_iterate_exec(channel_auth_agent_req_function,
+ channel->session,
+ channel);
+ /* in lieu of a return value, if the callback exists it's supported */
+ status = SSH2_MSG_CHANNEL_SUCCESS;
+ break;
+ }
+ ssh_callbacks_iterate_end();
+
+ if (want_reply) {
+ rc = ssh_buffer_pack(session->out_buffer,
+ "bd",
+ status,
+ channel->remote_channel);
+ if (rc != SSH_OK) {
+ return SSH_PACKET_USED;
+ }
+ ssh_packet_send(session);
+ }
return SSH_PACKET_USED;
}
@@ -853,7 +874,7 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
* client requests. That means we need to create a ssh message to be passed
* 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,want_reply);
#else
SSH_LOG(SSH_LOG_WARNING, "Unhandled channel request %s", request);
#endif