From 1bf529a45674dc07de6efba806b854f63f3dc0bf Mon Sep 17 00:00:00 2001 From: Mabin Date: Tue, 10 Mar 2015 10:00:07 +0800 Subject: [PATCH] Add logs when Docker enabled selinux Signed-off-by: Mabin --- daemon/daemon.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index 31fcded4c6..37a4c7b8e2 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -850,9 +850,6 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error) return nil, fmt.Errorf("Unable to get the full path to the TempDir (%s): %s", tmp, err) } os.Setenv("TMPDIR", realTmp) - if !config.EnableSelinuxSupport { - selinuxSetDisabled() - } // get the canonical path to the Docker root directory var realRoot string @@ -880,9 +877,18 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error) } log.Debugf("Using graph driver %s", driver) - // As Docker on btrfs and SELinux are incompatible at present, error on both being enabled - if selinuxEnabled() && config.EnableSelinuxSupport && driver.String() == "btrfs" { - return nil, fmt.Errorf("SELinux is not supported with the BTRFS graph driver!") + if config.EnableSelinuxSupport { + if selinuxEnabled() { + // As Docker on btrfs and SELinux are incompatible at present, error on both being enabled + if driver.String() == "btrfs" { + return nil, fmt.Errorf("SELinux is not supported with the BTRFS graph driver") + } + log.Debug("SELinux enabled successfully") + } else { + log.Warn("Docker could not enable SELinux on the host system") + } + } else { + selinuxSetDisabled() } daemonRepo := path.Join(config.Root, "containers")