sss_idmap  1.9.5
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_smb_sid_to_unix(struct sss_idmap_ctx *ctx,
216  struct dom_sid *smb_sid,
217  uint32_t *id);
218 
232 enum idmap_error_code sss_idmap_unix_to_sid(struct sss_idmap_ctx *ctx,
233  uint32_t id,
234  char **sid);
235 
248 enum idmap_error_code sss_idmap_unix_to_dom_sid(struct sss_idmap_ctx *ctx,
249  uint32_t id,
250  struct sss_dom_sid **dom_sid);
251 
266 enum idmap_error_code sss_idmap_unix_to_bin_sid(struct sss_idmap_ctx *ctx,
267  uint32_t id,
268  uint8_t **bin_sid,
269  size_t *length);
270 
279 enum idmap_error_code sss_idmap_free(struct sss_idmap_ctx *ctx);
280 
289 const char *idmap_error_string(enum idmap_error_code err);
290 
300 bool is_domain_sid(const char *str);
301 
315 enum idmap_error_code sss_idmap_bin_sid_to_dom_sid(struct sss_idmap_ctx *ctx,
316  const uint8_t *bin_sid,
317  size_t length,
318  struct sss_dom_sid **dom_sid);
319 
333 enum idmap_error_code sss_idmap_bin_sid_to_sid(struct sss_idmap_ctx *ctx,
334  const uint8_t *bin_sid,
335  size_t length,
336  char **sid);
337 
351 enum idmap_error_code sss_idmap_dom_sid_to_bin_sid(struct sss_idmap_ctx *ctx,
352  struct sss_dom_sid *dom_sid,
353  uint8_t **bin_sid,
354  size_t *length);
355 
369 enum idmap_error_code sss_idmap_sid_to_bin_sid(struct sss_idmap_ctx *ctx,
370  const char *sid,
371  uint8_t **bin_sid,
372  size_t *length);
373 
386 enum idmap_error_code sss_idmap_dom_sid_to_sid(struct sss_idmap_ctx *ctx,
387  struct sss_dom_sid *dom_sid,
388  char **sid);
389 
402 enum idmap_error_code sss_idmap_sid_to_dom_sid(struct sss_idmap_ctx *ctx,
403  const char *sid,
404  struct sss_dom_sid **dom_sid);
405 
418 enum idmap_error_code sss_idmap_sid_to_smb_sid(struct sss_idmap_ctx *ctx,
419  const char *sid,
420  struct dom_sid **smb_sid);
421 
434 enum idmap_error_code sss_idmap_smb_sid_to_sid(struct sss_idmap_ctx *ctx,
435  struct dom_sid *smb_sid,
436  char **sid);
437 
450 enum idmap_error_code sss_idmap_dom_sid_to_smb_sid(struct sss_idmap_ctx *ctx,
451  struct sss_dom_sid *dom_sid,
452  struct dom_sid **smb_sid);
453 
466 enum idmap_error_code sss_idmap_smb_sid_to_dom_sid(struct sss_idmap_ctx *ctx,
467  struct dom_sid *smb_sid,
468  struct sss_dom_sid **dom_sid);
469 
483 enum idmap_error_code sss_idmap_bin_sid_to_smb_sid(struct sss_idmap_ctx *ctx,
484  const uint8_t *bin_sid,
485  size_t length,
486  struct dom_sid **smb_sid);
487 
501 enum idmap_error_code sss_idmap_smb_sid_to_bin_sid(struct sss_idmap_ctx *ctx,
502  struct dom_sid *smb_sid,
503  uint8_t **bin_sid,
504  size_t *length);
508 #endif /* SSS_IDMAP_H_ */