sss_idmap  1.9.3
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 };
76 
80 typedef void *(idmap_alloc_func)(size_t size, void *pvt);
81 typedef void (idmap_free_func)(void *ptr, void *pvt);
82 
89  uint32_t min;
90  uint32_t max;
91 };
92 
96 struct sss_dom_sid;
97 
101 struct sss_idmap_ctx;
102 
108 struct dom_sid;
109 
124  void *alloc_pvt,
125  idmap_free_func *free_func,
126  struct sss_idmap_ctx **ctx);
127 
144 enum idmap_error_code sss_idmap_add_domain(struct sss_idmap_ctx *ctx,
145  const char *domain_name,
146  const char *domain_sid,
147  struct sss_idmap_range *range);
148 
162 enum idmap_error_code sss_idmap_sid_to_unix(struct sss_idmap_ctx *ctx,
163  const char *sid,
164  uint32_t *id);
165 
179 enum idmap_error_code sss_idmap_dom_sid_to_unix(struct sss_idmap_ctx *ctx,
180  struct sss_dom_sid *dom_sid,
181  uint32_t *id);
182 
197 enum idmap_error_code sss_idmap_bin_sid_to_unix(struct sss_idmap_ctx *ctx,
198  uint8_t *bin_sid,
199  size_t length,
200  uint32_t *id);
201 
215 enum idmap_error_code sss_idmap_unix_to_sid(struct sss_idmap_ctx *ctx,
216  uint32_t id,
217  char **sid);
218 
231 enum idmap_error_code sss_idmap_unix_to_dom_sid(struct sss_idmap_ctx *ctx,
232  uint32_t id,
233  struct sss_dom_sid **dom_sid);
234 
249 enum idmap_error_code sss_idmap_unix_to_bin_sid(struct sss_idmap_ctx *ctx,
250  uint32_t id,
251  uint8_t **bin_sid,
252  size_t *length);
253 
262 enum idmap_error_code sss_idmap_free(struct sss_idmap_ctx *ctx);
263 
272 const char *idmap_error_string(enum idmap_error_code err);
273 
283 bool is_domain_sid(const char *str);
284 
298 enum idmap_error_code sss_idmap_bin_sid_to_dom_sid(struct sss_idmap_ctx *ctx,
299  const uint8_t *bin_sid,
300  size_t length,
301  struct sss_dom_sid **dom_sid);
302 
316 enum idmap_error_code sss_idmap_bin_sid_to_sid(struct sss_idmap_ctx *ctx,
317  const uint8_t *bin_sid,
318  size_t length,
319  char **sid);
320 
334 enum idmap_error_code sss_idmap_dom_sid_to_bin_sid(struct sss_idmap_ctx *ctx,
335  struct sss_dom_sid *dom_sid,
336  uint8_t **bin_sid,
337  size_t *length);
338 
352 enum idmap_error_code sss_idmap_sid_to_bin_sid(struct sss_idmap_ctx *ctx,
353  const char *sid,
354  uint8_t **bin_sid,
355  size_t *length);
356 
369 enum idmap_error_code sss_idmap_dom_sid_to_sid(struct sss_idmap_ctx *ctx,
370  struct sss_dom_sid *dom_sid,
371  char **sid);
372 
385 enum idmap_error_code sss_idmap_sid_to_dom_sid(struct sss_idmap_ctx *ctx,
386  const char *sid,
387  struct sss_dom_sid **dom_sid);
388 
401 enum idmap_error_code sss_idmap_sid_to_smb_sid(struct sss_idmap_ctx *ctx,
402  const char *sid,
403  struct dom_sid **smb_sid);
404 
417 enum idmap_error_code sss_idmap_smb_sid_to_sid(struct sss_idmap_ctx *ctx,
418  struct dom_sid *smb_sid,
419  char **sid);
420 
433 enum idmap_error_code sss_idmap_dom_sid_to_smb_sid(struct sss_idmap_ctx *ctx,
434  struct sss_dom_sid *dom_sid,
435  struct dom_sid **smb_sid);
436 
449 enum idmap_error_code sss_idmap_smb_sid_to_dom_sid(struct sss_idmap_ctx *ctx,
450  struct dom_sid *smb_sid,
451  struct sss_dom_sid **dom_sid);
452 
466 enum idmap_error_code sss_idmap_bin_sid_to_smb_sid(struct sss_idmap_ctx *ctx,
467  const uint8_t *bin_sid,
468  size_t length,
469  struct dom_sid **smb_sid);
470 
484 enum idmap_error_code sss_idmap_smb_sid_to_bin_sid(struct sss_idmap_ctx *ctx,
485  struct dom_sid *smb_sid,
486  uint8_t **bin_sid,
487  size_t *length);
491 #endif /* SSS_IDMAP_H_ */