Documentation
¶
Index ¶
- Variables
- func CopyRegularFileByPath(src, dst string) error
- func CopyRegularFileByRelativePath(srcName string, dstRoot *os.Root, dstName string) error
- func CreateAt(root *os.Root, relativePath string) (*os.File, error)
- func Dup(file *os.File) (*os.File, error)
- func IsDirEmpty(pathname string) (bool, error)
- func IsRegularFile(name string) (bool, error)
- func MkdirAllAtExist(root *os.Root, relativePath string, perm fs.FileMode) error
- func MkdirAtExist(root *os.Root, relativePath string, perm fs.FileMode) error
- func NewProtectedReader(data []byte) io.ReaderAt
- func OpenAt(root *os.Root, relativePath string, flags int, perm fs.FileMode) (*os.File, error)
- func OpenRootDir(p string) (*os.Root, error)
- func RemoveAt(root *os.Root, relativePath string) error
- func RenameAt(root *os.Root, oldpath string, newpath string) error
- func SafeOpenFile(path string, flag int, perm os.FileMode) (*os.File, error)
- func SafeRemoveAll(path string) error
Constants ¶
This section is empty.
Variables ¶
var ErrMemoryAccess = errors.New("invalid memory access")
Functions ¶
func CopyRegularFileByPath ¶
CopyRegularFileByPath copies a file from src to dst
func CopyRegularFileByRelativePath ¶
CopyRegularFileByRelativePath copies a file from src to dst, where destination is relative to a given root directory. This function needs capabilities to be set before it is called.
func IsDirEmpty ¶
IsDirEmpty returns true if directory contains no files
func IsRegularFile ¶
IsRegularFile checks if the given file name points to a regular file
func MkdirAllAtExist ¶
MkdirAllAtExist recursively creates a directory and all necessary parents relative to root, ignoring "already exists" errors.
func MkdirAtExist ¶
MkdirAtExist creates a directory relative to root, ignoring "already exists" errors.
func NewProtectedReader ¶
NewProtectedReader returns an io.ReaderAt that wraps around a byte slice. Unlike the reader returned from bytes.NewReader(), this reader protects the reading function from fatal errors caused by invalid memory accesses to the underlying byte slice. If a fatal error occurs (e.g. SIGBUS or SIGSEGV), the read simply fails with an error that indicates a bad memory access. This is intended for reading from mmap'ed files, where a change to the file on disk can cause areas of the mapped memory to become invalid, resulting in a SIGBUS when accessing them.
func OpenAt ¶
OpenAt opens a file relative to root with the given flags and permissions. The operation is traversal-resistant: symlinks that escape root and ".." path components that would leave the tree are rejected by os.Root.
func OpenRootDir ¶
OpenRootDir opens a directory as an os.Root, providing traversal-resistant file operations. All file access through the returned Root is confined to the directory tree: symlinks that escape the root and ".." traversals are rejected. O_NOFOLLOW is applied to the initial open so that if p itself is a symlink, the call fails with ELOOP. The Root is constructed from the already-open fd via /proc/self/fd to avoid a TOCTOU window between the symlink check and the Root creation. Requires /proc mounted (standard on Linux, where Tracee exclusively runs).
func SafeOpenFile ¶
SafeOpenFile opens a file with O_NOFOLLOW, refusing to follow a symlink at the final path component. Use this for absolute or user-supplied paths that are not under an os.Root context.
func SafeRemoveAll ¶
SafeRemoveAll verifies with Lstat that path is not a symlink before calling os.RemoveAll. This prevents a top-level symlink from redirecting the recursive delete into an attacker-chosen tree.
Types ¶
This section is empty.