sss_idmap 2.12.0
Map Unix UIDs and GIDs to SIDs and back

Libsss_idmap provides a mechanism to translate a SID to a UNIX UID or GID or the other way round. More...

Data Structures

struct  sss_idmap_range
 Structure for id ranges FIXME: this struct might change when it is clear how ranges are handled on the server side. More...
struct  sss_idmap_offset_murmurhash3_data
 Structure for private data for offset_murmurhash3. More...

Typedefs

typedef void * idmap_alloc_func(size_t size, void *pvt)
 Typedef for memory allocation functions.
typedef enum idmap_error_code(* idmap_store_cb) (const char *dom_name, const char *dom_sid, const char *range_id, uint32_t min_id, uint32_t max_id, uint32_t first_rid, void *pvt)
 Typedef for storing mappings of dynamically created domains.

Enumerations

enum  idmap_error_code {
  IDMAP_SUCCESS = 0 , IDMAP_NOT_IMPLEMENTED , IDMAP_ERROR , IDMAP_OUT_OF_MEMORY ,
  IDMAP_NO_DOMAIN , IDMAP_CONTEXT_INVALID , IDMAP_SID_INVALID , IDMAP_SID_UNKNOWN ,
  IDMAP_NO_RANGE , IDMAP_BUILTIN_SID , IDMAP_OUT_OF_SLICES , IDMAP_COLLISION ,
  IDMAP_EXTERNAL , IDMAP_NAME_UNKNOWN , IDMAP_NO_REVERSE , IDMAP_UTF8_ERROR ,
  IDMAP_ERR_LAST
}
 Error codes used by libsss_idmap. More...

Functions

enum idmap_error_code sss_idmap_init (idmap_alloc_func *alloc_func, void *alloc_pvt, idmap_free_func *free_func, struct sss_idmap_ctx **ctx)
 Initialize idmap context.
enum idmap_error_code sss_idmap_ctx_set_autorid (struct sss_idmap_ctx *ctx, bool use_autorid)
 Set/unset autorid compatibility mode.
enum idmap_error_code sss_idmap_ctx_set_lower (struct sss_idmap_ctx *ctx, id_t lower)
 Set the lower bound of the range of POSIX IDs.
enum idmap_error_code sss_idmap_ctx_set_upper (struct sss_idmap_ctx *ctx, id_t upper)
 Set the upper bound of the range of POSIX IDs.
enum idmap_error_code sss_idmap_ctx_set_rangesize (struct sss_idmap_ctx *ctx, id_t rangesize)
 Set the range size of POSIX IDs available for single domain.
enum idmap_error_code sss_idmap_ctx_set_extra_slice_init (struct sss_idmap_ctx *ctx, int extra_slice_init)
 Set the number of secondary slices available for domain.
enum idmap_error_code sss_idmap_ctx_get_autorid (struct sss_idmap_ctx *ctx, bool *_autorid)
 Check if autorid compatibility mode is set.
enum idmap_error_code sss_idmap_ctx_get_lower (struct sss_idmap_ctx *ctx, id_t *_lower)
 Get the lower bound of the range of POSIX IDs.
enum idmap_error_code sss_idmap_ctx_get_upper (struct sss_idmap_ctx *ctx, id_t *_upper)
 Get the upper bound of the range of POSIX IDs.
enum idmap_error_code sss_idmap_ctx_get_rangesize (struct sss_idmap_ctx *ctx, id_t *rangesize)
 Get the range size of POSIX IDs available for single domain.
enum idmap_error_code sss_idmap_calculate_range (struct sss_idmap_ctx *ctx, const char *dom_sid, id_t *slice_num, struct sss_idmap_range *range)
 Calculate new range of available POSIX IDs.
enum idmap_error_code sss_idmap_add_domain (struct sss_idmap_ctx *ctx, const char *domain_name, const char *domain_sid, struct sss_idmap_range *range)
 Add a domain to the idmap context.
enum idmap_error_code sss_idmap_add_domain_ex (struct sss_idmap_ctx *ctx, const char *domain_name, const char *domain_sid, struct sss_idmap_range *range, const char *range_id, uint32_t rid, bool external_mapping)
 Add a domain with the first mappable RID to the idmap context.
enum idmap_error_code sss_idmap_add_auto_domain_ex (struct sss_idmap_ctx *ctx, const char *domain_name, const char *domain_sid, struct sss_idmap_range *range, const char *range_id, uint32_t rid, bool external_mapping, idmap_store_cb cb, void *pvt)
 Add a domain with the first mappable RID to the idmap context and generate automatically secondary slices.
enum idmap_error_code sss_idmap_check_collision (struct sss_idmap_ctx *ctx, char *n_name, char *n_sid, struct sss_idmap_range *n_range, uint32_t n_first_rid, char *n_range_id, bool n_external_mapping)
 Check if a new range would collide with any existing one.
enum idmap_error_code sss_idmap_check_collision_ex (const char *o_name, const char *o_sid, struct sss_idmap_range *o_range, uint32_t o_first_rid, const char *o_range_id, bool o_external_mapping, const char *n_name, const char *n_sid, struct sss_idmap_range *n_range, uint32_t n_first_rid, const char *n_range_id, bool n_external_mapping)
 Check if two ranges would collide.
