From 4fe5e9db772521e8a23efb344a9e2753471fd415 Mon Sep 17 00:00:00 2001 From: Andrei Date: Tue, 25 Jul 2017 06:59:57 -0700 Subject: [PATCH] [bugfix] update account pointer within session on reload --- lib/sshd.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/sshd.go b/lib/sshd.go index 0533dc2..bc8d3b3 100644 --- a/lib/sshd.go +++ b/lib/sshd.go @@ -131,9 +131,12 @@ func (s *SSHDState) reloadAccounts() { s.accounts = accounts s.keys = keys - // Now, iterate over sessions and close any invalid ones + // Now, iterate over all active sessions and update them, closing any sessions + // that point to now-invalid accounts. for _, session := range s.sessions { - if _, exists := accounts[session.Account.Username]; !exists { + session.Account = accounts[session.Account.Username] + + if session.Account == nil { s.log.Warn( "Closing session for user that was deleted from accounts", zap.String("username", session.Account.Username),