blueprint: don't create group with the same as one of the users

This commit is contained in:
Ondřej Budai 2019-10-31 18:51:53 +01:00 committed by Tom Gundersen
parent dc359fca3a
commit 4b546f1bbf

View file

@ -3,6 +3,7 @@ package blueprint
import (
"github.com/osbuild/osbuild-composer/internal/crypt"
"github.com/osbuild/osbuild-composer/internal/pipeline"
"log"
"strconv"
"strings"
)
@ -111,9 +112,13 @@ func (c *Customizations) customizeGroup(p *pipeline.Pipeline) {
return
}
// TODO: lorax-composer doesn't create group with the same name as user if both specified
groups := make(map[string]pipeline.GroupsStageOptionsGroup)
for _, group := range c.Group {
if userCustomizationsContainUsername(c.User, group.Name) {
log.Println("group with name ", group.Name, " was not created, because user with same name was defined!")
continue
}
groupData := pipeline.GroupsStageOptionsGroup{}
if group.GID != nil {
gid := strconv.Itoa(*group.GID)
@ -314,3 +319,13 @@ func findKeysForUser(sshKeyCustomizations []SSHKeyCustomization, user string) (k
}
return
}
func userCustomizationsContainUsername(userCustomizations []UserCustomization, name string) bool {
for _, usr := range userCustomizations {
if usr.Name == name {
return true
}
}
return false
}