1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 /* 27 * Additional API for Identity Mapping Service 28 */ 29 30 #ifndef _IDMAP_PRIV_H 31 #define _IDMAP_PRIV_H 32 33 #pragma ident "%Z%%M% %I% %E% SMI" 34 35 #include "idmap.h" 36 #include "idmap_prot.h" 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 #define IDMAP_MAX_NAME_LEN 512 43 44 #define IDMAP_ERROR(rc) rc != IDMAP_SUCCESS && rc != IDMAP_NEXT 45 #define IDMAP_FATAL_ERROR(rc) rc == IDMAP_ERR_MEMORY ||\ 46 rc == IDMAP_ERR_DB 47 48 /* Direction in which mapping is valid */ 49 #define IDMAP_DIRECTION_UNDEF -1 /* not defined */ 50 #define IDMAP_DIRECTION_BI 0 /* bi-directional */ 51 #define IDMAP_DIRECTION_W2U 1 /* windows to unix only */ 52 #define IDMAP_DIRECTION_U2W 2 /* unix to windows only */ 53 54 /* Opaque handle to batch config add/remove operations */ 55 typedef struct idmap_udt_handle idmap_udt_handle_t; 56 57 /* Opaque iterator */ 58 typedef struct idmap_iter idmap_iter_t; 59 60 61 /* 62 * Update API 63 */ 64 65 /* Create handle for updates */ 66 extern idmap_stat idmap_udt_create(idmap_handle_t *, 67 idmap_udt_handle_t **); 68 69 /* Commit */ 70 extern idmap_stat idmap_udt_commit(idmap_udt_handle_t *); 71 72 /* Destroy the update handle */ 73 extern void idmap_udt_destroy(idmap_udt_handle_t *); 74 75 /* Add name-based mapping rule */ 76 extern idmap_stat idmap_udt_add_namerule(idmap_udt_handle_t *, const char *, 77 boolean_t, const char *, const char *, boolean_t, int); 78 79 /* Remove name-based mapping rule */ 80 extern idmap_stat idmap_udt_rm_namerule(idmap_udt_handle_t *, boolean_t, 81 const char *, const char *, const char *, int); 82 83 /* Flush name-based mapping rules */ 84 extern idmap_stat idmap_udt_flush_namerules(idmap_udt_handle_t *, boolean_t); 85 86 87 /* 88 * Iterator API 89 */ 90 91 /* Create a iterator to get SID to UID/GID mappings */ 92 extern idmap_stat idmap_iter_mappings(idmap_handle_t *, boolean_t, 93 idmap_iter_t **); 94 95 /* Iterate through the SID to UID/GID mappings */ 96 extern idmap_stat idmap_iter_next_mapping(idmap_iter_t *, char **, 97 idmap_rid_t *, uid_t *, char **, char **, char **, int *); 98 99 /* Create a iterator to get name-based mapping rules */ 100 extern idmap_stat idmap_iter_namerules(idmap_handle_t *, const char *, 101 boolean_t, const char *, const char *, idmap_iter_t **); 102 103 /* Iterate through the name-based mapping rules */ 104 extern idmap_stat idmap_iter_next_namerule(idmap_iter_t *, char **, 105 char **, char **, boolean_t *, int *); 106 107 /* Set the number of entries requested per batch */ 108 extern idmap_stat idmap_iter_set_limit(idmap_iter_t *, uint64_t); 109 110 /* Destroy the iterator */ 111 extern void idmap_iter_destroy(idmap_iter_t *); 112 113 114 /* 115 * Get mapping 116 */ 117 extern idmap_stat idmap_get_w2u_mapping(idmap_handle_t *, const char *, 118 idmap_rid_t *, const char *, const char *, int, int *, 119 uid_t *, char **, int *); 120 121 extern idmap_stat idmap_get_u2w_mapping(idmap_handle_t *, uid_t *, 122 const char *, int, int, char **, idmap_rid_t *, char **, 123 char **, int *); 124 125 126 /* 127 * Miscellaneous 128 */ 129 130 /* utf8 to string */ 131 extern idmap_stat idmap_utf82str(char **, size_t, idmap_utf8str *); 132 133 /* string to utf8 */ 134 extern idmap_stat idmap_str2utf8(idmap_utf8str **, const char *, int); 135 136 /* string to status */ 137 extern idmap_stat idmap_string2stat(const char *); 138 139 /* internal status to protocol status */ 140 extern idmap_stat idmap_stat4prot(idmap_stat); 141 142 #ifdef __cplusplus 143 } 144 #endif 145 146 #endif /* _IDMAP_PRIV_H */ 147