xref: /titanic_52/usr/src/lib/libidmap/common/idmap.h (revision c5c4113dfcabb1eed3d4bdf7609de5170027a794)
1*c5c4113dSnw141292 /*
2*c5c4113dSnw141292  * CDDL HEADER START
3*c5c4113dSnw141292  *
4*c5c4113dSnw141292  * The contents of this file are subject to the terms of the
5*c5c4113dSnw141292  * Common Development and Distribution License (the "License").
6*c5c4113dSnw141292  * You may not use this file except in compliance with the License.
7*c5c4113dSnw141292  *
8*c5c4113dSnw141292  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*c5c4113dSnw141292  * or http://www.opensolaris.org/os/licensing.
10*c5c4113dSnw141292  * See the License for the specific language governing permissions
11*c5c4113dSnw141292  * and limitations under the License.
12*c5c4113dSnw141292  *
13*c5c4113dSnw141292  * When distributing Covered Code, include this CDDL HEADER in each
14*c5c4113dSnw141292  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*c5c4113dSnw141292  * If applicable, add the following below this CDDL HEADER, with the
16*c5c4113dSnw141292  * fields enclosed by brackets "[]" replaced with your own identifying
17*c5c4113dSnw141292  * information: Portions Copyright [yyyy] [name of copyright owner]
18*c5c4113dSnw141292  *
19*c5c4113dSnw141292  * CDDL HEADER END
20*c5c4113dSnw141292  */
21*c5c4113dSnw141292 /*
22*c5c4113dSnw141292  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*c5c4113dSnw141292  * Use is subject to license terms.
24*c5c4113dSnw141292  */
25*c5c4113dSnw141292 
26*c5c4113dSnw141292 /*
27*c5c4113dSnw141292  * Header File for Clients of Native Identity Mapping Service
28*c5c4113dSnw141292  */
29*c5c4113dSnw141292 
30*c5c4113dSnw141292 #ifndef _IDMAP_H
31*c5c4113dSnw141292 #define	_IDMAP_H
32*c5c4113dSnw141292 
33*c5c4113dSnw141292 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34*c5c4113dSnw141292 
35*c5c4113dSnw141292 #include <stdlib.h>
36*c5c4113dSnw141292 #include <ctype.h>
37*c5c4113dSnw141292 #include <sys/param.h>
38*c5c4113dSnw141292 #include <sys/types.h>
39*c5c4113dSnw141292 #include <sys/stat.h>
40*c5c4113dSnw141292 #include <sys/idmap.h>
41*c5c4113dSnw141292 
42*c5c4113dSnw141292 #ifdef __cplusplus
43*c5c4113dSnw141292 extern "C" {
44*c5c4113dSnw141292 #endif
45*c5c4113dSnw141292 
46*c5c4113dSnw141292 /* Status */
47*c5c4113dSnw141292 typedef int32_t	idmap_stat;
48*c5c4113dSnw141292 
49*c5c4113dSnw141292 typedef uint32_t	idmap_rid_t;
50*c5c4113dSnw141292 
51*c5c4113dSnw141292 /* Opaque client handle */
52*c5c4113dSnw141292 typedef struct idmap_handle idmap_handle_t;
53*c5c4113dSnw141292 
54*c5c4113dSnw141292 /* Opaque "get-mapping" handle */
55*c5c4113dSnw141292 typedef struct idmap_get_handle idmap_get_handle_t;
56*c5c4113dSnw141292 
57*c5c4113dSnw141292 
58*c5c4113dSnw141292 /*
59*c5c4113dSnw141292  * Setup API
60*c5c4113dSnw141292  */
61*c5c4113dSnw141292 /* Create/Init handle for userland clients */
62*c5c4113dSnw141292 extern idmap_stat idmap_init(idmap_handle_t **);
63*c5c4113dSnw141292 
64*c5c4113dSnw141292 /* Finalize/close handle */
65*c5c4113dSnw141292 extern idmap_stat idmap_fini(idmap_handle_t *);
66*c5c4113dSnw141292 
67*c5c4113dSnw141292 /* Status code to string */
68*c5c4113dSnw141292 extern const char *idmap_stat2string(idmap_handle_t *, idmap_stat);
69*c5c4113dSnw141292 
70*c5c4113dSnw141292 /* Free memory allocated by the API */
71*c5c4113dSnw141292 extern void idmap_free(void *);
72*c5c4113dSnw141292 
73*c5c4113dSnw141292 
74*c5c4113dSnw141292 /*
75*c5c4113dSnw141292  * API to batch SID to UID/GID mapping requests
76*c5c4113dSnw141292  */
77*c5c4113dSnw141292 /* Create handle */
78*c5c4113dSnw141292 extern idmap_stat idmap_get_create(idmap_handle_t *, idmap_get_handle_t **);
79*c5c4113dSnw141292 
80*c5c4113dSnw141292 /* Given SID, get UID */
81*c5c4113dSnw141292 extern idmap_stat idmap_get_uidbysid(idmap_get_handle_t *, char *,
82*c5c4113dSnw141292 	idmap_rid_t, int, uid_t *, idmap_stat *);
83*c5c4113dSnw141292 
84*c5c4113dSnw141292 /* Given SID, get GID */
85*c5c4113dSnw141292 extern idmap_stat idmap_get_gidbysid(idmap_get_handle_t *, char *,
86*c5c4113dSnw141292 	idmap_rid_t, int, gid_t *, idmap_stat *);
87*c5c4113dSnw141292 
88*c5c4113dSnw141292 /* Given SID, get UID or GID */
89*c5c4113dSnw141292 extern idmap_stat idmap_get_pidbysid(idmap_get_handle_t *, char *,
90*c5c4113dSnw141292 	idmap_rid_t, int, uid_t *, int *, idmap_stat *);
91*c5c4113dSnw141292 
92*c5c4113dSnw141292 /* Given UID, get SID */
93*c5c4113dSnw141292 extern idmap_stat idmap_get_sidbyuid(idmap_get_handle_t *, uid_t, int,
94*c5c4113dSnw141292 	char **, idmap_rid_t *, idmap_stat *);
95*c5c4113dSnw141292 
96*c5c4113dSnw141292 /* Given GID, get SID */
97*c5c4113dSnw141292 extern idmap_stat idmap_get_sidbygid(idmap_get_handle_t *, gid_t, int,
98*c5c4113dSnw141292 	char **, idmap_rid_t *, idmap_stat *);
99*c5c4113dSnw141292 
100*c5c4113dSnw141292 /* Process the batched requests */
101*c5c4113dSnw141292 extern idmap_stat idmap_get_mappings(idmap_get_handle_t *);
102*c5c4113dSnw141292 
103*c5c4113dSnw141292 /* Destroy the handle */
104*c5c4113dSnw141292 extern void idmap_get_destroy(idmap_get_handle_t *);
105*c5c4113dSnw141292 
106*c5c4113dSnw141292 #ifdef __cplusplus
107*c5c4113dSnw141292 }
108*c5c4113dSnw141292 #endif
109*c5c4113dSnw141292 
110*c5c4113dSnw141292 #endif /* _IDMAP_H */
111