Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kola: Enable SELinux as early as possible #487

Open
wants to merge 1 commit into
base: flatcar-master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions cmd/kola/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func init() {
root.PersistentFlags().StringVarP(&kolaOffering, "offering", "", "basic", "Offering: "+strings.Join(kolaOfferings, ", "))
root.PersistentFlags().StringVarP(&kola.Options.Distribution, "distro", "b", "cl", "Distribution: "+strings.Join(kolaDistros, ", "))
root.PersistentFlags().IntVarP(&kola.TestParallelism, "parallel", "j", 1, "number of tests to run in parallel")
bv(&kola.LateSelinux, "late-selinux", false, "Enable SELinux only after bootup")
sv(&kola.TAPFile, "tapfile", "", "file to write TAP results to")
sv(&kola.Options.BaseName, "basename", "kola", "Cluster name prefix")
ss("debug-systemd-unit", []string{}, "full-unit-name.service to enable SYSTEMD_LOG_LEVEL=debug on. Specify multiple times for multiple units.")
Expand Down
2 changes: 2 additions & 0 deletions kola/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ var (
TestParallelism int //glue var to set test parallelism from main
TAPFile string // if not "", write TAP results here
TorcxManifestFile string // torcx manifest to expose to tests, if set
LateSelinux bool // delay the switching of SELinux to enforce mode
DevcontainerURL string // dev container to expose to tests, if set
DevcontainerBinhostURL string // dev container binhost URL to use in the devcontainer test
DevcontainerFile string // dev container path to expose to tests, if set
Expand Down Expand Up @@ -574,6 +575,7 @@ func runTest(h *harness.H, t *register.Test, pltfrm string, flight platform.Flig
SSHRetries: Options.SSHRetries,
SSHTimeout: Options.SSHTimeout,
DefaultUser: t.DefaultUser,
LateSelinux: LateSelinux,
}
c, err := flight.NewCluster(rconf)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion kola/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
NoSSHKeyInUserData Flag = iota // don't inject SSH key into Ignition/cloud-config
NoSSHKeyInMetadata // don't add SSH key to platform metadata
NoEmergencyShellCheck // don't check console output for emergency shell invocation
NoEnableSelinux // don't enable selinux when starting or rebooting a machine
NoEnableSelinux // don't enable selinux
NoKernelPanicCheck // don't check console output for kernel panic
NoVerityCorruptionCheck // don't check console output for verity corruption
NoDisableUpdates // don't disable usage of the public update server
Expand Down
9 changes: 9 additions & 0 deletions platform/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ func (bc *BaseCluster) RenderUserData(userdata *conf.UserData, ignitionVars map[
conf.CopyKeys(keys)
}

if !bc.rconf.NoEnableSelinux && !bc.rconf.LateSelinux {
conf.AddFile("/etc/flatcar/update.conf", "root", `SELINUX=enforcing
SELINUXTYPE=mcs
`, 0644)
// These files used to be deleted but empty files should work, too
conf.AddFile("/etc/audit/rules.d/80-selinux.rules", "root", ``, 0644)
conf.AddFile("/etc/audit/rules.d/99-default.rules", "root", ``, 0644)
}

// disable the public update server by default
if !bc.rconf.NoDisableUpdates {
conf.AddFile("/etc/flatcar/update.conf", "root", `SERVER=disabled
Expand Down
1 change: 1 addition & 0 deletions platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ type RuntimeConfig struct {
AllowFailedUnits bool // don't fail CheckMachine if a systemd unit has failed
SSHRetries int // see SSHRetries field in Options
SSHTimeout time.Duration // see SSHTimeout field in Options
LateSelinux bool // see LateSelinux field in Options

// DefaultUser is the user used for SSH connection, it will be created via Ignition when possible.
DefaultUser string
Expand Down
2 changes: 1 addition & 1 deletion platform/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func StartMachine(m Machine, j *Journal) error {
if err := CheckMachine(context.TODO(), m); err != nil {
return fmt.Errorf("machine %q failed basic checks: %v", m.ID(), err)
}
if !m.RuntimeConf().NoEnableSelinux {
if !m.RuntimeConf().NoEnableSelinux && m.RuntimeConf().LateSelinux {
if err := EnableSelinux(m); err != nil {
return fmt.Errorf("machine %q failed to enable selinux: %v", m.ID(), err)
}
Expand Down