With -l/--links the local backend recreates a source ".rclonelink" as a real symlink at the destination. Remove and Rmdir deleted by path, which follows a symlink in any parent component, so when the destination contained a planted symlink "pwn" pointing outside the root, an object or directory named through it such as "pwn/secret" resolved to the outside file or directory and was deleted there. rclone's own sync never names destination paths through a symlink as the listing shows it as a ".rclonelink" file, but the clean up of a failed copy looks up and removes a ".partial" name derived from the source, and callers of the rc API or the Go API may pass such a name directly. Delete through os.Root when translating symlinks so a planted symlink can no longer redirect the removal out of the destination. This also covers the removal of a partially written file after a failed write. In-tree removals and the Windows sharing violation retry are unchanged.
9 lines
193 B
Go
9 lines
193 B
Go
//go:build !windows
|
|
|
|
package local
|
|
|
|
// remove removes name with removeFn, retrying on a sharing violation
|
|
func remove(name string, removeFn func(string) error) error {
|
|
return removeFn(name)
|
|
}
|