Fix exclude-users-regex option

When a session User matches the exclude-users-regex pattern, it is
probably not found in exclude-users list.

The current OR condition makes the user filtered.

We expect a AND condition here (user not in exclude-users AND not in
exclude-users-regex)

Signed-off-by: Nicolas Payart <npayart@gmail.com>
This commit is contained in:
Nicolas Payart 2021-10-19 09:11:31 +02:00
parent d402c3bea7
commit 0bb792a0ea

View file

@ -81,7 +81,7 @@ func (t *Terminator) filterUsers(sessions []*base.Session) (filtered []*base.Ses
for _, session := range sessions {
if t.config.IncludeUsers == nil && includeRegex == nil {
// append all sessions except excluded users
if !base.InSlice(session.User, excludeUsers) || (excludeRegex != nil && !excludeRegex.MatchString(session.User)) {
if !base.InSlice(session.User, excludeUsers) && (excludeRegex != nil && !excludeRegex.MatchString(session.User)) {
filtered = append(filtered, session)
}
} else {