ownership

package
v0.0.0-...-b8ca463 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lookup

type Lookup interface {
	UID(username string) (int, error)
	GID(groupname string) (int, error)
}

Lookup is the interface needed by Keysync to resolve a user ID from their username (and group) It is intended to be used with the implementation on Os. There's also one in mock.go that uses fixed data instead of operating-system sourced data.

type Mock

type Mock struct {
	Users  map[string]int
	Groups map[string]int
}

Mock implements the lookup interface using a fixed set of users and groups, useful for tests

func (*Mock) GID

func (m *Mock) GID(username string) (int, error)

func (*Mock) UID

func (m *Mock) UID(username string) (int, error)

type Os

type Os struct{}

Os implements Lookup using the os/user standard library package

func (Os) GID

func (o Os) GID(groupname string) (int, error)

func (Os) UID

func (o Os) UID(username string) (int, error)

type Ownership

type Ownership struct {
	UID int
	GID int
	// Where to look up users and groups
	Lookup
}

Ownership indicates the default ownership of filesystem entries.

func NewOwnership

func NewOwnership(username, groupname, fallbackUser, fallbackGroup string, lookup Lookup, logger *logrus.Entry) Ownership

NewOwnership initializes default file ownership struct. Logs as error anything that goes wrong, but always returns something Worst-case you get "0", ie root, owning things, which is safe as root can always read all files.

Jump to

Keyboard shortcuts

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