user

package
v0.0.0-...-2a34ce9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckUserExists

func CheckUserExists(username string) bool

func ParseFile

func ParseFile(path string) (map[string]UserEntry, error)

func ParseReader

func ParseReader(r io.Reader) (map[string]UserEntry, error)

func ReadShadow

func ReadShadow(path string) (map[string]ShadowEntry, error)

func ReadSystemShadow

func ReadSystemShadow() (map[string]ShadowEntry, error)

func ReadSystemUsers

func ReadSystemUsers() (map[string]UserEntry, error)

Parse opens the '/etc/passwd' file and parses it into a map from usernames to Entries

Types

type ShadowEntry

type ShadowEntry struct {
	Username string

	Password string `json:"-"`

	// Days since Jan 1, 1970 password was last changed.
	LastChange string

	// -1 if password aging is disabled.
	MinPasswordAge string

	// 用户必须更改密码的天数。
	//
	// -1 is password aging is disabled.
	MaxPasswordAge string

	// 密码到期前的天数(请参阅上面的密码最长使用期限),在此期间应向用户发出警告。
	//
	// -1 is password aging is disabled.
	WarnPeriod string

	// 密码过期后的天数(请参阅上面的密码最长使用期限),在此期间密码仍应被接受。
	//
	// -1 is password aging is disabled.
	InactivityPeriod string

	// 帐户的到期日期,表示为自1970年1月1日以来的天数。
	//
	// -1 is account never expires.
	AccountExpiry string

	// Unused now.
	Flags string
}

func (*ShadowEntry) GetAccountExpiry

func (u *ShadowEntry) GetAccountExpiry() string

func (*ShadowEntry) GetFlags

func (u *ShadowEntry) GetFlags() string

func (*ShadowEntry) ToString

func (u *ShadowEntry) ToString() string

type UserEntry

type UserEntry struct {
	Username string
	Password string
	Uid      string
	Gid      string
	Gecos    string
	Home     string
	Shell    string
}

func (*UserEntry) ToString

func (u *UserEntry) ToString() string

Jump to

Keyboard shortcuts

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