xref: /titanic_41/usr/src/uts/common/sys/kidmap.h (revision 672986541be54a7a471bb088e60780c37e371d7e)
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 2007 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
37 
38 #include <sys/idmap.h>
39 #include <sys/door.h>
40 
41 #ifdef	__cplusplus
42 extern "C" {
43 #endif
44 
45 /* Opaque get handle */
46 typedef struct idmap_get_handle idmap_get_handle_t;
47 
48 /* Return status */
49 typedef	int32_t idmap_stat;
50 
51 /*
52  * In all the routines a Windows SID is handled as a
53  * string SID prefix plus a RID. For example
54  *
55  * S-1-5-5-12-34-568 will be passed as SID prefix
56  * S-1-5-5-12-34 and RID 568
57  *
58  * Certain routines returns pointers to a SID prefix string.
59  * These strings are stored internally and should not be modified
60  * or freed.
61  */
62 
63 
64 /*
65  * The following routines are simple get ID mapping routines.
66  */
67 
68 
69 idmap_stat
70 kidmap_getuidbysid(const char *sid_prefix, uint32_t rid, uid_t *uid);
71 
72 idmap_stat
73 kidmap_getgidbysid(const char *sid_prefix, uint32_t rid, gid_t *gid);
74 
75 idmap_stat
76 kidmap_getpidbysid(const char *sid_prefix, uint32_t rid, uid_t *pid,
77 		int *is_user);
78 
79 idmap_stat
80 kidmap_getsidbyuid(uid_t uid, const char **sid_prefix, uint32_t *rid);
81 
82 idmap_stat
83 kidmap_getsidbygid(gid_t gid, const char **sid_prefix, uint32_t *rid);
84 
85 
86 
87 /*
88  * The following routines provide a batch interface for mapping IDs.
89  */
90 
91 /*
92  * Create a batch "get mapping" handle for batch mappings.
93  */
94 idmap_get_handle_t *
95 kidmap_get_create(void);
96 
97 /*
98  * These routines queue the request to the "get mapping" handle
99  */
100 
101 idmap_stat
102 kidmap_batch_getuidbysid(idmap_get_handle_t *get_handle,
103 		const char *sid_prefix, uint32_t rid,
104 		uid_t *uid, idmap_stat *stat);
105 
106 idmap_stat
107 kidmap_batch_getgidbysid(idmap_get_handle_t *get_handle,
108 		const char *sid_prefix, uint32_t rid,
109 		gid_t *gid, idmap_stat *stat);
110 
111 idmap_stat
112 kidmap_batch_getpidbysid(idmap_get_handle_t *get_handle,
113 		const char *sid_prefix, uint32_t rid,
114 		uid_t *pid, int *is_user, idmap_stat *stat);
115 
116 idmap_stat
117 kidmap_batch_getsidbyuid(idmap_get_handle_t *get_handle, uid_t uid,
118 		const char **sid_prefix, uint32_t *rid, idmap_stat *stat);
119 
120 idmap_stat
121 kidmap_batch_getsidbygid(idmap_get_handle_t *get_handle, gid_t gid,
122 		const char **sid_prefix, uint32_t *rid, idmap_stat *stat);
123 
124 /*
125  * Process the queued "get mapping" requests. The results (i.e.
126  * status and identity) will be available in the data areas
127  * provided by individual requests.
128  */
129 idmap_stat
130 kidmap_get_mappings(idmap_get_handle_t *get_handle);
131 
132 /*
133  * Destroy the "get mapping" handle
134  */
135 void
136 kidmap_get_destroy(idmap_get_handle_t *get_handle);
137 
138 /*
139  * Functions that do the hard part of door registration/unregistration
140  * for the idmap_reg()/idmap_unreg() syscalls
141  */
142 int idmap_reg_dh(door_handle_t dh);
143 int idmap_unreg_dh(door_handle_t dh);
144 
145 /*
146  * Functions needed by allocids() to ensure only the daemon that owns
147  * the door gets ephemeral IDS
148  */
149 typedef struct idmap_reg idmap_reg_t;
150 
151 void idmap_get_door(idmap_reg_t **state, door_handle_t *dh);
152 void idmap_release_door(idmap_reg_t *idmp);
153 
154 #ifdef	__cplusplus
155 }
156 #endif
157 
158 #endif	/* _SYS_KIDMAP_H */
159