fix: shadowed err

This commit is contained in:
go-compile 2024-02-20 17:41:49 +00:00
parent 9ce23a6488
commit 16f809bb5e
No known key found for this signature in database
GPG Key ID: 53F4922E9D5497B8
2 changed files with 6 additions and 3 deletions

View File

@ -47,13 +47,15 @@ func SecureBinary() error {
// Set permissions to root(read,write,exec), group(read,exec), public(read)
// This combined with changing the owner make the file undeletable without root privlages
// UNLESS THE PARENT FOLDER IS WRITABLE!
if err := os.Chmod(binary, 0755); err != nil {
err = os.Chmod(binary, 0755)
if err != nil {
return fmt.Errorf("os.Chmod() %q: %w", binary, err)
}
// 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, serviceInstallDir); err != nil {
err = os.Rename(binary, serviceInstallDir)
if err != nil {
return fmt.Errorf("os.Rename() %q to %q: %w", binary, serviceInstallDir, err)
}

View File

@ -775,7 +775,8 @@ func initWorkingDir(opts options) (err error) {
Context.workDir = "/var/lib/AdGuardHome"
// Create dir if it does not already exist
if err := os.MkdirAll(Context.workDir, 0755); err != nil {
err := os.MkdirAll(Context.workDir, 0755)
if err != nil {
return fmt.Errorf("os.MkdirAll: %s: %w", Context.workDir, err)
}
} else {