/usr/include/sss_idmap.h is in libsss-idmap-dev 1.11.5-1ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 | /*
SSSD
ID-mapping library
Authors:
Sumit Bose <sbose@redhat.com>
Copyright (C) 2012 Red Hat
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SSS_IDMAP_H_
#define SSS_IDMAP_H_
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <sys/types.h>
#define DOM_SID_PREFIX "S-1-5-21-"
#define DOM_SID_PREFIX_LEN (sizeof(DOM_SID_PREFIX) - 1)
/**
* @defgroup sss_idmap 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.
* @{
*/
/**
* Error codes used by libsss_idmap
*/
enum idmap_error_code {
/** Success */
IDMAP_SUCCESS = 0,
/** Function is not yet implemented */
IDMAP_NOT_IMPLEMENTED,
/** General error */
IDMAP_ERROR,
/** Ran out of memory during processing */
IDMAP_OUT_OF_MEMORY,
/** No domain added */
IDMAP_NO_DOMAIN,
/** The provided idmap context is invalid */
IDMAP_CONTEXT_INVALID,
/** The provided SID is invalid */
IDMAP_SID_INVALID,
/** The provided SID was not found */
IDMAP_SID_UNKNOWN,
/** The provided UID or GID could not be mapped */
IDMAP_NO_RANGE,
/** The provided SID is a built-in one */
IDMAP_BUILTIN_SID,
/** No more free slices */
IDMAP_OUT_OF_SLICES,
/** New domain collides with existing one */
IDMAP_COLLISION,
/** External source should be consulted for idmapping */
IDMAP_EXTERNAL,
/** The provided name was not found */
IDMAP_NAME_UNKNOWN
};
/**
* Typedef for memory allocation functions
*/
typedef void *(idmap_alloc_func)(size_t size, void *pvt);
typedef void (idmap_free_func)(void *ptr, void *pvt);
/**
* Structure for id ranges
* FIXME: this struct might change when it is clear how ranges are handled on
* the server side
*/
struct sss_idmap_range {
uint32_t min;
uint32_t max;
};
/**
* Opaque type for SIDs
*/
struct sss_dom_sid;
/**
* Opaque type for the idmap context
*/
struct sss_idmap_ctx;
/**
* Placeholder for Samba's struct dom_sid. Consumers of libsss_idmap should
* include an appropriate Samba header file to define struct dom_sid. We use
* it here to avoid a hard dependency on Samba devel packages.
*/
struct dom_sid;
/**
* @brief Initialize idmap context
*
* @param[in] alloc_func Function to allocate memory for the context, if
* NULL malloc() id used
* @param[in] alloc_pvt Private data for allocation routine
* @param[in] free_func Function to free the memory the context, if
* NULL free() id used
* @param[out] ctx idmap context
*
* @return
* - #IDMAP_OUT_OF_MEMORY: Insufficient memory to create the context
*/
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);
/**
* @brief Set/unset autorid compatibility mode
*
* @param[in] ctx idmap context
* @param[in] use_autorid If true, autorid compatibility mode will be used
*/
enum idmap_error_code
sss_idmap_ctx_set_autorid(struct sss_idmap_ctx *ctx, bool use_autorid);
/**
* @brief Set the lower bound of the range of POSIX IDs
*
* @param[in] ctx idmap context
* @param[in] lower lower bound of the range
*/
enum idmap_error_code
sss_idmap_ctx_set_lower(struct sss_idmap_ctx *ctx, id_t lower);
/**
* @brief Set the upper bound of the range of POSIX IDs
*
* @param[in] ctx idmap context
* @param[in] upper upper bound of the range
*/
enum idmap_error_code
sss_idmap_ctx_set_upper(struct sss_idmap_ctx *ctx, id_t upper);
/**
* @brief Set the range size of POSIX IDs available for single domain
*
* @param[in] ctx idmap context
* @param[in] rangesize range size of IDs
*/
enum idmap_error_code
sss_idmap_ctx_set_rangesize(struct sss_idmap_ctx *ctx, id_t rangesize);
/**
* @brief Check if autorid compatibility mode is set
*
* @param[in] ctx idmap context
* @param[out] _autorid true if autorid is used
*/
enum idmap_error_code
sss_idmap_ctx_get_autorid(struct sss_idmap_ctx *ctx, bool *_autorid);
/**
* @brief Get the lower bound of the range of POSIX IDs
*
* @param[in] ctx idmap context
* @param[out] _lower returned lower bound
*/
enum idmap_error_code
sss_idmap_ctx_get_lower(struct sss_idmap_ctx *ctx, id_t *_lower);
/**
* @brief Get the upper bound of the range of POSIX IDs
*
* @param[in] ctx idmap context
* @param[out] _upper returned upper bound
*/
enum idmap_error_code
sss_idmap_ctx_get_upper(struct sss_idmap_ctx *ctx, id_t *_upper);
/**
* @brief Get the range size of POSIX IDs available for single domain
*
* @param[in] ctx idmap context
* @param[out] rangesize returned range size
*/
enum idmap_error_code
sss_idmap_ctx_get_rangesize(struct sss_idmap_ctx *ctx, id_t *rangesize);
/**
* @brief Calculate new range of available POSIX IDs
*
* @param[in] ctx Idmap context
* @param[in] dom_sid Zero-terminated string representation of the domain
* SID (S-1-15-.....)
* @param[in,out] slice_num Slice 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.
* @param[out] range Structure containing upper and lower bound of the
* range of POSIX IDs
*
* @return
* - #IDMAP_OUT_OF_SLICES: Cannot calculate new range because all slices are
* used.
*/
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);
/**
* @brief Add a domain to the idmap context
*
* @param[in] ctx Idmap context
* @param[in] domain_name Zero-terminated string with the domain name
* @param[in] domain_sid Zero-terminated string representation of the domain
* SID (S-1-15-.....)
* @param[in] range TBD Some information about the id ranges of this
* domain
*
* @return
* - #IDMAP_OUT_OF_MEMORY: Insufficient memory to store the data in the idmap
* context
* - #IDMAP_SID_INVALID: Invalid SID provided
* - #IDMAP_NO_DOMAIN: No domain domain name given
* - #IDMAP_COLLISION: New domain collides with existing one
*/
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);
/**
* @brief Add a domain with the first mappable RID to the idmap context
*
* @param[in] ctx Idmap context
* @param[in] domain_name Zero-terminated string with the domain name
* @param[in] domain_sid Zero-terminated string representation of the domain
* SID (S-1-15-.....)
* @param[in] range TBD Some information about the id ranges of this
* domain
* @param[in] range_id optional unique identifier of a range, it is needed
* to allow updates at runtime
* @param[in] rid The RID that should be mapped to the first ID of the
* given range.
* @param[in] external_mapping If 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.
*
* @return
* - #IDMAP_OUT_OF_MEMORY: Insufficient memory to store the data in the idmap
* context
* - #IDMAP_SID_INVALID: Invalid SID provided
* - #IDMAP_NO_DOMAIN: No domain domain name given
* - #IDMAP_COLLISION: New domain collides with existing one
*/
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);
/**
* @brief Check if a new range would collide with any existing one
*
* @param[in] ctx Idmap context
* @param[in] n_name Zero-terminated string with the domain name the new
* range should belong to
* @param[in] n_sid Zero-terminated string representation of the domain
* SID (S-1-15-.....) the new range sould belong to
* @param[in] n_range The new id range
* @param[in] n_range_id unique identifier of the new range, it is needed
* to allow updates at runtime, may be NULL
* @param[in] n_first_rid The RID that should be mapped to the first ID of the
* new range.
* @param[in] n_external_mapping Mapping type of the new range
*
* @return
* - #IDMAP_COLLISION: New range collides with existing one
*/
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);
/**
* @brief Check if two ranges would collide
*
* @param[in] o_name Zero-terminated string with the domain name the
* first range should belong to
* @param[in] o_sid Zero-terminated string representation of the domain
* SID (S-1-15-.....) the first range sould belong to
* @param[in] o_range The first id range
* @param[in] o_range_id unique identifier of the first range, it is needed
* to allow updates at runtime, may be NULL
* @param[in] o_first_rid The RID that should be mapped to the first ID of the
* first range.
* @param[in] o_external_mapping Mapping type of the first range
* @param[in] n_name Zero-terminated string with the domain name the
* second range should belong to
* @param[in] n_sid Zero-terminated string representation of the domain
* SID (S-1-15-.....) the second range sould belong to
* @param[in] n_range The second id range
* @param[in] n_range_id unique identifier of the second range, it is needed
* to allow updates at runtime, may be NULL
* @param[in] n_first_rid The RID that should be mapped to the first ID of the
* second range.
* @param[in] n_external_mapping Mapping type of the second range
*
* @return
* - #IDMAP_COLLISION: New range collides with 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);
/**
* @brief Translate SID to a unix UID or GID
*
* @param[in] ctx Idmap context
* @param[in] sid Zero-terminated string representation of the SID
* @param[out] id Returned unix UID or GID
*
* @return
* - #IDMAP_NO_DOMAIN: No domains are added to the idmap context
* - #IDMAP_SID_INVALID: Invalid SID provided
* - #IDMAP_SID_UNKNOWN: SID cannot be found in the domains added to the
* idmap context
* - #IDMAP_EXTERNAL: external source is authoritative for mapping
*/
enum idmap_error_code sss_idmap_sid_to_unix(struct sss_idmap_ctx *ctx,
const char *sid,
uint32_t *id);
/**
* @brief Translate a SID stucture to a unix UID or GID
*
* @param[in] ctx Idmap context
* @param[in] dom_sid SID structure
* @param[out] id Returned unix UID or GID
*
* @return
* - #IDMAP_NO_DOMAIN: No domains are added to the idmap context
* - #IDMAP_SID_INVALID: Invalid SID provided
* - #IDMAP_SID_UNKNOWN: SID cannot be found in the domains added to the
* idmap context
* - #IDMAP_EXTERNAL: external source is authoritative for mapping
*/
enum idmap_error_code sss_idmap_dom_sid_to_unix(struct sss_idmap_ctx *ctx,
struct sss_dom_sid *dom_sid,
uint32_t *id);
/**
* @brief Translate a binary SID to a unix UID or GID
*
* @param[in] ctx Idmap context
* @param[in] bin_sid Array with the binary SID
* @param[in] length Size of the array containing the binary SID
* @param[out] id Returned unix UID or GID
*
* @return
* - #IDMAP_NO_DOMAIN: No domains are added to the idmap context
* - #IDMAP_SID_INVALID: Invalid SID provided
* - #IDMAP_SID_UNKNOWN: SID cannot be found in the domains added to the
* idmap context
* - #IDMAP_EXTERNAL: external source is authoritative for mapping
*/
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);
/**
* @brief Translate a Samba dom_sid stucture to a unix UID or GID
*
* @param[in] ctx Idmap context
* @param[in] smb_sid Samba dom_sid structure
* @param[out] id Returned unix UID or GID
*
* @return
* - #IDMAP_NO_DOMAIN: No domains are added to the idmap context
* - #IDMAP_SID_INVALID: Invalid SID provided
* - #IDMAP_SID_UNKNOWN: SID cannot be found in the domains added to the
* idmap context
* - #IDMAP_EXTERNAL: external source is authoritative for mapping
*/
enum idmap_error_code sss_idmap_smb_sid_to_unix(struct sss_idmap_ctx *ctx,
struct dom_sid *smb_sid,
uint32_t *id);
/**
* @brief Check if a SID and a unix UID or GID belong to the same range
*
* @param[in] ctx Idmap context
* @param[in] sid Zero-terminated string representation of the SID
* @param[in] id Unix UID or GID
*
* @return
* - #IDMAP_NO_DOMAIN: No domains are added to the idmap context
* - #IDMAP_SID_INVALID: Invalid SID provided
* - #IDMAP_SID_UNKNOWN: SID cannot be found in the domains added to the
* idmap context
* - #IDMAP_NO_RANGE No matching ID range found
*/
enum idmap_error_code sss_idmap_check_sid_unix(struct sss_idmap_ctx *ctx,
const char *sid,
uint32_t id);
/**
* @brief Check if a SID structure and a unix UID or GID belong to the same range
*
* @param[in] ctx Idmap context
* @param[in] dom_sid SID structure
* @param[in] id Unix UID or GID
*
* @return
* - #IDMAP_NO_DOMAIN: No domains are added to the idmap context
* - #IDMAP_SID_INVALID: Invalid SID provided
* - #IDMAP_SID_UNKNOWN: SID cannot be found in the domains added to the
* idmap context
* - #IDMAP_NO_RANGE No matching ID range found
*/
enum idmap_error_code sss_idmap_check_dom_sid_unix(struct sss_idmap_ctx *ctx,
struct sss_dom_sid *dom_sid,
uint32_t id);
/**
* @brief Check if a binary SID and a unix UID or GID belong to the same range
*
* @param[in] ctx Idmap context
* @param[in] bin_sid Array with the binary SID
* @param[in] length Size of the array containing the binary SID
* @param[in] id Unix UID or GID
*
* @return
* - #IDMAP_NO_DOMAIN: No domains are added to the idmap context
* - #IDMAP_SID_INVALID: Invalid SID provided
* - #IDMAP_SID_UNKNOWN: SID cannot be found in the domains added to the
* idmap context
* - #IDMAP_NO_RANGE No matching ID range found
*/
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);
/**
* @brief Check if a Samba dom_sid structure and a unix UID or GID belong to
* the same range
*
* @param[in] ctx Idmap context
* @param[in] smb_sid Samba dom_sid structure
* @param[in] id Unix UID or GID
*
* @return
* - #IDMAP_NO_DOMAIN: No domains are added to the idmap context
* - #IDMAP_SID_INVALID: Invalid SID provided
* - #IDMAP_SID_UNKNOWN: SID cannot be found in the domains added to the
* idmap context
* - #IDMAP_NO_RANGE No matching ID range found
*/
enum idmap_error_code sss_idmap_check_smb_sid_unix(struct sss_idmap_ctx *ctx,
struct dom_sid *smb_sid,
uint32_t id);
/**
* @brief Translate unix UID or GID to a SID
*
* @param[in] ctx Idmap context
* @param[in] id unix UID or GID
* @param[out] sid Zero-terminated string representation of the SID, must be
* freed if not needed anymore
*
* @return
* - #IDMAP_NO_DOMAIN: No domains are added to the idmap context
* - #IDMAP_NO_RANGE: The provided ID cannot be found in the domains added
* to the idmap context
* - #IDMAP_EXTERNAL: external source is authoritative for mapping
*/
enum idmap_error_code sss_idmap_unix_to_sid(struct sss_idmap_ctx *ctx,
uint32_t id,
char **sid);
/**
* @brief Translate unix UID or GID to a SID structure
*
* @param[in] ctx Idmap context
* @param[in] id unix UID or GID
* @param[out] dom_sid SID structure, must be freed if not needed anymore
*
* @return
* - #IDMAP_NO_DOMAIN: No domains are added to the idmap context
* - #IDMAP_NO_RANGE: The provided ID cannot be found in the domains added
* to the idmap context
* - #IDMAP_EXTERNAL: external source is authoritative for mapping
*/
enum idmap_error_code sss_idmap_unix_to_dom_sid(struct sss_idmap_ctx *ctx,
uint32_t id,
struct sss_dom_sid **dom_sid);
/**
* @brief Translate unix UID or GID to a binary SID
*
* @param[in] ctx Idmap context
* @param[in] id unix UID or GID
* @param[out] bin_sid Array with the binary SID,
* must be freed if not needed anymore
* @param[out] length size of the array containing the binary SID
*
* @return
* - #IDMAP_NO_DOMAIN: No domains are added to the idmap context
* - #IDMAP_NO_RANGE: The provided ID cannot be found in the domains added
* to the idmap context
* - #IDMAP_EXTERNAL: external source is authoritative for mapping
*/
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);
/**
* @brief Free all the allocated memory of the idmap context
*
* @param[in] ctx Idmap context
*
* @return
* - #IDMAP_CONTEXT_INVALID: Provided context is invalid
*/
enum idmap_error_code sss_idmap_free(struct sss_idmap_ctx *ctx);
/**
* @brief Free mapped SID.
*
* @param[in] ctx Idmap context
* @param[in] sid SID to be freed.
*
* @return
* - #IDMAP_CONTEXT_INVALID: Provided context is invalid
*/
enum idmap_error_code sss_idmap_free_sid(struct sss_idmap_ctx *ctx,
char *sid);
/**
* @brief Free mapped domain SID.
*
* @param[in] ctx Idmap context
* @param[in] dom_sid Domain SID to be freed.
*
* @return
* - #IDMAP_CONTEXT_INVALID: Provided context is invalid
*/
enum idmap_error_code sss_idmap_free_dom_sid(struct sss_idmap_ctx *ctx,
struct sss_dom_sid *dom_sid);
/**
* @brief Free mapped Samba SID.
*
* @param[in] ctx Idmap context
* @param[in] smb_sid Samba SID to be freed.
*
* @return
* - #IDMAP_CONTEXT_INVALID: Provided context is invalid
*/
enum idmap_error_code sss_idmap_free_smb_sid(struct sss_idmap_ctx *ctx,
struct dom_sid *smb_sid);
/**
* @brief Free mapped binary SID.
*
* @param[in] ctx Idmap context
* @param[in] bin_sid Binary SID to be freed.
*
* @return
* - #IDMAP_CONTEXT_INVALID: Provided context is invalid
*/
enum idmap_error_code sss_idmap_free_bin_sid(struct sss_idmap_ctx *ctx,
uint8_t *bin_sid);
/**
* @brief Translate error code to a string
*
* @param[in] err Idmap error code
*
* @return
* - Error description as a zero-terminated string
*/
const char *idmap_error_string(enum idmap_error_code err);
/**
* @brief Check if given string can be used as domain SID
*
* @param[in] str String to check
*
* @return
* - true: String can be used as domain SID
* - false: String can not be used as domain SID
*/
bool is_domain_sid(const char *str);
/**
* @brief Check if a domain is configured with algorithmic mapping
*
* @param[in] ctx Idmap context
* @param[in] dom_sid SID string, can be either a domain SID
* or an object SID
* @param[out] has_algorithmic_mapping Boolean value indicating if the given
* domain is configured for algorithmic
* mapping or not.
*
* @return
* - #IDMAP_SUCCESS: Domain for the given SID was found and
* has_algorithmic_mapping is set accordingly
* - #IDMAP_SID_INVALID: Provided SID is invalid
* - #IDMAP_CONTEXT_INVALID: Provided idmap context is invalid
* - #IDMAP_NO_DOMAIN: No domains are available in the idmap context
* - #IDMAP_SID_UNKNOWN: No domain with the given SID was found in the
* idmap context
*/
enum idmap_error_code
sss_idmap_domain_has_algorithmic_mapping(struct sss_idmap_ctx *ctx,
const char *dom_sid,
bool *has_algorithmic_mapping);
/**
* @brief Check if a domain is configured with algorithmic mapping
*
* @param[in] ctx Idmap context
* @param[in] dom_name Name of the domain
* @param[out] has_algorithmic_mapping Boolean value indicating if the given
* domain is configured for algorithmic
* mapping or not.
*
* @return
* - #IDMAP_SUCCESS: Domain for the given name was found and
* has_algorithmic_mapping is set accordingly
* - #IDMAP_ERROR: Provided name is invalid
* - #IDMAP_CONTEXT_INVALID: Provided idmap context is invalid
* - #IDMAP_NO_DOMAIN: No domains are available in the idmap context
* - #IDMAP_NAME_UNKNOWN: No domain with the given name was found in the
* idmap context
*/
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);
/**
* @brief Convert binary SID to SID structure
*
* @param[in] ctx Idmap context
* @param[in] bin_sid Array with the binary SID
* @param[in] length Size of the array containing the binary SID
* @param[out] dom_sid SID structure,
* must be freed if not needed anymore
*
* @return
* - #IDMAP_SID_INVALID: Given SID is invalid
* - #IDMAP_OUT_OF_MEMORY: Failed to allocate memory for the result
*/
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);
/**
* @brief Convert binary SID to SID string
*
* @param[in] ctx Idmap context
* @param[in] bin_sid Array with the binary SID
* @param[in] length Size of the array containing the binary SID
* @param[out] sid Zero-terminated string representation of the SID,
* must be freed if not needed anymore
*
* @return
* - #IDMAP_SID_INVALID: Given SID is invalid
* - #IDMAP_OUT_OF_MEMORY: Failed to allocate memory for the result
*/
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);
/**
* @brief Convert SID structure to binary SID
*
* @param[in] ctx Idmap context
* @param[in] dom_sid SID structure
* @param[out] bin_sid Array with the binary SID,
* must be freed if not needed anymore
* @param[out] length Size of the array containing the binary SID
*
* @return
* - #IDMAP_SID_INVALID: Given SID is invalid
* - #IDMAP_OUT_OF_MEMORY: Failed to allocate memory for the result
*/
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);
/**
* @brief Convert SID string to binary SID
*
* @param[in] ctx Idmap context
* @param[in] sid Zero-terminated string representation of the SID
* @param[out] bin_sid Array with the binary SID,
* must be freed if not needed anymore
* @param[out] length Size of the array containing the binary SID
*
* @return
* - #IDMAP_SID_INVALID: Given SID is invalid
* - #IDMAP_OUT_OF_MEMORY: Failed to allocate memory for the result
*/
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);
/**
* @brief Convert SID structure to SID string
*
* @param[in] ctx Idmap context
* @param[in] dom_sid SID structure
* @param[out] sid Zero-terminated string representation of the SID,
* must be freed if not needed anymore
*
* @return
* - #IDMAP_SID_INVALID: Given SID is invalid
* - #IDMAP_OUT_OF_MEMORY: Failed to allocate memory for the result
*/
enum idmap_error_code sss_idmap_dom_sid_to_sid(struct sss_idmap_ctx *ctx,
struct sss_dom_sid *dom_sid,
char **sid);
/**
* @brief Convert SID string to SID structure
*
* @param[in] ctx Idmap context
* @param[in] sid Zero-terminated string representation of the SID
* @param[out] dom_sid SID structure,
* must be freed if not needed anymore
*
* @return
* - #IDMAP_SID_INVALID: Given SID is invalid
* - #IDMAP_OUT_OF_MEMORY: Failed to allocate memory for the result
*/
enum idmap_error_code sss_idmap_sid_to_dom_sid(struct sss_idmap_ctx *ctx,
const char *sid,
struct sss_dom_sid **dom_sid);
/**
* @brief Convert SID string to Samba dom_sid structure
*
* @param[in] ctx Idmap context
* @param[in] sid Zero-terminated string representation of the SID
* @param[out] smb_sid Samba dom_sid structure,
* must be freed if not needed anymore
*
* @return
* - #IDMAP_SID_INVALID: Given SID is invalid
* - #IDMAP_OUT_OF_MEMORY: Failed to allocate memory for the result
*/
enum idmap_error_code sss_idmap_sid_to_smb_sid(struct sss_idmap_ctx *ctx,
const char *sid,
struct dom_sid **smb_sid);
/**
* @brief Convert Samba dom_sid structure to SID string
*
* @param[in] ctx Idmap context
* @param[in] smb_sid Samba dom_sid structure
* @param[out] sid Zero-terminated string representation of the SID,
* must be freed if not needed anymore
*
* @return
* - #IDMAP_SID_INVALID: Given SID is invalid
* - #IDMAP_OUT_OF_MEMORY: Failed to allocate memory for the result
*/
enum idmap_error_code sss_idmap_smb_sid_to_sid(struct sss_idmap_ctx *ctx,
struct dom_sid *smb_sid,
char **sid);
/**
* @brief Convert SID stucture to Samba dom_sid structure
*
* @param[in] ctx Idmap context
* @param[in] dom_sid SID structure
* @param[out] smb_sid Samba dom_sid structure,
* must be freed if not needed anymore
*
* @return
* - #IDMAP_SID_INVALID: Given SID is invalid
* - #IDMAP_OUT_OF_MEMORY: Failed to allocate memory for the result
*/
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);
/**
* @brief Convert Samba dom_sid structure to SID structure
*
* @param[in] ctx Idmap context
* @param[in] smb_sid Samba dom_sid structure
* @param[out] dom_sid SID structure,
* must be freed if not needed anymore
*
* @return
* - #IDMAP_SID_INVALID: Given SID is invalid
* - #IDMAP_OUT_OF_MEMORY: Failed to allocate memory for the result
*/
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);
/**
* @brief Convert binary SID to Samba dom_sid structure
*
* @param[in] ctx Idmap context
* @param[in] bin_sid Array with the binary SID
* @param[in] length Size of the array containing the binary SID
* @param[out] smb_sid Samba dom_sid structure,
* must be freed if not needed anymore
*
* @return
* - #IDMAP_SID_INVALID: Given SID is invalid
* - #IDMAP_OUT_OF_MEMORY: Failed to allocate memory for the result
*/
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);
/**
* @brief Convert Samba dom_sid structure to binary SID
*
* @param[in] ctx Idmap context
* @param[in] smb_sid Samba dom_sid structure
* @param[out] bin_sid Array with the binary SID,
* must be freed if not needed anymore
* @param[out] length Size of the array containing the binary SID
*
* @return
* - #IDMAP_SID_INVALID: Given SID is invalid
* - #IDMAP_OUT_OF_MEMORY: Failed to allocate memory for the result
*/
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);
/**
* @}
*/
#endif /* SSS_IDMAP_H_ */
|