sss_idmap  1.9.95
sss_idmap.h
1 /*
2  SSSD
3 
4  ID-mapping library
5 
6  Authors:
7  Sumit Bose <sbose@redhat.com>
8 
9  Copyright (C) 2012 Red Hat
10 
11  This program is free software; you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published by
13  the Free Software Foundation; either version 3 of the License, or
14  (at your option) any later version.
15 
16  This program is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with this program. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #ifndef SSS_IDMAP_H_
26 #define SSS_IDMAP_H_
27 
28 #include <stdlib.h>
29 #include <stdint.h>
30 #include <stdbool.h>
31 
32 #define DOM_SID_PREFIX "S-1-5-21-"
33 #define DOM_SID_PREFIX_LEN (sizeof(DOM_SID_PREFIX) - 1)
34 
48 
51 
54 
57 
60 
63 
66 
69 
72 
75 
78 };
79 
83 typedef void *(idmap_alloc_func)(size_t size, void *pvt);
84 typedef void (idmap_free_func)(void *ptr, void *pvt);
85 
92  uint32_t min;
93  uint32_t max;
94 };
95 
99 struct sss_dom_sid;
100 
104 struct sss_idmap_ctx;
105 
111 struct dom_sid;
112 
127  void *alloc_pvt,
128  idmap_free_func *free_func,
129  struct sss_idmap_ctx **ctx);
130 
137 enum idmap_error_code
138 sss_idmap_ctx_set_autorid(struct sss_idmap_ctx *ctx, bool use_autorid);
139 
146 enum idmap_error_code
147 sss_idmap_ctx_set_lower(struct sss_idmap_ctx *ctx, id_t lower);
148 
155 enum idmap_error_code
156 sss_idmap_ctx_set_upper(struct sss_idmap_ctx *ctx, id_t upper);
157 
164 enum idmap_error_code
165 sss_idmap_ctx_set_rangesize(struct sss_idmap_ctx *ctx, id_t rangesize);
166 
173 enum idmap_error_code
174 sss_idmap_ctx_get_autorid(struct sss_idmap_ctx *ctx, bool *_autorid);
175 
182 enum idmap_error_code
183 sss_idmap_ctx_get_lower(struct sss_idmap_ctx *ctx, id_t *_lower);
184 
191 enum idmap_error_code
192 sss_idmap_ctx_get_upper(struct sss_idmap_ctx *ctx, id_t *_upper);
193 
200 enum idmap_error_code
201 sss_idmap_ctx_get_rangesize(struct sss_idmap_ctx *ctx, id_t *rangesize);
202 
220 enum idmap_error_code sss_idmap_calculate_range(struct sss_idmap_ctx *ctx,
221  const char *dom_sid,
222  id_t *slice_num,
223  struct sss_idmap_range *range);
224 
241 enum idmap_error_code sss_idmap_add_domain(struct sss_idmap_ctx *ctx,
242  const char *domain_name,
243  const char *domain_sid,
244  struct sss_idmap_range *range);
245 
259 enum idmap_error_code sss_idmap_sid_to_unix(struct sss_idmap_ctx *ctx,
260  const char *sid,
261  uint32_t *id);
262 
276 enum idmap_error_code sss_idmap_dom_sid_to_unix(struct sss_idmap_ctx *ctx,
277  struct sss_dom_sid *dom_sid,
278  uint32_t *id);
279 
294 enum idmap_error_code sss_idmap_bin_sid_to_unix(struct sss_idmap_ctx *ctx,
295  uint8_t *bin_sid,
296  size_t length,
297  uint32_t *id);
298 
312 enum idmap_error_code sss_idmap_smb_sid_to_unix(struct sss_idmap_ctx *ctx,
313  struct dom_sid *smb_sid,
314  uint32_t *id);
315 
329 enum idmap_error_code sss_idmap_unix_to_sid(struct sss_idmap_ctx *ctx,
330  uint32_t id,
331  char **sid);
332 
345 enum idmap_error_code sss_idmap_unix_to_dom_sid(struct sss_idmap_ctx *ctx,
346  uint32_t id,
347  struct sss_dom_sid **dom_sid);
348 
363 enum idmap_error_code sss_idmap_unix_to_bin_sid(struct sss_idmap_ctx *ctx,
364  uint32_t id,
365  uint8_t **bin_sid,
366  size_t *length);
367 
376 enum idmap_error_code sss_idmap_free(struct sss_idmap_ctx *ctx);
377 
386 const char *idmap_error_string(enum idmap_error_code err);
387 
397 bool is_domain_sid(const char *str);
398 
412 enum idmap_error_code sss_idmap_bin_sid_to_dom_sid(struct sss_idmap_ctx *ctx,
413  const uint8_t *bin_sid,
414  size_t length,
415  struct sss_dom_sid **dom_sid);
416 
430 enum idmap_error_code sss_idmap_bin_sid_to_sid(struct sss_idmap_ctx *ctx,
431  const uint8_t *bin_sid,
432  size_t length,
433  char **sid);
434 
448 enum idmap_error_code sss_idmap_dom_sid_to_bin_sid(struct sss_idmap_ctx *ctx,
449  struct sss_dom_sid *dom_sid,
450  uint8_t **bin_sid,
451  size_t *length);
452 
466 enum idmap_error_code sss_idmap_sid_to_bin_sid(struct sss_idmap_ctx *ctx,
467  const char *sid,
468  uint8_t **bin_sid,
469  size_t *length);
470 
483 enum idmap_error_code sss_idmap_dom_sid_to_sid(struct sss_idmap_ctx *ctx,
484  struct sss_dom_sid *dom_sid,
485  char **sid);
486 
499 enum idmap_error_code sss_idmap_sid_to_dom_sid(struct sss_idmap_ctx *ctx,
500  const char *sid,
501  struct sss_dom_sid **dom_sid);
502 
515 enum idmap_error_code sss_idmap_sid_to_smb_sid(struct sss_idmap_ctx *ctx,
516  const char *sid,
517  struct dom_sid **smb_sid);
518 
531 enum idmap_error_code sss_idmap_smb_sid_to_sid(struct sss_idmap_ctx *ctx,
532  struct dom_sid *smb_sid,
533  char **sid);
534 
547 enum idmap_error_code sss_idmap_dom_sid_to_smb_sid(struct sss_idmap_ctx *ctx,
548  struct sss_dom_sid *dom_sid,
549  struct dom_sid **smb_sid);
550 
563 enum idmap_error_code sss_idmap_smb_sid_to_dom_sid(struct sss_idmap_ctx *ctx,
564  struct dom_sid *smb_sid,
565  struct sss_dom_sid **dom_sid);
566 
580 enum idmap_error_code sss_idmap_bin_sid_to_smb_sid(struct sss_idmap_ctx *ctx,
581  const uint8_t *bin_sid,
582  size_t length,
583  struct dom_sid **smb_sid);
584 
598 enum idmap_error_code sss_idmap_smb_sid_to_bin_sid(struct sss_idmap_ctx *ctx,
599  struct dom_sid *smb_sid,
600  uint8_t **bin_sid,
601  size_t *length);
605 #endif /* SSS_IDMAP_H_ */