File: openat_unix.go

package info (click to toggle)
golang-github-hanwen-go-fuse 2.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,584 kB
  • sloc: cpp: 78; sh: 47; makefile: 16
file content (15 lines) | stat: -rw-r--r-- 504 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//go:build !linux

package openat

import (
	"golang.org/x/sys/unix"
)

// TODO: This is insecure as O_NOFOLLOW only affects the final path component.
// See https://github.com/rfjakob/gocryptfs/issues/165 for how this could be handled.
func openatNoSymlinks(dirfd int, path string, flags int, mode uint32) (fd int, err error) {
	// os/exec expects all fds to have O_CLOEXEC or it will leak them to subprocesses.
	flags |= unix.O_NOFOLLOW | unix.O_CLOEXEC
	return unix.Openat(dirfd, path, flags, mode)
}