xref: /illumos-gate/usr/src/uts/common/sys/kidmap.h (revision 2d6eb4a5)
1c5c4113dSnw /*
2c5c4113dSnw  * CDDL HEADER START
3c5c4113dSnw  *
4c5c4113dSnw  * The contents of this file are subject to the terms of the
5c5c4113dSnw  * Common Development and Distribution License (the "License").
6c5c4113dSnw  * You may not use this file except in compliance with the License.
7c5c4113dSnw  *
8c5c4113dSnw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9c5c4113dSnw  * or http://www.opensolaris.org/os/licensing.
10c5c4113dSnw  * See the License for the specific language governing permissions
11c5c4113dSnw  * and limitations under the License.
12c5c4113dSnw  *
13c5c4113dSnw  * When distributing Covered Code, include this CDDL HEADER in each
14c5c4113dSnw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15c5c4113dSnw  * If applicable, add the following below this CDDL HEADER, with the
16c5c4113dSnw  * fields enclosed by brackets "[]" replaced with your own identifying
17c5c4113dSnw  * information: Portions Copyright [yyyy] [name of copyright owner]
18c5c4113dSnw  *
19c5c4113dSnw  * CDDL HEADER END
20c5c4113dSnw  */
21c5c4113dSnw 
22c5c4113dSnw /*
23*bda89588Sjp  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24c5c4113dSnw  * Use is subject to license terms.
25c5c4113dSnw  */
26c5c4113dSnw 
27c5c4113dSnw /*
28c5c4113dSnw  * Windows to Solaris Identity Mapping kernel API
29c5c4113dSnw  * This header defines an API to map Windows SIDs to
30c5c4113dSnw  * Solaris UID and GIDs and versa visa.
31c5c4113dSnw  */
32c5c4113dSnw 
33c5c4113dSnw #ifndef	_SYS_KIDMAP_H
34c5c4113dSnw #define	_SYS_KIDMAP_H
35c5c4113dSnw 
36c5c4113dSnw #include <sys/idmap.h>
37c5c4113dSnw #include <sys/door.h>
38*bda89588Sjp #include <sys/zone.h>
39c5c4113dSnw 
40c5c4113dSnw #ifdef	__cplusplus
41c5c4113dSnw extern "C" {
42c5c4113dSnw #endif
43c5c4113dSnw 
44c5c4113dSnw /* Opaque get handle */
45c5c4113dSnw typedef struct idmap_get_handle idmap_get_handle_t;
46c5c4113dSnw 
47c5c4113dSnw /* Return status */
48c5c4113dSnw typedef	int32_t idmap_stat;
49c5c4113dSnw 
50c5c4113dSnw /*
51c5c4113dSnw  * In all the routines a Windows SID is handled as a
52c5c4113dSnw  * string SID prefix plus a RID. For example
53c5c4113dSnw  *
54c5c4113dSnw  * S-1-5-5-12-34-568 will be passed as SID prefix
55c5c4113dSnw  * S-1-5-5-12-34 and RID 568
56c5c4113dSnw  *
57c5c4113dSnw  * Certain routines returns pointers to a SID prefix string.
58c5c4113dSnw  * These strings are stored internally and should not be modified
59c5c4113dSnw  * or freed.
60c5c4113dSnw  */
61c5c4113dSnw 
62c5c4113dSnw 
63c5c4113dSnw /*
64c5c4113dSnw  * The following routines are simple get ID mapping routines.
65c5c4113dSnw  */
66c5c4113dSnw 
67c5c4113dSnw 
68c5c4113dSnw idmap_stat
69*bda89588Sjp kidmap_getuidbysid(zone_t *zone, const char *sid_prefix, uint32_t rid,
70*bda89588Sjp 		uid_t *uid);
71c5c4113dSnw 
72c5c4113dSnw idmap_stat
73*bda89588Sjp kidmap_getgidbysid(zone_t *zone, const char *sid_prefix, uint32_t rid,
74*bda89588Sjp 		gid_t *gid);
75c5c4113dSnw 
76c5c4113dSnw idmap_stat
77*bda89588Sjp kidmap_getpidbysid(zone_t *zone, const char *sid_prefix, uint32_t rid,
78*bda89588Sjp 		uid_t *pid, int *is_user);
79c5c4113dSnw 
80c5c4113dSnw idmap_stat
81*bda89588Sjp kidmap_getsidbyuid(zone_t *zone, uid_t uid, const char **sid_prefix,
82*bda89588Sjp 		uint32_t *rid);
83c5c4113dSnw 
84c5c4113dSnw idmap_stat
85*bda89588Sjp kidmap_getsidbygid(zone_t *zone, gid_t gid, const char **sid_prefix,
86*bda89588Sjp 		uint32_t *rid);
87c5c4113dSnw 
88c5c4113dSnw 
89c5c4113dSnw 
90c5c4113dSnw /*
91c5c4113dSnw  * The following routines provide a batch interface for mapping IDs.
92c5c4113dSnw  */
93c5c4113dSnw 
94c5c4113dSnw /*
95c5c4113dSnw  * Create a batch "get mapping" handle for batch mappings.
96c5c4113dSnw  */
97c5c4113dSnw idmap_get_handle_t *
98*bda89588Sjp kidmap_get_create(zone_t *zone);
99c5c4113dSnw 
100c5c4113dSnw /*
101c5c4113dSnw  * These routines queue the request to the "get mapping" handle
102c5c4113dSnw  */
103c5c4113dSnw 
104c5c4113dSnw idmap_stat
105c5c4113dSnw kidmap_batch_getuidbysid(idmap_get_handle_t *get_handle,
106c5c4113dSnw 		const char *sid_prefix, uint32_t rid,
107c5c4113dSnw 		uid_t *uid, idmap_stat *stat);
108c5c4113dSnw 
109c5c4113dSnw idmap_stat
110c5c4113dSnw kidmap_batch_getgidbysid(idmap_get_handle_t *get_handle,
111c5c4113dSnw 		const char *sid_prefix, uint32_t rid,
112c5c4113dSnw 		gid_t *gid, idmap_stat *stat);
113c5c4113dSnw 
114c5c4113dSnw idmap_stat
115c5c4113dSnw kidmap_batch_getpidbysid(idmap_get_handle_t *get_handle,
116c5c4113dSnw 		const char *sid_prefix, uint32_t rid,
117c5c4113dSnw 		uid_t *pid, int *is_user, idmap_stat *stat);
118c5c4113dSnw 
119c5c4113dSnw idmap_stat
120c5c4113dSnw kidmap_batch_getsidbyuid(idmap_get_handle_t *get_handle, uid_t uid,
121c5c4113dSnw 		const char **sid_prefix, uint32_t *rid, idmap_stat *stat);
122c5c4113dSnw 
123c5c4113dSnw idmap_stat
124c5c4113dSnw kidmap_batch_getsidbygid(idmap_get_handle_t *get_handle, gid_t gid,
125c5c4113dSnw 		const char **sid_prefix, uint32_t *rid, idmap_stat *stat);
126c5c4113dSnw 
127c5c4113dSnw /*
128c5c4113dSnw  * Process the queued "get mapping" requests. The results (i.e.
129c5c4113dSnw  * status and identity) will be available in the data areas
130c5c4113dSnw  * provided by individual requests.
131c5c4113dSnw  */
132c5c4113dSnw idmap_stat
133c5c4113dSnw kidmap_get_mappings(idmap_get_handle_t *get_handle);
134c5c4113dSnw 
135c5c4113dSnw /*
136c5c4113dSnw  * Destroy the "get mapping" handle
137c5c4113dSnw  */
138c5c4113dSnw void
139c5c4113dSnw kidmap_get_destroy(idmap_get_handle_t *get_handle);
140c5c4113dSnw 
141c5c4113dSnw /*
142c5c4113dSnw  * Functions that do the hard part of door registration/unregistration
143c5c4113dSnw  * for the idmap_reg()/idmap_unreg() syscalls
144c5c4113dSnw  */
145*bda89588Sjp int idmap_reg_dh(zone_t *zone, door_handle_t dh);
146*bda89588Sjp int idmap_unreg_dh(zone_t *zone, door_handle_t dh);
147c5c4113dSnw 
148c5c4113dSnw /*
149*bda89588Sjp  * Function needed by allocids() to ensure only the daemon that owns
150c5c4113dSnw  * the door gets ephemeral IDS
151c5c4113dSnw  */
152*bda89588Sjp door_handle_t idmap_get_door(zone_t *zone);
153*bda89588Sjp 
154*bda89588Sjp /*
155*bda89588Sjp  * Function used by system call allocids() to purge the
156*bda89588Sjp  * ID mapping cache
157*bda89588Sjp  */
158*bda89588Sjp void idmap_purge_cache(zone_t *zone);
159c5c4113dSnw 
160c5c4113dSnw 
161c5c4113dSnw #ifdef	__cplusplus
162c5c4113dSnw }
163c5c4113dSnw #endif
164c5c4113dSnw 
165c5c4113dSnw #endif	/* _SYS_KIDMAP_H */
166