enum idmap_error_code sss_idmap_sid_to_unix (struct sss_idmap_ctx *ctx, const char *sid, uint32_t *id)
 Translate SID to a unix UID or GID.
enum idmap_error_code sss_idmap_dom_sid_to_unix (struct sss_idmap_ctx *ctx, struct sss_dom_sid *dom_sid, uint32_t *id)
 Translate a SID stucture to a unix UID or GID.
enum idmap_error_code sss_idmap_bin_sid_to_unix (struct sss_idmap_ctx *ctx, uint8_t *bin_sid, size_t length, uint32_t *id)
 Translate a binary SID to a unix UID or GID.
enum idmap_error_code sss_idmap_smb_sid_to_unix (struct sss_idmap_ctx *ctx, struct dom_sid *smb_sid, uint32_t *id)
 Translate a Samba dom_sid stucture to a unix UID or GID.
enum idmap_error_code sss_idmap_check_sid_unix (struct sss_idmap_ctx *ctx, const char *sid, uint32_t id)
 Check if a SID and a unix UID or GID belong to the same range.
enum idmap_error_code sss_idmap_check_dom_sid_unix (struct sss_idmap_ctx *ctx, struct sss_dom_sid *dom_sid, uint32_t id)
 Check if a SID structure and a unix UID or GID belong to the same range.
enum idmap_error_code sss_idmap_check_bin_sid_unix (struct sss_idmap_ctx *ctx, uint8_t *bin_sid, size_t length, uint32_t id)
 Check if a binary SID and a unix UID or GID belong to the same range.
enum idmap_error_code sss_idmap_check_smb_sid_unix (struct sss_idmap_ctx *ctx, struct dom_sid *smb_sid, uint32_t id)
 Check if a Samba dom_sid structure and a unix UID or GID belong to the same range.
enum idmap_error_code sss_idmap_unix_to_sid (struct sss_idmap_ctx *ctx, uint32_t id, char **sid)
 Translate unix UID or GID to a SID.
enum idmap_error_code sss_idmap_unix_to_dom_sid (struct sss_idmap_ctx *ctx, uint32_t id, struct sss_dom_sid **dom_sid)
 Translate unix UID or GID to a SID structure.
enum idmap_error_code sss_idmap_unix_to_bin_sid (struct sss_idmap_ctx *ctx, uint32_t id, uint8_t **bin_sid, size_t *length)
 Translate unix UID or GID to a binary SID.
enum idmap_error_code sss_idmap_free (struct sss_idmap_ctx *ctx)
 Free all the allocated memory of the idmap context.
enum idmap_error_code sss_idmap_free_sid (struct sss_idmap_ctx *ctx, char *sid)
 Free mapped SID.
enum idmap_error_code sss_idmap_free_dom_sid (struct sss_idmap_ctx *ctx, struct sss_dom_sid *dom_sid)
 Free mapped domain SID.
enum idmap_error_code sss_idmap_free_smb_sid (struct sss_idmap_ctx *ctx, struct dom_sid *smb_sid)
 Free mapped Samba SID.
enum idmap_error_code sss_idmap_free_bin_sid (struct sss_idmap_ctx *ctx, uint8_t *bin_sid)
 Free mapped binary SID.
const char * idmap_error_string (enum idmap_error_code err)
 Translate error code to a string.
bool is_domain_sid (const char *str)
 Check if given string can be used as domain SID.
enum idmap_error_code sss_idmap_domain_has_algorithmic_mapping (struct sss_idmap_ctx *ctx, const char *dom_sid, bool *has_algorithmic_mapping)
 Check if a domain is configured with algorithmic mapping.
enum idmap_error_code sss_idmap_domain_by_name_has_algorithmic_mapping (struct sss_idmap_ctx *ctx, const char *dom_name, bool *has_algorithmic_mapping)
 Check if a domain is configured with algorithmic mapping.
enum idmap_error_code sss_idmap_bin_sid_to_dom_sid (struct sss_idmap_ctx *ctx, const uint8_t *bin_sid, size_t length, struct sss_dom_sid **dom_sid)
 Convert binary SID to SID structure.
enum idmap_error_code sss_idmap_bin_sid_to_sid (struct sss_idmap_ctx *ctx, const uint8_t *bin_sid, size_t length, char **sid)
 Convert binary SID to SID string.
enum idmap_error_code sss_idmap_dom_sid_to_bin_sid (struct sss_idmap_ctx *ctx, struct sss_dom_sid *dom_sid, uint8_t **bin_sid, size_t *length)
 Convert SID structure to binary SID.
enum idmap_error_code sss_idmap_sid_to_bin_sid (struct sss_idmap_ctx *ctx, const char *sid, uint8_t **bin_sid, size_t *length)
 Convert SID string to binary SID.
enum idmap_error_code sss_idmap_dom_sid_to_sid (struct sss_idmap_ctx *ctx, struct sss_dom_sid *dom_sid, char **sid)
 Convert SID structure to SID string.
