Create all config/entry files (both local and remote) with 0600 permissions

This commit is contained in:
2024-08-13 17:20:15 -04:00
parent cbf9139713
commit 88b7a6be6d
16 changed files with 62 additions and 45 deletions
+4 -3
View File
@@ -36,12 +36,13 @@ func ShearLocal(targetLocationIncomplete, clientDeviceID string) string {
if onServer {
for _, device := range *deviceIDList {
if device.Name() != clientDeviceID {
_, err := os.Create(core.ConfigDir + core.PathSeparator + "deletions" + core.PathSeparator + device.Name() + FSSpace + strings.ReplaceAll(targetLocationIncomplete, "/", FSPath))
fileToClose, err := os.OpenFile(core.ConfigDir+core.PathSeparator+"deletions"+core.PathSeparator+device.Name()+FSSpace+strings.ReplaceAll(targetLocationIncomplete, "/", FSPath), os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
// do not print error as there is currently no way of seeing server-side errors
// failure to add the target to the deletions list will exit the program and result in a client re-uploading the target (non-critical)
os.Exit(102)
}
_ = fileToClose.Close() // error ignored; if the file could be created, it can probably be closed
}
}
}
@@ -53,7 +54,7 @@ func ShearLocal(targetLocationIncomplete, clientDeviceID string) string {
}
err := os.RemoveAll(targetLocationComplete)
if err != nil {
fmt.Println(core.AnsiError + "Failed to remove local target: " + err.Error() + core.AnsiReset)
fmt.Println(core.AnsiError+"Failed to remove local target:", err.Error()+core.AnsiReset)
os.Exit(102)
}
@@ -103,7 +104,7 @@ func AddFolderLocal(targetLocationIncomplete string) {
fmt.Println(core.AnsiError + "Directory already exists" + core.AnsiReset)
os.Exit(106)
} else {
fmt.Println(core.AnsiError + "Failed to create directory: " + err.Error() + core.AnsiReset)
fmt.Println(core.AnsiError+"Failed to create directory:", err.Error()+core.AnsiReset)
os.Exit(102)
}
}