Skip to content

Commit

Permalink
manifest: disable selinux when using a bootstrap container
Browse files Browse the repository at this point in the history
We cannot make assumption about the container being used, so
disable selinux inside the bootstrap container.
  • Loading branch information
mvo5 committed Feb 25, 2025
1 parent 38baecf commit 9a1d0f3
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions pkg/manifest/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ func maybeAddExperimentalContainerBootstrap(m *Manifest, runner runner.Runner, o
}
name := "bootstrap-buildroot"
bootstrapPipeline := &BuildrootFromContainer{
Base: NewBase(name, nil),
runner: runner,
dependents: make([]Pipeline, 0),
containers: cntSrcs,
Base: NewBase(name, nil),
runner: runner,
dependents: make([]Pipeline, 0),
containers: cntSrcs,
disableSelinux: true,
}
m.addPipeline(bootstrapPipeline)
build.build = bootstrapPipeline
Expand All @@ -193,6 +194,7 @@ type BuildrootFromContainer struct {
containerSpecs []container.Spec

containerBuildable bool
disableSelinux bool
}

// NewBuildFromContainer creates a new build pipeline from the given
Expand Down Expand Up @@ -247,6 +249,10 @@ func (p *BuildrootFromContainer) serializeEnd() {
}

func (p *BuildrootFromContainer) getSELinuxLabels() map[string]string {
if p.disableSelinux {
return nil
}

labels := map[string]string{
"/usr/bin/ostree": "system_u:object_r:install_exec_t:s0",
}
Expand Down Expand Up @@ -276,13 +282,15 @@ func (p *BuildrootFromContainer) serialize() osbuild.Pipeline {
panic(err)
}
pipeline.AddStage(stage)
pipeline.AddStage(osbuild.NewSELinuxStage(
&osbuild.SELinuxStageOptions{
FileContexts: "etc/selinux/targeted/contexts/files/file_contexts",
ExcludePaths: []string{"/sysroot"},
Labels: p.getSELinuxLabels(),
},
))
if !p.disableSelinux {
pipeline.AddStage(osbuild.NewSELinuxStage(
&osbuild.SELinuxStageOptions{
FileContexts: "etc/selinux/targeted/contexts/files/file_contexts",
ExcludePaths: []string{"/sysroot"},
Labels: p.getSELinuxLabels(),
},
))
}

return pipeline
}

0 comments on commit 9a1d0f3

Please sign in to comment.