xref: /titanic_41/usr/src/lib/libidmap/common/idmap.h (revision 2a8d6eba033e4713ab12b61178f0513f1f075482)
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 2009 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 
34 #include <stdlib.h>
35 #include <ctype.h>
36 #include <sys/param.h>
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include <sys/idmap.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /* Status */
46 typedef int32_t	idmap_stat;
47 
48 typedef uint32_t	idmap_rid_t;
49 
50 /* Opaque client handle */
51 typedef struct idmap_handle idmap_handle_t;
52 
53 /* Opaque "get-mapping" handle */
54 typedef struct idmap_get_handle idmap_get_handle_t;
55 
56 /* Logger prototype which is based on syslog */
57 typedef void (*idmap_logger)(int, const char *, ...);
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  * Supported flag values for mapping requests.
77  * These flag values are applicable to the batch API and the
78  * Windows Name API below.
79  */
80 /* Use the libidmap cache */
81 #define	IDMAP_REQ_FLG_USE_CACHE	0x00000010
82 
83 /*
84  * API to batch SID to UID/GID mapping requests
85  */
86 /* Create handle */
87 extern idmap_stat idmap_get_create(idmap_handle_t *, idmap_get_handle_t **);
88 
89 /* Given SID, get UID */
90 extern idmap_stat idmap_get_uidbysid(idmap_get_handle_t *, char *,
91 	idmap_rid_t, int, uid_t *, idmap_stat *);
92 
93 /* Given SID, get GID */
94 extern idmap_stat idmap_get_gidbysid(idmap_get_handle_t *, char *,
95 	idmap_rid_t, int, gid_t *, idmap_stat *);
96 
97 /* Given SID, get UID or GID */
98 extern idmap_stat idmap_get_pidbysid(idmap_get_handle_t *, char *,
99 	idmap_rid_t, int, uid_t *, int *, idmap_stat *);
100 
101 /* Given UID, get SID */
102 extern idmap_stat idmap_get_sidbyuid(idmap_get_handle_t *, uid_t, int,
103 	char **, idmap_rid_t *, idmap_stat *);
104 
105 /* Given GID, get SID */
106 extern idmap_stat idmap_get_sidbygid(idmap_get_handle_t *, gid_t, int,
107 	char **, idmap_rid_t *, idmap_stat *);
108 
109 /* Process the batched requests */
110 extern idmap_stat idmap_get_mappings(idmap_get_handle_t *);
111 
112 /* Destroy the handle */
113 extern void idmap_get_destroy(idmap_get_handle_t *);
114 
115 
116 /*
117  * API to get Windows name by UID/GID and vice-versa
118  */
119 /* Given UID, get Windows name */
120 extern idmap_stat idmap_getwinnamebyuid(uid_t, int, char **, char **);
121 
122 /* Given GID, get Windows name */
123 extern idmap_stat idmap_getwinnamebygid(gid_t, int, char **, char **);
124 
125 /* Given Windows name, get UID */
126 extern idmap_stat idmap_getuidbywinname(const char *, const char *,
127 	int, uid_t *);
128 
129 /* Given Windows name, get GID */
130 extern idmap_stat idmap_getgidbywinname(const char *, const char *,
131 	int, gid_t *);
132 
133 
134 /* Logger */
135 extern void idmap_set_logger(idmap_logger funct);
136 
137 #ifdef __cplusplus
138 }
139 #endif
140 
141 #endif /* _IDMAP_H */
142