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