etcdata

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGroupsLocation = "/etc/group"

DefaultGroupsLocation the default location of the group file

View Source
const DefaultPasswdLocation = "/etc/passwd"

DefaultPasswdLocation the default location of the passwd file

View Source
const GroupFileRegex = `^(?P<name>[^:]*):(?P<password>[^:]*):(?P<gid>[^:]*):(?P<members>[^:]*)$`

GroupFileRegex Regex that is used to parse the /etc/passwd file

View Source
const MountRegex = `^(?P<device>.+) on (?P<path>\S+) ((type (?P<fstype_linux>\S+)\s+\()|(\((?P<fstype_bsd>\S+),))(?P<options>.*)\)`

MountRegex Regex used to parse the output of the `mount` command

View Source
const MountTimeout = (2 * time.Second)

MountTimeout The timeout before the `mount` command should be canceled

View Source
const PasswdFileRegex = `^(?P<username>[^:]*):(?P<password>[^:]*):(?P<uid>[^:]*):(?P<gid>[^:]*):(?P<comment>[^:]*):(?P<home>[^:]*):(?P<shell>[^:]*)$`

PasswdFileRegex Regex that is used to parse the /etc/passwd file

Variables

View Source
var DefaultHostsLocation string

DefaultHostsLocation Default path to the hosts file

View Source
var Entry = regexp.MustCompile(`^(?P<address>[0-9a-f:]\S+)\s+(?P<name>[^#\s+]\S+)\s*(?P<aliases>.*?)?(?:\s*#\s*(?P<comment>.*))?$`)

Entry matches a hosts file entry

View Source
var GroupParser = parser.Parser{
	Ignore:  regexp.MustCompile("^#"),
	Capture: regexp.MustCompile(GroupFileRegex),
}

GroupParser A Parser for the /etc/passwd file

View Source
var MountParser = parser.Parser{
	Ignore:  regexp.MustCompile("^#"),
	Capture: regexp.MustCompile(MountRegex),
}

MountParser A Parser for the /etc/passwd file

View Source
var PasswdParser = parser.Parser{
	Ignore:  regexp.MustCompile("^#"),
	Capture: regexp.MustCompile(PasswdFileRegex),
}

PasswdParser A Parser for the /etc/passwd file

Functions

This section is empty.

Types

type GroupsSource

type GroupsSource struct {
	GroupsLocation string
}

GroupsSource struct on which all methods are registered

func (*GroupsSource) Contexts

func (s *GroupsSource) Contexts() []string

List of contexts that this source is capable of find items for

func (*GroupsSource) Find

func (s *GroupsSource) Find(ctx context.Context, itemContext string) ([]*sdp.Item, error)

Find Gets information about all item that the source can possibly find. If nothing is found then just return an empty list (Required)

func (*GroupsSource) Get

func (s *GroupsSource) Get(ctx context.Context, itemContext string, query string) (*sdp.Item, error)

Get takes the UniqueAttribute value as a parameter (also referred to as the "name" of the item) and returns a full item will all details. This function must return an item whose UniqueAttribute value exactly matches the supplied parameter. If the item cannot be found it should return an ItemNotFoundError (Required)

func (*GroupsSource) GroupFile

func (s *GroupsSource) GroupFile() (*os.File, error)

GroupFile opens and returns the passwd file

func (*GroupsSource) Name

func (s *GroupsSource) Name() string

Name Returns the name of the backend package. This is used for debugging and logging (Required)

func (*GroupsSource) Search

func (s *GroupsSource) Search(ctx context.Context, itemContext string, query string) ([]*sdp.Item, error)

Search Searches by UID or Name (exact match). A "*" can also be passed which will return all items

func (*GroupsSource) Supported

func (s *GroupsSource) Supported() bool

Supported A function that can be executed to see if the backend is supported in the current environment, if it returns false the backend simply won't be loaded (Optional)

func (*GroupsSource) Type

func (s *GroupsSource) Type() string

Type is the type of items that this returns (Required)

func (*GroupsSource) Weight

func (s *GroupsSource) Weight() int

Weighting of duplicate sources

type HostsSource

type HostsSource struct {
	// Where to find the hosts file if not the default location (optional)
	HostsLocation string
}

HostsSource struct on which all methods are registered

func (*HostsSource) Contexts

func (s *HostsSource) Contexts() []string

List of contexts that this source is capable of find items for

func (*HostsSource) Find

func (s *HostsSource) Find(ctx context.Context, itemContext string) ([]*sdp.Item, error)

Find finds all items

func (*HostsSource) Get

func (s *HostsSource) Get(ctx context.Context, itemContext string, query string) (*sdp.Item, error)

