mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-03-12 21:48:33 +03:00
fix: use os.Executable instead of os.Args[0] to get prog path
This commit is contained in:
parent
60177cebf2
commit
2c4ebe71d9
1 changed files with 6 additions and 2 deletions
|
@ -708,10 +708,13 @@ func secureBinaryUnix() error {
|
|||
}
|
||||
|
||||
// Get current file path
|
||||
binary := os.Args[0]
|
||||
binary, err := os.Executable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Change owner to root:root
|
||||
err := os.Chown(binary, 0, 0)
|
||||
err = os.Chown(binary, 0, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -724,6 +727,7 @@ func secureBinaryUnix() error {
|
|||
}
|
||||
|
||||
// Move binary to the PATH in a folder which is read-only to non root users
|
||||
// If already moved, this is a no-op
|
||||
if err := os.Rename(binary, "/usr/bin/AdGuardHome"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue