From bbc05ca1a31cf9844280041520b73edb3752cb6d 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) --- apparmor/setup.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apparmor/setup.go b/apparmor/setup.go index e07759cc..4e1c9514 100644 --- a/apparmor/setup.go +++ b/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 }