filecheck

package
v0.0.0-...-9474aff Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package filecheck helps tests check permissions and ownership of on-disk files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(ctx context.Context, root string, pats []*Pattern) (
	problems map[string][]string, numPaths int, err error)

Check inspects all files within (and including) root. pats are executed in-order against each path. If a pattern matches a path, no later patterns are evaluated against it. If SkipChildren is included in a pattern , any matched directories' children are skipped. A map from absolute path names to strings describing problems is returned, along with the number of paths (not including ones skipped by SkipChildren) that were inspected.

Types

type Matcher

type Matcher func(path string) bool

Matcher matches a path relative to the root passed to Check.

func AllPaths

func AllPaths() Matcher

AllPaths returns a Matcher that matches all paths.

func Path

func Path(path string) Matcher

Path returns a Matcher that matches only the supplied path (relative to the root passed to Check).

func PathRegexp

func PathRegexp(r string) Matcher

PathRegexp returns a Matcher that matches all paths matched by regular expression r. r is evaluated against paths relative to the root passed to Check.

func Root

func Root() Matcher

Root returns a Matcher that matches the root path passed to Check.

func Tree

func Tree(path string) Matcher

Tree returns a Matcher that matches both path and its children. The path is relative to the root passed to Check.

type Option

type Option func(*Pattern)

Option is used to configure a Pattern.

func GID

func GID(gids ...uint32) Option

GID requires that the path be owned by one of the supplied group IDs.

func Groups

func Groups(gs ...string) Option

Groups returns options that permit a path to be owned by any of the supplied groups (all of which must exist).

func Mode

func Mode(m os.FileMode) Option

Mode requires that permission-related bits in the path's mode exactly match m. Only 0777, setuid, setgid, and the sticky bit may be supplied.

func NotMode

func NotMode(nm os.FileMode) Option

NotMode requires that the permission-related bits in the path's mode contain none of the bits in nm. Only 0777, setuid, setgid, and the sticky bit may be supplied.

func SkipChildren

func SkipChildren() Option

SkipChildren indicates that any child paths should not be checked. The directory itself will still be checked. This has no effect for non-directories.

func UID

func UID(uids ...uint32) Option

UID requires that the path be owned by one of the supplied user IDs.

func Users

func Users(usernames ...string) Option

Users returns options that permit a path to be owned by any of the supplied users (all of which must exist).

type Pattern

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

Pattern matches one or more paths. It can be used to verify that matched paths have expected ownership and permissions.

func NewPattern

func NewPattern(m Matcher, opts ...Option) *Pattern

NewPattern returns a new Pattern that verifies that paths matched by m meet the requirements specified by rs.

func (*Pattern) String

func (p *Pattern) String() string

Jump to

Keyboard shortcuts

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