Skip to content

Commit

Permalink
fix panic child.Close() called without logger initialized (#11117)
Browse files Browse the repository at this point in the history
  • Loading branch information
greedy52 committed Jun 27, 2022
1 parent a24cbcb commit 43f00b8
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/srv/ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,18 @@ func NewServerContext(ctx context.Context, parent *sshutils.ConnectionContext, s
cancel: cancel,
}

fields := log.Fields{
"local": child.ServerConn.LocalAddr(),
"remote": child.ServerConn.RemoteAddr(),
"login": child.Identity.Login,
"teleportUser": child.Identity.TeleportUser,
"id": child.id,
}
child.Entry = log.WithFields(log.Fields{
trace.Component: child.srv.Component(),
trace.ComponentFields: fields,
})

authPref, err := srv.GetAccessPoint().GetAuthPreference(ctx)
if err != nil {
childErr := child.Close()
Expand All @@ -332,13 +344,7 @@ func NewServerContext(ctx context.Context, parent *sshutils.ConnectionContext, s
child.disconnectExpiredCert = identityContext.CertValidBefore
}

fields := log.Fields{
"local": child.ServerConn.LocalAddr(),
"remote": child.ServerConn.RemoteAddr(),
"login": child.Identity.Login,
"teleportUser": child.Identity.TeleportUser,
"id": child.id,
}
// Update log entry fields.
if !child.disconnectExpiredCert.IsZero() {
fields["cert"] = child.disconnectExpiredCert
}
Expand Down

0 comments on commit 43f00b8

Please sign in to comment.