messages: Invoke callbacks also for no-more-sessions

Improve also logging and send reply only if requested for keepalive@openssh.com

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
This commit is contained in:
Jakub Jelen
2024-07-18 16:52:31 +02:00
committed by Sahana Prasad
parent 716950fc9e
commit bd091239d3

View File

@@ -1665,11 +1665,15 @@ SSH_PACKET_CALLBACK(ssh_packet_global_request)
want_reply);
if (ssh_callbacks_exists(session->common.callbacks,
global_request_function)) {
SSH_LOG(SSH_LOG_DEBUG,
"Calling callback for SSH_MSG_GLOBAL_REQUEST %s %hhu",
request,
want_reply);
session->common.callbacks->global_request_function(
session,
msg,
session->common.callbacks->userdata);
} else {
} else if (want_reply) {
ssh_message_global_request_reply_success(msg, 0);
}
} else if (strcmp(request, "no-more-sessions@openssh.com") == 0) {
@@ -1679,8 +1683,17 @@ SSH_PACKET_CALLBACK(ssh_packet_global_request)
SSH_LOG(SSH_LOG_PROTOCOL,
"Received no-more-sessions@openssh.com %hhu",
want_reply);
if (want_reply) {
if (ssh_callbacks_exists(session->common.callbacks,
global_request_function)) {
SSH_LOG(SSH_LOG_DEBUG,
"Calling callback for SSH_MSG_GLOBAL_REQUEST %s %hhu",
request,
want_reply);
session->common.callbacks->global_request_function(
session,
msg,
session->common.callbacks->userdata);
} else if (want_reply) {
ssh_message_global_request_reply_success(msg, 0);
}