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