/*
* 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
*/
/*
*/
/*
* This module provides Security Descriptor handling functions.
*/
#include <strings.h>
#include <assert.h>
#include <errno.h>
#include <libshare.h>
#include <smbsrv/smb_idmap.h>
/*
* This mapping table is provided to map permissions set by chmod
* using 'read_set' and 'modify_set' to what Windows share ACL GUI
* expects as Read and Control, respectively.
*/
static struct {
int am_ace_perms;
int am_share_perms;
} smb_ace_map[] = {
};
void
{
}
/*
* smb_sd_term
*
* Free non-NULL members of 'sd' which has to be in
* absolute (pointer) form.
*/
void
{
}
{
if (secinfo & SMB_OWNER_SECINFO)
if (secinfo & SMB_GROUP_SECINFO)
if (secinfo & SMB_DACL_SECINFO)
if (secinfo & SMB_SACL_SECINFO)
return (length);
}
/*
* smb_sd_get_secinfo
*
* Return the security information mask for the specified security
* descriptor.
*/
{
return (0);
return (sec_info);
}
/*
* Adjust the Access Mask so that ZFS ACE mask and Windows ACE read mask match.
*/
static int
{
int i;
for (i = 0; i < SMB_ACE_MASK_MAP_SIZE; ++i) {
return (smb_ace_map[i].am_share_perms);
}
return (mask);
}
/*
* Get ZFS acl from the share via sa_share_get_acl().
*/
static uint32_t
{
int rc;
switch (rc) {
case SA_NO_PERMISSION:
return (NT_STATUS_ACCESS_DENIED);
case SA_MNTPNT_NOT_FOUND:
case SA_INVALID_SHARE_PATH:
case SA_NOT_SUPPORTED:
return (NT_STATUS_OBJECT_PATH_NOT_FOUND);
default:
return (NT_STATUS_INTERNAL_ERROR);
}
}
return (NT_STATUS_INVALID_ACL);
return (NT_STATUS_SUCCESS);
}
/*
* smb_sd_read
*
* Reads ZFS acl from filesystem using acl_get() method. Convert the ZFS acl to
* a Win SD and return the Win SD in absolute form.
*
* NOTE: upon successful return caller MUST free the memory allocated
* for the returned SD by calling smb_sd_term().
*/
{
int error;
if (error != NT_STATUS_SUCCESS) {
return (error);
}
return (status);
}
/*
* Apply ZFS acl to the share path via acl_set() method.
* A NULL ACL pointer here represents an error.
* Null or empty ACLs are handled in smb_sd_tofs().
*/
static uint32_t
{
return (NT_STATUS_INVALID_ACL);
return (NT_STATUS_INVALID_ACL);
return (status);
}
/*
* smb_sd_write
*
* Takes a Win SD in absolute form, converts it to
* ZFS acl and applies the acl to the share via sa_share_set_acl().
*/
{
int error;
if (error != NT_STATUS_SUCCESS) {
return (error);
}
return (status);
}
/*
* smb_sd_tofs
*
* Creates a filesystem security structure based on the given
* Windows security descriptor.
*/
{
int idtype;
int flags = 0;
/*
* ZFS only has one set of flags so for now only
* Windows DACL flags are taken into account.
*/
if (sd_control & SE_DACL_DEFAULTED)
flags |= ACL_DEFAULTED;
if (sd_control & SE_DACL_AUTO_INHERITED)
if (sd_control & SE_DACL_PROTECTED)
flags |= ACL_PROTECTED;
flags |= ACL_IS_DIR;
/* Owner */
if (!smb_sid_isvalid(sid))
return (NT_STATUS_INVALID_SID);
if (idm_stat != IDMAP_SUCCESS) {
return (NT_STATUS_NONE_MAPPED);
}
}
/* Group */
if (!smb_sid_isvalid(sid))
return (NT_STATUS_INVALID_SID);
if (idm_stat != IDMAP_SUCCESS) {
return (NT_STATUS_NONE_MAPPED);
}
}
/* DACL */
if (status != NT_STATUS_SUCCESS)
return (status);
}
else
return (NT_STATUS_INVALID_ACL);
}
/* SACL */
if (status != NT_STATUS_SUCCESS) {
return (status);
}
} else {
return (NT_STATUS_INVALID_ACL);
}
}
return (status);
}
/*
* smb_sd_fromfs
*
* Makes an Windows style security descriptor in absolute form
* based on the given filesystem security information.
*
* Should call smb_sd_term() for the returned sd to free allocated
* members.
*/
{
/* Owner */
SMB_IDMAP_USER, &sid);
if (idm_stat != IDMAP_SUCCESS) {
return (NT_STATUS_NONE_MAPPED);
}
}
/* Group */
SMB_IDMAP_GROUP, &sid);
if (idm_stat != IDMAP_SUCCESS) {
return (NT_STATUS_NONE_MAPPED);
}
}
/* DACL */
return (NT_STATUS_INTERNAL_ERROR);
}
/*
* Need to sort the ACL before send it to Windows
* clients. Winodws GUI is sensitive about the order
* of ACEs.
*/
} else {
}
}
/* SACL */
return (NT_STATUS_INTERNAL_ERROR);
}
} else {
}
}
return (status);
}
static void
{
if (flags & ACL_DEFAULTED)
if (flags & ACL_AUTO_INHERIT)
if (flags & ACL_PROTECTED)
if (present)
}
static void
{
if (flags & ACL_DEFAULTED)
if (flags & ACL_AUTO_INHERIT)
if (flags & ACL_PROTECTED)
if (present)
}
/*
* smb_fssd_init
*
* Initializes the given FS SD structure.
*/
void
{
}
/*
* smb_fssd_term
*
* Frees allocated memory for acl fields.
*/
void
{
}