From 3e89864534f7aeba4043db88d89701516fab8fc2 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Wed, 12 Mar 2014 11:13:24 -0700 Subject: [PATCH] Fix issue when /etc/apparmor.d does not exists Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes (github: creack) --- libcontainer/apparmor/setup.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libcontainer/apparmor/setup.go b/libcontainer/apparmor/setup.go index e07759c..4e1c951 100644 --- a/libcontainer/apparmor/setup.go +++ b/libcontainer/apparmor/setup.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "os" "os/exec" + "path" ) const DefaultProfilePath = "/etc/apparmor.d/docker" @@ -85,6 +86,11 @@ func InstallDefaultProfile() error { return nil } + // Make sure /etc/apparmor.d exists + if err := os.MkdirAll(path.Dir(DefaultProfilePath), 0755); err != nil { + return err + } + if err := ioutil.WriteFile(DefaultProfilePath, []byte(DefaultProfile), 0644); err != nil { return err }