enum idmap_error_code sss_idmap_sid_to_dom_sid (struct sss_idmap_ctx *ctx, const char *sid, struct sss_dom_sid **dom_sid)
 Convert SID string to SID structure.
enum idmap_error_code sss_idmap_sid_to_smb_sid (struct sss_idmap_ctx *ctx, const char *sid, struct dom_sid **smb_sid)
 Convert SID string to Samba dom_sid structure.
enum idmap_error_code sss_idmap_smb_sid_to_sid (struct sss_idmap_ctx *ctx, struct dom_sid *smb_sid, char **sid)
 Convert Samba dom_sid structure to SID string.
enum idmap_error_code sss_idmap_dom_sid_to_smb_sid (struct sss_idmap_ctx *ctx, struct sss_dom_sid *dom_sid, struct dom_sid **smb_sid)
 Convert SID stucture to Samba dom_sid structure.
enum idmap_error_code sss_idmap_smb_sid_to_dom_sid (struct sss_idmap_ctx *ctx, struct dom_sid *smb_sid, struct sss_dom_sid **dom_sid)
 Convert Samba dom_sid structure to SID structure.
enum idmap_error_code sss_idmap_bin_sid_to_smb_sid (struct sss_idmap_ctx *ctx, const uint8_t *bin_sid, size_t length, struct dom_sid **smb_sid)
 Convert binary SID to Samba dom_sid structure.
enum idmap_error_code sss_idmap_smb_sid_to_bin_sid (struct sss_idmap_ctx *ctx, struct dom_sid *smb_sid, uint8_t **bin_sid, size_t *length)
 Convert Samba dom_sid structure to binary SID.
enum idmap_error_code idmap_offset_func (void *pvt, uint32_t range_size, const char *input, long long *offset)
 Typedef for functions to calculate an offset for id-mapping and, if possible, for the reverse operation.
enum idmap_error_code sss_idmap_add_gen_domain_ex (struct sss_idmap_ctx *ctx, const char *domain_name, const char *domain_id, struct sss_idmap_range *range, const char *range_id, idmap_offset_func *offset_func, idmap_rev_offset_func *rev_offset_func, void *offset_func_pvt, uint32_t shift, bool external_mapping)
 Add a generic domain to the idmap context.
enum idmap_error_code sss_idmap_offset_identity (void *pvt, uint32_t range_size, const char *input, long long *offset)
 Calculate offset from string containing only numbers.
enum idmap_error_code sss_idmap_rev_offset_identity (struct sss_idmap_ctx *ctx, void *pvt, uint32_t id, char **_out)
 Reverse of sss_idmap_offset_identity, return a string containig only numbers representing the given offset.
enum idmap_error_code sss_idmap_offset_murmurhash3 (void *pvt, uint32_t range_size, const char *input, long long *offset)
 Calculate offset from string with the help of murmurhash3.
enum idmap_error_code sss_idmap_gen_to_unix (struct sss_idmap_ctx *ctx, const char *domain_id, const char *input, uint32_t *_id)
 Translate some input to a unix UID or GID.
enum idmap_error_code sss_idmap_unix_to_gen (struct sss_idmap_ctx *ctx, uint32_t id, char **out)
 Translate a unix UID or GID to some original value, if possible.

Detailed Description

Libsss_idmap provides a mechanism to translate a SID to a UNIX UID or GID or the other way round.

Enumeration Type Documentation

◆ idmap_error_code

Error codes used by libsss_idmap.

Enumerator
IDMAP_SUCCESS 

Success.

IDMAP_NOT_IMPLEMENTED 

Function is not yet implemented.

IDMAP_ERROR 

General error.

IDMAP_OUT_OF_MEMORY 

Ran out of memory during processing.

IDMAP_NO_DOMAIN 

No domain added.

IDMAP_CONTEXT_INVALID 

The provided idmap context is invalid.

IDMAP_SID_INVALID 

The provided SID is invalid.

IDMAP_SID_UNKNOWN 

The provided SID was not found.

IDMAP_NO_RANGE 

The provided UID or GID could not be mapped.

IDMAP_BUILTIN_SID 

The provided SID is a built-in one.

IDMAP_OUT_OF_SLICES 

No more free slices.

IDMAP_COLLISION 

New domain collides with existing one.

IDMAP_EXTERNAL 

External source should be consulted for idmapping.

IDMAP_NAME_UNKNOWN 

The provided name was not found.

IDMAP_NO_REVERSE 

It is not possible to convert an id into the original value the id was derived from.

IDMAP_UTF8_ERROR 

Error during UTF8 operation like normalization or casefolding.

IDMAP_ERR_LAST 

Sentinel to indicate the end of the error code list, not returned by any call.

Function Documentation

◆ idmap_error_string()

const char * idmap_error_string ( enum idmap_error_code err)

Translate error code to a string.

Parameters
[in]errIdmap error code
Returns
  • Error description as a zero-terminated string

◆ is_domain_sid()

bool is_domain_sid ( const char * str)

Check if given string can be used as domain SID.

Parameters
[in]strString to check
Returns
  • true: String can be used as domain SID
  • false: String can not be used as domain SID

◆ sss_idmap_add_auto_domain_ex()

