users

package
v0.0.0-...-38cbf26 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(e interface{}) (string, error)

Decodes the json from embeded interface to indented string

Types

type UserList

type UserList struct {
	// Userinfo lists for all system users
	Users []Userinfo `json:"users"`
}

func (*UserList) Get

func (ul *UserList) Get() (*UserList, error)

Get the userlist of all users

func (*UserList) ReadEtcPasswd

func (ul *UserList) ReadEtcPasswd(f string) ([]string, error)

Read file /etc/passwd and return slice of users

type UserListOps

type UserListOps interface {
	Get() (*UserList, error)
	ReadEtcPasswd(string) ([]string, error)
}

UserListOps interface provides list of all system users by parsing Linux password file.

func NewUserList

func NewUserList() UserListOps

NewUserList inits the interface for UserList

type UserOps

type UserOps interface {

	// Exported methods for Userinfo
	Get(string) (*Userinfo, error)
	AddUser(string) (string, error)
	DeleteUser(string) (string, error)
	// contains filtered or unexported methods
}

func NewUserOps

func NewUserOps() UserOps

NewUserOps inits the interface for Userinfo

type Userinfo

type Userinfo struct {
	// Uid is the user ID.
	Uid string `json:"uid"`

	// Gid is the primary group ID.
	Gid string `json:"gid"`

	// Username is the login name.
	Username string `json:"userName,omitempty"`

	// Group name / optional
	Groupname string `json:"groupName,omitempty"`

	// Name is the user's real or display name.
	// It might be blank.
	Name string `json:"name,omitempty"`

	// HomeDir is the path to the user's home directory
	// (if they have one).
	HomeDir string `json:"homeDir,omitempty"`

	UserPasswd string `json:"userPasswd,omitempty"`
}

func (*Userinfo) AddUser

func (u *Userinfo) AddUser(usrJsonFile string) (string, error)

AddUser adds the system user with provided schema

func (*Userinfo) DeleteUser

func (u *Userinfo) DeleteUser(userName string) (string, error)

DeleteUser gets the schema for user by name, deletes it if available.

func (*Userinfo) Get

func (u *Userinfo) Get(userName string) (*Userinfo, error)

Get user schema with username

Jump to

Keyboard shortcuts

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