Skip to content

Commit

Permalink
Add seccomp build tag
Browse files Browse the repository at this point in the history
Add a seccomp build tag and also support in the Makefile to add or
remove build tags.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
  • Loading branch information
crosbymichael committed Sep 11, 2015
1 parent cd01b01 commit a8e0185
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
RUNC_TEST_IMAGE=runc_test
PROJECT=github.com/opencontainers/runc
TEST_DOCKERFILE=script/test_Dockerfile
BUILDTAGS=seccomp
export GOPATH:=$(CURDIR)/Godeps/_workspace:$(GOPATH)

all:
go build -o runc .
go build -tags "$(BUILDTAGS)" -o runc .

vet:
go get golang.org/x/tools/cmd/vet
Expand All @@ -20,7 +21,8 @@ test: runctestimage
docker run -e TESTFLAGS --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_TEST_IMAGE) make localtest

localtest:
go test ${TESTFLAGS} -v ./...
go test -tags "$(BUILDTAGS)" ${TESTFLAGS} -v ./...


install:
cp runc /usr/local/bin/runc
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ make
sudo make install
```

In order to enable seccomp support you will need to install libseccomp on your platform.
If you do not with to build `runc` with seccomp support you can add `BUILDTAGS=""` when running make.

### Using:

To run a container, execute `runc start` in the bundle's root directory:
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/seccomp/seccomp_linux.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build linux,cgo
// +build linux,cgo,seccomp

package seccomp

Expand Down
9 changes: 8 additions & 1 deletion libcontainer/seccomp/seccomp_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
// +build !linux !cgo
// +build !linux !cgo !seccomp

package seccomp

import (
"errors"

"github.com/opencontainers/runc/libcontainer/configs"
)

var ErrSeccompNotEnabled = errors.New("seccomp: config provided but seccomp not supported")

// Seccomp not supported, do nothing
func InitSeccomp(config *configs.Seccomp) error {
if config != nil {
return ErrSeccompNotEnabled
}
return nil
}

0 comments on commit a8e0185

Please sign in to comment.