1c5c4113dSnw141292 /* 2c5c4113dSnw141292 * CDDL HEADER START 3c5c4113dSnw141292 * 4c5c4113dSnw141292 * The contents of this file are subject to the terms of the 5c5c4113dSnw141292 * Common Development and Distribution License (the "License"). 6c5c4113dSnw141292 * You may not use this file except in compliance with the License. 7c5c4113dSnw141292 * 8c5c4113dSnw141292 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9c5c4113dSnw141292 * or http://www.opensolaris.org/os/licensing. 10c5c4113dSnw141292 * See the License for the specific language governing permissions 11c5c4113dSnw141292 * and limitations under the License. 12c5c4113dSnw141292 * 13c5c4113dSnw141292 * When distributing Covered Code, include this CDDL HEADER in each 14c5c4113dSnw141292 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15c5c4113dSnw141292 * If applicable, add the following below this CDDL HEADER, with the 16c5c4113dSnw141292 * fields enclosed by brackets "[]" replaced with your own identifying 17c5c4113dSnw141292 * information: Portions Copyright [yyyy] [name of copyright owner] 18c5c4113dSnw141292 * 19c5c4113dSnw141292 * CDDL HEADER END 20c5c4113dSnw141292 */ 21c5c4113dSnw141292 22c5c4113dSnw141292 /* 23f7b4b2feSjp151216 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24c5c4113dSnw141292 * Use is subject to license terms. 25c5c4113dSnw141292 */ 26c5c4113dSnw141292 27c5c4113dSnw141292 /* 28c5c4113dSnw141292 * Windows to Solaris Identity Mapping kernel API 29c5c4113dSnw141292 * This header file contains private definitions. 30c5c4113dSnw141292 */ 31c5c4113dSnw141292 32c5c4113dSnw141292 #ifndef _KIDMAP_PRIV_H 33c5c4113dSnw141292 #define _KIDMAP_PRIV_H 34c5c4113dSnw141292 35c5c4113dSnw141292 #include <sys/avl.h> 36c5c4113dSnw141292 37c5c4113dSnw141292 #ifdef __cplusplus 38c5c4113dSnw141292 extern "C" { 39c5c4113dSnw141292 #endif 40c5c4113dSnw141292 41*32ff2b3cSJulian Pullen typedef struct sid2pid { 42*32ff2b3cSJulian Pullen avl_node_t avl_link; 43*32ff2b3cSJulian Pullen struct sid2pid *flink; 44*32ff2b3cSJulian Pullen struct sid2pid *blink; 45*32ff2b3cSJulian Pullen const char *sid_prefix; 46*32ff2b3cSJulian Pullen uint32_t rid; 47*32ff2b3cSJulian Pullen uid_t uid; 48*32ff2b3cSJulian Pullen time_t uid_ttl; 49*32ff2b3cSJulian Pullen gid_t gid; 50*32ff2b3cSJulian Pullen time_t gid_ttl; 51*32ff2b3cSJulian Pullen int is_user; 52*32ff2b3cSJulian Pullen } sid2pid_t; 53*32ff2b3cSJulian Pullen 54*32ff2b3cSJulian Pullen 55*32ff2b3cSJulian Pullen typedef struct pid2sid { 56*32ff2b3cSJulian Pullen avl_node_t avl_link; 57*32ff2b3cSJulian Pullen struct pid2sid *flink; 58*32ff2b3cSJulian Pullen struct pid2sid *blink; 59*32ff2b3cSJulian Pullen const char *sid_prefix; 60*32ff2b3cSJulian Pullen uint32_t rid; 61*32ff2b3cSJulian Pullen uid_t pid; 62*32ff2b3cSJulian Pullen time_t ttl; 63*32ff2b3cSJulian Pullen } pid2sid_t; 64*32ff2b3cSJulian Pullen 65c5c4113dSnw141292 66d15447b6Sjp151216 67d15447b6Sjp151216 typedef struct idmap_sid2pid_cache { 68c5c4113dSnw141292 avl_tree_t tree; 69c5c4113dSnw141292 kmutex_t mutex; 70*32ff2b3cSJulian Pullen struct sid2pid head; 71c5c4113dSnw141292 time_t purge_time; 72d15447b6Sjp151216 int uid_num; 73d15447b6Sjp151216 int gid_num; 74d15447b6Sjp151216 int pid_num; 75d15447b6Sjp151216 } idmap_sid2pid_cache_t; 76d15447b6Sjp151216 77d15447b6Sjp151216 78d15447b6Sjp151216 typedef struct idmap_pid2sid_cache { 79d15447b6Sjp151216 avl_tree_t tree; 80d15447b6Sjp151216 kmutex_t mutex; 81*32ff2b3cSJulian Pullen struct pid2sid head; 82d15447b6Sjp151216 time_t purge_time; 83d15447b6Sjp151216 } idmap_pid2sid_cache_t; 84c5c4113dSnw141292 850b10de9fSjp151216 860b10de9fSjp151216 /* 870b10de9fSjp151216 * There is a cache for every mapping request because a group SID 880b10de9fSjp151216 * on Windows can be set in a file owner field and versa-visa. 890b10de9fSjp151216 * To stop this causing problems on Solaris a SID can map to 900b10de9fSjp151216 * both a UID and a GID. 910b10de9fSjp151216 */ 92c5c4113dSnw141292 typedef struct idmap_cache { 93d15447b6Sjp151216 idmap_sid2pid_cache_t sid2pid; 94d15447b6Sjp151216 idmap_pid2sid_cache_t uid2sid; 95d15447b6Sjp151216 idmap_pid2sid_cache_t gid2sid; 96c5c4113dSnw141292 } idmap_cache_t; 97c5c4113dSnw141292 98c5c4113dSnw141292 99c5c4113dSnw141292 void 100c5c4113dSnw141292 kidmap_cache_create(idmap_cache_t *cache); 101c5c4113dSnw141292 102c5c4113dSnw141292 void 103c5c4113dSnw141292 kidmap_cache_delete(idmap_cache_t *cache); 104c5c4113dSnw141292 1050b10de9fSjp151216 void 1060b10de9fSjp151216 kidmap_cache_purge(idmap_cache_t *cache); 107c5c4113dSnw141292 108d15447b6Sjp151216 109c5c4113dSnw141292 int 1100b10de9fSjp151216 kidmap_cache_lookup_uidbysid(idmap_cache_t *cache, const char *sid_prefix, 1110b10de9fSjp151216 uint32_t rid, uid_t *uid); 1120b10de9fSjp151216 1130b10de9fSjp151216 int 1140b10de9fSjp151216 kidmap_cache_lookup_gidbysid(idmap_cache_t *cache, const char *sid_prefix, 1150b10de9fSjp151216 uint32_t rid, gid_t *gid); 1160b10de9fSjp151216 1170b10de9fSjp151216 int 1180b10de9fSjp151216 kidmap_cache_lookup_pidbysid(idmap_cache_t *cache, const char *sid_prefix, 119c5c4113dSnw141292 uint32_t rid, uid_t *pid, int *is_user); 120c5c4113dSnw141292 1210b10de9fSjp151216 int 1220b10de9fSjp151216 kidmap_cache_lookup_sidbyuid(idmap_cache_t *cache, const char **sid_prefix, 1230b10de9fSjp151216 uint32_t *rid, uid_t uid); 1240b10de9fSjp151216 1250b10de9fSjp151216 int 1260b10de9fSjp151216 kidmap_cache_lookup_sidbygid(idmap_cache_t *cache, const char **sid_prefix, 1270b10de9fSjp151216 uint32_t *rid, gid_t gid); 1280b10de9fSjp151216 129c5c4113dSnw141292 130c5c4113dSnw141292 void 131d15447b6Sjp151216 kidmap_cache_add_sid2uid(idmap_cache_t *cache, const char *sid_prefix, 132d15447b6Sjp151216 uint32_t rid, uid_t uid, int direction); 1330b10de9fSjp151216 1340b10de9fSjp151216 void 135d15447b6Sjp151216 kidmap_cache_add_sid2gid(idmap_cache_t *cache, const char *sid_prefix, 136d15447b6Sjp151216 uint32_t rid, gid_t gid, int direction); 1370b10de9fSjp151216 1380b10de9fSjp151216 void 139d15447b6Sjp151216 kidmap_cache_add_sid2pid(idmap_cache_t *cache, const char *sid_prefix, 140d15447b6Sjp151216 uint32_t rid, uid_t pid, int is_user, int direction); 141f7b4b2feSjp151216 void 142f7b4b2feSjp151216 kidmap_cache_get_data(idmap_cache_t *cache, size_t *uidbysid, size_t *gidbysid, 143f7b4b2feSjp151216 size_t *pidbysid, size_t *sidbyuid, size_t *sidbygid); 144c5c4113dSnw141292 int 145c5c4113dSnw141292 kidmap_start(void); 146c5c4113dSnw141292 147c5c4113dSnw141292 int 148c5c4113dSnw141292 kidmap_stop(void); 149c5c4113dSnw141292 150c5c4113dSnw141292 void 151c5c4113dSnw141292 kidmap_sid_prefix_store_init(void); 152c5c4113dSnw141292 153c5c4113dSnw141292 const char * 154c5c4113dSnw141292 kidmap_find_sid_prefix(const char *sid_prefix); 155c5c4113dSnw141292 156c5c4113dSnw141292 #ifdef __cplusplus 157c5c4113dSnw141292 } 158c5c4113dSnw141292 #endif 159c5c4113dSnw141292 160c5c4113dSnw141292 #endif /* _KIDMAP_PRIV_H */ 161