passwd

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package passwd implements simple functions to parse and manipulate /etc/passwd and /etc/group files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GroupEntry

type GroupEntry struct {
	GroupName string
	Password  string
	GID       uint32
	Members   []string
}

GroupEntry describes a single line in /etc/group.

func (*GroupEntry) Parse

func (ge *GroupEntry) Parse(line string) error

Parse parses an /etc/group line into a GroupEntry.

func (*GroupEntry) Write

func (ge *GroupEntry) Write(w io.Writer) error

Write writes an /etc/group line into an io.Writer.

type GroupFile

type GroupFile struct {
	Entries []GroupEntry
}

GroupFile describes an entire /etc/group file's contents.

func ReadGroupFile added in v0.7.0

func ReadGroupFile(fsys fs.FS, filePath string) (GroupFile, error)

ReadGroupFile parses an /etc/group file into a GroupFile. If /etc/group is missing, returns an error

func ReadOrCreateGroupFile

func ReadOrCreateGroupFile(fsys apkfs.FullFS, filePath string) (GroupFile, error)

ReadOrCreateGroupFile parses an /etc/group file into a GroupFile. An empty file is created if /etc/group is missing.

func (*GroupFile) Load

func (gf *GroupFile) Load(r io.Reader) error

Load loads an /etc/passwd file into a GroupFile from an io.Reader.

func (*GroupFile) Write

func (gf *GroupFile) Write(w io.Writer) error

Write writes an /etc/passwd file into an io.Writer.

func (*GroupFile) WriteFile

func (gf *GroupFile) WriteFile(fsys apkfs.FullFS, filePath string) error

WriteFile writes an /etc/passwd file from a GroupFile.

type UserEntry

type UserEntry struct {
	UserName string
	Password string
	UID      uint32
	GID      uint32
	Info     string
	HomeDir  string
	Shell    string
}

UserEntry contains the parsed data from an /etc/passwd entry.

func (*UserEntry) Parse

func (ue *UserEntry) Parse(line string) error

Parse parses an /etc/passwd line into a UserEntry.

func (*UserEntry) Write

func (ue *UserEntry) Write(w io.Writer) error

Write writes an /etc/passwd line into an io.Writer.

type UserFile

type UserFile struct {
	Entries []UserEntry
	// contains filtered or unexported fields
}

UserFile contains the entries from an /etc/passwd file.

func ReadOrCreateUserFile

func ReadOrCreateUserFile(fsys apkfs.FullFS, filePath string) (UserFile, error)

ReadOrCreateUserFile parses an /etc/passwd file into a UserFile. An empty file is created if /etc/passwd is missing.

func ReadUserFile added in v0.7.0

func ReadUserFile(fsys fs.FS, filePath string) (UserFile, error)

ReadUserFile parses an /etc/passwd file into a UserFile. If it is missing, returns an error.

func (*UserFile) Load

func (uf *UserFile) Load(r io.Reader) error

Load loads an /etc/passwd file into a UserFile from an io.Reader.

func (*UserFile) Write

func (uf *UserFile) Write(w io.Writer) error

Write writes an /etc/passwd file into an io.Writer.

func (*UserFile) WriteFile

func (uf *UserFile) WriteFile(filePath string) error

WriteFile writes an /etc/passwd file from a UserFile.

Jump to

Keyboard shortcuts

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