Get takes the UniqueAttribute value as a parameter (also referred to as the "name" of the item) and returns a full item will all details. This function must return an item whose UniqueAttribute value exactly matches the supplied parameter. If the item cannot be found it should return an ItemNotFoundError (Required)

func (*HostsSource) HostsFile

func (s *HostsSource) HostsFile() (*os.File, error)

HostsFile Opens and returns the hosts file

func (*HostsSource) Name

func (s *HostsSource) Name() string

Name Returns the name of the backend package. This is used for debugging and logging (Required)

func (*HostsSource) Search

func (s *HostsSource) Search(ctx context.Context, itemContext string, query string) ([]*sdp.Item, error)

Search Search for a host entry, the query can be an ip, a name or '*'

func (*HostsSource) Type

func (s *HostsSource) Type() string

Type is the type of items that this returns (Required)

func (*HostsSource) Weight

func (s *HostsSource) Weight() int

Weighting of duplicate sources

type MountsSource

type MountsSource struct {
	MountFunction func() (*bufio.Scanner, error)
}

MountsSource struct on which all methods are registered

func (*MountsSource) Contexts

func (s *MountsSource) Contexts() []string

List of contexts that this source is capable of find items for

func (*MountsSource) Find

func (s *MountsSource) Find(ctx context.Context, itemContext string) ([]*sdp.Item, error)

Find Gets information about all item that the source can possibly find. If nothing is found then just return an empty list (Required)

func (*MountsSource) Get

func (s *MountsSource) Get(ctx context.Context, itemContext string, query string) (*sdp.Item, error)

Get takes the UniqueAttribute value as a parameter (also referred to as the "name" of the item) and returns a full item will all details. This function must return an item whose UniqueAttribute value exactly matches the supplied parameter. If the item cannot be found it should return an ItemNotFoundError (Required)

func (*MountsSource) Name

func (s *MountsSource) Name() string

Name Returns the name of the backend package. This is used for debugging and logging (Required)

func (*MountsSource) Scanner

func (s *MountsSource) Scanner(ctx context.Context) (*bufio.Scanner, error)

Scanner Executes the MountFunction and returns the scanner

func (*MountsSource) Search

func (s *MountsSource) Search(ctx context.Context, itemContext string, query string) ([]*sdp.Item, error)

Search Searches by path or device (exact match). A "*" can also be passed which will return all items

func (*MountsSource) Supported

func (s *MountsSource) Supported() bool

Supported A function that can be executed to see if the backend is supported in the current environment, if it returns false the backend simply won't be loaded (Optional)

func (*MountsSource) Type

func (s *MountsSource) Type() string

Type is the type of items that this returns (Required)

func (*MountsSource) Weight

func (s *MountsSource) Weight() int

Weighting of duplicate sources

type UsersSource

type UsersSource struct {
	PasswdLocation string
}

UsersSource struct on which all methods are registered

func (*UsersSource) Contexts

func (s *UsersSource) Contexts() []string

List of contexts that this source is capable of find items for

func (*UsersSource) Find

func (s *UsersSource) Find(ctx context.Context, itemContext string) ([]*sdp.Item, error)

Find Gets information about all item that the source can possibly find. If nothing is found then just return an empty list (Required)

func (*UsersSource) Get

func (s *UsersSource) Get(ctx context.Context, itemContext string, query string) (*sdp.Item, error)

Get takes the UniqueAttribute value as a parameter (also referred to as the "name" of the item) and returns a full item will all details. This function must return an item whose UniqueAttribute value exactly matches the supplied parameter. If the item cannot be found it should return an ItemNotFoundError (Required)

func (*UsersSource) Name

func (s *UsersSource) Name() string

Name Returns the name of the backend package. This is used for debugging and logging (Required)

func (*UsersSource) PasswdFile

func (s *UsersSource) PasswdFile() (*os.File, error)

PasswdFile opens and returns the passwd file

func (*UsersSource) Search

func (s *UsersSource) Search(ctx context.Context, itemContext string, query string) ([]*sdp.Item, error)

Search Searches by UID or Name (exact match). A "*" can also be passed which will return all items

func (*UsersSource) Supported

func (s *UsersSource) Supported() bool

Supported A function that can be executed to see if the backend is supported in the current environment, if it returns false the backend simply won't be loaded (Optional)

func (*UsersSource) Type

func (s *UsersSource) Type() string

Type is the type of items that this returns (Required)

func (*UsersSource) Weight

func (s *UsersSource) Weight() int

Weighting of duplicate sources

Jump to

Keyboard shortcuts

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