xref: /onnv-gate/usr/src/lib/libidmap/common/idmap.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  * Header File for Clients of Native Identity Mapping Service
274520Snw141292  */
284520Snw141292 
294520Snw141292 #ifndef _IDMAP_H
304520Snw141292 #define	_IDMAP_H
314520Snw141292 
324520Snw141292 
334520Snw141292 #include <stdlib.h>
344520Snw141292 #include <ctype.h>
354520Snw141292 #include <sys/param.h>
364520Snw141292 #include <sys/types.h>
374520Snw141292 #include <sys/stat.h>
384520Snw141292 #include <sys/idmap.h>
394520Snw141292 
404520Snw141292 #ifdef __cplusplus
414520Snw141292 extern "C" {
424520Snw141292 #endif
434520Snw141292 
444520Snw141292 /* Status */
454520Snw141292 typedef int32_t	idmap_stat;
464520Snw141292 
474520Snw141292 typedef uint32_t	idmap_rid_t;
484520Snw141292 
494520Snw141292 /* Opaque "get-mapping" handle */
504520Snw141292 typedef struct idmap_get_handle idmap_get_handle_t;
514520Snw141292 
528671SJulian.Pullen@Sun.COM /* Logger prototype which is based on syslog */
5312065SKeyur.Desai@Sun.COM typedef void (*idmap_logger_t)(int, const char *, ...);
546616Sdm199847 
554520Snw141292 /*
564520Snw141292  * Setup API
574520Snw141292  */
584520Snw141292 
594520Snw141292 /* Status code to string */
60*12914SJoyce.McIntosh@Sun.COM extern const char *idmap_stat2string(idmap_stat);
614520Snw141292 
624520Snw141292 /* Free memory allocated by the API */
634520Snw141292 extern void idmap_free(void *);
644520Snw141292 
654520Snw141292 
664520Snw141292 /*
677369SJulian.Pullen@Sun.COM  * Supported flag values for mapping requests.
687369SJulian.Pullen@Sun.COM  * These flag values are applicable to the batch API and the
697369SJulian.Pullen@Sun.COM  * Windows Name API below.
707369SJulian.Pullen@Sun.COM  */
717369SJulian.Pullen@Sun.COM /* Use the libidmap cache */
727369SJulian.Pullen@Sun.COM #define	IDMAP_REQ_FLG_USE_CACHE	0x00000010
737369SJulian.Pullen@Sun.COM 
747369SJulian.Pullen@Sun.COM /*
754520Snw141292  * API to batch SID to UID/GID mapping requests
764520Snw141292  */
774520Snw141292 /* Create handle */
78*12914SJoyce.McIntosh@Sun.COM extern idmap_stat idmap_get_create(idmap_get_handle_t **);
794520Snw141292 
804520Snw141292 /* Given SID, get UID */
814520Snw141292 extern idmap_stat idmap_get_uidbysid(idmap_get_handle_t *, char *,
824520Snw141292 	idmap_rid_t, int, uid_t *, idmap_stat *);
834520Snw141292 
844520Snw141292 /* Given SID, get GID */
854520Snw141292 extern idmap_stat idmap_get_gidbysid(idmap_get_handle_t *, char *,
864520Snw141292 	idmap_rid_t, int, gid_t *, idmap_stat *);
874520Snw141292 
884520Snw141292 /* Given SID, get UID or GID */
894520Snw141292 extern idmap_stat idmap_get_pidbysid(idmap_get_handle_t *, char *,
904520Snw141292 	idmap_rid_t, int, uid_t *, int *, idmap_stat *);
914520Snw141292 
924520Snw141292 /* Given UID, get SID */
934520Snw141292 extern idmap_stat idmap_get_sidbyuid(idmap_get_handle_t *, uid_t, int,
944520Snw141292 	char **, idmap_rid_t *, idmap_stat *);
954520Snw141292 
964520Snw141292 /* Given GID, get SID */
974520Snw141292 extern idmap_stat idmap_get_sidbygid(idmap_get_handle_t *, gid_t, int,
984520Snw141292 	char **, idmap_rid_t *, idmap_stat *);
994520Snw141292 
1004520Snw141292 /* Process the batched requests */
1014520Snw141292 extern idmap_stat idmap_get_mappings(idmap_get_handle_t *);
1024520Snw141292 
1034520Snw141292 /* Destroy the handle */
1044520Snw141292 extern void idmap_get_destroy(idmap_get_handle_t *);
1054520Snw141292 
1065043Sbaban 
1075043Sbaban /*
1085043Sbaban  * API to get Windows name by UID/GID and vice-versa
1095043Sbaban  */
1105043Sbaban /* Given UID, get Windows name */
1117369SJulian.Pullen@Sun.COM extern idmap_stat idmap_getwinnamebyuid(uid_t, int, char **, char **);
1125043Sbaban 
1135043Sbaban /* Given GID, get Windows name */
1147369SJulian.Pullen@Sun.COM extern idmap_stat idmap_getwinnamebygid(gid_t, int, char **, char **);
1155043Sbaban 
1165043Sbaban /* Given Windows name, get UID */
1177369SJulian.Pullen@Sun.COM extern idmap_stat idmap_getuidbywinname(const char *, const char *,
1187369SJulian.Pullen@Sun.COM 	int, uid_t *);
1195043Sbaban 
1205043Sbaban /* Given Windows name, get GID */
1217369SJulian.Pullen@Sun.COM extern idmap_stat idmap_getgidbywinname(const char *, const char *,
1227369SJulian.Pullen@Sun.COM 	int, gid_t *);
1235043Sbaban 
1245043Sbaban 
1258671SJulian.Pullen@Sun.COM /* Logger */
12612065SKeyur.Desai@Sun.COM extern void idmap_set_logger(idmap_logger_t funct);
1278671SJulian.Pullen@Sun.COM 
1284520Snw141292 #ifdef __cplusplus
1294520Snw141292 }
1304520Snw141292 #endif
1314520Snw141292 
1324520Snw141292 #endif /* _IDMAP_H */
133