xref: /onnv-gate/usr/src/lib/libidmap/common/idmap_priv.h (revision 12914:e95332bf1454)
14520Snw141292 /*
24520Snw141292  * CDDL HEADER START
34520Snw141292  *
44520Snw141292  * The contents of this file are subject to the terms of the
54520Snw141292  * Common Development and Distribution License (the "License").
64520Snw141292  * You may not use this file except in compliance with the License.
74520Snw141292  *
84520Snw141292  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
94520Snw141292  * or http://www.opensolaris.org/os/licensing.
104520Snw141292  * See the License for the specific language governing permissions
114520Snw141292  * and limitations under the License.
124520Snw141292  *
134520Snw141292  * When distributing Covered Code, include this CDDL HEADER in each
144520Snw141292  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
154520Snw141292  * If applicable, add the following below this CDDL HEADER, with the
164520Snw141292  * fields enclosed by brackets "[]" replaced with your own identifying
174520Snw141292  * information: Portions Copyright [yyyy] [name of copyright owner]
184520Snw141292  *
194520Snw141292  * CDDL HEADER END
204520Snw141292  */
214520Snw141292 /*
2212065SKeyur.Desai@Sun.COM  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
234520Snw141292  */
244520Snw141292 
254520Snw141292 /*
264520Snw141292  * Additional API for Identity Mapping Service
274520Snw141292  */
284520Snw141292 
294520Snw141292 #ifndef _IDMAP_PRIV_H
304520Snw141292 #define	_IDMAP_PRIV_H
314520Snw141292 
324520Snw141292 
336616Sdm199847 #include <libscf.h>
346616Sdm199847 #include <resolv.h>
356616Sdm199847 
364520Snw141292 #include "idmap.h"
379565SJordan.Brown@Sun.COM #include <rpcsvc/idmap_prot.h>
384520Snw141292 
394520Snw141292 #ifdef __cplusplus
404520Snw141292 extern "C" {
414520Snw141292 #endif
424520Snw141292 
434520Snw141292 #define	IDMAP_MAX_NAME_LEN	512
444520Snw141292 
455968Snw141292 #define	IDMAP_ERROR(rc)		(rc != IDMAP_SUCCESS && rc != IDMAP_NEXT)
465968Snw141292 #define	IDMAP_FATAL_ERROR(rc)	(rc == IDMAP_ERR_MEMORY ||\
475968Snw141292 				rc == IDMAP_ERR_DB)
484520Snw141292 
496616Sdm199847 
506616Sdm199847 /* is_user values */
516616Sdm199847 
526616Sdm199847 #define	IDMAP_YES 1
536616Sdm199847 #define	IDMAP_NO 0
546616Sdm199847 #define	IDMAP_UNKNOWN -1
556616Sdm199847 
567198Sjp151216 #define	CHECK_NULL(s)	(s != NULL ? s : "null")
577198Sjp151216 #define	EMPTY_STRING(str)	(str == NULL || *str == '\0')
587198Sjp151216 
594520Snw141292 /* Opaque handle to batch config add/remove operations */
604520Snw141292 typedef struct idmap_udt_handle idmap_udt_handle_t;
614520Snw141292 
624520Snw141292 /* Opaque iterator */
634520Snw141292 typedef struct idmap_iter idmap_iter_t;
644520Snw141292 
657198Sjp151216 
667198Sjp151216 /*
674520Snw141292  * Update API
684520Snw141292  */
694520Snw141292 
704520Snw141292 /* Create handle for updates */
71*12914SJoyce.McIntosh@Sun.COM extern idmap_stat idmap_udt_create(idmap_udt_handle_t **);
724520Snw141292 
734520Snw141292 /* Commit */
744520Snw141292 extern idmap_stat idmap_udt_commit(idmap_udt_handle_t *);
754520Snw141292 
765064Sdm199847 /* Get index of the failed batch element */
775064Sdm199847 extern idmap_stat idmap_udt_get_error_index(idmap_udt_handle_t *, int64_t *);
785064Sdm199847 
795064Sdm199847 /* Get the rule which caused the batch to failed */
805064Sdm199847 extern idmap_stat idmap_udt_get_error_rule(idmap_udt_handle_t *, char **,
815696Snw141292     char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
825064Sdm199847 
835064Sdm199847 /* Get the rule which caused a conflict */
845064Sdm199847 extern idmap_stat idmap_udt_get_conflict_rule(idmap_udt_handle_t *, char **,
855696Snw141292     char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
865064Sdm199847 
874520Snw141292 /* Destroy the update handle */
884520Snw141292 extern void idmap_udt_destroy(idmap_udt_handle_t *);
894520Snw141292 
904520Snw141292 /* Add name-based mapping rule */
914520Snw141292 extern idmap_stat idmap_udt_add_namerule(idmap_udt_handle_t *, const char *,
925696Snw141292 	boolean_t, boolean_t, const char *, const char *, boolean_t, int);
934520Snw141292 
944520Snw141292 /* Remove name-based mapping rule */
954520Snw141292 extern idmap_stat idmap_udt_rm_namerule(idmap_udt_handle_t *, boolean_t,
965696Snw141292 	boolean_t, const char *, const char *, const char *, int);
974520Snw141292 
984520Snw141292 /* Flush name-based mapping rules */
995696Snw141292 extern idmap_stat idmap_udt_flush_namerules(idmap_udt_handle_t *);
1004520Snw141292 
10111963SAfshin.Ardakani@Sun.COM /* Flush caches */
102*12914SJoyce.McIntosh@Sun.COM extern idmap_stat idmap_flush(idmap_flush_op);
1034520Snw141292 
1044520Snw141292 /*
1054520Snw141292  * Iterator API
1064520Snw141292  */
1074520Snw141292 
1084520Snw141292 /* Create a iterator to get SID to UID/GID mappings */
109*12914SJoyce.McIntosh@Sun.COM extern idmap_stat idmap_iter_mappings(idmap_iter_t **, int flag);
1104520Snw141292 
1114520Snw141292 /* Iterate through the SID to UID/GID mappings */
1124520Snw141292 extern idmap_stat idmap_iter_next_mapping(idmap_iter_t *, char **,
1135696Snw141292 	idmap_rid_t *, uid_t *, char **, char **, char **, boolean_t *,
1146386Sjp151216 	boolean_t *, int *, idmap_info *);
1154520Snw141292 
1164520Snw141292 /* Create a iterator to get name-based mapping rules */
117*12914SJoyce.McIntosh@Sun.COM extern idmap_stat idmap_iter_namerules(const char *,
1185696Snw141292 	boolean_t, boolean_t, const char *, const char *, idmap_iter_t **);
1194520Snw141292 
1204520Snw141292 /* Iterate through the name-based mapping rules */
1214520Snw141292 extern idmap_stat idmap_iter_next_namerule(idmap_iter_t *, char **,
1225696Snw141292 	char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
1234520Snw141292 
1244520Snw141292 /* Set the number of entries requested per batch */
1254520Snw141292 extern idmap_stat idmap_iter_set_limit(idmap_iter_t *, uint64_t);
1264520Snw141292 
1274520Snw141292 /* Destroy the iterator */
1284520Snw141292 extern void idmap_iter_destroy(idmap_iter_t *);
1294520Snw141292 
1304520Snw141292 
1314520Snw141292 /*
1324520Snw141292  * Get mapping
1334520Snw141292  */
134*12914SJoyce.McIntosh@Sun.COM extern idmap_stat idmap_get_w2u_mapping(const char *,
1355696Snw141292 	idmap_rid_t *, const char *, const char *, int, int *, int *,
1366386Sjp151216 	uid_t *, char **, int *, idmap_info *);
1374520Snw141292 
138*12914SJoyce.McIntosh@Sun.COM extern idmap_stat idmap_get_u2w_mapping(uid_t *,
1395696Snw141292 	const char *, int, int, int *, char **, idmap_rid_t *, char **,
1406386Sjp151216 	char **, int *, idmap_info *);
1414520Snw141292 
1424520Snw141292 
1434520Snw141292 /*
1444520Snw141292  * Miscellaneous
1454520Snw141292  */
1464520Snw141292 
1474520Snw141292 /* string to status */
1484520Snw141292 extern idmap_stat idmap_string2stat(const char *);
1494520Snw141292 
1504520Snw141292 /* internal status to protocol status */
1514520Snw141292 extern idmap_stat idmap_stat4prot(idmap_stat);
1524520Snw141292 
1535064Sdm199847 /* copy idmap_namerule including strings */
1545064Sdm199847 extern idmap_stat idmap_namerule_cpy(idmap_namerule *, idmap_namerule *);
1555064Sdm199847 
1566386Sjp151216 /* Move  idmap_info info including strings */
15712508Samw@Sun.COM extern void idmap_info_mov(idmap_info *to, idmap_info *from);
1586386Sjp151216 
1596386Sjp151216 /* free idmap_info info from  user supplied struct */
1606386Sjp151216 extern void idmap_info_free(idmap_info *);
16112508Samw@Sun.COM extern void idmap_how_clear(idmap_how *);
1626386Sjp151216 
1636386Sjp151216 
1646386Sjp151216 /*
1656386Sjp151216  * Extended API to batch SID to UID/GID mapping requests
1666386Sjp151216  */
1676386Sjp151216 
1686386Sjp151216 /* Given SID, get UID */
1696386Sjp151216 extern idmap_stat idmap_getext_uidbysid(idmap_get_handle_t *, char *,
1706386Sjp151216 	idmap_rid_t, int, uid_t *, idmap_info *, idmap_stat *);
1716386Sjp151216 
1726386Sjp151216 /* Given SID, get GID */
1736386Sjp151216 extern idmap_stat idmap_getext_gidbysid(idmap_get_handle_t *, char *,
1746386Sjp151216 	idmap_rid_t, int, gid_t *, idmap_info *, idmap_stat *);
1756386Sjp151216 
1766386Sjp151216 /* Given SID, get UID or GID */
1776386Sjp151216 extern idmap_stat idmap_getext_pidbysid(idmap_get_handle_t *, char *,
1786386Sjp151216 	idmap_rid_t, int, uid_t *, int *, idmap_info *, idmap_stat *);
1796386Sjp151216 
1806386Sjp151216 /* Given UID, get SID */
1816386Sjp151216 extern idmap_stat idmap_getext_sidbyuid(idmap_get_handle_t *, uid_t, int,
1826386Sjp151216 	char **, idmap_rid_t *, idmap_info *, idmap_stat *);
1836386Sjp151216 
1846386Sjp151216 /* Given GID, get SID */
1856386Sjp151216 extern idmap_stat idmap_getext_sidbygid(idmap_get_handle_t *, gid_t, int,
1866386Sjp151216 	char **, idmap_rid_t *, idmap_info *, idmap_stat *);
1876386Sjp151216 
18812065SKeyur.Desai@Sun.COM /* Properties */
189*12914SJoyce.McIntosh@Sun.COM extern idmap_stat idmap_get_prop_ds(idmap_prop_type, idmap_ad_disc_ds_t *);
190*12914SJoyce.McIntosh@Sun.COM extern idmap_stat idmap_get_prop_str(idmap_prop_type, char **);
1916386Sjp151216 
19212508Samw@Sun.COM /*
19312508Samw@Sun.COM  * Trace
19412508Samw@Sun.COM  *
19512508Samw@Sun.COM  * These are the names of the trace parameters that may be returned
19612508Samw@Sun.COM  * when tracing is requested.
19712508Samw@Sun.COM  */
19812508Samw@Sun.COM #define	IDMAP_TRACE_NAME_MAX	100	/* max length of a trace param name */
19912508Samw@Sun.COM #define	IDMAP_TRACE_TYPE	"-type"		/* prefix with "from" or "to" */
20012508Samw@Sun.COM #define	IDMAP_TRACE_NAME	"-name"		/* prefix with "from" or "to" */
20112508Samw@Sun.COM #define	IDMAP_TRACE_SID		"-sid"		/* prefix with "from" or "to" */
20212508Samw@Sun.COM #define	IDMAP_TRACE_UNIXID	"-unixid"	/* prefix with "from" or "to" */
20312508Samw@Sun.COM #define	IDMAP_TRACE_ERROR	"error"
20412508Samw@Sun.COM #define	IDMAP_TRACE_MESSAGE	"message"
20512508Samw@Sun.COM 
20612508Samw@Sun.COM extern void idmap_trace_print_1(FILE *out, char *prefix, nvlist_t *entry);
20712508Samw@Sun.COM extern void idmap_trace_print(FILE *out, char *prefix, nvlist_t *trace);
20812508Samw@Sun.COM 
2094520Snw141292 #ifdef __cplusplus
2104520Snw141292 }
2114520Snw141292 #endif
2124520Snw141292 
2134520Snw141292 #endif /* _IDMAP_PRIV_H */
214