]> Cypherpunks repositories - gostls13.git/commit
os: add support for long path names on unix RemoveAll
authorOliver Stenbom <ostenbom@pivotal.io>
Tue, 30 Oct 2018 00:40:24 +0000 (00:40 +0000)
committerIan Lance Taylor <iant@golang.org>
Tue, 30 Oct 2018 15:18:02 +0000 (15:18 +0000)
commit85143d355493c6bba994d49ed154b4df8b78874b
treef4054e4ec814e1a01cd86c38b583a74e53b9c78c
parent7bada2cf4676938be46cde13e2b8e11e42b5441c
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, and several bsds.

Fixes #27029

Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io>
Co-authored-by: Julia Nedialkova <yulia.nedyalkova@sap.com>
Change-Id: Id9fcdf4775962b021b7ff438dc51ee6d16bb5f56
GitHub-Last-Rev: b30a621fe359fa2acbb055445b54202b0c508167
GitHub-Pull-Request: golang/go#27871
Reviewed-on: https://go-review.googlesource.com/c/137442
Run-TryBot: Ian Lance Taylor <iant@golang.org>
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]