From 9ce23a6488b1a92d2850252795da9dcb77f91961 Mon Sep 17 00:00:00 2001 From: go-compile <97609133+go-compile@users.noreply.github.com> Date: Tue, 20 Feb 2024 17:37:16 +0000 Subject: [PATCH] fix: typos --- internal/aghos/binarysecurity_others.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/internal/aghos/binarysecurity_others.go b/internal/aghos/binarysecurity_others.go index 7cadc4d6..a7410df4 100644 --- a/internal/aghos/binarysecurity_others.go +++ b/internal/aghos/binarysecurity_others.go @@ -5,10 +5,9 @@ package aghos import ( "fmt" "os" - "path/filepath" + "strings" "github.com/AdguardTeam/golibs/errors" - "github.com/AdguardTeam/golibs/log" ) // protectedDirectories are directories which contain other application binaries, @@ -16,13 +15,13 @@ import ( // overwriting other files. Moreover, these directories are innapproriate for storage of // config files or session storage. var protectedDirectories = []string{ - "/usr/bin" - "/usr/sbin" - "/user/bin" + "/usr/bin", + "/usr/sbin", + "/user/bin", } // serviceInstallDir is a executable path in a directory which secure permissions -// which prevent the manipulation of the binary. +// which prevent the manipulation of the binary. const serviceInstallDir = "/usr/bin/AdGuardHome" // SecureBinary is used before service.Install(). This function protects AdGuardHome from @@ -52,11 +51,10 @@ func SecureBinary() error { 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 { - return fmt.Errorf("os.Rename() %q to %q: %w", binary, installDir, err) + return fmt.Errorf("os.Rename() %q to %q: %w", binary, serviceInstallDir, err) } return nil @@ -67,7 +65,7 @@ func SecureBinary() error { func CurrentDirAvaliable() (bool, error) { binary, err := os.Executable() if err != nil { - return fmt.Errorf("os.Executable(): %w", err) + return false, fmt.Errorf("os.Executable(): %w", err) } for i := 0; i < len(protectedDirectories); i++ { @@ -80,4 +78,4 @@ func CurrentDirAvaliable() (bool, error) { // The binary is outside of all checked protected directories return true, nil -} \ No newline at end of file +}