enum idmap_error_code sss_idmap_add_auto_domain_ex ( struct sss_idmap_ctx * ctx,
const char * domain_name,
const char * domain_sid,
struct sss_idmap_range * range,
const char * range_id,
uint32_t rid,
bool external_mapping,
idmap_store_cb cb,
void * pvt )

Add a domain with the first mappable RID to the idmap context and generate automatically secondary slices.

Parameters
[in]ctxIdmap context
[in]domain_nameZero-terminated string with the domain name
[in]domain_sidZero-terminated string representation of the domain SID (S-1-15-.....)
[in]rangeTBD Some information about the id ranges of this domain
[in]range_idoptional unique identifier of a range, it is needed to allow updates at runtime
[in]ridThe RID that should be mapped to the first ID of the given range.
[in]external_mappingIf set to true the ID will not be mapped algorithmically, but the to_unix and *_unix_to calls will return IDMAP_EXTERNAL to instruct the caller to check external sources. For a single domain all ranges must be of the same type. It is not possible to mix algorithmic and external mapping.
[in]cbThe callback for storing mapping of dynamically created domains.
[in]pvtPrivate data for callback cb.
Returns

◆ sss_idmap_add_domain()

enum idmap_error_code sss_idmap_add_domain ( struct sss_idmap_ctx * ctx,
const char * domain_name,
const char * domain_sid,
struct sss_idmap_range * range )

Add a domain to the idmap context.

Parameters
[in]ctxIdmap context
[in]domain_nameZero-terminated string with the domain name
[in]domain_sidZero-terminated string representation of the domain SID (S-1-15-.....)
[in]rangeTBD Some information about the id ranges of this domain
Returns

◆ sss_idmap_add_domain_ex()

enum idmap_error_code sss_idmap_add_domain_ex ( struct sss_idmap_ctx * ctx,
const char * domain_name,
const char * domain_sid,
struct sss_idmap_range * range,
const char * range_id,
uint32_t rid,
bool external_mapping )

Add a domain with the first mappable RID to the idmap context.

Parameters
[in]ctxIdmap context
[in]domain_nameZero-terminated string with the domain name
[in]domain_sidZero-terminated string representation of the domain SID (S-1-15-.....)
[in]rangeTBD Some information about the id ranges of this domain
[in]range_idoptional unique identifier of a range, it is needed to allow updates at runtime
[in]ridThe RID that should be mapped to the first ID of the given range.
[in]external_mappingIf set to true the ID will not be mapped algorithmically, but the to_unix and *_unix_to calls will return IDMAP_EXTERNAL to instruct the caller to check external sources. For a single domain all ranges must be of the same type. It is not possible to mix algorithmic and external mapping.
Returns

◆ sss_idmap_add_gen_domain_ex()

enum idmap_error_code sss_idmap_add_gen_domain_ex ( struct sss_idmap_ctx * ctx,
const char * domain_name,
const char * domain_id,
struct sss_idmap_range * range,
const char * range_id,
idmap_offset_func * offset_func,
idmap_rev_offset_func * rev_offset_func,
void * offset_func_pvt,
uint32_t shift,
bool external_mapping )

Add a generic domain to the idmap context.

Parameters
[in]ctxIdmap context
[in]domain_nameZero-terminated string with the domain name
[in]domain_idZero-terminated string representation of a unique identifier of the domain, e.g. if available a domain UUID or the URI of domain specific service
[in]rangeId range struct with smallest and largest POSIX id of the range
[in]range_idA name for the id range, currently not used, might become important when we allow multiple ranges for a single domain
[in]offset_funcFunction to calculate an offset in a given range from some input given as string, if NULL sss_idmap_offset_murmurhash3() will be used if mapping is not done externally.
[in]rev_offset_funcFunction to calculate the original input from a given offset, i.e. the reverse of offset_func, may be NULL
[in]offset_func_pvtPrivate data for offset_func and rev_offset_func, may be NULL
[in]shiftCurrently not used, might become important when we allow multiple ranges for a single domain
[in]external_mappingIndicates that for this domain the mapping should not be done by libsss_idmap, the related calls will return IDMAP_EXTERNAL in this case. Nevertheless it might be important to add the domain to the idmap context so that libsss_idmap will not use the related ranges for mapping.
Returns

◆ sss_idmap_bin_sid_to_dom_sid()

enum idmap_error_code sss_idmap_bin_sid_to_dom_sid ( struct sss_idmap_ctx * ctx,
const uint8_t * bin_sid,
size_t length,
struct sss_dom_sid ** dom_sid )

Convert binary SID to SID structure.

Parameters
[in]ctxIdmap context
[in]bin_sidArray with the binary SID
[in]lengthSize of the array containing the binary SID
[out]dom_sidSID structure, must be freed if not needed anymore
Returns

◆ sss_idmap_bin_sid_to_sid()

enum idmap_error_code sss_idmap_bin_sid_to_sid ( struct sss_idmap_ctx * ctx,
const uint8_t * bin_sid,
size_t length,
char ** sid )

Convert binary SID to SID string.

Parameters
[in]ctxIdmap context
[in]bin_sidArray with the binary SID
[in]lengthSize of the array containing the binary SID
[out]sidZero-terminated string representation of the SID, must be freed if not needed anymore
Returns

