Documentation
¶
Index ¶
- Constants
- Variables
- type GroupsSource
- func (s *GroupsSource) Contexts() []string
- func (s *GroupsSource) Find(ctx context.Context, itemContext string) ([]*sdp.Item, error)
- func (s *GroupsSource) Get(ctx context.Context, itemContext string, query string) (*sdp.Item, error)
- func (s *GroupsSource) GroupFile() (*os.File, error)
- func (s *GroupsSource) Name() string
- func (s *GroupsSource) Search(ctx context.Context, itemContext string, query string) ([]*sdp.Item, error)
- func (s *GroupsSource) Supported() bool
- func (s *GroupsSource) Type() string
- func (s *GroupsSource) Weight() int
- type HostsSource
- func (s *HostsSource) Contexts() []string
- func (s *HostsSource) Find(ctx context.Context, itemContext string) ([]*sdp.Item, error)
- func (s *HostsSource) Get(ctx context.Context, itemContext string, query string) (*sdp.Item, error)
- func (s *HostsSource) HostsFile() (*os.File, error)
- func (s *HostsSource) Name() string
- func (s *HostsSource) Search(ctx context.Context, itemContext string, query string) ([]*sdp.Item, error)
- func (s *HostsSource) Type() string
- func (s *HostsSource) Weight() int
- type MountsSource
- func (s *MountsSource) Contexts() []string
- func (s *MountsSource) Find(ctx context.Context, itemContext string) ([]*sdp.Item, error)
- func (s *MountsSource) Get(ctx context.Context, itemContext string, query string) (*sdp.Item, error)
- func (s *MountsSource) Name() string
- func (s *MountsSource) Scanner(ctx context.Context) (*bufio.Scanner, error)
- func (s *MountsSource) Search(ctx context.Context, itemContext string, query string) ([]*sdp.Item, error)
- func (s *MountsSource) Supported() bool
- func (s *MountsSource) Type() string
- func (s *MountsSource) Weight() int
- type UsersSource
- func (s *UsersSource) Contexts() []string
- func (s *UsersSource) Find(ctx context.Context, itemContext string) ([]*sdp.Item, error)
- func (s *UsersSource) Get(ctx context.Context, itemContext string, query string) (*sdp.Item, error)
- func (s *UsersSource) Name() string
- func (s *UsersSource) PasswdFile() (*os.File, error)
- func (s *UsersSource) Search(ctx context.Context, itemContext string, query string) ([]*sdp.Item, error)
- func (s *UsersSource) Supported() bool
- func (s *UsersSource) Type() string
- func (s *UsersSource) Weight() int
Constants ¶
const DefaultGroupsLocation = "/etc/group"
DefaultGroupsLocation the default location of the group file
const DefaultPasswdLocation = "/etc/passwd"
DefaultPasswdLocation the default location of the passwd file
const GroupFileRegex = `^(?P<name>[^:]*):(?P<password>[^:]*):(?P<gid>[^:]*):(?P<members>[^:]*)$`
GroupFileRegex Regex that is used to parse the /etc/passwd file
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
const MountTimeout = (2 * time.Second)
MountTimeout The timeout before the `mount` command should be canceled
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 ¶
var DefaultHostsLocation string
DefaultHostsLocation Default path to the hosts file
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
var GroupParser = parser.Parser{ Ignore: regexp.MustCompile("^#"), Capture: regexp.MustCompile(GroupFileRegex), }
GroupParser A Parser for the /etc/passwd file
var MountParser = parser.Parser{ Ignore: regexp.MustCompile("^#"), Capture: regexp.MustCompile(MountRegex), }
MountParser A Parser for the /etc/passwd file
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)
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 ¶
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)
type MountsSource ¶
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) 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)
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 ¶
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)