xref: /titanic_52/usr/src/lib/libidmap/common/idmap.h (revision c2785286330b58810071fc24f6ca69f401682dff)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * Header File for Clients of Native Identity Mapping Service
28  */
29 
30 #ifndef _IDMAP_H
31 #define	_IDMAP_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #include <stdlib.h>
36 #include <ctype.h>
37 #include <sys/param.h>
38 #include <sys/types.h>
39 #include <sys/stat.h>
40 #include <sys/idmap.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /* Status */
47 typedef int32_t	idmap_stat;
48 
49 typedef uint32_t	idmap_rid_t;
50 
51 /* Opaque client handle */
52 typedef struct idmap_handle idmap_handle_t;
53 
54 /* Opaque "get-mapping" handle */
55 typedef struct idmap_get_handle idmap_get_handle_t;
56 
57 
58 
59 /*
60  * Setup API
61  */
62 /* Create/Init handle for userland clients */
63 extern idmap_stat idmap_init(idmap_handle_t **);
64 
65 /* Finalize/close handle */
66 extern idmap_stat idmap_fini(idmap_handle_t *);
67 
68 /* Status code to string */
69 extern const char *idmap_stat2string(idmap_handle_t *, idmap_stat);
70 
71 /* Free memory allocated by the API */
72 extern void idmap_free(void *);
73 
74 
75 /*
76  * Directory based name map API
77  */
78 
79 /* Set namemap */
80 extern idmap_stat idmap_set_namemap(char *, char *, char *,
81     char *, char *, char *, int, int, int);
82 
83 /* Unset namemap */
84 extern idmap_stat idmap_unset_namemap(char *, char *, char *,
85 	char *, char *, char *, int, int, int);
86 
87 extern idmap_stat idmap_get_namemap(int *, char **, char **, int *, char **,
88     char **);
89 
90 /*
91  * API to batch SID to UID/GID mapping requests
92  */
93 /* Create handle */
94 extern idmap_stat idmap_get_create(idmap_handle_t *, idmap_get_handle_t **);
95 
96 /* Given SID, get UID */
97 extern idmap_stat idmap_get_uidbysid(idmap_get_handle_t *, char *,
98 	idmap_rid_t, int, uid_t *, idmap_stat *);
99 
100 /* Given SID, get GID */
101 extern idmap_stat idmap_get_gidbysid(idmap_get_handle_t *, char *,
102 	idmap_rid_t, int, gid_t *, idmap_stat *);
103 
104 /* Given SID, get UID or GID */
105 extern idmap_stat idmap_get_pidbysid(idmap_get_handle_t *, char *,
106 	idmap_rid_t, int, uid_t *, int *, idmap_stat *);
107 
108 /* Given UID, get SID */
109 extern idmap_stat idmap_get_sidbyuid(idmap_get_handle_t *, uid_t, int,
110 	char **, idmap_rid_t *, idmap_stat *);
111 
112 /* Given GID, get SID */
113 extern idmap_stat idmap_get_sidbygid(idmap_get_handle_t *, gid_t, int,
114 	char **, idmap_rid_t *, idmap_stat *);
115 
116 /* Process the batched requests */
117 extern idmap_stat idmap_get_mappings(idmap_get_handle_t *);
118 
119 /* Destroy the handle */
120 extern void idmap_get_destroy(idmap_get_handle_t *);
121 
122 
123 /*
124  * API to get Windows name by UID/GID and vice-versa
125  */
126 /* Given UID, get Windows name */
127 extern idmap_stat idmap_getwinnamebyuid(uid_t, char **, char **);
128 
129 /* Given GID, get Windows name */
130 extern idmap_stat idmap_getwinnamebygid(gid_t, char **, char **);
131 
132 /* Given Windows name, get UID */
133 extern idmap_stat idmap_getuidbywinname(const char *, const char *, uid_t *);
134 
135 /* Given Windows name, get GID */
136 extern idmap_stat idmap_getgidbywinname(const char *, const char *, gid_t *);
137 
138 
139 #ifdef __cplusplus
140 }
141 #endif
142 
143 #endif /* _IDMAP_H */
144