◆ sss_idmap_bin_sid_to_smb_sid()

enum idmap_error_code sss_idmap_bin_sid_to_smb_sid ( struct sss_idmap_ctx * ctx,
const uint8_t * bin_sid,
size_t length,
struct dom_sid ** smb_sid )

Convert binary SID to Samba dom_sid structure.

Parameters
[in]ctxIdmap context
[in]bin_sidArray with the binary SID
[in]lengthSize of the array containing the binary SID
[out]smb_sidSamba dom_sid structure, must be freed if not needed anymore
Returns

◆ sss_idmap_bin_sid_to_unix()

enum idmap_error_code sss_idmap_bin_sid_to_unix ( struct sss_idmap_ctx * ctx,
uint8_t * bin_sid,
size_t length,
uint32_t * id )

Translate a binary SID to a unix UID or GID.

Parameters
[in]ctxIdmap context
[in]bin_sidArray with the binary SID
[in]lengthSize of the array containing the binary SID
[out]idReturned unix UID or GID
Returns

◆ sss_idmap_calculate_range()

enum idmap_error_code sss_idmap_calculate_range ( struct sss_idmap_ctx * ctx,
const char * dom_sid,
id_t * slice_num,
struct sss_idmap_range * range )

Calculate new range of available POSIX IDs.

Parameters
[in]ctxIdmap context
[in]dom_sidZero-terminated string representation of the domain SID (S-1-15-.....)
[in,out]slice_numSlice number to be used. Set this pointer to NULL or the addressed value to -1 to calculate slice number automatically. The calculated value will be returned in this parameter.
[out]rangeStructure containing upper and lower bound of the range of POSIX IDs
Returns

◆ sss_idmap_check_bin_sid_unix()

enum idmap_error_code sss_idmap_check_bin_sid_unix ( struct sss_idmap_ctx * ctx,
uint8_t * bin_sid,
size_t length,
uint32_t id )

Check if a binary SID and a unix UID or GID belong to the same range.

Parameters
[in]ctxIdmap context
[in]bin_sidArray with the binary SID
[in]lengthSize of the array containing the binary SID
[in]idUnix UID or GID
Returns

◆ sss_idmap_check_collision()

enum idmap_error_code sss_idmap_check_collision ( struct sss_idmap_ctx * ctx,
char * n_name,
char * n_sid,
struct sss_idmap_range * n_range,
uint32_t n_first_rid,
char * n_range_id,
bool n_external_mapping )

Check if a new range would collide with any existing one.

Parameters
[in]ctxIdmap context
[in]n_nameZero-terminated string with the domain name the new range should belong to
[in]n_sidZero-terminated string representation of the domain SID (S-1-15-.....) the new range sould belong to
[in]n_rangeThe new id range
[in]n_range_idunique identifier of the new range, it is needed to allow updates at runtime, may be NULL
[in]n_first_ridThe RID that should be mapped to the first ID of the new range.
[in]n_external_mappingMapping type of the new range
Returns

◆ sss_idmap_check_collision_ex()

enum idmap_error_code sss_idmap_check_collision_ex ( const char * o_name,
const char * o_sid,
struct sss_idmap_range * o_range,
uint32_t o_first_rid,
const char * o_range_id,
bool o_external_mapping,
const char * n_name,
const char * n_sid,
struct sss_idmap_range * n_range,
uint32_t n_first_rid,
const char * n_range_id,
bool n_external_mapping )

Check if two ranges would collide.

Parameters
[in]o_nameZero-terminated string with the domain name the first range should belong to
[in]o_sidZero-terminated string representation of the domain SID (S-1-15-.....) the first range sould belong to
[in]o_rangeThe first id range
[in]o_range_idunique identifier of the first range, it is needed to allow updates at runtime, may be NULL
[in]o_first_ridThe RID that should be mapped to the first ID of the first range.
[in]o_external_mappingMapping type of the first range
[in]n_nameZero-terminated string with the domain name the second range should belong to
[in]n_sidZero-terminated string representation of the domain SID (S-1-15-.....) the second range sould belong to
[in]n_rangeThe second id range
[in]n_range_idunique identifier of the second range, it is needed to allow updates at runtime, may be NULL
[in]n_first_ridThe RID that should be mapped to the first ID of the second range.
[in]n_external_mappingMapping type of the second range
Returns

◆ sss_idmap_check_dom_sid_unix()

enum idmap_error_code sss_idmap_check_dom_sid_unix ( struct sss_idmap_ctx * ctx,
struct sss_dom_sid * dom_sid,
uint32_t id )

Check if a SID structure and a unix UID or GID belong to the same range.

Parameters
[in]ctxIdmap context
[in]dom_sidSID structure
[in]idUnix UID or GID
Returns

◆ sss_idmap_check_sid_unix()

enum idmap_error_code sss_idmap_check_sid_unix ( struct sss_idmap_ctx * ctx,
const char * sid,
uint32_t id )

Check if a SID and a unix UID or GID belong to the same range.

Parameters
[in]ctxIdmap context
[in]sidZero-terminated string representation of the SID
[in]idUnix UID or GID
Returns

