Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions lib/services/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,19 +270,20 @@ func validateRule(r types.Rule) error {
}

func filterInvalidUnixLogins(candidates []string) []string {
// The tests for `ApplyTraits()` require that an empty list is nil
// rather than a 0-size slice, and I don't understand the potential
// knock-on effects of changing that, so the default value is `nil`
output := []string(nil)
var output []string

for _, candidate := range candidates {
if !cstrings.IsValidUnixUser(candidate) {
log.Debugf("Skipping login %v, not a valid Unix login.", candidate)
if cstrings.IsValidUnixUser(candidate) {
// A valid variable was found in the traits, append it to the list of logins.
output = append(output, candidate)
continue
}

// A valid variable was found in the traits, append it to the list of logins.
output = append(output, candidate)
// Log any invalid logins which were added by a user but ignore any
// Teleport internal logins which are known to be invalid.
if candidate != teleport.SSHSessionJoinPrincipal && !strings.HasPrefix(candidate, "no-login-") {
log.Debugf("Skipping login %v, not a valid Unix login.", candidate)
}
}
return output
}
Expand Down