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