◆ sss_idmap_check_smb_sid_unix()

enum idmap_error_code sss_idmap_check_smb_sid_unix ( struct sss_idmap_ctx * ctx,
struct dom_sid * smb_sid,
uint32_t id )

Check if a Samba dom_sid structure and a unix UID or GID belong to the same range.

Parameters
[in]ctxIdmap context
[in]smb_sidSamba dom_sid structure
[in]idUnix UID or GID
Returns

◆ sss_idmap_ctx_get_autorid()

enum idmap_error_code sss_idmap_ctx_get_autorid ( struct sss_idmap_ctx * ctx,
bool * _autorid )

Check if autorid compatibility mode is set.

Parameters
[in]ctxidmap context
[out]_autoridtrue if autorid is used

◆ sss_idmap_ctx_get_lower()

enum idmap_error_code sss_idmap_ctx_get_lower ( struct sss_idmap_ctx * ctx,
id_t * _lower )

Get the lower bound of the range of POSIX IDs.

Parameters
[in]ctxidmap context
[out]_lowerreturned lower bound

◆ sss_idmap_ctx_get_rangesize()

enum idmap_error_code sss_idmap_ctx_get_rangesize ( struct sss_idmap_ctx * ctx,
id_t * rangesize )

Get the range size of POSIX IDs available for single domain.

Parameters
[in]ctxidmap context
[out]rangesizereturned range size

◆ sss_idmap_ctx_get_upper()

enum idmap_error_code sss_idmap_ctx_get_upper ( struct sss_idmap_ctx * ctx,
id_t * _upper )

Get the upper bound of the range of POSIX IDs.

Parameters
[in]ctxidmap context
[out]_upperreturned upper bound

◆ sss_idmap_ctx_set_autorid()

enum idmap_error_code sss_idmap_ctx_set_autorid ( struct sss_idmap_ctx * ctx,
bool use_autorid )

Set/unset autorid compatibility mode.

Parameters
[in]ctxidmap context
[in]use_autoridIf true, autorid compatibility mode will be used

◆ sss_idmap_ctx_set_extra_slice_init()

enum idmap_error_code sss_idmap_ctx_set_extra_slice_init ( struct sss_idmap_ctx * ctx,
int extra_slice_init )

Set the number of secondary slices available for domain.

Parameters
[in]ctxidmap context
[in]extra_slice_initnumber of secondary slices to be generated at startup

◆ sss_idmap_ctx_set_lower()

enum idmap_error_code sss_idmap_ctx_set_lower ( struct sss_idmap_ctx * ctx,
id_t lower )

Set the lower bound of the range of POSIX IDs.

Parameters
[in]ctxidmap context
[in]lowerlower bound of the range

◆ sss_idmap_ctx_set_rangesize()

enum idmap_error_code sss_idmap_ctx_set_rangesize ( struct sss_idmap_ctx * ctx,
id_t rangesize )

Set the range size of POSIX IDs available for single domain.

Parameters
[in]ctxidmap context
[in]rangesizerange size of IDs

◆ sss_idmap_ctx_set_upper()

enum idmap_error_code sss_idmap_ctx_set_upper ( struct sss_idmap_ctx * ctx,
id_t upper )

Set the upper bound of the range of POSIX IDs.

Parameters
[in]ctxidmap context
[in]upperupper bound of the range

◆ sss_idmap_dom_sid_to_bin_sid()

enum idmap_error_code sss_idmap_dom_sid_to_bin_sid ( struct sss_idmap_ctx * ctx,
struct sss_dom_sid * dom_sid,
uint8_t ** bin_sid,
size_t * length )

Convert SID structure to binary SID.

Parameters
[in]ctxIdmap context
[in]dom_sidSID structure
[out]bin_sidArray with the binary SID, must be freed if not needed anymore
[out]lengthSize of the array containing the binary SID
Returns

◆ sss_idmap_dom_sid_to_sid()

enum idmap_error_code sss_idmap_dom_sid_to_sid ( struct sss_idmap_ctx * ctx,
struct sss_dom_sid * dom_sid,
char ** sid )

Convert SID structure to SID string.

Parameters
[in]ctxIdmap context
[in]dom_sidSID structure
[out]sidZero-terminated string representation of the SID, must be freed if not needed anymore
Returns

◆ sss_idmap_dom_sid_to_smb_sid()

enum idmap_error_code sss_idmap_dom_sid_to_smb_sid ( struct sss_idmap_ctx * ctx,
struct sss_dom_sid * dom_sid,
struct dom_sid ** smb_sid )

Convert SID stucture to Samba dom_sid structure.

Parameters
[in]ctxIdmap context
[in]dom_sidSID structure
[out]smb_sidSamba dom_sid structure, must be freed if not needed anymore
Returns

◆ sss_idmap_dom_sid_to_unix()

enum idmap_error_code sss_idmap_dom_sid_to_unix ( struct sss_idmap_ctx * ctx,
struct sss_dom_sid * dom_sid,
uint32_t * id )

Translate a SID stucture to a unix UID or GID.

Parameters
[in]ctxIdmap context
[in]dom_sidSID structure
[out]idReturned unix UID or GID
Returns

