fix: use os.Executable instead of os.Args[0] to get prog dir

This commit is contained in:
go-compile 2024-02-20 13:35:31 +00:00
parent 2c4ebe71d9
commit 11a7ac2013
No known key found for this signature in database
GPG key ID: 53F4922E9D5497B8

View file

@ -740,6 +740,11 @@ func secureBinaryUnix() error {
// If AdGuardHome is running as a service, it should not use the binary's location as a
// workDir, thus this function will return false.
func execDirAvaliable() bool {
binary, err := os.Executable()
if err != nil {
panic(err)
}
// If installed in /usr/bin do not use /usr/bin/data to store files
return filepath.Dir(os.Args[0]) != "/usr/bin"
return filepath.Dir(binary) != "/usr/bin"
}