sss_idmap  1.10.92
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 
81 
84 };
85 
89 typedef void *(idmap_alloc_func)(size_t size, void *pvt);
90 typedef void (idmap_free_func)(void *ptr, void *pvt);
91 
98  uint32_t min;
99  uint32_t max;
100 };
101 
105 struct sss_dom_sid;
106 
110 struct sss_idmap_ctx;
111 
117 struct dom_sid;
118 
133  void *alloc_pvt,
134  idmap_free_func *free_func,
135  struct sss_idmap_ctx **ctx);
136 
143 enum idmap_error_code
144 sss_idmap_ctx_set_autorid(struct sss_idmap_ctx *ctx, bool use_autorid);
145 
152 enum idmap_error_code
153 sss_idmap_ctx_set_lower(struct sss_idmap_ctx *ctx, id_t lower);
154 
161 enum idmap_error_code
162 sss_idmap_ctx_set_upper(struct sss_idmap_ctx *ctx, id_t upper);
163 
170 enum idmap_error_code
171 sss_idmap_ctx_set_rangesize(struct sss_idmap_ctx *ctx, id_t rangesize);
172 
179 enum idmap_error_code
180 sss_idmap_ctx_get_autorid(struct sss_idmap_ctx *ctx, bool *_autorid);
181 
188 enum idmap_error_code
189 sss_idmap_ctx_get_lower(struct sss_idmap_ctx *ctx, id_t *_lower);
190 
197 enum idmap_error_code
198 sss_idmap_ctx_get_upper(struct sss_idmap_ctx *ctx, id_t *_upper);
199 
206 enum idmap_error_code
207 sss_idmap_ctx_get_rangesize(struct sss_idmap_ctx *ctx, id_t *rangesize);
208 
226 enum idmap_error_code sss_idmap_calculate_range(struct sss_idmap_ctx *ctx,
227  const char *dom_sid,
228  id_t *slice_num,
229  struct sss_idmap_range *range);
230 
248 enum idmap_error_code sss_idmap_add_domain(struct sss_idmap_ctx *ctx,
249  const char *domain_name,
250  const char *domain_sid,
251  struct sss_idmap_range *range);
252 
281 enum idmap_error_code sss_idmap_add_domain_ex(struct sss_idmap_ctx *ctx,
282  const char *domain_name,
283  const char *domain_sid,
284  struct sss_idmap_range *range,
285  const char *range_id,
286  uint32_t rid,
287  bool external_mapping);
302 enum idmap_error_code sss_idmap_sid_to_unix(struct sss_idmap_ctx *ctx,
303  const char *sid,
304  uint32_t *id);
305 
320 enum idmap_error_code sss_idmap_dom_sid_to_unix(struct sss_idmap_ctx *ctx,
321  struct sss_dom_sid *dom_sid,
322  uint32_t *id);
323 
339 enum idmap_error_code sss_idmap_bin_sid_to_unix(struct sss_idmap_ctx *ctx,
340  uint8_t *bin_sid,
341  size_t length,
342  uint32_t *id);
343 
358 enum idmap_error_code sss_idmap_smb_sid_to_unix(struct sss_idmap_ctx *ctx,
359  struct dom_sid *smb_sid,
360  uint32_t *id);
361 
376 enum idmap_error_code sss_idmap_check_sid_unix(struct sss_idmap_ctx *ctx,
377  const char *sid,
378  uint32_t id);
379 
394 enum idmap_error_code sss_idmap_check_dom_sid_unix(struct sss_idmap_ctx *ctx,
395  struct sss_dom_sid *dom_sid,
396  uint32_t id);
397 
413 enum idmap_error_code sss_idmap_check_bin_sid_unix(struct sss_idmap_ctx *ctx,
414  uint8_t *bin_sid,
415  size_t length,
416  uint32_t id);
417 
433 enum idmap_error_code sss_idmap_check_smb_sid_unix(struct sss_idmap_ctx *ctx,
434  struct dom_sid *smb_sid,
435  uint32_t id);
436 
451 enum idmap_error_code sss_idmap_unix_to_sid(struct sss_idmap_ctx *ctx,
452  uint32_t id,
453  char **sid);
454 
468 enum idmap_error_code sss_idmap_unix_to_dom_sid(struct sss_idmap_ctx *ctx,
469  uint32_t id,
470  struct sss_dom_sid **dom_sid);
471 
487 enum idmap_error_code sss_idmap_unix_to_bin_sid(struct sss_idmap_ctx *ctx,
488  uint32_t id,
489  uint8_t **bin_sid,
490  size_t *length);
491 
500 enum idmap_error_code sss_idmap_free(struct sss_idmap_ctx *ctx);
501 
510 const char *idmap_error_string(enum idmap_error_code err);
511 
521 bool is_domain_sid(const char *str);
522 
532 enum idmap_error_code
533 sss_idmap_domain_has_algorithmic_mapping(struct sss_idmap_ctx *ctx,
534  const char *dom_sid,
535  bool *has_algorithmic_mapping);
536 
550 enum idmap_error_code sss_idmap_bin_sid_to_dom_sid(struct sss_idmap_ctx *ctx,
551  const uint8_t *bin_sid,
552  size_t length,
553  struct sss_dom_sid **dom_sid);
554 
568 enum idmap_error_code sss_idmap_bin_sid_to_sid(struct sss_idmap_ctx *ctx,
569  const uint8_t *bin_sid,
570  size_t length,
571  char **sid);
572 
586 enum idmap_error_code sss_idmap_dom_sid_to_bin_sid(struct sss_idmap_ctx *ctx,
587  struct sss_dom_sid *dom_sid,
588  uint8_t **bin_sid,
589  size_t *length);
590 
604 enum idmap_error_code sss_idmap_sid_to_bin_sid(struct sss_idmap_ctx *ctx,
605  const char *sid,
606  uint8_t **bin_sid,
607  size_t *length);
608 
621 enum idmap_error_code sss_idmap_dom_sid_to_sid(struct sss_idmap_ctx *ctx,
622  struct sss_dom_sid *dom_sid,
623  char **sid);
624 
637 enum idmap_error_code sss_idmap_sid_to_dom_sid(struct sss_idmap_ctx *ctx,
638  const char *sid,
639  struct sss_dom_sid **dom_sid);
640 
653 enum idmap_error_code sss_idmap_sid_to_smb_sid(struct sss_idmap_ctx *ctx,
654  const char *sid,
655  struct dom_sid **smb_sid);
656 
669 enum idmap_error_code sss_idmap_smb_sid_to_sid(struct sss_idmap_ctx *ctx,
670  struct dom_sid *smb_sid,
671  char **sid);
672 
685 enum idmap_error_code sss_idmap_dom_sid_to_smb_sid(struct sss_idmap_ctx *ctx,
686  struct sss_dom_sid *dom_sid,
687  struct dom_sid **smb_sid);
688 
701 enum idmap_error_code sss_idmap_smb_sid_to_dom_sid(struct sss_idmap_ctx *ctx,
702  struct dom_sid *smb_sid,
703  struct sss_dom_sid **dom_sid);
704 
718 enum idmap_error_code sss_idmap_bin_sid_to_smb_sid(struct sss_idmap_ctx *ctx,
719  const uint8_t *bin_sid,
720  size_t length,
721  struct dom_sid **smb_sid);
722 
736 enum idmap_error_code sss_idmap_smb_sid_to_bin_sid(struct sss_idmap_ctx *ctx,
737  struct dom_sid *smb_sid,
738  uint8_t **bin_sid,
739  size_t *length);
743 #endif /* SSS_IDMAP_H_ */