passwd

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: Apache-2.0 Imports: 6 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 ReadOrCreateGroupFile

func ReadOrCreateGroupFile(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(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
}

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

func ReadOrCreateUserFile

func ReadOrCreateUserFile(filePath string) (UserFile, error)

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

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