fdfs

package
v6.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package fdfs is like os.DirFS, but with a file descriptor and openat(2), fchownat(2), etc, to ensure symlinks do not escape.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

type FS struct {
	// contains filtered or unexported fields
}

FS uses a file descriptor for a directory as the base of a fs.FS.

func DirFS

func DirFS(dir string) (*FS, error)

DirFS opens the directory dir, and returns an FS rooted at that directory. It uses open(2) with O_RDONLY+O_DIRECTORY+O_CLOEXEC. Note that this will resolve symlinks in the path, so only use this to open a trusted base path.

func (*FS) Close

func (s *FS) Close() error

Close closes the file descriptor.

func (*FS) Lchown

func (s *FS) Lchown(path string, uid, gid int) error

Lchown wraps fchownat(2) (with AT_SYMLINK_NOFOLLOW).

func (*FS) Open

func (s *FS) Open(path string) (fs.File, error)

Open wraps openat2(2) with O_RDONLY+O_NOFOLLOW+O_CLOEXEC, and prohibits symlinks etc within the path.

func (*FS) RecursiveChown

func (s *FS) RecursiveChown(uid, gid int) error

RecursiveChown lchowns everything within the receiver.

func (*FS) Sub

func (s *FS) Sub(dir string) (*FS, error)

Sub wraps openat2(2) (with O_RDONLY+O_DIRECTORY+O_NOFOLLOW+O_CLOEXEC), and returns an FS.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL