[go] os: return an error in os.MkdirAll when user permissions are insufficient

51 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
Mar 7, 2021, 7:18:41 PM3/7/21
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Bot has uploaded this change for review.

View Change

os: return an error in os.MkdirAll when user permissions are insufficient

Fixes #44848

Change-Id: I31d75110e03e2f694c17655d31c21c0fb874dd6e
GitHub-Last-Rev: c101296deae714fdd23adc89adae2d4adb3abd40
GitHub-Pull-Request: golang/go#44850
---
M src/os/path.go
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/os/path.go b/src/os/path.go
index df87887..6443dac 100644
--- a/src/os/path.go
+++ b/src/os/path.go
@@ -25,6 +25,11 @@
return &PathError{Op: "mkdir", Path: path, Err: syscall.ENOTDIR}
}

+ // Break out early if any portion of the path is inaccessible to the invoking user
+ if err == syscall.EACCES {
+ return err
+ }
+
// Slow path: make sure parent exists and then call Mkdir for path.
i := len(path)
for i > 0 && IsPathSeparator(path[i-1]) { // Skip trailing path separator.

To view, visit change 299611. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I31d75110e03e2f694c17655d31c21c0fb874dd6e
Gerrit-Change-Number: 299611
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-MessageType: newchange
Reply all
Reply to author
Forward
0 new messages