Show "seccomp" in docker info (#20909).

This pull request added a `SecurityOptions` field in the `GET /info`
output to show if there is `apparmor`, `seccomp`, or `selinux` suport.

The API changes are updated in the documentation and the update in
`GET /info` is covered by the test case in `TestInfoApi`.

This pull request fixes #20909.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang 2016-03-29 04:10:37 +00:00
parent 2f35c6b3fb
commit 190654aa2e
4 changed files with 20 additions and 1 deletions

View file

@ -67,6 +67,17 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
} }
}) })
var securityOptions []string
if sysInfo.AppArmor {
securityOptions = append(securityOptions, "apparmor")
}
if sysInfo.Seccomp {
securityOptions = append(securityOptions, "seccomp")
}
if selinuxEnabled() {
securityOptions = append(securityOptions, "selinux")
}
v := &types.Info{ v := &types.Info{
ID: daemon.ID, ID: daemon.ID,
Containers: int(cRunning + cPaused + cStopped), Containers: int(cRunning + cPaused + cStopped),
@ -104,6 +115,7 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
HTTPProxy: sockets.GetProxyEnv("http_proxy"), HTTPProxy: sockets.GetProxyEnv("http_proxy"),
HTTPSProxy: sockets.GetProxyEnv("https_proxy"), HTTPSProxy: sockets.GetProxyEnv("https_proxy"),
NoProxy: sockets.GetProxyEnv("no_proxy"), NoProxy: sockets.GetProxyEnv("no_proxy"),
SecurityOptions: securityOptions,
} }
// TODO Windows. Refactor this more once sysinfo is refactored into // TODO Windows. Refactor this more once sysinfo is refactored into

View file

@ -117,6 +117,7 @@ This section lists each version from latest to oldest. Each listing includes a
[Docker Remote API v1.24](docker_remote_api_v1.24.md) documentation [Docker Remote API v1.24](docker_remote_api_v1.24.md) documentation
* `POST /containers/create` now takes `StorageOpt` field. * `POST /containers/create` now takes `StorageOpt` field.
* `GET /info` now returns `SecurityOptions` field, showing if `apparmor`, `seccomp`, or `selinux` is supported.
### v1.23 API changes ### v1.23 API changes

View file

@ -2239,6 +2239,11 @@ Display system-wide information
"127.0.0.0/8" "127.0.0.0/8"
] ]
}, },
"SecurityOptions": [
"apparmor",
"seccomp",
"selinux"
],
"ServerVersion": "1.9.0", "ServerVersion": "1.9.0",
"SwapLimit": false, "SwapLimit": false,
"SystemStatus": [["State", "Healthy"]], "SystemStatus": [["State", "Healthy"]],

View file

@ -31,7 +31,8 @@ func (s *DockerSuite) TestInfoApi(c *check.C) {
"MemTotal", "MemTotal",
"KernelVersion", "KernelVersion",
"Driver", "Driver",
"ServerVersion"} "ServerVersion",
"SecurityOptions"}
out := string(body) out := string(body)
for _, linePrefix := range stringsToCheck { for _, linePrefix := range stringsToCheck {