Documentation ¶
Overview ¶
Package userid provides complimentary functionality to the standard os/user package by using the 'id' command to avoid loss of functionality when cross compiling. It provides minimal functionality for windows, see below. On Unix systems, it first uses the os/user package and then falls back to the using the 'id' command. It offers reduced functionality as compared to os/user. By way of background os/user has both a pure-go implementation and a cgo implementation. The former parses /etc/passwd and the latter uses the getwpent operations. The cgo implementation cannot be used when cross compiling since cgo is generally disabled for cross compilation. Hence applications that use os/user can find themselves losing the ability to resolve info for all users when cross compiled and used on systems that use a directory service that is accessible via getpwent but whose members do not appear in the text file /etc/passwd.
For windows it uses the PowerShell to obtain minimal information on the user and windows SID and represents that information in the same format as the 'id' command.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCurrentUser ¶
func GetCurrentUser() string
GetCurrentUser returns the current user as determined by environment variables.
func ParseWindowsUser ¶
ParseWindowsUser returns the domain and user component of a windows username (domain\user).
Types ¶
type IDInfo ¶
IDInfo represents the parsed output of the 'id' command. It follows the convention of os/user.User and user.Group in that UID and GID are decimal strings on Posix systems but take on other, non-decimal, values on other systems (e.g SIDs on windows). The Username and Groupname are the system specific 'human-friendly' names.
func ParseIDCommandOutput ¶
ParseIDCommandOutput parses the output of the unix id command.
type IDManager ¶
type IDManager struct {
// contains filtered or unexported fields
}
IDManager implements a caching lookup of user information by id or username that uses the 'id' command.
func NewIDManager ¶
func NewIDManager() *IDManager
NewIDManager creates a new instance of IDManager.
func (*IDManager) LookupGroup ¶
LookupGroup returns IDInfo for the specified group id or group name. It returns user.UnknownGroupError if the group cannot be found or the invocation of the 'id' command fails somehow.