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

Configure the Selinux type tag when the AppArmor is disabled regardless of EnableSelinux flag #1339

Merged
merged 2 commits into from
Nov 30, 2022
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
18 changes: 13 additions & 5 deletions internal/pkg/manager/spod/spod_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ func (r *ReconcileSPOd) getConfiguredSPOd(
if enableSelinux {
templateSpec.InitContainers = append(
templateSpec.InitContainers,
r.baseSPOd.Spec.Template.Spec.InitContainers[bindata.ContainerIDSelinuxd])
r.baseSPOd.Spec.Template.Spec.InitContainers[bindata.InitContainerIDSelinuxSharedPoliciesCopier])
templateSpec.Containers = append(
templateSpec.Containers,
r.baseSPOd.Spec.Template.Spec.Containers[bindata.ContainerIDSelinuxd])
Expand Down Expand Up @@ -592,8 +592,12 @@ func (r *ReconcileSPOd) getConfiguredSPOd(
// Set the logging verbosity
templateSpec.InitContainers[i].Env = append(templateSpec.InitContainers[i].Env, verbosityEnv(cfg.Spec.Verbosity))

// Update the SELinux type tag when is defined in the configuration
if cfg.Spec.EnableSelinux != nil && *cfg.Spec.EnableSelinux {
// Update the SELinux type tag only when AppArmor is not enabled this is to prevent a crash.
// The SELinux type tag needs to be configured independent of EnableSelinux flag, because the
// SELinux can be active on the node regardless if the SELinux feature is enabled or not in the operator.
// For instance, on Flatcar Linux SELinux type tag needs to be set to 'unconfined_t' instead of 'spc_t'
// even though SELinux is disabled in order to get the containers to start.
if !cfg.Spec.EnableAppArmor {
configureSeLinuxTag(templateSpec.InitContainers[i].SecurityContext, cfg.Spec.SelinuxTypeTag)
}
}
Expand All @@ -613,8 +617,12 @@ func (r *ReconcileSPOd) getConfiguredSPOd(
if cfg.Spec.EnableProfiling {
enableContainerProfiling(templateSpec, i)
}
// Update the SELinux type tag when is defined in the configuration
if cfg.Spec.EnableSelinux != nil && *cfg.Spec.EnableSelinux {
// Update the SELinux type tag only when AppArmor is not enabled this is to prevent a crash.
// The SELinux type tag needs to be configured independent of EnableSelinux flag, because the
// SELinux can be active on the node regardless if the SELinux feature is enabled or not in the operator.
// For instance, on Flatcar Linux SELinux type tag needs to be set to 'unconfined_t' instead of 'spc_t'
// even though SELinux is disabled in order to get the containers to start.
if !cfg.Spec.EnableAppArmor {
configureSeLinuxTag(templateSpec.Containers[i].SecurityContext, cfg.Spec.SelinuxTypeTag)
}
}
Expand Down