package openat

import "github.com/hanwen/go-fuse/v2/internal/openat"

Index

Functions

func OpenSymlinkAware

func OpenSymlinkAware(baseDir string, path string, flags int, mode uint32) (fd int, err error)

OpenSymlinkAware is a symlink-aware syscall.Open replacement.

What it does:

  1. Open baseDir (usually an absolute path), following symlinks.

    The user may have set up the directory tree with symlinks, that's not neccessarily malicous, but a normal use case.

  2. Open path (must be a relative path) within baseDir, rejecting symlinks with ELOOP.

    On Linux, it calls openat2(2) with RESOLVE_NO_SYMLINKS. This prevents following symlinks in any component of the path.

    On other platforms, it calls openat(2) with O_NOFOLLOW. TODO: This is insecure as O_NOFOLLOW only affects the final path component.

Source Files

openat.go openat_linux.go

Version
v2.8.0 (latest)
Published
Jun 11, 2025
Platform
linux/amd64
Imports
1 packages
Last checked
9 hours ago

Tools for package owners.