mirror of
https://github.com/docker/cli.git
synced 2026-01-13 18:22:35 +03:00
Merge pull request #12664 from Mashimiao/sysinfo-support-ipv4_forward-check
sysinfo: add IPv4Forwarding check Upstream-commit: fc9033a9c89a86e28d77053b0737aecbb068246d Component: engine
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/libcontainer/cgroups"
|
||||
@@ -48,6 +50,17 @@ func New(quiet bool) *SysInfo {
|
||||
}
|
||||
}
|
||||
|
||||
// Checek if ipv4_forward is disabled.
|
||||
if data, err := ioutil.ReadFile("/proc/sys/net/ipv4/ip_forward"); os.IsNotExist(err) {
|
||||
sysInfo.IPv4ForwardingDisabled = true
|
||||
} else {
|
||||
if enabled, _ := strconv.Atoi(strings.TrimSpace(string(data))); enabled == 0 {
|
||||
sysInfo.IPv4ForwardingDisabled = true
|
||||
} else {
|
||||
sysInfo.IPv4ForwardingDisabled = false
|
||||
}
|
||||
}
|
||||
|
||||
// Check if AppArmor is supported.
|
||||
if _, err := os.Stat("/sys/kernel/security/apparmor"); os.IsNotExist(err) {
|
||||
sysInfo.AppArmor = false
|
||||
|
||||
Reference in New Issue
Block a user