username logging fix (#762)

* initial pass at including username from sftp

* initialize user to unknown

* update tests

* fix spacing

* fix test take 2
This commit is contained in:
Tess Gauthier 2024-11-21 16:42:02 -05:00 committed by GitHub
parent 27f6cfa7b0
commit 0dd6d2cd21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 7 deletions

View File

@ -483,14 +483,14 @@ monitor_read_log(struct monitor *pmonitor)
/*log it*/ /*log it*/
if (authctxt->authenticated == 0) if (authctxt->authenticated == 0)
sshlogdirect(level, forced, "%s [preauth]", msg); sshlogdirect(level, forced, "user: %s: %s [preauth]", authctxt->user, msg);
else { else {
if (strcmp(pname, "sftp-server") == 0) { if (strcmp(pname, "sftp-server") == 0) {
log_init(pname, sftp_log_level, sftp_log_facility, sftp_log_stderr); log_init(pname, sftp_log_level, sftp_log_facility, sftp_log_stderr);
sshlogdirect(level, forced, "%s", msg); sshlogdirect(level, forced, "user: %s: %s", authctxt->user, msg);
log_init("sshd", options.log_level, options.log_facility, log_stderr); log_init("sshd", options.log_level, options.log_facility, log_stderr);
} else } else
sshlogdirect(level, forced, "%s", msg); sshlogdirect(level, forced, "user: %s: %s", authctxt->user, msg);
} }
#else #else
/*log it*/ /*log it*/

View File

@ -200,9 +200,9 @@ exit"
$sshdlog | Should Contain "Accepted publickey for $nonadminusername" $sshdlog | Should Contain "Accepted publickey for $nonadminusername"
$sshdlog | Should Contain "KEX done \[preauth\]" $sshdlog | Should Contain "KEX done \[preauth\]"
$sshdlog | Should Contain "debug2: subsystem request for sftp by user $nonadminusername" $sshdlog | Should Contain "debug2: user: $nonadminusername`: subsystem request for sftp by user $nonadminusername"
$sftplog | Should Contain "session opened for local user $nonadminusername" $sftplog | Should Contain "session opened for local user $nonadminusername"
$sftplog | Should Contain "debug3: request 3: opendir" $sftplog | Should Contain "debug3: user: $nonadminusername`: request 3: opendir"
$sftplog | Should Contain "session closed for local user $nonadminusername" $sftplog | Should Contain "session closed for local user $nonadminusername"
} }
@ -216,9 +216,9 @@ exit"
$sshdlog | Should Contain "Accepted publickey for $adminusername" $sshdlog | Should Contain "Accepted publickey for $adminusername"
$sshdlog | Should Contain "KEX done \[preauth\]" $sshdlog | Should Contain "KEX done \[preauth\]"
$sshdlog | Should Contain "debug2: subsystem request for sftp by user $adminusername" $sshdlog | Should Contain "debug2: user: $adminusername`: subsystem request for sftp by user $adminusername"
$sftplog | Should Contain "session opened for local user $adminusername" $sftplog | Should Contain "session opened for local user $adminusername"
$sftplog | Should Contain "debug3: request 3: opendir" $sftplog | Should Contain "debug3: user: $adminusername`: request 3: opendir"
$sftplog | Should Contain "session closed for local user $adminusername" $sftplog | Should Contain "session closed for local user $adminusername"
} }
} }