maddy/directories.go
fox.cpp 2b67435dbf
Fix libexecdir/statedir being empty by default
Issue was caused by move to config.Map for global values, config.Map
sets to these values to empty strings by default.
2019-05-06 02:21:24 +03:00

39 lines
743 B
Go

package maddy
import (
"os"
)
var (
defaultConfigDirectory = "/etc/maddy"
defaultStateDirectory = "/var/lib/maddy"
defaultLibexecDirectory = "/usr/libexec/maddy"
)
func ConfigDirectory() string {
return defaultConfigDirectory
}
func StateDirectory(globals map[string]interface{}) string {
if dir := os.Getenv("MADDYSTATE"); dir != "" {
return dir
}
if val, ok := globals["statedir"]; ok && val.(string) != "" {
return val.(string)
}
return defaultStateDirectory
}
func LibexecDirectory(globals map[string]interface{}) string {
if dir := os.Getenv("MADDYLIBEXEC"); dir != "" {
return dir
}
if val, ok := globals["libexecdir"]; ok && val.(string) != "" {
return val.(string)
}
return defaultLibexecDirectory
}