Skip to content

Commit 2748ff8

Browse files
Merge pull request #17094 from bparees/crio_selinux
Automatic merge from submit-queue (batch tested with PRs 17476, 17143, 15115, 17094, 17500). set selinux labels on build docker containers when running pods in crio for bug https://bugzilla.redhat.com/show_bug.cgi?id=1507424
2 parents 404cb18 + bce732a commit 2748ff8

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

pkg/build/builder/docker.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ func (d *DockerBuilder) dockerBuild(dir string, tag string, secrets []buildapi.S
313313
}
314314
opts.NetworkMode = network
315315
if len(resolvConfHostPath) != 0 {
316+
cmd := exec.Command("chcon", "system_u:object_r:svirt_sandbox_file_t:s0", "/etc/resolv.conf")
317+
err := cmd.Run()
318+
if err != nil {
319+
return fmt.Errorf("unable to set permissions on /etc/resolv.conf: %v", err)
320+
}
316321
opts.BuildBinds = fmt.Sprintf("[\"%s:/etc/resolv.conf\"]", resolvConfHostPath)
317322
}
318323
// Though we are capped on memory and cpu at the cgroup parent level,

pkg/build/builder/sti.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"net/url"
99
"os"
10+
"os/exec"
1011
"path/filepath"
1112
"strings"
1213
"time"
@@ -203,6 +204,11 @@ func (s *S2IBuilder) Build() error {
203204
}
204205

205206
if len(resolvConfHostPath) != 0 {
207+
cmd := exec.Command("chcon", "system_u:object_r:svirt_sandbox_file_t:s0", "/etc/resolv.conf")
208+
err := cmd.Run()
209+
if err != nil {
210+
return fmt.Errorf("unable to set permissions on /etc/resolv.conf: %v", err)
211+
}
206212
config.BuildVolumes = []string{fmt.Sprintf("%s:/etc/resolv.conf", resolvConfHostPath)}
207213
}
208214

0 commit comments

Comments
 (0)