Update recently added logging to be less verbose

In 20d9642c and parent commits, log levels were
recategorized to be less verbose when using the
level INFO and lower. These levels should not
print any information redundant to the end user.

This commit fixes recently added uses of logging
that are not consistent with the abovementioned
categorization, in particular:

- logs in ssh_strict_fopen should not have
  the RARE/WARNING level since failing to open
  a file may not be an issue at all (e.g., when
  trying to open the knownhosts file).

- logging the username used in authentication
  or proxyjump-related information should be done
  at the DEBUG level, otherwise it could pollute
  the output of, e.g., curl.

Signed-off-by: Pavol Žáčik <pzacik@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Pavol Žáčik
2026-02-19 10:03:28 +01:00
committed by Jakub Jelen
parent f8cba20859
commit a7fd80795e
4 changed files with 11 additions and 9 deletions

View File

@@ -1397,7 +1397,7 @@ int ssh_userauth_publickey_auto(ssh_session session,
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }
SSH_LOG(SSH_LOG_INFO, SSH_LOG(SSH_LOG_DEBUG,
"Starting authentication as a user %s", "Starting authentication as a user %s",
username ? username : session->opts.username); username ? username : session->opts.username);

View File

@@ -258,7 +258,9 @@ local_parse_file(ssh_session session,
f = ssh_strict_fopen(filename, SSH_MAX_CONFIG_FILE_SIZE); f = ssh_strict_fopen(filename, SSH_MAX_CONFIG_FILE_SIZE);
if (f == NULL) { if (f == NULL) {
/* The underlying function logs the reasons */ SSH_LOG(SSH_LOG_RARE,
"Failed to open included configuration file %s",
filename);
return; return;
} }

View File

@@ -2454,7 +2454,7 @@ FILE *ssh_strict_fopen(const char *filename, size_t max_file_size)
/* open first to avoid TOCTOU */ /* open first to avoid TOCTOU */
fd = open(filename, O_RDONLY); fd = open(filename, O_RDONLY);
if (fd == -1) { if (fd == -1) {
SSH_LOG(SSH_LOG_RARE, SSH_LOG(SSH_LOG_TRACE,
"Failed to open a file %s for reading: %s", "Failed to open a file %s for reading: %s",
filename, filename,
ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX)); ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
@@ -2464,7 +2464,7 @@ FILE *ssh_strict_fopen(const char *filename, size_t max_file_size)
/* Check the file is sensible for a configuration file */ /* Check the file is sensible for a configuration file */
r = fstat(fd, &sb); r = fstat(fd, &sb);
if (r != 0) { if (r != 0) {
SSH_LOG(SSH_LOG_RARE, SSH_LOG(SSH_LOG_TRACE,
"Failed to stat %s: %s", "Failed to stat %s: %s",
filename, filename,
ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX)); ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
@@ -2472,7 +2472,7 @@ FILE *ssh_strict_fopen(const char *filename, size_t max_file_size)
return NULL; return NULL;
} }
if ((sb.st_mode & S_IFMT) != S_IFREG) { if ((sb.st_mode & S_IFMT) != S_IFREG) {
SSH_LOG(SSH_LOG_RARE, SSH_LOG(SSH_LOG_TRACE,
"The file %s is not a regular file: skipping", "The file %s is not a regular file: skipping",
filename); filename);
close(fd); close(fd);
@@ -2480,7 +2480,7 @@ FILE *ssh_strict_fopen(const char *filename, size_t max_file_size)
} }
if ((size_t)sb.st_size > max_file_size) { if ((size_t)sb.st_size > max_file_size) {
SSH_LOG(SSH_LOG_RARE, SSH_LOG(SSH_LOG_TRACE,
"The file %s is too large (%jd MB > %zu MB): skipping", "The file %s is too large (%jd MB > %zu MB): skipping",
filename, filename,
(intmax_t)sb.st_size / 1024 / 1024, (intmax_t)sb.st_size / 1024 / 1024,
@@ -2491,7 +2491,7 @@ FILE *ssh_strict_fopen(const char *filename, size_t max_file_size)
f = fdopen(fd, "r"); f = fdopen(fd, "r");
if (f == NULL) { if (f == NULL) {
SSH_LOG(SSH_LOG_RARE, SSH_LOG(SSH_LOG_TRACE,
"Failed to open a file %s for reading: %s", "Failed to open a file %s for reading: %s",
filename, filename,
ssh_strerror(r, err_msg, SSH_ERRNO_MSG_MAX)); ssh_strerror(r, err_msg, SSH_ERRNO_MSG_MAX));

View File

@@ -1435,7 +1435,7 @@ ssh_socket_connect_proxyjump(ssh_socket s)
session = s->session; session = s->session;
SSH_LOG(SSH_LOG_INFO, SSH_LOG(SSH_LOG_DEBUG,
"Connecting to host %s port %d user %s through ProxyJump", "Connecting to host %s port %d user %s through ProxyJump",
session->opts.host, session->opts.host,
session->opts.port, session->opts.port,
@@ -1515,7 +1515,7 @@ ssh_socket_connect_proxyjump(ssh_socket s)
/* transferred to the jump_thread_data */ /* transferred to the jump_thread_data */
jump_session = NULL; jump_session = NULL;
SSH_LOG(SSH_LOG_INFO, SSH_LOG(SSH_LOG_DEBUG,
"Starting proxy thread to host %s port %d user %s, callbacks=%p", "Starting proxy thread to host %s port %d user %s, callbacks=%p",
jump_thread_data->next_jump->hostname, jump_thread_data->next_jump->hostname,
jump_thread_data->next_jump->port, jump_thread_data->next_jump->port,