Skip to content

Commit

Permalink
Merge pull request #17546 from runcom/backport-17094
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue.

[release-3.7] setup selinux labels for build containers

back ports #17094 to `release-3.7`

@smarterclayton PTAL
  • Loading branch information
openshift-merge-robot committed Feb 15, 2018
2 parents de12586 + f6c0345 commit a8deba5
Show file tree
Hide file tree
Showing 3 changed files with 32 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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a8deba5

Please sign in to comment.