Documentation
¶
Index ¶
- Constants
- func MarshalRequest(command uint32, data []byte) ([]byte, error)
- func MarshalString(s string) []byte
- func UnmarshalString(data []byte, offset int) (string, int, error)
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect() error
- func (c *Client) ConnectContext(ctx context.Context) error
- func (c *Client) GetGroupByGID(gid uint32) (*Group, error)
- func (c *Client) GetGroupByName(groupname string) (*Group, error)
- func (c *Client) GetGroupsForUser(username string) ([]uint32, error)
- func (c *Client) GetUserByName(username string) (*User, error)
- func (c *Client) GetUserByUID(uid uint32) (*User, error)
- type ClientOption
- type Group
- type MessageHeader
- type Request
- type Response
- type User
Constants ¶
const ( // Default socket paths DefaultNSSSocketPath = "/var/lib/sss/pipes/nss" // Protocol version ProtocolVersion = 1 // Request commands (based on SSSD NSS responder protocol) // From src/sss_client/sss_cli.h SSS_GET_VERSION = 0x0001 // Get protocol version SSS_NSS_GETPWNAM = 0x0011 // Get user by name SSS_NSS_GETPWUID = 0x0012 // Get user by UID SSS_NSS_SETPWENT = 0x0013 // Begin user enumeration SSS_NSS_GETPWENT = 0x0014 // Get next user entry SSS_NSS_ENDPWENT = 0x0015 // End user enumeration SSS_NSS_GETGRNAM = 0x0021 // Get group by name SSS_NSS_GETGRGID = 0x0022 // Get group by GID SSS_NSS_SETGRENT = 0x0023 // Begin group enumeration SSS_NSS_GETGRENT = 0x0024 // Get next group entry SSS_NSS_ENDGRENT = 0x0025 // End group enumeration SSS_NSS_INITGR = 0x0026 // Get groups for user SSS_NSS_SETNETGRENT = 0x0061 // Begin netgroup enumeration SSS_NSS_GETNETGRENT = 0x0062 // Get next netgroup entry SSS_NSS_ENDNETGRENT = 0x0063 // End netgroup enumeration SSS_NSS_GETSERVBYNAME = 0x00A1 // Get service by name SSS_NSS_GETSERVBYPORT = 0x00A2 // Get service by port SSS_NSS_SETSERVENT = 0x00A3 // Begin service enumeration SSS_NSS_GETSERVENT = 0x00A4 // Get next service entry SSS_NSS_ENDSERVENT = 0x00A5 // End service enumeration // Response status codes SSS_NSS_STATUS_SUCCESS = 0 SSS_NSS_STATUS_NOTFOUND = 1 SSS_NSS_STATUS_UNAVAIL = 2 SSS_NSS_STATUS_TRYAGAIN = 3 SSS_NSS_STATUS_PROTOCOL_ERROR = 4 )
SSSD NSS protocol constants
Variables ¶
This section is empty.
Functions ¶
func MarshalRequest ¶
MarshalRequest creates a binary request message
func MarshalString ¶
MarshalString creates a null-terminated string for protocol messages For GETPWNAM requests, it's just the username as a null-terminated string
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a connection to the SSSD NSS responder. NOTE: Client is not goroutine-safe; callers must serialize access or use separate Client instances per goroutine.
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
NewClient creates a new SSSD NSS client
func (*Client) ConnectContext ¶
ConnectContext establishes a connection using the provided context for dialing and for managing the lifecycle of the connection (socket will be closed when ctx is done). This is a convenience wrapper that avoids storing the context on the client.
func (*Client) GetGroupByGID ¶
GetGroupByGID looks up a group by GID
func (*Client) GetGroupByName ¶
GetGroupByName looks up a group by name
func (*Client) GetGroupsForUser ¶
GetGroupsForUser retrieves all groups that a user belongs to Protocol: INITGROUP Reply format 0-3: 32bit unsigned number of results 4-7: 32bit unsigned (reserved/padding) For each result: 0-3: 32bit number with gid
func (*Client) GetUserByName ¶
GetUserByName looks up a user by username
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is a function that configures a Client
func WithContext ¶
func WithContext(ctx context.Context) ClientOption
WithContext sets a context used to cancel in-flight operations.
func WithSocketPath ¶
func WithSocketPath(path string) ClientOption
WithSocketPath sets a custom socket path
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout sets the timeout for socket operations
type Group ¶
Group represents a group entry returned by SSSD
func UnmarshalGroup ¶
UnmarshalGroup parses group data from a response Protocol format (from nss_group.c): 0-3: 32bit unsigned number of results 4-7: 32bit unsigned (reserved/padding) For each result:
0-3: 32bit number gid 4-7: 32bit unsigned number of members 8-X: sequence of 0 terminated strings (name, passwd, members...)
type MessageHeader ¶
type MessageHeader struct {
Length uint32 // Total message length including header
Command uint32 // Command/request type
Status uint32 // Response status (for responses)
Reserved uint32 // Reserved for future use
}
MessageHeader represents the SSSD protocol message header The protocol uses a simple TLV (Type-Length-Value) format
type Request ¶
type Request struct {
Header MessageHeader
Data []byte
}
Request represents a generic SSSD NSS request
type Response ¶
type Response struct {
Header MessageHeader
Data []byte
}
Response represents a generic SSSD NSS response
func UnmarshalResponse ¶
UnmarshalResponse parses a binary response message
type User ¶
type User struct {
Name string
Passwd string
UID uint32
GID uint32
Gecos string
HomeDir string
Shell string
}
User represents a passwd entry returned by SSSD
func UnmarshalUser ¶
UnmarshalUser parses user data from a response Protocol format (from nss_passwd.c): 0-3: 32bit unsigned number of results 4-7: 32bit unsigned (reserved/padding) For each result:
0-3: 32bit number uid 4-7: 32bit number gid 8-X: sequence of 5, 0 terminated, strings (name, passwd, gecos, dir, shell)