dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libidmap / common / idmap_priv.h
blob2b28b219bea7570b0f2fec2c83f68fabb1446469
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
26 * Additional API for Identity Mapping Service
29 #ifndef _IDMAP_PRIV_H
30 #define _IDMAP_PRIV_H
33 #include <libscf.h>
34 #include <resolv.h>
36 #include "idmap.h"
37 #include <rpcsvc/idmap_prot.h>
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
43 #define IDMAP_MAX_NAME_LEN 512
45 #define IDMAP_ERROR(rc) (rc != IDMAP_SUCCESS && rc != IDMAP_NEXT)
46 #define IDMAP_FATAL_ERROR(rc) (rc == IDMAP_ERR_MEMORY ||\
47 rc == IDMAP_ERR_DB)
50 /* is_user values */
52 #define IDMAP_YES 1
53 #define IDMAP_NO 0
54 #define IDMAP_UNKNOWN -1
56 #define CHECK_NULL(s) (s != NULL ? s : "null")
57 #define EMPTY_STRING(str) (str == NULL || *str == '\0')
59 /* Opaque handle to batch config add/remove operations */
60 typedef struct idmap_udt_handle idmap_udt_handle_t;
62 /* Opaque iterator */
63 typedef struct idmap_iter idmap_iter_t;
67 * Update API
70 /* Create handle for updates */
71 extern idmap_stat idmap_udt_create(idmap_udt_handle_t **);
73 /* Commit */
74 extern idmap_stat idmap_udt_commit(idmap_udt_handle_t *);
76 /* Get index of the failed batch element */
77 extern idmap_stat idmap_udt_get_error_index(idmap_udt_handle_t *, int64_t *);
79 /* Get the rule which caused the batch to failed */
80 extern idmap_stat idmap_udt_get_error_rule(idmap_udt_handle_t *, char **,
81 char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
83 /* Get the rule which caused a conflict */
84 extern idmap_stat idmap_udt_get_conflict_rule(idmap_udt_handle_t *, char **,
85 char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
87 /* Destroy the update handle */
88 extern void idmap_udt_destroy(idmap_udt_handle_t *);
90 /* Add name-based mapping rule */
91 extern idmap_stat idmap_udt_add_namerule(idmap_udt_handle_t *, const char *,
92 boolean_t, boolean_t, const char *, const char *, boolean_t, int);
94 /* Remove name-based mapping rule */
95 extern idmap_stat idmap_udt_rm_namerule(idmap_udt_handle_t *, boolean_t,
96 boolean_t, const char *, const char *, const char *, int);
98 /* Flush name-based mapping rules */
99 extern idmap_stat idmap_udt_flush_namerules(idmap_udt_handle_t *);
101 /* Flush caches */
102 extern idmap_stat idmap_flush(idmap_flush_op);
105 * Iterator API
108 /* Create a iterator to get SID to UID/GID mappings */
109 extern idmap_stat idmap_iter_mappings(idmap_iter_t **, int flag);
111 /* Iterate through the SID to UID/GID mappings */
112 extern idmap_stat idmap_iter_next_mapping(idmap_iter_t *, char **,
113 idmap_rid_t *, uid_t *, char **, char **, char **, boolean_t *,
114 boolean_t *, int *, idmap_info *);
116 /* Create a iterator to get name-based mapping rules */
117 extern idmap_stat idmap_iter_namerules(const char *,
118 boolean_t, boolean_t, const char *, const char *, idmap_iter_t **);
120 /* Iterate through the name-based mapping rules */
121 extern idmap_stat idmap_iter_next_namerule(idmap_iter_t *, char **,
122 char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
124 /* Set the number of entries requested per batch */
125 extern idmap_stat idmap_iter_set_limit(idmap_iter_t *, uint64_t);
127 /* Destroy the iterator */
128 extern void idmap_iter_destroy(idmap_iter_t *);
132 * Get mapping
134 extern idmap_stat idmap_get_w2u_mapping(const char *,
135 idmap_rid_t *, const char *, const char *, int, int *, int *,
136 uid_t *, char **, int *, idmap_info *);
138 extern idmap_stat idmap_get_u2w_mapping(uid_t *,
139 const char *, int, int, int *, char **, idmap_rid_t *, char **,
140 char **, int *, idmap_info *);
144 * Miscellaneous
147 /* string to status */
148 extern idmap_stat idmap_string2stat(const char *);
150 /* internal status to protocol status */
151 extern idmap_stat idmap_stat4prot(idmap_stat);
153 /* copy idmap_namerule including strings */
154 extern idmap_stat idmap_namerule_cpy(idmap_namerule *, idmap_namerule *);
156 /* Move idmap_info info including strings */
157 extern void idmap_info_mov(idmap_info *to, idmap_info *from);
159 /* free idmap_info info from user supplied struct */
160 extern void idmap_info_free(idmap_info *);
161 extern void idmap_how_clear(idmap_how *);
165 * Extended API to batch SID to UID/GID mapping requests
168 /* Given SID, get UID */
169 extern idmap_stat idmap_getext_uidbysid(idmap_get_handle_t *, char *,
170 idmap_rid_t, int, uid_t *, idmap_info *, idmap_stat *);
172 /* Given SID, get GID */
173 extern idmap_stat idmap_getext_gidbysid(idmap_get_handle_t *, char *,
174 idmap_rid_t, int, gid_t *, idmap_info *, idmap_stat *);
176 /* Given SID, get UID or GID */
177 extern idmap_stat idmap_getext_pidbysid(idmap_get_handle_t *, char *,
178 idmap_rid_t, int, uid_t *, int *, idmap_info *, idmap_stat *);
180 /* Given UID, get SID */
181 extern idmap_stat idmap_getext_sidbyuid(idmap_get_handle_t *, uid_t, int,
182 char **, idmap_rid_t *, idmap_info *, idmap_stat *);
184 /* Given GID, get SID */
185 extern idmap_stat idmap_getext_sidbygid(idmap_get_handle_t *, gid_t, int,
186 char **, idmap_rid_t *, idmap_info *, idmap_stat *);
188 /* Properties */
189 extern idmap_stat idmap_get_prop_ds(idmap_prop_type, idmap_ad_disc_ds_t *);
190 extern idmap_stat idmap_get_prop_str(idmap_prop_type, char **);
193 * Trace
195 * These are the names of the trace parameters that may be returned
196 * when tracing is requested.
198 #define IDMAP_TRACE_NAME_MAX 100 /* max length of a trace param name */
199 #define IDMAP_TRACE_TYPE "-type" /* prefix with "from" or "to" */
200 #define IDMAP_TRACE_NAME "-name" /* prefix with "from" or "to" */
201 #define IDMAP_TRACE_SID "-sid" /* prefix with "from" or "to" */
202 #define IDMAP_TRACE_UNIXID "-unixid" /* prefix with "from" or "to" */
203 #define IDMAP_TRACE_ERROR "error"
204 #define IDMAP_TRACE_MESSAGE "message"
206 extern void idmap_trace_print_1(FILE *out, char *prefix, nvlist_t *entry);
207 extern void idmap_trace_print(FILE *out, char *prefix, nvlist_t *trace);
209 #ifdef __cplusplus
211 #endif
213 #endif /* _IDMAP_PRIV_H */