From 2ebbb891311c69d75e8df2f59935e5fe882ec23a Mon Sep 17 00:00:00 2001 From: Hugo Landau Date: Mon, 25 Jan 2016 21:44:53 +0000 Subject: [PATCH] Fix bug causing webroot path in legacy config file not to be used This bug was caused by loading the legacy configuration file after the targets were loaded, but default configuration is copied over to the targets when the targets are loaded, so the configured webroots were never used. A workaround is to move the webroot paths to the conf/target file, the now-preferred location for them. This fixes this bug, making the workaround no longer necessary. Fixes #85. --- responder/http.go | 3 ++- storage/storage-fdb.go | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/responder/http.go b/responder/http.go index 074655f..20a493d 100644 --- a/responder/http.go +++ b/responder/http.go @@ -155,11 +155,12 @@ L: // Tries to write a challenge file to each of the directories. func webrootWriteChallenge(webroots map[string]struct{}, token string, ka []byte) { - log.Debug("writing webroot challenge files") + log.Debugf("writing %d webroot challenge files", len(webroots)) for wr := range webroots { os.MkdirAll(wr, 0755) // ignore errors fn := filepath.Join(wr, token) + log.Debugf("writing webroot file %s", fn) // Because /var/run/acme/acme-challenge may not exist due to /var/run // possibly being a tmpfs, and because that tmpfs is likely to be world diff --git a/storage/storage-fdb.go b/storage/storage-fdb.go index 54505d1..9f5fc78 100644 --- a/storage/storage-fdb.go +++ b/storage/storage-fdb.go @@ -221,10 +221,6 @@ func (s *fdbStore) Reload() error { return err } - // Legacy support - s.loadWebrootPaths() - s.loadRSAKeySize() - return nil } @@ -494,14 +490,18 @@ func (s *fdbStore) loadTargets() error { dtgt, err := s.validateTargetInner("target", confc, true) if err == nil { - dtgt.Satisfy.Names = nil - dtgt.Satisfy.ReducedNames = nil - dtgt.Request.Names = nil + dtgt.genericise() s.defaultTarget = dtgt } else { + log.Errore(err, "error loading default target file") s.defaultTarget = &Target{} } + // Legacy support. We have to do this here so that these defaults get copied + // across to the targets. + s.loadWebrootPaths() + s.loadRSAKeySize() + // targets c := s.db.Collection("desired")