16432Sas200622 /* 26432Sas200622 * CDDL HEADER START 36432Sas200622 * 46432Sas200622 * The contents of this file are subject to the terms of the 56432Sas200622 * Common Development and Distribution License (the "License"). 66432Sas200622 * You may not use this file except in compliance with the License. 76432Sas200622 * 86432Sas200622 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 96432Sas200622 * or http://www.opensolaris.org/os/licensing. 106432Sas200622 * See the License for the specific language governing permissions 116432Sas200622 * and limitations under the License. 126432Sas200622 * 136432Sas200622 * When distributing Covered Code, include this CDDL HEADER in each 146432Sas200622 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 156432Sas200622 * If applicable, add the following below this CDDL HEADER, with the 166432Sas200622 * fields enclosed by brackets "[]" replaced with your own identifying 176432Sas200622 * information: Portions Copyright [yyyy] [name of copyright owner] 186432Sas200622 * 196432Sas200622 * CDDL HEADER END 206432Sas200622 */ 216432Sas200622 /* 22*12508Samw@Sun.COM * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 236432Sas200622 */ 246432Sas200622 256432Sas200622 #ifndef _SMB_SID_H 266432Sas200622 #define _SMB_SID_H 276432Sas200622 286432Sas200622 /* 298474SJose.Borrego@Sun.COM * Security Identifier (SID) interface definition. 306432Sas200622 */ 316432Sas200622 #include <smbsrv/wintypes.h> 326432Sas200622 336432Sas200622 #ifdef __cplusplus 346432Sas200622 extern "C" { 356432Sas200622 #endif 366432Sas200622 376432Sas200622 /* 386432Sas200622 * Predefined global user RIDs. 396432Sas200622 */ 406432Sas200622 #define DOMAIN_USER_RID_ADMIN (0x000001F4L) /* 500 */ 416432Sas200622 #define DOMAIN_USER_RID_GUEST (0x000001F5L) /* 501 */ 426432Sas200622 #define DOMAIN_USER_RID_KRBTGT (0x000001F6L) /* 502 */ 436432Sas200622 446432Sas200622 /* 456432Sas200622 * Predefined global group RIDs. 466432Sas200622 */ 476432Sas200622 #define DOMAIN_GROUP_RID_ADMINS (0x00000200L) /* 512 */ 4811447Samw@Sun.COM #define DOMAIN_GROUP_RID_USERS (0x00000201L) /* 513 */ 4911447Samw@Sun.COM #define DOMAIN_GROUP_RID_GUESTS (0x00000202L) /* 514 */ 5011447Samw@Sun.COM #define DOMAIN_GROUP_RID_COMPUTERS (0x00000203L) /* 515 */ 5111447Samw@Sun.COM #define DOMAIN_GROUP_RID_CONTROLLERS (0x00000204L) /* 516 */ 5211447Samw@Sun.COM #define DOMAIN_GROUP_RID_CERT_ADMINS (0x00000205L) /* 517 */ 5311447Samw@Sun.COM #define DOMAIN_GROUP_RID_SCHEMA_ADMINS (0x00000206L) /* 518 */ 5411447Samw@Sun.COM #define DOMAIN_GROUP_RID_EP_ADMINS (0x00000207L) /* 519 */ 5511447Samw@Sun.COM #define DOMAIN_GROUP_RID_GP_CREATOR (0x00000208L) /* 520 */ 566432Sas200622 576432Sas200622 586432Sas200622 /* 596432Sas200622 * Predefined local alias RIDs. 606432Sas200622 */ 616432Sas200622 #define DOMAIN_ALIAS_RID_ADMINS (0x00000220L) /* 544 */ 626432Sas200622 #define DOMAIN_ALIAS_RID_USERS (0x00000221L) 636432Sas200622 #define DOMAIN_ALIAS_RID_GUESTS (0x00000222L) 646432Sas200622 #define DOMAIN_ALIAS_RID_POWER_USERS (0x00000223L) 656432Sas200622 #define DOMAIN_ALIAS_RID_ACCOUNT_OPS (0x00000224L) 666432Sas200622 #define DOMAIN_ALIAS_RID_SYSTEM_OPS (0x00000225L) 676432Sas200622 #define DOMAIN_ALIAS_RID_PRINT_OPS (0x00000226L) 686432Sas200622 #define DOMAIN_ALIAS_RID_BACKUP_OPS (0x00000227L) 696432Sas200622 #define DOMAIN_ALIAS_RID_REPLICATOR (0x00000228L) 706432Sas200622 716432Sas200622 726432Sas200622 /* 736432Sas200622 * Universal and NT well-known SIDs 746432Sas200622 */ 7511447Samw@Sun.COM #define NT_NULL_AUTH_SIDSTR "S-1-0" 766432Sas200622 #define NT_NULL_SIDSTR "S-1-0-0" 7711447Samw@Sun.COM #define NT_WORLD_AUTH_SIDSTR "S-1-1" 786432Sas200622 #define NT_WORLD_SIDSTR "S-1-1-0" 7911447Samw@Sun.COM #define NT_LOCAL_AUTH_SIDSTR "S-1-2" 806432Sas200622 #define NT_LOCAL_SIDSTR "S-1-2-0" 8111447Samw@Sun.COM #define NT_CREATOR_AUTH_SIDSTR "S-1-3" 826432Sas200622 #define NT_CREATOR_OWNER_ID_SIDSTR "S-1-3-0" 836432Sas200622 #define NT_CREATOR_GROUP_ID_SIDSTR "S-1-3-1" 846432Sas200622 #define NT_CREATOR_OWNER_SERVER_ID_SIDSTR "S-1-3-2" 856432Sas200622 #define NT_CREATOR_GROUP_SERVER_ID_SIDSTR "S-1-3-3" 8611447Samw@Sun.COM #define NT_OWNER_RIGHTS_SIDSTR "S-1-3-4" 8711447Samw@Sun.COM #define NT_GROUP_RIGHTS_SIDSTR "S-1-3-5" 886432Sas200622 #define NT_NON_UNIQUE_IDS_SIDSTR "S-1-4" 896432Sas200622 #define NT_AUTHORITY_SIDSTR "S-1-5" 906432Sas200622 #define NT_DIALUP_SIDSTR "S-1-5-1" 916432Sas200622 #define NT_NETWORK_SIDSTR "S-1-5-2" 926432Sas200622 #define NT_BATCH_SIDSTR "S-1-5-3" 936432Sas200622 #define NT_INTERACTIVE_SIDSTR "S-1-5-4" 9411447Samw@Sun.COM #define NT_LOGON_SESSION_SIDSTR "S-1-5-5" 956432Sas200622 #define NT_SERVICE_SIDSTR "S-1-5-6" 966432Sas200622 #define NT_ANONYMOUS_LOGON_SIDSTR "S-1-5-7" 976432Sas200622 #define NT_PROXY_SIDSTR "S-1-5-8" 986432Sas200622 #define NT_SERVER_LOGON_SIDSTR "S-1-5-9" 996432Sas200622 #define NT_SELF_SIDSTR "S-1-5-10" 1006432Sas200622 #define NT_AUTHENTICATED_USER_SIDSTR "S-1-5-11" 1016432Sas200622 #define NT_RESTRICTED_CODE_SIDSTR "S-1-5-12" 10211447Samw@Sun.COM #define NT_TERMINAL_SERVER_SIDSTR "S-1-5-13" 1036432Sas200622 #define NT_LOCAL_SYSTEM_SIDSTR "S-1-5-18" 1046432Sas200622 #define NT_NON_UNIQUE_SIDSTR "S-1-5-21" 1056432Sas200622 #define NT_BUILTIN_DOMAIN_SIDSTR "S-1-5-32" 10611447Samw@Sun.COM #define NT_BUILTIN_CURRENT_OWNER_SIDSTR "S-1-5-32-766" 10711447Samw@Sun.COM #define NT_BUILTIN_CURRENT_GROUP_SIDSTR "S-1-5-32-767" 1086432Sas200622 1096432Sas200622 1106432Sas200622 /* 1116432Sas200622 * SID type indicators (SID_NAME_USE). 1126432Sas200622 */ 1136432Sas200622 #define SidTypeNull 0 1146432Sas200622 #define SidTypeUser 1 1156432Sas200622 #define SidTypeGroup 2 1166432Sas200622 #define SidTypeDomain 3 1176432Sas200622 #define SidTypeAlias 4 1186432Sas200622 #define SidTypeWellKnownGroup 5 1196432Sas200622 #define SidTypeDeletedAccount 6 1206432Sas200622 #define SidTypeInvalid 7 1216432Sas200622 #define SidTypeUnknown 8 1226432Sas200622 #define SidTypeComputer 9 12311337SWilliam.Krier@Sun.COM #define SidTypeLabel 10 1246432Sas200622 1256432Sas200622 1266432Sas200622 /* 1276432Sas200622 * Identifier authorities for various domains. 1286432Sas200622 */ 1296432Sas200622 #define NT_SID_NULL_AUTH 0 1306432Sas200622 #define NT_SID_WORLD_AUTH 1 1316432Sas200622 #define NT_SID_LOCAL_AUTH 2 1326432Sas200622 #define NT_SID_CREATOR_AUTH 3 1336432Sas200622 #define NT_SID_NON_UNIQUE_AUTH 4 1346432Sas200622 #define NT_SID_NT_AUTH 5 1356432Sas200622 1366432Sas200622 1376432Sas200622 #define NT_SECURITY_NULL_AUTH {0, 0, 0, 0, 0, 0} 1386432Sas200622 #define NT_SECURITY_WORLD_AUTH {0, 0, 0, 0, 0, 1} 1396432Sas200622 #define NT_SECURITY_LOCAL_AUTH {0, 0, 0, 0, 0, 2} 1406432Sas200622 #define NT_SECURITY_CREATOR_AUTH {0, 0, 0, 0, 0, 3} 1416432Sas200622 #define NT_SECURITY_NON_UNIQUE_AUTH {0, 0, 0, 0, 0, 4} 1426432Sas200622 #define NT_SECURITY_NT_AUTH {0, 0, 0, 0, 0, 5} 1436432Sas200622 #define NT_SECURITY_UNIX_AUTH {0, 0, 0, 0, 0, 99} 1446432Sas200622 1456432Sas200622 1466432Sas200622 #define SECURITY_NULL_RID (0x00000000L) 1476432Sas200622 #define SECURITY_WORLD_RID (0x00000000L) 1486432Sas200622 #define SECURITY_LOCAL_RID (0X00000000L) 1496432Sas200622 1506432Sas200622 #define SECURITY_CREATOR_OWNER_RID (0x00000000L) 1516432Sas200622 #define SECURITY_CREATOR_GROUP_RID (0x00000001L) 1526432Sas200622 #define SECURITY_CREATOR_OWNER_SERVER_RID (0x00000002L) 1536432Sas200622 #define SECURITY_CREATOR_GROUP_SERVER_RID (0x00000003L) 15411447Samw@Sun.COM #define SECURITY_OWNER_RIGHTS_RID (0x00000004L) 15511447Samw@Sun.COM #define SECURITY_GROUP_RIGHTS_RID (0x00000005L) 15611447Samw@Sun.COM #define SECURITY_CURRENT_OWNER_RID (0x000002FEL) 15711447Samw@Sun.COM #define SECURITY_CURRENT_GROUP_RID (0x000002FFL) 1586432Sas200622 1596432Sas200622 #define SECURITY_DIALUP_RID (0x00000001L) 1606432Sas200622 #define SECURITY_NETWORK_RID (0x00000002L) 1616432Sas200622 #define SECURITY_BATCH_RID (0x00000003L) 1626432Sas200622 #define SECURITY_INTERACTIVE_RID (0x00000004L) 1636432Sas200622 #define SECURITY_LOGON_IDS_RID (0x00000005L) 1646432Sas200622 #define SECURITY_LOGON_IDS_RID_COUNT (3L) 1656432Sas200622 #define SECURITY_SERVICE_RID (0x00000006L) 1666432Sas200622 #define SECURITY_ANONYMOUS_LOGON_RID (0x00000007L) 1676432Sas200622 #define SECURITY_PROXY_RID (0x00000008L) 1686432Sas200622 #define SECURITY_ENTERPRISE_CONTROLLERS_RID (0x00000009L) 1696432Sas200622 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID 1706432Sas200622 #define SECURITY_PRINCIPAL_SELF_RID (0x0000000AL) 1716432Sas200622 #define SECURITY_AUTHENTICATED_USER_RID (0x0000000BL) 1726432Sas200622 #define SECURITY_RESTRICTED_CODE_RID (0x0000000CL) 1736432Sas200622 1746432Sas200622 #define SECURITY_LOCAL_SYSTEM_RID (0x00000012L) 1756432Sas200622 #define SECURITY_NT_NON_UNIQUE (0x00000015L) 1766432Sas200622 #define SECURITY_BUILTIN_DOMAIN_RID (0x00000020L) 1776432Sas200622 1786432Sas200622 1796432Sas200622 #define NT_SID_NON_UNIQUE_SUBAUTH 21 1806432Sas200622 1816432Sas200622 1826432Sas200622 /* 1836432Sas200622 * Common definition for a SID. 1846432Sas200622 */ 1856432Sas200622 #define NT_SID_REVISION 1 1866432Sas200622 #define NT_SID_AUTH_MAX 6 1876432Sas200622 #define NT_SID_SUBAUTH_MAX 15 1886432Sas200622 1896432Sas200622 1906432Sas200622 /* 1916432Sas200622 * Security Identifier (SID) 1926432Sas200622 * 1936432Sas200622 * The security identifier (SID) uniquely identifies a user, group or 1946432Sas200622 * a domain. It consists of a revision number, the identifier authority, 1956432Sas200622 * and a list of sub-authorities. The revision number is currently 1. 1966432Sas200622 * The identifier authority identifies which system issued the SID. The 1976432Sas200622 * sub-authorities of a domain SID uniquely identify a domain. A user 1986432Sas200622 * or group SID consists of a domain SID with the user or group id 1996432Sas200622 * appended. The user or group id (also known as a relative id (RID) 2006432Sas200622 * uniquely identifies a user within a domain. A user or group SID 2016432Sas200622 * uniquely identifies a user or group across all domains. The SidType 2026432Sas200622 * values identify the various types of SID. 2036432Sas200622 * 2046432Sas200622 * 1 1 1 1 1 1 2056432Sas200622 * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 2066432Sas200622 * +---------------------------------------------------------------+ 2076432Sas200622 * | SubAuthorityCount |Reserved1 (SBZ)| Revision | 2086432Sas200622 * +---------------------------------------------------------------+ 2096432Sas200622 * | IdentifierAuthority[0] | 2106432Sas200622 * +---------------------------------------------------------------+ 2116432Sas200622 * | IdentifierAuthority[1] | 2126432Sas200622 * +---------------------------------------------------------------+ 2136432Sas200622 * | IdentifierAuthority[2] | 2146432Sas200622 * +---------------------------------------------------------------+ 2156432Sas200622 * | | 2166432Sas200622 * +- - - - - - - - SubAuthority[] - - - - - - - - -+ 2176432Sas200622 * | | 2186432Sas200622 * +---------------------------------------------------------------+ 2196432Sas200622 * 2206432Sas200622 */ 2216432Sas200622 /* 2226432Sas200622 * Note: NT defines the Identifier Authority as a separate 2236432Sas200622 * structure (SID_IDENTIFIER_AUTHORITY) containing a literal 2246432Sas200622 * definition of a 6 byte vector but the effect is the same 2256432Sas200622 * as defining it as a member value. 2266432Sas200622 */ 2276432Sas200622 typedef struct smb_sid { 2286432Sas200622 uint8_t sid_revision; 2296432Sas200622 uint8_t sid_subauthcnt; 2306432Sas200622 uint8_t sid_authority[NT_SID_AUTH_MAX]; 2316432Sas200622 uint32_t sid_subauth[ANY_SIZE_ARRAY]; 2326432Sas200622 } smb_sid_t; 2336432Sas200622 23411963SAfshin.Ardakani@Sun.COM #define SMB_MAX_SID_SIZE ((2 * sizeof (uint8_t)) + \ 23511963SAfshin.Ardakani@Sun.COM (NT_SID_AUTH_MAX * sizeof (uint8_t)) + \ 23611963SAfshin.Ardakani@Sun.COM (NT_SID_SUBAUTH_MAX * sizeof (uint32_t))) 23711963SAfshin.Ardakani@Sun.COM 23811963SAfshin.Ardakani@Sun.COM /* 23911963SAfshin.Ardakani@Sun.COM * Estimated number of sid_subauth is SECURITY_LOGON_IDS_RID_COUNT 24011963SAfshin.Ardakani@Sun.COM * plus the DOMAIN_RID and the RID. 24111963SAfshin.Ardakani@Sun.COM */ 24211963SAfshin.Ardakani@Sun.COM #define SMB_EST_SID_SIZE ((2 * sizeof (uint8_t)) + \ 24311963SAfshin.Ardakani@Sun.COM (NT_SID_AUTH_MAX * sizeof (uint8_t)) + \ 24411963SAfshin.Ardakani@Sun.COM ((2 + SECURITY_LOGON_IDS_RID_COUNT) * sizeof (uint32_t))) 24511963SAfshin.Ardakani@Sun.COM 2466432Sas200622 /* 2478670SJose.Borrego@Sun.COM * Only group attributes are defined. No user attributes defined. 2488670SJose.Borrego@Sun.COM */ 2498670SJose.Borrego@Sun.COM #define SE_GROUP_MANDATORY 0x00000001 2508670SJose.Borrego@Sun.COM #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002 2518670SJose.Borrego@Sun.COM #define SE_GROUP_ENABLED 0x00000004 2528670SJose.Borrego@Sun.COM #define SE_GROUP_OWNER 0x00000008 2538670SJose.Borrego@Sun.COM #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010 2548670SJose.Borrego@Sun.COM #define SE_GROUP_LOGON_ID 0xC0000000 2558670SJose.Borrego@Sun.COM 2568670SJose.Borrego@Sun.COM /* 2578670SJose.Borrego@Sun.COM * smb_id_t consists of both the Windows security identifier 2588670SJose.Borrego@Sun.COM * and its corresponding POSIX/ephemeral ID. 2598670SJose.Borrego@Sun.COM */ 2608670SJose.Borrego@Sun.COM typedef struct smb_id { 2618670SJose.Borrego@Sun.COM uint32_t i_attrs; 2628670SJose.Borrego@Sun.COM smb_sid_t *i_sid; 2638670SJose.Borrego@Sun.COM uid_t i_id; 2648670SJose.Borrego@Sun.COM } smb_id_t; 2658670SJose.Borrego@Sun.COM 2668670SJose.Borrego@Sun.COM typedef struct smb_ids { 2678670SJose.Borrego@Sun.COM uint32_t i_cnt; 2688670SJose.Borrego@Sun.COM smb_id_t *i_ids; 2698670SJose.Borrego@Sun.COM } smb_ids_t; 2708670SJose.Borrego@Sun.COM 2718670SJose.Borrego@Sun.COM /* 2726432Sas200622 * The maximum size of a SID in string format 2736432Sas200622 */ 2746432Sas200622 #define SMB_SID_STRSZ 256 2756432Sas200622 2766432Sas200622 boolean_t smb_sid_isvalid(smb_sid_t *); 2776432Sas200622 int smb_sid_len(smb_sid_t *); 2786432Sas200622 smb_sid_t *smb_sid_dup(smb_sid_t *); 2796432Sas200622 smb_sid_t *smb_sid_splice(smb_sid_t *, uint32_t); 2806432Sas200622 int smb_sid_getrid(smb_sid_t *, uint32_t *); 2818670SJose.Borrego@Sun.COM smb_sid_t *smb_sid_split(smb_sid_t *, uint32_t *); 2826432Sas200622 boolean_t smb_sid_cmp(smb_sid_t *, smb_sid_t *); 2836432Sas200622 boolean_t smb_sid_islocal(smb_sid_t *); 2846432Sas200622 boolean_t smb_sid_indomain(smb_sid_t *, smb_sid_t *); 2856432Sas200622 void smb_sid_free(smb_sid_t *); 2866432Sas200622 int smb_sid_splitstr(char *, uint32_t *); 287*12508Samw@Sun.COM void smb_sid_tostr(const smb_sid_t *, char *); 288*12508Samw@Sun.COM smb_sid_t *smb_sid_fromstr(const char *); 2896432Sas200622 char *smb_sid_type2str(uint16_t); 2906432Sas200622 2918670SJose.Borrego@Sun.COM void smb_ids_free(smb_ids_t *); 2928670SJose.Borrego@Sun.COM 2936432Sas200622 #ifdef __cplusplus 2946432Sas200622 } 2956432Sas200622 #endif 2966432Sas200622 2976432Sas200622 2986432Sas200622 #endif /* _SMB_SID_H */ 299