xref: /titanic_44/usr/src/uts/common/idmap/kidmap_priv.h (revision 444ce08e035c2cafaa89f7236e38bbe82a287904)
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 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 
45 typedef struct idmap_sid2pid_cache {
46 	avl_tree_t		tree;
47 	kmutex_t		mutex;
48 	struct sid2pid		*prev;
49 	time_t			purge_time;
50 	int			uid_num;
51 	int			gid_num;
52 	int			pid_num;
53 } idmap_sid2pid_cache_t;
54 
55 
56 typedef struct idmap_pid2sid_cache {
57 	avl_tree_t		tree;
58 	kmutex_t		mutex;
59 	struct pid2sid		*prev;
60 	time_t			purge_time;
61 } idmap_pid2sid_cache_t;
62 
63 
64 /*
65  * There is a cache for every mapping request because a group SID
66  * on Windows can be set in a file owner field and versa-visa.
67  * To stop this causing problems on Solaris a SID can map to
68  * both a UID and a GID.
69  */
70 typedef struct idmap_cache {
71 	idmap_sid2pid_cache_t	sid2pid;
72 	idmap_pid2sid_cache_t	uid2sid;
73 	idmap_pid2sid_cache_t	gid2sid;
74 } idmap_cache_t;
75 
76 
77 void
78 kidmap_cache_create(idmap_cache_t *cache);
79 
80 void
81 kidmap_cache_delete(idmap_cache_t *cache);
82 
83 void
84 kidmap_cache_purge(idmap_cache_t *cache);
85 
86 
87 int
88 kidmap_cache_lookup_uidbysid(idmap_cache_t *cache, const char *sid_prefix,
89 			uint32_t rid, uid_t *uid);
90 
91 int
92 kidmap_cache_lookup_gidbysid(idmap_cache_t *cache, const char *sid_prefix,
93 			uint32_t rid, gid_t *gid);
94 
95 int
96 kidmap_cache_lookup_pidbysid(idmap_cache_t *cache, const char *sid_prefix,
97 			uint32_t rid, uid_t *pid, int *is_user);
98 
99 int
100 kidmap_cache_lookup_sidbyuid(idmap_cache_t *cache, const char **sid_prefix,
101 			uint32_t *rid, uid_t uid);
102 
103 int
104 kidmap_cache_lookup_sidbygid(idmap_cache_t *cache, const char **sid_prefix,
105 			uint32_t *rid, gid_t gid);
106 
107 
108 void
109 kidmap_cache_add_sid2uid(idmap_cache_t *cache, const char *sid_prefix,
110 			uint32_t rid, uid_t uid, int direction);
111 
112 void
113 kidmap_cache_add_sid2gid(idmap_cache_t *cache, const char *sid_prefix,
114 			uint32_t rid, gid_t gid, int direction);
115 
116 void
117 kidmap_cache_add_sid2pid(idmap_cache_t *cache, const char *sid_prefix,
118 			uint32_t rid, uid_t pid, int is_user, int direction);
119 void
120 kidmap_cache_get_data(idmap_cache_t *cache, size_t *uidbysid, size_t *gidbysid,
121 			size_t *pidbysid, size_t *sidbyuid, size_t *sidbygid);
122 int
123 kidmap_start(void);
124 
125 int
126 kidmap_stop(void);
127 
128 void
129 kidmap_sid_prefix_store_init(void);
130 
131 const char *
132 kidmap_find_sid_prefix(const char *sid_prefix);
133 
134 #ifdef	__cplusplus
135 }
136 #endif
137 
138 #endif	/* _KIDMAP_PRIV_H */
139