1
0
mirror of https://github.com/zu1k/nali.git synced 2025-01-22 13:19:02 +08:00

fix: delete write permission validation for files when self-update

This commit is contained in:
Zhiyong(Johnny) Zhao 2023-09-29 13:01:48 -04:00
parent f2bec94681
commit 4123411ecb

View File

@ -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
}