Documentation
¶
Index ¶
Constants ¶
const ModeHomePerms = fs.FileMode(0600)
ModeHomePerms is the expected permission bits that should be set for opkssh user home policy files `~/.opk/auth_id`.
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 ¶
Types ¶
type ConfigLog ¶
type ConfigLog struct {
// contains filtered or unexported fields
}
func ConfigProblems ¶
func ConfigProblems() *ConfigLog
func (*ConfigLog) GetProblems ¶
func (c *ConfigLog) GetProblems() []ConfigProblem
func (*ConfigLog) NoProblems ¶
func (*ConfigLog) RecordProblem ¶
func (c *ConfigLog) RecordProblem(entry ConfigProblem)
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 ¶
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 ¶
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.