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