Skip to content

Commit

Permalink
setup selinux labels for build containers
Browse files Browse the repository at this point in the history
  • Loading branch information
bparees authored and runcom committed Nov 30, 2017
1 parent d1e9479 commit 87f090e
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 87f090e

Please sign in to comment.