From 4b546f1bbfa3c0ef9e6556349d9ef822d2b2b4d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Thu, 31 Oct 2019 18:51:53 +0100 Subject: [PATCH] blueprint: don't create group with the same as one of the users --- internal/blueprint/customizations.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/internal/blueprint/customizations.go b/internal/blueprint/customizations.go index 7497c202d..44243a5db 100644 --- a/internal/blueprint/customizations.go +++ b/internal/blueprint/customizations.go @@ -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 +}