/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stddef.h>
#include <strings.h>
#include <assert.h>
#include <smbsrv/smb_idmap.h>
/*
* ACE groups within a DACL
*
* This is from lower to higher ACE order priority
*/
#define SMB_AG_START 0
#define SMB_AG_ALW_INHRT 0
{
int size;
return (NULL);
return (acl);
}
void
{
int i;
void *ace;
return;
}
/*
* smb_acl_len
*
* Returns the size of given ACL in bytes. Note that this
* is not an in-memory size, it's the ACL's size as it would
* appear on the wire
*/
{
}
/*ARGSUSED*/
{
return (B_FALSE);
/*
* we are rejecting ACLs with object-specific ACEs for now
*/
return (B_FALSE);
}
return (B_TRUE);
}
/*
* smb_acl_sort
*
* Sorts the given ACL in place if it needs to be sorted.
*
* The following is an excerpt from MSDN website.
*
* Order of ACEs in a DACL
*
* For Windows NT versions 4.0 and earlier, the preferred order of ACEs
* is simple: In a DACL, all access-denied ACEs should precede any
* access-allowed ACEs.
*
* For Windows 2000 or later, the proper order of ACEs is more complicated
* because of the introduction of object-specific ACEs and automatic
* inheritance.
*
* The following describes the preferred order:
*
* To ensure that noninherited ACEs have precedence over inherited ACEs,
* place all noninherited ACEs in a group before any inherited ACEs. This
* ordering ensures, for example, that a noninherited access-denied ACE
* is enforced regardless of any inherited ACE that allows access.
* Within the groups of noninherited ACEs and inherited ACEs, order ACEs
* according to ACE type, as the following shows:
* . Access-denied ACEs that apply to the object itself
* . Access-denied ACEs that apply to a subobject of the
* object, such as a property set or property
* . Access-allowed ACEs that apply to the object itself
* . Access-allowed ACEs that apply to a subobject of the object
*
* So, here is the desired ACE order
*
* deny-direct, allow-direct, deny-inherited, allow-inherited
*
* Of course, not all ACE types are required in an ACL.
*/
void
{
int ag, i;
/*
* ACL with no entry is a valid ACL and it means
* no access for anybody.
*/
return;
}
for (i = SMB_AG_START; i < SMB_AG_NUM; i++) {
}
case ACCESS_DENIED_ACE_TYPE:
break;
case ACCESS_ALLOWED_ACE_TYPE:
break;
default:
/*
* This is the lowest priority group so we put
* evertything unknown here.
*/
break;
}
/* Add the ACE to the selected group */
}
/*
* start with highest priority ACE group and append
* the ACEs to the ACL.
*/
}
}
}
/*
* smb_acl_from_zfs
*
* Converts given ZFS ACL to a Windows ACL.
*
* A pointer to allocated memory for the Windows ACL will be
* returned upon successful conversion.
*/
{
int numaces;
if (idm_stat != IDMAP_SUCCESS)
return (NULL);
return (NULL);
}
break;
}
}
return (acl);
}
/*
* smb_acl_to_zfs
*
* Converts given Windows ACL to a ZFS ACL.
*
* fs_acl will contain a pointer to the created ZFS ACL.
* The allocated memory should be freed by calling
* smb_fsacl_free().
*
* Since the output parameter, fs_acl, is allocated in this
* function, the caller has to make sure *fs_acl is NULL which
* means it's not pointing to any memory.
*/
{
int i;
return (NT_STATUS_INVALID_ACL);
if (which_acl == SMB_DACL_SECINFO) {
}
return (NT_STATUS_SUCCESS);
}
if (idm_stat != IDMAP_SUCCESS)
return (NT_STATUS_INTERNAL_ERROR);
if (idm_stat != IDMAP_SUCCESS) {
return (NT_STATUS_INTERNAL_ERROR);
}
}
}
if (idm_stat != IDMAP_SUCCESS) {
return (NT_STATUS_NONE_MAPPED);
}
/*
* Set the ACEs group flag based on the type of ID returned.
*/
continue;
}
return (NT_STATUS_SUCCESS);
}
static boolean_t
{
struct {
char *sid;
} map[] = {
{ NT_WORLD_SIDSTR, ACE_EVERYONE },
(ACE_GROUP | ACE_IDENTIFIER_GROUP) },
};
int i;
return (B_TRUE);
}
}
return (B_FALSE);
}
/*
* smb_fsacl_getsids
*
*/
static idmap_stat
{
int i, idtype;
case ACE_OWNER:
break;
case (ACE_GROUP | ACE_IDENTIFIER_GROUP):
/* owning group */
break;
case ACE_IDENTIFIER_GROUP:
/* regular group */
break;
case ACE_EVERYONE:
break;
default:
/* user entry */
}
if (idm_stat != IDMAP_SUCCESS) {
return (idm_stat);
}
}
return (idm_stat);
}
/*
* smb_fsacl_null_empty
*
* NULL DACL means everyone full-access
* Empty DACL means everyone full-deny
*
* ZFS ACL must have at least one entry so smb server has
* to simulate the aforementioned expected behavior by adding
* an entry in case the requested DACL is null or empty. Adding
* a everyone full-deny entry has proved to be problematic in
* tests since a deny entry takes precedence over allow entries.
* So, instead of adding a everyone full-deny, an owner ACE with
* owner implicit permissions will be set.
*/
static acl_t *
{
if (null) {
} else {
}
return (zacl);
}
/*
* FS ACL (acl_t) Functions
*/
acl_t *
{
return (NULL);
return (acl);
}
void
{
if (acl)
}
/*
* ACE Functions
*/
/*
* smb_ace_len
*
* Returns the length of the given ACE as it appears in an
* ACL on the wire (i.e. a flat buffer which contains the SID)
*/
static uint16_t
{
return (0);
}
/*
* smb_ace_mask_g2s
*
* Converts generic access bits in the given mask (if any)
* to file specific bits. Generic access masks shouldn't be
* stored in filesystem ACEs.
*/
static uint32_t
{
if (mask & GENERIC_ALL) {
| GENERIC_EXECUTE);
mask |= FILE_ALL_ACCESS;
return (mask);
}
if (mask & GENERIC_READ) {
mask &= ~GENERIC_READ;
}
if (mask & GENERIC_WRITE) {
mask &= ~GENERIC_WRITE;
}
if (mask & GENERIC_EXECUTE) {
mask &= ~GENERIC_EXECUTE;
}
return (mask);
}
/*
* smb_ace_flags_tozfs
*
* This function maps the flags which have different values
* in Windows and Solaris. The ones with the same value are
* transferred untouched.
*/
static uint16_t
{
if (c_flags & FAILED_ACCESS_ACE_FLAG)
if (c_flags & INHERITED_ACE)
return (z_flags);
}
static uint8_t
{
if (z_flags & ACE_INHERITED_ACE)
c_flags |= INHERITED_ACE;
return (c_flags);
}