entities

package
v0.0.0-...-68348ba Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ENTITY_ENV_DEF_GROUPS        = "ENTITY_DEFAULT_GROUPS"
	ENTITY_ENV_DEF_PASSWD        = "ENTITY_DEFAULT_PASSWD"
	ENTITY_ENV_DEF_SHADOW        = "ENTITY_DEFAULT_SHADOW"
	ENTITY_ENV_DEF_GSHADOW       = "ENTITY_DEFAULT_GSHADOW"
	ENTITY_ENV_DEF_DYNAMIC_RANGE = "ENTITY_DYNAMIC_RANGE"
)
View Source
const (
	UserKind    = "user"
	ShadowKind  = "shadow"
	GroupKind   = "group"
	GShadowKind = "gshadow"
)

Variables

This section is empty.

Functions

func DynamicRange

func DynamicRange() (int, int)

func GShadowDefault

func GShadowDefault(s string) string

func GroupsDefault

func GroupsDefault(s string) string

func ParseGShadow

func ParseGShadow(path string) (map[string]GShadow, error)

ParseGShadow opens the file and parses it into a map from usernames to Entries

func ParseGShadowReader

func ParseGShadowReader(r io.Reader) (map[string]GShadow, error)

ParseGShadowReader consumes the contents of r and parses it into a map from usernames to Entries

func ParseGroup

func ParseGroup(path string) (map[string]Group, error)

ParseGroup opens the file and parses it into a map from usernames to Entries

func ParseGroupReader

func ParseGroupReader(r io.Reader) (map[string]Group, error)

ParseGroupReader consumes the contents of r and parses it into a map from usernames to Entries

func ParseReader

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

ParseReader consumes the contents of r and parses it into a map from usernames to Entries

func ParseShadow

func ParseShadow(path string) (map[string]Shadow, error)

ParseShadow opens the file and parses it into a map from usernames to Entries

func ParseUser

func ParseUser(path string) (map[string]UserPasswd, error)

func ShadowDefault

func ShadowDefault(s string) string

func Unique

func Unique(strSlice []string) []string

func UserDefault

func UserDefault(s string) string

Types

type EntitiesParser

type EntitiesParser interface {
	ReadEntity(entity string) (Entity, error)
}

type EntitiesStore

type EntitiesStore struct {
	Users    map[string]UserPasswd
	Groups   map[string]Group
	Shadows  map[string]Shadow
	GShadows map[string]GShadow
}

func NewEntitiesStore

func NewEntitiesStore() *EntitiesStore

func (*EntitiesStore) AddEntity

func (s *EntitiesStore) AddEntity(e Entity) error

func (*EntitiesStore) AddGShadow

func (s *EntitiesStore) AddGShadow(e GShadow) error

func (*EntitiesStore) AddGroup

func (s *EntitiesStore) AddGroup(g Group) error

func (*EntitiesStore) AddShadow

func (s *EntitiesStore) AddShadow(e Shadow) error

func (*EntitiesStore) AddUser

func (s *EntitiesStore) AddUser(u UserPasswd) error

func (*EntitiesStore) GetGShadow

func (s *EntitiesStore) GetGShadow(name string) (GShadow, bool)

func (*EntitiesStore) GetGroup

func (s *EntitiesStore) GetGroup(name string) (Group, bool)

func (*EntitiesStore) GetShadow

func (s *EntitiesStore) GetShadow(name string) (Shadow, bool)

func (*EntitiesStore) GetUser

func (s *EntitiesStore) GetUser(name string) (UserPasswd, bool)

func (*EntitiesStore) Load

func (s *EntitiesStore) Load(dir string) error

type Entity

type Entity interface {
	GetKind() string
	String() string
	Delete(s string) error
	Create(s string) error
	Apply(s string, safe bool) error
}

type GShadow

type GShadow struct {
	Name           string `yaml:"name"`
	Password       string `yaml:"password"`
	Administrators string `yaml:"administrators"`
	Members        string `yaml:"members"`
}

func (GShadow) Apply

func (u GShadow) Apply(s string, safe bool) error

func (GShadow) Create

func (u GShadow) Create(s string) error

func (GShadow) Delete

func (u GShadow) Delete(s string) error

func (GShadow) GetKind

func (u GShadow) GetKind() string

func (GShadow) String

func (u GShadow) String() string

type Group

type Group struct {
	Name     string `yaml:"group_name"`
	Password string `yaml:"password"`
	Gid      *int   `yaml:"gid"`
	Users    string `yaml:"users"`
}

func (Group) Apply

func (u Group) Apply(s string, safe bool) error

func (Group) Create

func (u Group) Create(s string) error

func (Group) Delete

func (u Group) Delete(s string) error

func (Group) GetKind

func (u Group) GetKind() string

func (Group) String

func (u Group) String() string

type Parser

type Parser struct{}

func (Parser) ReadEntity

func (p Parser) ReadEntity(entity string) (Entity, error)

func (Parser) ReadEntityFromBytes

func (p Parser) ReadEntityFromBytes(yamlFile []byte) (Entity, error)

type Shadow

type Shadow struct {
	Username       string `yaml:"username"`
	Password       string `yaml:"password"`
	LastChanged    string `yaml:"last_changed"`
	MinimumChanged string `yaml:"minimum_changed"`
	MaximumChanged string `yaml:"maximum_changed"`
	Warn           string `yaml:"warn"`
	Inactive       string `yaml:"inactive"`
	Expire         string `yaml:"expire"`
	Reserved       string `yaml:"reserved"`
}

func (Shadow) Apply

func (u Shadow) Apply(s string, safe bool) error

func (Shadow) Create

func (u Shadow) Create(s string) error

FIXME: Create can be shared across all of the supported Entities

func (Shadow) Delete

func (u Shadow) Delete(s string) error

FIXME: Delete can be shared across all of the supported Entities

func (Shadow) GetKind

func (u Shadow) GetKind() string

func (Shadow) String

func (u Shadow) String() string

type Signature

type Signature struct {
	Kind string `yaml:"kind"`
}

type UserPasswd

type UserPasswd struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Uid      int    `yaml:"uid"`
	Gid      int    `yaml:"gid"`
	Group    string `yaml:"group"`
	Info     string `yaml:"info"`
	Homedir  string `yaml:"homedir"`
	Shell    string `yaml:"shell"`
}

func (UserPasswd) Apply

func (u UserPasswd) Apply(s string, safe bool) error

func (UserPasswd) Create

func (u UserPasswd) Create(s string) error

func (UserPasswd) Delete

func (u UserPasswd) Delete(s string) error

func (UserPasswd) GetKind

func (u UserPasswd) GetKind() string

func (UserPasswd) String

func (u UserPasswd) String() string

Jump to

Keyboard shortcuts

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