xref: /illumos-gate/usr/src/lib/libidmap/common/idmap.h (revision 1007fd6fd24227460e77ce89f5ca85641a85a576)
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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 /*
26  * Header File for Clients of Native Identity Mapping Service
27  */
28 
29 #ifndef _IDMAP_H
30 #define	_IDMAP_H
31 
32 
33 #include <stdlib.h>
34 #include <ctype.h>
35 #include <sys/param.h>
36 #include <sys/types.h>
37 #include <sys/stat.h>
38 #include <sys/idmap.h>
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /* Status */
45 typedef int32_t	idmap_stat;
46 
47 typedef uint32_t	idmap_rid_t;
48 
49 /* Opaque "get-mapping" handle */
50 typedef struct idmap_get_handle idmap_get_handle_t;
51 
52 /* Logger prototype which is based on syslog */
53 typedef void (*idmap_logger_t)(int, const char *, ...);
54 
55 /*
56  * Setup API
57  */
58 
59 /* Status code to string */
60 extern const char *idmap_stat2string(idmap_stat);
61 
62 /* Free memory allocated by the API */
63 extern void idmap_free(void *);
64 
65 
66 /*
67  * Supported flag values for mapping requests.
68  * These flag values are applicable to the batch API and the
69  * Windows Name API below.
70  */
71 /* Use the libidmap cache */
72 #define	IDMAP_REQ_FLG_USE_CACHE	0x00000010
73 
74 /*
75  * API to batch SID to UID/GID mapping requests
76  */
77 /* Create handle */
78 extern idmap_stat idmap_get_create(idmap_get_handle_t **);
79 
80 /* Given SID, get UID */
81 extern idmap_stat idmap_get_uidbysid(idmap_get_handle_t *, char *,
82 	idmap_rid_t, int, uid_t *, idmap_stat *);
83 
84 /* Given SID, get GID */
85 extern idmap_stat idmap_get_gidbysid(idmap_get_handle_t *, char *,
86 	idmap_rid_t, int, gid_t *, idmap_stat *);
87 
88 /* Given SID, get UID or GID */
89 extern idmap_stat idmap_get_pidbysid(idmap_get_handle_t *, char *,
90 	idmap_rid_t, int, uid_t *, int *, idmap_stat *);
91 
92 /* Given UID, get SID */
93 extern idmap_stat idmap_get_sidbyuid(idmap_get_handle_t *, uid_t, int,
94 	char **, idmap_rid_t *, idmap_stat *);
95 
96 /* Given GID, get SID */
97 extern idmap_stat idmap_get_sidbygid(idmap_get_handle_t *, gid_t, int,
98 	char **, idmap_rid_t *, idmap_stat *);
99 
100 /* Process the batched requests */
101 extern idmap_stat idmap_get_mappings(idmap_get_handle_t *);
102 
103 /* Destroy the handle */
104 extern void idmap_get_destroy(idmap_get_handle_t *);
105 
106 
107 /*
108  * API to get Windows name by UID/GID and vice-versa
109  */
110 /* Given UID, get Windows name */
111 extern idmap_stat idmap_getwinnamebyuid(uid_t, int, char **, char **);
112 
113 /* Given GID, get Windows name */
114 extern idmap_stat idmap_getwinnamebygid(gid_t, int, char **, char **);
115 
116 /* Given Windows name, get UID */
117 extern idmap_stat idmap_getuidbywinname(const char *, const char *,
118 	int, uid_t *);
119 
120 /* Given Windows name, get GID */
121 extern idmap_stat idmap_getgidbywinname(const char *, const char *,
122 	int, gid_t *);
123 
124 
125 /* Logger */
126 extern void idmap_set_logger(idmap_logger_t funct);
127 
128 #ifdef __cplusplus
129 }
130 #endif
131 
132 #endif /* _IDMAP_H */
133