Skip to content

Commit

Permalink
Merge pull request #17094 from bparees/crio_selinux
Browse files Browse the repository at this point in the history
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
  • Loading branch information
openshift-merge-robot authored Nov 29, 2017
2 parents 404cb18 + bce732a commit 2748ff8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/build/builder/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ func (d *DockerBuilder) dockerBuild(dir string, tag string, secrets []buildapi.S
}
opts.NetworkMode = network
if len(resolvConfHostPath) != 0 {
cmd := exec.Command("chcon", "system_u:object_r:svirt_sandbox_file_t:s0", "/etc/resolv.conf")
err := cmd.Run()
if err != nil {
return fmt.Errorf("unable to set permissions on /etc/resolv.conf: %v", err)
}
opts.BuildBinds = fmt.Sprintf("[\"%s:/etc/resolv.conf\"]", resolvConfHostPath)
}
// Though we are capped on memory and cpu at the cgroup parent level,
Expand Down
6 changes: 6 additions & 0 deletions pkg/build/builder/sti.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"net/url"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
Expand Down Expand Up @@ -203,6 +204,11 @@ func (s *S2IBuilder) Build() error {
}

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

Expand Down

0 comments on commit 2748ff8

Please sign in to comment.