◆ sss_idmap_domain_by_name_has_algorithmic_mapping()

enum idmap_error_code sss_idmap_domain_by_name_has_algorithmic_mapping ( struct sss_idmap_ctx * ctx,
const char * dom_name,
bool * has_algorithmic_mapping )

Check if a domain is configured with algorithmic mapping.

Parameters
[in]ctxIdmap context
[in]dom_nameName of the domain
[out]has_algorithmic_mappingBoolean value indicating if the given domain is configured for algorithmic mapping or not.
Returns

◆ sss_idmap_domain_has_algorithmic_mapping()

enum idmap_error_code sss_idmap_domain_has_algorithmic_mapping ( struct sss_idmap_ctx * ctx,
const char * dom_sid,
bool * has_algorithmic_mapping )

Check if a domain is configured with algorithmic mapping.

Parameters
[in]ctxIdmap context
[in]dom_sidSID string, can be either a domain SID or an object SID
[out]has_algorithmic_mappingBoolean value indicating if the given domain is configured for algorithmic mapping or not.
Returns

◆ sss_idmap_free()

enum idmap_error_code sss_idmap_free ( struct sss_idmap_ctx * ctx)

Free all the allocated memory of the idmap context.

Parameters
[in]ctxIdmap context
Returns

◆ sss_idmap_free_bin_sid()

enum idmap_error_code sss_idmap_free_bin_sid ( struct sss_idmap_ctx * ctx,
uint8_t * bin_sid )

Free mapped binary SID.

Parameters
[in]ctxIdmap context
[in]bin_sidBinary SID to be freed.
Returns

◆ sss_idmap_free_dom_sid()

enum idmap_error_code sss_idmap_free_dom_sid ( struct sss_idmap_ctx * ctx,
struct sss_dom_sid * dom_sid )

Free mapped domain SID.

Parameters
[in]ctxIdmap context
[in]dom_sidDomain SID to be freed.
Returns

◆ sss_idmap_free_sid()

enum idmap_error_code sss_idmap_free_sid ( struct sss_idmap_ctx * ctx,
char * sid )

Free mapped SID.

Parameters
[in]ctxIdmap context
[in]sidSID to be freed.
Returns

◆ sss_idmap_free_smb_sid()

enum idmap_error_code sss_idmap_free_smb_sid ( struct sss_idmap_ctx * ctx,
struct dom_sid * smb_sid )

Free mapped Samba SID.

Parameters
[in]ctxIdmap context
[in]smb_sidSamba SID to be freed.
Returns

◆ sss_idmap_gen_to_unix()

enum idmap_error_code sss_idmap_gen_to_unix ( struct sss_idmap_ctx * ctx,
const char * domain_id,
const char * input,
uint32_t * _id )

Translate some input to a unix UID or GID.

Parameters
[in]ctxIdmap context
[in]domain_idZero-terminated string with the domain ID of a known domain
[in]inputZero-terminated string which should be translated into an offset to calculate the unix UID or GID
[out]_idReturned unix UID or GID
Returns

◆ sss_idmap_init()

enum idmap_error_code sss_idmap_init ( idmap_alloc_func * alloc_func,
void * alloc_pvt,
idmap_free_func * free_func,
struct sss_idmap_ctx ** ctx )

Initialize idmap context.

Parameters
[in]alloc_funcFunction to allocate memory for the context, if NULL malloc() id used
[in]alloc_pvtPrivate data for allocation routine
[in]free_funcFunction to free the memory the context, if NULL free() id used
[out]ctxidmap context
Returns

◆ sss_idmap_offset_identity()

enum idmap_error_code sss_idmap_offset_identity ( void * pvt,
uint32_t range_size,
const char * input,
long long * offset )

Calculate offset from string containing only numbers.

This is an offset function of type idmap_rev_offset_func for sss_idmap_add_gen_domain_ex() which can be used to convert an input string which only contains a decimal integer number into a offset value of type long long. The matching reverse offset function is sss_idmap_rev_offset_identity().

◆ sss_idmap_offset_murmurhash3()

enum idmap_error_code sss_idmap_offset_murmurhash3 ( void * pvt,
uint32_t range_size,
const char * input,
long long * offset )

Calculate offset from string with the help of murmurhash3.

This is an offset function of type idmap_offset_func for sss_idmap_add_gen_domain_ex() which can be used to convert an input string into an offset value of type long long with the help of murmurhash3. This operation is not revertible and hence there is no matching reverse offset function of type idmap_rev_offset_func.

◆ sss_idmap_rev_offset_identity()

enum idmap_error_code sss_idmap_rev_offset_identity ( struct sss_idmap_ctx * ctx,
void * pvt,
uint32_t id,
char ** _out )

Reverse of sss_idmap_offset_identity, return a string containig only numbers representing the given offset.

This is the matching reverse offset function to sss_idmap_offset_identity() of type idmap_rev_offset_func. The given integer id is translated back into a string which represents the decimal version of the integer.

◆ sss_idmap_sid_to_bin_sid()

enum idmap_error_code sss_idmap_sid_to_bin_sid ( struct sss_idmap_ctx * ctx,
const char * sid,
uint8_t ** bin_sid,
size_t * length )

