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