nss

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2015 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package nss contains the gateway to query system Name Switch Service databases.

Index

Constants

This section is empty.

Variables

View Source
var DefaultService = New(sys.DefaultExecutor)

DefaultService is the NSS gateway that interacts with the system using the default command execution process in sys.DefaultExecutor.

Functions

func GetCurrentUser

func GetCurrentUser() (*user.User, error)

CurrentUser is an implementation of user.Current() since it's not implemented in some Linux distributions.

func GetIDsForUser

func GetIDsForUser(username string) (userID int, groupID int, err error)

GetIDsForUser searches the system for the given user name and returns the user ID and the primary group ID of that user.

func GetUser

func GetUser(name string) (*user.User, error)

GetUser is an implementation of user.Lookup() since it's not implemented in some Linux distributions.

Types

type Database

type Database string

Database represents NSS entry databases such as passwd, group, hosts, etc.

const (
	UserDatabase        Database = "passwd"
	UserShadowDatabase  Database = "shadow"
	GroupDatabase       Database = "group"
	GroupShadowDatabase Database = "gshadow"

	HostsDatabase Database = "hosts"
)

type GroupEntry

type GroupEntry struct {
	GroupName     string
	GID           int
	IsSystemGroup bool

	Members []string
}

GroupEntry is the representation of Name Switch Service 'group' database entry fields.

func GetGroupEntry

func GetGroupEntry(s Service, groupKey string) (*GroupEntry, error)

GetGroup queries the Name Switch Service 'group' Database for a given group key. Group key is usually the name of that group. It returns the parsed group entry.

type GroupShadowEntry

type GroupShadowEntry struct {
	GroupName    string
	PasswordHash string
	Admins       []string
	Members      []string
}

GroupShadowEntry is the representation of Name Switch Service 'gshadow' database entry fields.

func GetGroupShadowEntry

func GetGroupShadowEntry(s Service, groupKey string) (*GroupShadowEntry, error)

GetGroup queries the Name Switch Service 'gshadow' Database. It returns the parsed 'gshadow' entry belonging to given group key.

type MockService

type MockService struct {
	DB  chan Database
	Key chan string

	OutStr chan string
	OutErr chan error
}

func NewMockService

func NewMockService() *MockService

func (*MockService) GetEntryFrom

func (ms *MockService) GetEntryFrom(db Database, key string) (string, error)

type PasswdEntry

type PasswdEntry struct {
	UserName        string
	UID             int
	GID             int
	GECOS           string
	HomeDir         string
	DefaultShell    string
	IsSystemAccount bool
}

PasswdEntry is the representation of Name Switch Service 'passwd' database entry fields.

func GetPasswdEntry

func GetPasswdEntry(s Service, key string) (*PasswdEntry, error)

type Server

type Server struct {
	Exec sys.Executor
}

Server is an NSS Service implementation It takes a sys.Executor to execute nss query commands.

func New

func New(e sys.Executor) *Server

New returns an NSS Service using the given sys.Executor

func (*Server) GetEntryFrom

func (s *Server) GetEntryFrom(db Database, key string) (string, error)

GetEntryFrom queries the given Name Service Switch libraries with the supplied database key. Returns the raw database entry/entries or a meaningful error message about the retrieval of the key.

type Service

type Service interface {
	GetEntryFrom(Database, string) (string, error)
}

Service is a wrapper that can query the system NSS databases.

type ShadowEntry

type ShadowEntry struct {
	UserName      string
	PasswordHash  string
	ChangedAgo    string
	ChangedBefore string
	ExpiryPeriod  string
	DisabledSince string
}

ShadowEntry is the representation of Name Switch Service 'shadow' database entry fields.

func GetShadowEntry

func GetShadowEntry(s Service, key string) (*ShadowEntry, error)

ShadowEntry queries the NSS User Shadow Database.

Jump to

Keyboard shortcuts

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