files

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ModeHomePerms = fs.FileMode(0600)

ModeHomePerms is the expected permission bits that should be set for opkssh user home policy files `~/.opk/auth_id`.

View Source
const ModeSystemPerms = fs.FileMode(0640)

ModeSystemPerms is the expected permission bits that should be set for opkssh system policy files (`/etc/opk/auth_id`, `/etc/opk/providers`). This mode means that only the owner of the file can write/read to the file, but the group which should be opksshuser can read the file.

Variables

This section is empty.

Functions

func CleanRow

func CleanRow(row string) string

Types

type ConfigLog

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

func ConfigProblems

func ConfigProblems() *ConfigLog

func (*ConfigLog) Clear

func (c *ConfigLog) Clear()

func (*ConfigLog) GetProblems

func (c *ConfigLog) GetProblems() []ConfigProblem

func (*ConfigLog) NoProblems

func (c *ConfigLog) NoProblems() bool

func (*ConfigLog) RecordProblem

func (c *ConfigLog) RecordProblem(entry ConfigProblem)

func (*ConfigLog) String

func (c *ConfigLog) String() string

type ConfigProblem

type ConfigProblem struct {
	Filepath            string
	OffendingLine       string
	OffendingLineNumber int
	ErrorMessage        string
	Source              string
}

func (ConfigProblem) String

func (e ConfigProblem) String() string

type FileLoader

type FileLoader struct {
	Fs           afero.Fs
	RequiredPerm fs.FileMode
}

UserPolicyLoader contains methods to read/write the opkssh policy file from/to an arbitrary filesystem. All methods that read policy from the filesystem fail and return an error immediately if the permission bits are invalid.

func (FileLoader) CreateIfDoesNotExist

func (l FileLoader) CreateIfDoesNotExist(path string) error

CreateIfDoesNotExist creates a file at the given path if it does not exist.

func (*FileLoader) Dump

func (l *FileLoader) Dump(fileBytes []byte, path string) error

Dump writes the bytes in fileBytes to the filepath

func (*FileLoader) LoadFileAtPath

func (l *FileLoader) LoadFileAtPath(path string) ([]byte, error)

LoadFileAtPath validates that the file at path exists, can be read by the current process, and has the correct permission bits set. Parses the contents and returns the bytes if file permissions are valid and reading is successful; otherwise returns an error.

type PermsChecker

type PermsChecker struct {
	Fs afero.Fs
	// contains filtered or unexported fields
}

PermsChecker contains methods to check the ownership, group and file permissions of a file on a Unix-like system.

func NewPermsChecker

func NewPermsChecker(fs afero.Fs) *PermsChecker

func (*PermsChecker) CheckPerm

func (u *PermsChecker) CheckPerm(path string, requirePerm fs.FileMode, requiredOwner string, requiredGroup string) error

CheckPerm checks the file at the given path if it has the desired permissions. If the requiredOwner or requiredGroup are not empty then the function will also that the owner and group of the file match the requiredOwner and requiredGroup specified and fail if they do not.

type Table

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

func NewTable

func NewTable(content []byte) *Table

func (*Table) AddRow

func (t *Table) AddRow(row ...string)

func (Table) GetRows

func (t Table) GetRows() [][]string

func (Table) ToBytes

func (t Table) ToBytes() []byte

func (Table) ToString

func (t Table) ToString() string

Jump to

Keyboard shortcuts

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