Skip to content

Commit c85d2b0

Browse files
committed
HACK: work around issue with core user creation in FCOS
There is currently a bug where if the core user is created via Ignition it is not added to the correct set of groups. This completely blocks kola from running as the core user is not directly added to the sudoers file with NOPASSWD but rather inherits it from the sudo group. Temporarily work around it until a fix lands. Upstream tracking ticket: coreos/fedora-coreos-config#41
1 parent a08948a commit c85d2b0

File tree

4 files changed

+120
-5
lines changed

4 files changed

+120
-5
lines changed

kola/tests/ignition/passwd.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func init() {
175175
]
176176
}
177177
}`),
178-
Distros: []string{"rhcos", "fcos"},
178+
Distros: []string{"rhcos"},
179179
})
180180
register.Register(&register.Test{
181181
Name: "rhcos.ignition.v2.users",
@@ -203,7 +203,7 @@ func init() {
203203
]
204204
}
205205
}`),
206-
Distros: []string{"rhcos", "fcos"},
206+
Distros: []string{"rhcos"},
207207
})
208208
}
209209

kola/tests/misc/selinux.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ func init() {
3333
Run: SelinuxBoolean,
3434
ClusterSize: 1,
3535
Name: "coreos.selinux.boolean",
36-
Distros: []string{"cl", "rhcos", "fcos"},
36+
Distros: []string{"cl", "rhcos"},
3737
})
3838
register.Register(&register.Test{
3939
Run: SelinuxBooleanPersist,
4040
ClusterSize: 1,
4141
Name: "rhcos.selinux.boolean.persist",
42-
Distros: []string{"rhcos", "fcos"},
42+
Distros: []string{"rhcos"},
4343
})
4444
register.Register(&register.Test{
4545
Run: SelinuxManage,
4646
ClusterSize: 1,
4747
Name: "rhcos.selinux.manage",
48-
Distros: []string{"rhcos", "fcos"},
48+
Distros: []string{"rhcos"},
4949
})
5050
}
5151

platform/conf/conf.go

+114
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,120 @@ func (c *Conf) CopyKeys(keys []*agent.Key) {
616616
}
617617
}
618618

619+
// HACK: Adds list of groups to core user
620+
func (c *Conf) AddGroups(groups []string) {
621+
if c.ignitionV1 != nil {
622+
c.addGroupsIgnitionV1(groups)
623+
} else if c.ignitionV2 != nil {
624+
c.addGroupsIgnitionV2(groups)
625+
} else if c.ignitionV21 != nil {
626+
c.addGroupsIgnitionV21(groups)
627+
} else if c.ignitionV22 != nil {
628+
c.addGroupsIgnitionV22(groups)
629+
} else if c.ignitionV23 != nil {
630+
c.addGroupsIgnitionV23(groups)
631+
}
632+
}
633+
634+
func (c *Conf) addGroupsIgnitionV1(groups []string) {
635+
for i := range c.ignitionV1.Passwd.Users {
636+
user := &c.ignitionV1.Passwd.Users[i]
637+
if user.Name == "core" {
638+
if user.Create != nil {
639+
user.Create.Groups = append(user.Create.Groups, groups...)
640+
return
641+
} else {
642+
user.Create = &v1types.UserCreate{
643+
Groups: groups,
644+
}
645+
}
646+
}
647+
}
648+
c.ignitionV1.Passwd.Users = append(c.ignitionV1.Passwd.Users, v1types.User{
649+
Name: "core",
650+
Create: &v1types.UserCreate{
651+
Groups: groups,
652+
},
653+
})
654+
}
655+
656+
func (c *Conf) addGroupsIgnitionV2(groups []string) {
657+
for i := range c.ignitionV2.Passwd.Users {
658+
user := &c.ignitionV2.Passwd.Users[i]
659+
if user.Name == "core" {
660+
if user.Create != nil {
661+
user.Create.Groups = append(user.Create.Groups, groups...)
662+
return
663+
} else {
664+
user.Create = &v2types.UserCreate{
665+
Groups: groups,
666+
}
667+
return
668+
}
669+
}
670+
}
671+
c.ignitionV2.Passwd.Users = append(c.ignitionV2.Passwd.Users, v2types.User{
672+
Name: "core",
673+
Create: &v2types.UserCreate{
674+
Groups: groups,
675+
},
676+
})
677+
}
678+
679+
func (c *Conf) addGroupsIgnitionV21(groups []string) {
680+
var groupObjs []v21types.PasswdUserGroup
681+
for _, group := range groups {
682+
groupObjs = append(groupObjs, v21types.PasswdUserGroup(group))
683+
}
684+
for i := range c.ignitionV21.Passwd.Users {
685+
user := &c.ignitionV21.Passwd.Users[i]
686+
if user.Name == "core" {
687+
user.Groups = append(user.Groups, groupObjs...)
688+
return
689+
}
690+
}
691+
c.ignitionV21.Passwd.Users = append(c.ignitionV21.Passwd.Users, v21types.PasswdUser{
692+
Name: "core",
693+
Groups: groupObjs,
694+
})
695+
}
696+
697+
func (c *Conf) addGroupsIgnitionV22(groups []string) {
698+
var groupObjs []v22types.Group
699+
for _, group := range groups {
700+
groupObjs = append(groupObjs, v22types.Group(group))
701+
}
702+
for i := range c.ignitionV22.Passwd.Users {
703+
user := &c.ignitionV22.Passwd.Users[i]
704+
if user.Name == "core" {
705+
user.Groups = append(user.Groups, groupObjs...)
706+
return
707+
}
708+
}
709+
c.ignitionV22.Passwd.Users = append(c.ignitionV22.Passwd.Users, v22types.PasswdUser{
710+
Name: "core",
711+
Groups: groupObjs,
712+
})
713+
}
714+
715+
func (c *Conf) addGroupsIgnitionV23(groups []string) {
716+
var groupObjs []v23types.Group
717+
for _, group := range groups {
718+
groupObjs = append(groupObjs, v23types.Group(group))
719+
}
720+
for i := range c.ignitionV23.Passwd.Users {
721+
user := &c.ignitionV23.Passwd.Users[i]
722+
if user.Name == "core" {
723+
user.Groups = append(user.Groups, groupObjs...)
724+
return
725+
}
726+
}
727+
c.ignitionV23.Passwd.Users = append(c.ignitionV23.Passwd.Users, v23types.PasswdUser{
728+
Name: "core",
729+
Groups: groupObjs,
730+
})
731+
}
732+
619733
func keysToStrings(keys []*agent.Key) (keyStrs []string) {
620734
for _, key := range keys {
621735
keyStrs = append(keyStrs, key.String())

platform/machine/unprivqemu/cluster.go

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func (qc *Cluster) NewMachineWithOptions(userdata *conf.UserData, options Machin
7272
}
7373
qc.mu.Unlock()
7474

75+
conf.AddGroups([]string{"wheel", "sudo", "adm", "systemd-journal"})
7576
var confPath string
7677
if conf.IsIgnition() {
7778
confPath = filepath.Join(dir, "ignition.json")

0 commit comments

Comments
 (0)