passwd

package
v1.2.26 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 8 Imported by: 1

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 ShadowEntry added in v1.2.25

type ShadowEntry struct {
	UserName string
	Password string
	LastChg  string
	Min      string
	Max      string
	Warn     string
	Inact    string
	Expire   string
	Flag     string
}

func (*ShadowEntry) Parse added in v1.2.25

func (se *ShadowEntry) Parse(line string) error

Parse parses an /etc/shadow line into a ShadowEntry

func (*ShadowEntry) Write added in v1.2.25

func (se *ShadowEntry) Write(w io.Writer) error

Write writes an /etc/shadow line into a io.writer

type ShadowFile added in v1.2.25

type ShadowFile struct {
	Entries []ShadowEntry
	// contains filtered or unexported fields
}

func ReadOrCreateShadowFile added in v1.2.25

func ReadOrCreateShadowFile(fsys apkfs.FullFS, filepath string) (ShadowFile, error)

ReadOrCreateShadowFile parses an /etc/shadow file into a ShadowFile. An empty file is created if /etc/shadow is missing.

func ReadShadowFile added in v1.2.25

func ReadShadowFile(fsys fs.FS, filepath string) (ShadowFile, error)

Read ShadowFile parses an /etc/shadow file into a ShadowFile. If /etc/shadow is missing, returns an error

func (*ShadowFile) Load added in v1.2.25

func (sf *ShadowFile) Load(r io.Reader) error

func (*ShadowFile) Write added in v1.2.25

func (sf *ShadowFile) Write(w io.Writer) error

Write writes an /etc/shadow file into an io.writer

func (*ShadowFile) WriteFile added in v1.2.25

func (sf *ShadowFile) WriteFile(filepath string) error

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