From 16f809bb5e0d7f8b595eb2896a8627d53577cc89 Mon Sep 17 00:00:00 2001 From: go-compile <97609133+go-compile@users.noreply.github.com> Date: Tue, 20 Feb 2024 17:41:49 +0000 Subject: [PATCH] fix: shadowed err --- internal/aghos/binarysecurity_others.go | 6 ++++-- internal/home/home.go | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/aghos/binarysecurity_others.go b/internal/aghos/binarysecurity_others.go index a7410df4..bfd790d3 100644 --- a/internal/aghos/binarysecurity_others.go +++ b/internal/aghos/binarysecurity_others.go @@ -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) } diff --git a/internal/home/home.go b/internal/home/home.go index fe44771a..925c2d02 100644 --- a/internal/home/home.go +++ b/internal/home/home.go @@ -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 {