mirror of
https://github.com/zu1k/nali.git
synced 2025-02-02 10:22:41 +08:00
fix: delete write permission validation for files when self-update
This commit is contained in:
parent
f2bec94681
commit
4123411ecb
@ -95,9 +95,6 @@ func update(asset io.Reader, cmdPath string) error {
|
|||||||
if !canWriteDir(updateDir) {
|
if !canWriteDir(updateDir) {
|
||||||
return fmt.Errorf("no write permissions on the directory, consider updating nali manually")
|
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
|
// Copy the contents of new binary to a new executable file
|
||||||
newPath := filepath.Join(updateDir, fmt.Sprintf(".%s.new", filename))
|
newPath := filepath.Join(updateDir, fmt.Sprintf(".%s.new", filename))
|
||||||
@ -184,12 +181,3 @@ func canWriteDir(path string) bool {
|
|||||||
|
|
||||||
return err == nil
|
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
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user