audit/file: Attempt to create directory path. Fixes #38

This commit is contained in:
Armon Dadgar 2015-04-27 12:40:32 -07:00
parent 1a5b774527
commit 27c73da308

View file

@ -3,6 +3,7 @@ package file
import (
"fmt"
"os"
"path/filepath"
"sync"
"github.com/hashicorp/vault/audit"
@ -56,6 +57,9 @@ func (b *Backend) open() error {
if b.f != nil {
return nil
}
if err := os.MkdirAll(filepath.Dir(b.Path), 0600); err != nil {
return err
}
var err error
b.f, err = os.OpenFile(b.Path, os.O_APPEND|os.O_WRONLY, 0600)