mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
agent: Improve logging.
This commit is contained in:
23
src/agent.c
23
src/agent.c
@@ -211,19 +211,19 @@ static int agent_talk(struct ssh_session_struct *session,
|
||||
uint8_t payload[1024] = {0};
|
||||
|
||||
len = buffer_get_rest_len(request);
|
||||
ssh_log(session, SSH_LOG_PACKET, "agent_talk - len of request: %u", len);
|
||||
SSH_LOG(session, SSH_LOG_TRACE, "Request length: %u", len);
|
||||
agent_put_u32(payload, len);
|
||||
|
||||
/* send length and then the request packet */
|
||||
if (atomicio(session->agent->sock, payload, 4, 0) == 4) {
|
||||
if (atomicio(session->agent->sock, buffer_get_rest(request), len, 0)
|
||||
!= len) {
|
||||
ssh_log(session, SSH_LOG_PACKET, "atomicio sending request failed: %s",
|
||||
SSH_LOG(session, SSH_LOG_WARN, "atomicio sending request failed: %s",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
ssh_log(session, SSH_LOG_PACKET,
|
||||
SSH_LOG(session, SSH_LOG_WARN,
|
||||
"atomicio sending request length failed: %s",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
@@ -231,7 +231,7 @@ static int agent_talk(struct ssh_session_struct *session,
|
||||
|
||||
/* wait for response, read the length of the response packet */
|
||||
if (atomicio(session->agent->sock, payload, 4, 1) != 4) {
|
||||
ssh_log(session, SSH_LOG_PACKET, "atomicio read response length failed: %s",
|
||||
SSH_LOG(session, SSH_LOG_WARN, "atomicio read response length failed: %s",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
@@ -242,7 +242,7 @@ static int agent_talk(struct ssh_session_struct *session,
|
||||
"Authentication response too long: %u", len);
|
||||
return -1;
|
||||
}
|
||||
ssh_log(session, SSH_LOG_PACKET, "agent_talk - response length: %u", len);
|
||||
SSH_LOG(session, SSH_LOG_TRACE, "Response length: %u", len);
|
||||
|
||||
while (len > 0) {
|
||||
size_t n = len;
|
||||
@@ -250,13 +250,12 @@ static int agent_talk(struct ssh_session_struct *session,
|
||||
n = sizeof(payload);
|
||||
}
|
||||
if (atomicio(session->agent->sock, payload, n, 1) != n) {
|
||||
ssh_log(session, SSH_LOG_RARE,
|
||||
SSH_LOG(session, SSH_LOG_WARN,
|
||||
"Error reading response from authentication socket.");
|
||||
return -1;
|
||||
}
|
||||
if (buffer_add_data(reply, payload, n) < 0) {
|
||||
ssh_log(session, SSH_LOG_FUNCTIONS,
|
||||
"Not enough space");
|
||||
SSH_LOG(session, SSH_LOG_WARN, "Not enough space");
|
||||
return -1;
|
||||
}
|
||||
len -= n;
|
||||
@@ -306,8 +305,8 @@ int ssh_agent_get_ident_count(struct ssh_session_struct *session) {
|
||||
|
||||
/* get message type and verify the answer */
|
||||
buffer_get_u8(reply, (uint8_t *) &type);
|
||||
ssh_log(session, SSH_LOG_PACKET,
|
||||
"agent_ident_count - answer type: %d, expected answer: %d",
|
||||
SSH_LOG(session, SSH_LOG_WARN,
|
||||
"Answer type: %d, expected answer: %d",
|
||||
type, c2);
|
||||
if (agent_failed(type)) {
|
||||
return 0;
|
||||
@@ -319,7 +318,7 @@ int ssh_agent_get_ident_count(struct ssh_session_struct *session) {
|
||||
|
||||
buffer_get_u32(reply, (uint32_t *) buf);
|
||||
session->agent->count = agent_get_u32(buf);
|
||||
ssh_log(session, SSH_LOG_PACKET, "agent_ident_count - count: %d",
|
||||
SSH_LOG(session, SSH_LOG_DEBUG, "Agent count: %d",
|
||||
session->agent->count);
|
||||
if (session->agent->count > 1024) {
|
||||
ssh_set_error(session, SSH_FATAL,
|
||||
@@ -492,7 +491,7 @@ ssh_string ssh_agent_sign_data(ssh_session session,
|
||||
}
|
||||
|
||||
if (agent_failed(type)) {
|
||||
ssh_log(session, SSH_LOG_RARE, "Agent reports failure in signing the key");
|
||||
SSH_LOG(session, SSH_LOG_WARN, "Agent reports failure in signing the key");
|
||||
ssh_buffer_free(reply);
|
||||
return NULL;
|
||||
} else if (type != SSH2_AGENT_SIGN_RESPONSE) {
|
||||
|
||||
Reference in New Issue
Block a user