]> Cypherpunks repositories - gostls13.git/commitdiff
os: fix Root.Mkdir permission bits on OpenBSD
authorJosh Rickmar <jrick@zettaport.com>
Thu, 1 May 2025 15:09:40 +0000 (15:09 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 1 May 2025 23:36:58 +0000 (16:36 -0700)
Pass missing mode bits in the mkdirat() syscall wrapper.

Fixes #73559

Change-Id: I54b1985bd77b1fe5d1a48acab9f2597f8c931854
GitHub-Last-Rev: 669c17361d86bc9065bb6b47a2d60aa86bcfa12d
GitHub-Pull-Request: golang/go#73565
Reviewed-on: https://go-review.googlesource.com/c/go/+/669375
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
src/internal/syscall/unix/at_openbsd.go
src/os/root_test.go

index 0fd5e90e5c3bc562b504e791fa6baa9143d49ec7..96e77eb408454b9d51fb15146aaf7aa4146d164b 100644 (file)
@@ -43,7 +43,7 @@ func Mkdirat(dirfd int, path string, mode uint32) error {
        if err != nil {
                return err
        }
-       _, _, errno := syscall_syscall6(abi.FuncPCABI0(libc_mkdirat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(p)), 0, 0, 0, 0)
+       _, _, errno := syscall_syscall6(abi.FuncPCABI0(libc_mkdirat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(mode), 0, 0, 0)
        if errno != 0 {
                return errno
        }
index 3fec9c5684ee8b2a5b5d3f0ae7698d443baa92ee..63c921b66bec799930f739d6fa8be48ff01c40ad 100644 (file)
@@ -507,6 +507,12 @@ func TestRootMkdir(t *testing.T) {
                        if !fi.IsDir() {
                                t.Fatalf(`stat file created with Root.Mkdir(%q): not a directory`, test.open)
                        }
+                       if mode := fi.Mode(); mode&0o777 == 0 {
+                               // Issue #73559: We're not going to worry about the exact
+                               // mode bits (which will have been modified by umask),
+                               // but there should be mode bits.
+                               t.Fatalf(`stat file created with Root.Mkdir(%q): mode=%v, want non-zero`, test.open, mode)
+                       }
                })
        }
 }