Fix windows config/socket dir location

RMM uses non-user account which results in config + socket file being
written to a random directory, which is not a real directory that can be
accessed.

Fix this by using directory of ctrld binary as user home dir.
This commit is contained in:
Connie Lukawski
2023-09-23 16:06:10 +00:00
committed by Cuong Manh Le
parent 34758f6205
commit c58516cfb0

View File

@@ -1309,7 +1309,13 @@ func userHomeDir() (string, error) {
}
// viper will expand for us.
if runtime.GOOS == "windows" {
return os.UserHomeDir()
// If we're on windows, use the install path for this.
exePath, err := os.Executable()
if err != nil {
return "", err
}
return filepath.Dir(exePath), nil
}
// Mobile platform should provide a rw dir path for this.
if isMobile() {