Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: support get security options in daemon #2408

Merged
merged 1 commit into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions daemon/mgr/spec_seccomp_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import (
specs "github.com/opencontainers/runtime-spec/specs-go"
)

// IsSeccompEnable return true since pouch support seccomp in build
func IsSeccompEnable() bool {
return true
}

// setupSeccomp creates seccomp security settings spec.
func setupSeccomp(ctx context.Context, c *Container, s *specs.Spec) error {
if c.HostConfig.Privileged {
Expand Down
5 changes: 5 additions & 0 deletions daemon/mgr/spec_seccomp_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import (
specs "github.com/opencontainers/runtime-spec/specs-go"
)

// IsSeccompEnable return false since pouch do not support seccomp in build
func IsSeccompEnable() bool {
return false
}

func setupSeccomp(ctx context.Context, c *Container, s *specs.Spec) error {
if c.SeccompProfile != "" && c.SeccompProfile != "unconfined" {
return fmt.Errorf("Seccomp is not support by pouch, can not set seccomp profile %s", c.SeccompProfile)
Expand Down
19 changes: 17 additions & 2 deletions daemon/mgr/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/alibaba/pouch/registry"
volumedriver "github.com/alibaba/pouch/storage/volume/driver"
"github.com/alibaba/pouch/version"
fuweid marked this conversation as resolved.
Show resolved Hide resolved
"github.com/opencontainers/runc/libcontainer/apparmor"
selinux "github.com/opencontainers/selinux/go-selinux"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -112,6 +114,19 @@ func (mgr *SystemManager) Info() (types.SystemInfo, error) {
}
volumeDrivers := volumedriver.AllDriversName()

// security options get four part, seccomp, apparmor, selinux and userns
securityOpts := []string{}
sysInfo := system.NewInfo()
if sysInfo.Seccomp && IsSeccompEnable() {
securityOpts = append(securityOpts, "seccomp")
}
if sysInfo.AppArmor && apparmor.IsEnabled() {
securityOpts = append(securityOpts, "apparmor")
}
if selinux.GetEnabled() {
securityOpts = append(securityOpts, "selinux")
}

info := types.SystemInfo{
Architecture: runtime.GOARCH,
// CgroupDriver: ,
Expand Down Expand Up @@ -148,8 +163,8 @@ func (mgr *SystemManager) Info() (types.SystemInfo, error) {
PouchRootDir: mgr.config.HomeDir,
RegistryConfig: &mgr.config.RegistryService,
// RuncCommit: ,
Runtimes: mgr.config.Runtimes,
// SecurityOptions: ,
Runtimes: mgr.config.Runtimes,
SecurityOptions: securityOpts,
ServerVersion: version.Version,
ListenAddresses: mgr.config.Listen,
}
Expand Down