]> Cypherpunks repositories - gostls13.git/commit
os: add support for long path names on unix RemoveAll
authorOliver Stenbom <ostenbom@pivotal.io>
Wed, 31 Oct 2018 10:55:24 +0000 (10:55 +0000)
committerIan Lance Taylor <iant@golang.org>
Wed, 31 Oct 2018 13:55:01 +0000 (13:55 +0000)
commite8ffb8a74c90e3723dd6777af2c894f39d656795
tree3407b57a00711aa3a7a8f7e10c7b197b4cebc04a
parent49dafc70c8558271fc2205061d07eed490f2bc18
os: add support for long path names on unix RemoveAll

On unix systems, long enough path names will fail when performing syscalls
like `Lstat`. The current RemoveAll uses several of these syscalls, and so
will fail for long paths. This can be risky, as it can let users "hide"
files from the system or otherwise make long enough paths for programs
to fail. By using `Unlinkat` and `Openat` syscalls instead, RemoveAll is
safer on unix systems. Initially implemented for linux, darwin, dragonfly,
netbsd and openbsd. Not yet implemented on freebsd due to fstatat 64-bit
inode compatibility issues.

Fixes #27029

Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io>
Co-authored-by: Julia Nedialkova <yulia.nedyalkova@sap.com>
Change-Id: I978a6a4986878fe076d3c7af86e7927675624a96
GitHub-Last-Rev: 9235489c81b90c228210144b7c25b28a46bb80b7
GitHub-Pull-Request: golang/go#28494
Reviewed-on: https://go-review.googlesource.com/c/146020
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
16 files changed:
src/internal/syscall/unix/at.go [new file with mode: 0644]
src/internal/syscall/unix/at_sysnum_darwin.go [new file with mode: 0644]
src/internal/syscall/unix/at_sysnum_dragonfly.go [new file with mode: 0644]
src/internal/syscall/unix/at_sysnum_freebsd.go [new file with mode: 0644]
src/internal/syscall/unix/at_sysnum_fstatat64_linux.go [new file with mode: 0644]
src/internal/syscall/unix/at_sysnum_fstatat_linux.go [new file with mode: 0644]
src/internal/syscall/unix/at_sysnum_linux.go [new file with mode: 0644]
src/internal/syscall/unix/at_sysnum_netbsd.go [new file with mode: 0644]
src/internal/syscall/unix/at_sysnum_newfstatat_linux.go [new file with mode: 0644]
src/internal/syscall/unix/at_sysnum_openbsd.go [new file with mode: 0644]
src/os/path.go
src/os/path_test.go
src/os/path_unix.go
src/os/removeall_at.go [new file with mode: 0644]
src/os/removeall_noat.go [new file with mode: 0644]
src/os/removeall_test.go [new file with mode: 0644]