Convert SID string to binary SID.

Parameters
[in]ctxIdmap context
[in]sidZero-terminated string representation of the SID
[out]bin_sidArray with the binary SID, must be freed if not needed anymore
[out]lengthSize of the array containing the binary SID
Returns

◆ sss_idmap_sid_to_dom_sid()

enum idmap_error_code sss_idmap_sid_to_dom_sid ( struct sss_idmap_ctx * ctx,
const char * sid,
struct sss_dom_sid ** dom_sid )

Convert SID string to SID structure.

Parameters
[in]ctxIdmap context
[in]sidZero-terminated string representation of the SID
[out]dom_sidSID structure, must be freed if not needed anymore
Returns

◆ sss_idmap_sid_to_smb_sid()

enum idmap_error_code sss_idmap_sid_to_smb_sid ( struct sss_idmap_ctx * ctx,
const char * sid,
struct dom_sid ** smb_sid )

Convert SID string to Samba dom_sid structure.

Parameters
[in]ctxIdmap context
[in]sidZero-terminated string representation of the SID
[out]smb_sidSamba dom_sid structure, must be freed if not needed anymore
Returns

◆ sss_idmap_sid_to_unix()

enum idmap_error_code sss_idmap_sid_to_unix ( struct sss_idmap_ctx * ctx,
const char * sid,
uint32_t * id )

Translate SID to a unix UID or GID.

Parameters
[in]ctxIdmap context
[in]sidZero-terminated string representation of the SID
[out]idReturned unix UID or GID
Returns

◆ sss_idmap_smb_sid_to_bin_sid()

enum idmap_error_code sss_idmap_smb_sid_to_bin_sid ( struct sss_idmap_ctx * ctx,
struct dom_sid * smb_sid,
uint8_t ** bin_sid,
size_t * length )

Convert Samba dom_sid structure to binary SID.

Parameters
[in]ctxIdmap context
[in]smb_sidSamba dom_sid structure
[out]bin_sidArray with the binary SID, must be freed if not needed anymore
[out]lengthSize of the array containing the binary SID
Returns

◆ sss_idmap_smb_sid_to_dom_sid()

enum idmap_error_code sss_idmap_smb_sid_to_dom_sid ( struct sss_idmap_ctx * ctx,
struct dom_sid * smb_sid,
struct sss_dom_sid ** dom_sid )

Convert Samba dom_sid structure to SID structure.

Parameters
[in]ctxIdmap context
[in]smb_sidSamba dom_sid structure
[out]dom_sidSID structure, must be freed if not needed anymore
Returns

◆ sss_idmap_smb_sid_to_sid()

enum idmap_error_code sss_idmap_smb_sid_to_sid ( struct sss_idmap_ctx * ctx,
struct dom_sid * smb_sid,
char ** sid )

Convert Samba dom_sid structure to SID string.

Parameters
[in]ctxIdmap context
[in]smb_sidSamba dom_sid structure
[out]sidZero-terminated string representation of the SID, must be freed if not needed anymore
Returns

◆ sss_idmap_smb_sid_to_unix()

enum idmap_error_code sss_idmap_smb_sid_to_unix ( struct sss_idmap_ctx * ctx,
struct dom_sid * smb_sid,
uint32_t * id )

Translate a Samba dom_sid stucture to a unix UID or GID.

Parameters
[in]ctxIdmap context
[in]smb_sidSamba dom_sid structure
[out]idReturned unix UID or GID
Returns

◆ sss_idmap_unix_to_bin_sid()

enum idmap_error_code sss_idmap_unix_to_bin_sid ( struct sss_idmap_ctx * ctx,
uint32_t id,
uint8_t ** bin_sid,
size_t * length )

Translate unix UID or GID to a binary SID.

Parameters
[in]ctxIdmap context
[in]idunix UID or GID
[out]bin_sidArray with the binary SID, must be freed if not needed anymore
[out]lengthsize of the array containing the binary SID
Returns

◆ sss_idmap_unix_to_dom_sid()

enum idmap_error_code sss_idmap_unix_to_dom_sid ( struct sss_idmap_ctx * ctx,
uint32_t id,
struct sss_dom_sid ** dom_sid )

Translate unix UID or GID to a SID structure.

Parameters
[in]ctxIdmap context
[in]idunix UID or GID
[out]dom_sidSID structure, must be freed if not needed anymore
Returns

◆ sss_idmap_unix_to_gen()

enum idmap_error_code sss_idmap_unix_to_gen ( struct sss_idmap_ctx * ctx,
uint32_t id,
char ** out )

Translate a unix UID or GID to some original value, if possible.

Parameters
[in]ctxIdmap context
[in]idUnix UID or GID
[out]outOriginal value the UID or GID was derived from
Returns

◆ sss_idmap_unix_to_sid()

enum idmap_error_code sss_idmap_unix_to_sid ( struct sss_idmap_ctx * ctx,
uint32_t id,
char ** sid )

Translate unix UID or GID to a SID.

Parameters
[in]ctxIdmap context
[in]idunix UID or GID
[out]sidZero-terminated string representation of the SID, must be freed if not needed anymore
Returns