xref: /titanic_50/usr/src/uts/common/idmap/kidmap_priv.h (revision 6343349bf9d42501532d1ee2e75718d86ee366fe)
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 file contains private definitions.
30  */
31 
32 #ifndef _KIDMAP_PRIV_H
33 #define	_KIDMAP_PRIV_H
34 
35 #pragma ident	"%Z%%M%	%I%	%E% SMI"
36 
37 #include <sys/avl.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 
44 typedef struct idmap_avl_cache {
45 	avl_tree_t		tree;
46 	kmutex_t		mutex;
47 	time_t			purge_time;
48 } idmap_avl_cache_t;
49 
50 
51 /*
52  * There is a cache for every mapping request because a group SID
53  * on Windows can be set in a file owner field and versa-visa.
54  * To stop this causing problems on Solaris a SID can map to
55  * both a UID and a GID.
56  */
57 typedef struct idmap_cache {
58 	idmap_avl_cache_t	uidbysid;
59 	idmap_avl_cache_t	gidbysid;
60 	idmap_avl_cache_t	pidbysid;
61 	idmap_avl_cache_t	sidbyuid;
62 	idmap_avl_cache_t	sidbygid;
63 } idmap_cache_t;
64 
65 
66 void
67 kidmap_cache_create(idmap_cache_t *cache);
68 
69 void
70 kidmap_cache_delete(idmap_cache_t *cache);
71 
72 void
73 kidmap_cache_purge(idmap_cache_t *cache);
74 
75 int
76 kidmap_cache_lookup_uidbysid(idmap_cache_t *cache, const char *sid_prefix,
77 			uint32_t rid, uid_t *uid);
78 
79 int
80 kidmap_cache_lookup_gidbysid(idmap_cache_t *cache, const char *sid_prefix,
81 			uint32_t rid, gid_t *gid);
82 
83 int
84 kidmap_cache_lookup_pidbysid(idmap_cache_t *cache, const char *sid_prefix,
85 			uint32_t rid, uid_t *pid, int *is_user);
86 
87 int
88 kidmap_cache_lookup_sidbyuid(idmap_cache_t *cache, const char **sid_prefix,
89 			uint32_t *rid, uid_t uid);
90 
91 int
92 kidmap_cache_lookup_sidbygid(idmap_cache_t *cache, const char **sid_prefix,
93 			uint32_t *rid, gid_t gid);
94 
95 
96 void
97 kidmap_cache_add_uidbysid(idmap_cache_t *cache, const char *sid_prefix,
98 			uint32_t rid, uid_t uid);
99 
100 void
101 kidmap_cache_add_gidbysid(idmap_cache_t *cache, const char *sid_prefix,
102 			uint32_t rid, gid_t gid);
103 
104 void
105 kidmap_cache_add_pidbysid(idmap_cache_t *cache, const char *sid_prefix,
106 			uint32_t rid, uid_t pid, int is_user);
107 
108 void
109 kidmap_cache_add_sidbyuid(idmap_cache_t *cache, const char *sid_prefix,
110 			uint32_t rid, uid_t uid);
111 
112 void
113 kidmap_cache_add_sidbygid(idmap_cache_t *cache, const char *sid_prefix,
114 			uint32_t rid, gid_t gid);
115 
116 int
117 kidmap_start(void);
118 
119 int
120 kidmap_stop(void);
121 
122 void
123 kidmap_sid_prefix_store_init(void);
124 
125 const char *
126 kidmap_find_sid_prefix(const char *sid_prefix);
127 
128 #ifdef	__cplusplus
129 }
130 #endif
131 
132 #endif	/* _KIDMAP_PRIV_H */
133