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 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 * 25 * Copyright 2018 Nexenta Systems, Inc. All rights reserved. 26 * Copyright 2023 RackTop Systems, Inc. 27 */ 28 29 #ifndef _SMB_IDMAP_H 30 #define _SMB_IDMAP_H 31 32 #if defined(_KERNEL) /* intentionally not || defined(_FAKE_KERNEL) */ 33 #include <sys/kidmap.h> 34 #else 35 #include <idmap.h> 36 #endif 37 38 #include <smbsrv/smb_sid.h> 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* 45 * SMB ID mapping 46 * 47 * Solaris ID mapping service (aka Winchester) works with domain SIDs 48 * and RIDs where domain SIDs are in string format. CIFS service works 49 * with binary SIDs understanable by CIFS clients. A layer of SMB ID 50 * mapping functions are implemeted to hide the SID conversion details 51 * and also hide the handling of array of batch mapping requests. 52 */ 53 54 #define SMB_IDMAP_UNKNOWN -1 55 #define SMB_IDMAP_GROUP 0 56 #define SMB_IDMAP_USER 1 57 #define SMB_IDMAP_OWNERAT 2 58 #define SMB_IDMAP_GROUPAT 3 59 #define SMB_IDMAP_EVERYONE 4 60 61 #define SMB_IDMAP_SID2ID 0x0001 62 #define SMB_IDMAP_ID2SID 0x0002 63 #define SMB_IDMAP_SKIP_ERRS 0x0004 64 65 /* 66 * smb_idmap_t 67 * 68 * sim_idtype: ID type (output in sid->uid mapping) 69 * sim_id: UID/GID (output in sid->uid mapping) 70 */ 71 typedef struct smb_idmap { 72 int sim_idtype; 73 uid_t *sim_id; 74 char *sim_domsid; 75 uint32_t sim_rid; 76 smb_sid_t *sim_sid; 77 idmap_stat sim_stat; 78 } smb_idmap_t; 79 80 typedef struct smb_idmap_batch { 81 uint16_t sib_nmap; 82 uint16_t sib_nerr; 83 uint32_t sib_flags; 84 uint32_t sib_size; 85 smb_idmap_t *sib_maps; 86 idmap_get_handle_t *sib_idmaph; 87 } smb_idmap_batch_t; 88 89 typedef void (*smb_idmap_batch_errcb_t)(smb_idmap_batch_t *, smb_idmap_t *); 90 91 idmap_stat smb_idmap_getsid(uid_t, int, smb_sid_t **); 92 idmap_stat smb_idmap_getid(smb_sid_t *, uid_t *, int *); 93 94 void smb_idmap_batch_destroy(smb_idmap_batch_t *); 95 idmap_stat smb_idmap_batch_create(smb_idmap_batch_t *, uint16_t, int); 96 idmap_stat smb_idmap_batch_getmappings(smb_idmap_batch_t *, 97 smb_idmap_batch_errcb_t); 98 idmap_stat smb_idmap_batch_getid(idmap_get_handle_t *, smb_idmap_t *, 99 smb_sid_t *, int); 100 idmap_stat smb_idmap_batch_getsid(idmap_get_handle_t *, smb_idmap_t *, 101 uid_t, int); 102 103 #ifdef __cplusplus 104 } 105 #endif 106 107 108 #endif /* _SMB_IDMAP_H */ 109