Skip to content

Commit bbba129

Browse files
Ace-Tangfuweid
authored andcommitted
feature: support get security options in daemon
show daemon security options, include four part, seccomp, apparmor, selinux and userns. Signed-off-by: Ace-Tang <[email protected]>
1 parent 87544ad commit bbba129

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

daemon/mgr/spec_seccomp_linux.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ import (
1212
specs "github.com/opencontainers/runtime-spec/specs-go"
1313
)
1414

15+
// IsSeccompEnable return true since pouch support seccomp in build
16+
func IsSeccompEnable() bool {
17+
return true
18+
}
19+
1520
// setupSeccomp creates seccomp security settings spec.
1621
func setupSeccomp(ctx context.Context, c *Container, s *specs.Spec) error {
1722
if c.HostConfig.Privileged {

daemon/mgr/spec_seccomp_unsupported.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import (
99
specs "github.com/opencontainers/runtime-spec/specs-go"
1010
)
1111

12+
// IsSeccompEnable return false since pouch do not support seccomp in build
13+
func IsSeccompEnable() bool {
14+
return false
15+
}
16+
1217
func setupSeccomp(ctx context.Context, c *Container, s *specs.Spec) error {
1318
if c.SeccompProfile != "" && c.SeccompProfile != "unconfined" {
1419
return fmt.Errorf("Seccomp is not support by pouch, can not set seccomp profile %s", c.SeccompProfile)

daemon/mgr/system.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"github.com/alibaba/pouch/registry"
2020
volumedriver "github.com/alibaba/pouch/storage/volume/driver"
2121
"github.com/alibaba/pouch/version"
22+
"github.com/opencontainers/runc/libcontainer/apparmor"
23+
selinux "github.com/opencontainers/selinux/go-selinux"
2224

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

117+
// security options get four part, seccomp, apparmor, selinux and userns
118+
securityOpts := []string{}
119+
sysInfo := system.NewInfo()
120+
if sysInfo.Seccomp && IsSeccompEnable() {
121+
securityOpts = append(securityOpts, "seccomp")
122+
}
123+
if sysInfo.AppArmor && apparmor.IsEnabled() {
124+
securityOpts = append(securityOpts, "apparmor")
125+
}
126+
if selinux.GetEnabled() {
127+
securityOpts = append(securityOpts, "selinux")
128+
}
129+
115130
info := types.SystemInfo{
116131
Architecture: runtime.GOARCH,
117132
// CgroupDriver: ,
@@ -148,8 +163,8 @@ func (mgr *SystemManager) Info() (types.SystemInfo, error) {
148163
PouchRootDir: mgr.config.HomeDir,
149164
RegistryConfig: &mgr.config.RegistryService,
150165
// RuncCommit: ,
151-
Runtimes: mgr.config.Runtimes,
152-
// SecurityOptions: ,
166+
Runtimes: mgr.config.Runtimes,
167+
SecurityOptions: securityOpts,
153168
ServerVersion: version.Version,
154169
ListenAddresses: mgr.config.Listen,
155170
}

0 commit comments

Comments
 (0)