$OpenBSD: patch-libbeat_cfgfile_cfgfile_go,v 1.1 2020/11/21 15:58:40 pvk Exp $

Index: libbeat/cfgfile/cfgfile.go
--- libbeat/cfgfile/cfgfile.go.orig
+++ libbeat/cfgfile/cfgfile.go
@@ -37,10 +37,10 @@ var (
 	// Additional default settings, that must be available for variable expansion
 	defaults = common.MustNewConfigFrom(map[string]interface{}{
 		"path": map[string]interface{}{
-			"home":   ".", // to be initialized by beat
-			"config": "${path.home}",
-			"data":   fmt.Sprint("${path.home}", string(os.PathSeparator), "data"),
-			"logs":   fmt.Sprint("${path.home}", string(os.PathSeparator), "logs"),
+			"home":   "${LOCALSTATEDIR}/db/${BEAT}", // to be initialized by beat
+			"config": "${SYSCONFDIR}/${BEAT}",
+			"data":   "${LOCALSTATEDIR}/db/${BEAT}",
+			"logs":   "${LOCALSTATEDIR}/log/${BEAT}",
 		},
 	})
 
@@ -96,8 +96,8 @@ func GetDefaultCfgfile() string {
 
 // HandleFlags adapts default config settings based on command line flags.
 func HandleFlags() error {
-	// default for the home path is the binary location
-	home, err := filepath.Abs(filepath.Dir(os.Args[0]))
+	// default for the home path is "${LOCALSTATEDIR}/db/${BEAT}"
+	home, err := filepath.Abs("${LOCALSTATEDIR}/db/${BEAT}")
 	if err != nil {
 		if *homePath == "" {
 			return fmt.Errorf("The absolute path to %s could not be obtained. %v",
@@ -217,5 +217,5 @@ func GetPathConfig() string {
 		return *homePath
 	}
 	// TODO: Do we need this or should we always return *homePath?
-	return ""
+	return "${SYSCONFDIR}/${BEAT}"
 }
