From 4123411ecbeff9622326cdf324de7dff2e8328fc Mon Sep 17 00:00:00 2001 From: "Zhiyong(Johnny) Zhao" Date: Fri, 29 Sep 2023 13:01:48 -0400 Subject: [PATCH] fix: delete write permission validation for files when self-update --- internal/repo/update.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/internal/repo/update.go b/internal/repo/update.go index e14e1f3..2c0fcd6 100644 --- a/internal/repo/update.go +++ b/internal/repo/update.go @@ -95,9 +95,6 @@ func update(asset io.Reader, cmdPath string) error { if !canWriteDir(updateDir) { return fmt.Errorf("no write permissions on the directory, consider updating nali manually") } - if !canWriteFile(cmdPath) { - return fmt.Errorf("no write permissions on the executable, consider updating nali manually") - } // Copy the contents of new binary to a new executable file newPath := filepath.Join(updateDir, fmt.Sprintf(".%s.new", filename)) @@ -184,12 +181,3 @@ func canWriteDir(path string) bool { return err == nil } - -func canWriteFile(path string) bool { - f, err := os.OpenFile(path, os.O_WRONLY, 0644) - if err == nil { - defer f.Close() - } - - return err == nil -}