Skip to content

Commit

Permalink
manifest: disable selinux for the bootstrap container
Browse files Browse the repository at this point in the history
We cannot make assumption about the bootstrap container being used,
so disable selinux when setting up the bootstrap container.

The real buildroot will be correctly labeld, no change here.
  • Loading branch information
mvo5 committed Feb 26, 2025
1 parent ec20905 commit 8f78c04
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 @@ -180,10 +180,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 @@ -199,6 +200,7 @@ type BuildrootFromContainer struct {
containerSpecs []container.Spec

containerBuildable bool
disableSelinux bool
}

// NewBuildFromContainer creates a new build pipeline from the given
Expand Down Expand Up @@ -253,6 +255,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 @@ -282,13 +288,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 8f78c04

Please sign in to comment.