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.
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.
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]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SMBFS_NTACL_H
28 #define _SMBFS_NTACL_H
31 * Internal functions for dealing with
32 * NT Security data structures.
35 #include <netsmb/mchain.h>
38 * Internal form of an NT SID
39 * Same as on the wire, but possibly byte-swapped.
41 typedef struct i_ntsid
{
43 uint8_t sid_subauthcount
;
44 uint8_t sid_authority
[6];
45 uint32_t sid_subauthvec
[1]; /* actually len=subauthcount */
47 #define I_SID_SIZE(sacnt) (8 + 4 * (sacnt))
50 * Internal form of an NT ACE - first the header.
51 * See MS SDK: ACE_HEADER (For MS, it's the OtW form)
52 * Note: ace_size here is the in-memoy size, not OtW.
54 typedef struct i_ntace_hdr
{
61 * Simple ACE for types: ACCESS_ALLOWED through SYSTEM_ALARM
62 * See MS SDK: ACCESS_ALLOWED_ACE, ACCESS_DENIED_ACE,
63 * SYSTEM_AUDIT_ACE, SYSTEM_ALARM_ACE.
65 * The above are the only types that appear in a V2 ACL.
66 * Note that in the Windows SDK, the SID is stored as
67 * "flat" data after the ACE header. This implementation
68 * stores the SID as a pointer instead.
70 typedef struct i_ntace_v2
{
71 i_ntace_hdr_t ace_hdr
;
72 uint32_t ace_rights
; /* generic, standard, specific, etc */
77 * A union for convenience of the conversion code.
78 * There are lots more ACE types, ignored for now.
80 typedef union i_ntace_u
{
81 i_ntace_hdr_t ace_hdr
;
86 * Internal form of an NT ACL (see sacl/dacl below)
88 typedef struct i_ntacl
{
89 uint8_t acl_revision
; /* 0x02 observed with W2K */
90 uint16_t acl_acecount
;
91 i_ntace_t
*acl_acevec
[1]; /* actually, len=acecount */
95 * Internal form of an NT Security Descriptor (SD)
97 typedef struct i_ntsd
{
98 uint8_t sd_revision
; /* 0x01 observed between W2K */
99 uint8_t sd_rmctl
; /* resource mgr control (MBZ) */
108 * Import a raw SD (mb chain) into "internal" form.
109 * (like "absolute" form per. NT docs)
110 * Returns allocated data in sdp
112 int md_get_ntsd(mdchain_t
*mbp
, i_ntsd_t
**sdp
);
115 * Export an "internal" SD into an raw SD (mb chain).
116 * (a.k.a "self-relative" form per. NT docs)
117 * Returns allocated mbchain in mbp.
119 int mb_put_ntsd(mbchain_t
*mbp
, i_ntsd_t
*sd
);
122 * Convert an internal SD to a ZFS-style ACL.
123 * Get uid/gid too if pointers != NULL.
126 int smbfs_acl_sd2zfs(i_ntsd_t
*, vsecattr_t
*, uid_t
*, gid_t
*);
128 /* See also: lib/libsmbfs/netsmb/smbfs_acl.h */
129 int smbfs_acl_sd2zfs(struct i_ntsd
*, acl_t
*, uid_t
*, gid_t
*);
133 * Convert a ZFS-style ACL to an internal SD.
134 * Set owner/group too if selector indicates.
135 * Always need to pass uid+gid, either the new
136 * (when setting them) or existing, so that any
137 * owner@ or group@ ACEs can be translated.
140 int smbfs_acl_zfs2sd(vsecattr_t
*, uid_t
, gid_t
, uint32_t, i_ntsd_t
**);
142 /* See also: lib/libsmbfs/netsmb/smbfs_acl.h */
143 int smbfs_acl_zfs2sd(acl_t
*, uid_t
, gid_t
, uint32_t, struct i_ntsd
**);
147 * Free an i_ntsd_t from md_get_ntsd() or smbfs_acl_zfs2sd().
148 * See also: lib/libsmbfs/netsmb/smbfs_acl.h
150 void smbfs_acl_free_sd(struct i_ntsd
*);
153 * Convert an NT SID to string format.
155 int smbfs_sid2str(i_ntsid_t
*sid
,
156 char *obuf
, size_t olen
, uint32_t *ridp
);
158 #endif /* _SMBFS_NTACL_H */