tls: Ensure parent dir exists before creating lock file

This commit is contained in:
Matthew Holt 2018-02-14 13:32:16 -07:00
parent 4b2e22289d
commit ef585ed810
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5

View file

@ -61,6 +61,10 @@ func (s *fileStorageLock) TryLock(name string) (Waiter, error) {
filename: s.storage.siteCertFile(name) + ".lock",
wg: new(sync.WaitGroup),
}
// parent dir must exist
if err := os.MkdirAll(s.storage.site(name), 0700); err != nil {
return nil, err
}
lf, err := os.OpenFile(fw.filename, os.O_CREATE|os.O_EXCL, 0644)
if err != nil {
if os.IsExist(err) {