/*
* 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 2013 Nexenta Systems, Inc. All rights reserved.
*/
/*
* SMB server interface to idmap
* (smb_idmap_get..., smb_idmap_batch_...)
*
* There are three implementations of this interface:
* uts/common/fs/smbsrv/smb_idmap.c (smbsrv kmod)
* lib/smbsrv/libfksmbsrv/common/fksmb_idmap.c (libfksmbsrv)
* lib/smbsrv/libsmb/common/smb_idmap.c (libsmb)
*
* There are enough differences (relative to the code size)
* that it's more trouble than it's worth to merge them.
*
* This one differs from the others in that it:
* calls kernel (kidmap_...) interfaces
* domain SIDs are shared, not strdup'ed
*/
/*
* SMB ID mapping
*
* Solaris ID mapping service (aka Winchester) works with domain SIDs
* and RIDs where domain SIDs are in string format. CIFS service works
* with binary SIDs understandable by CIFS clients. A layer of SMB ID
* mapping functions are implemeted to hide the SID conversion details
* and also hide the handling of array of batch mapping requests.
*/
#include <smbsrv/smb_kproto.h>
#include <smbsrv/smb_fsops.h>
#include <smbsrv/smb_vops.h>
#include <smbsrv/smb_idmap.h>
#include <sys/priv_names.h>
/*
* smb_idmap_getsid
*
* Maps the given Solaris ID to a Windows SID using the
* simple mapping API.
*/
{
switch (idtype) {
case SMB_IDMAP_USER:
break;
case SMB_IDMAP_GROUP:
break;
case SMB_IDMAP_EVERYONE:
/* Everyone S-1-1-0 */
break;
default:
ASSERT(0);
return (IDMAP_ERR_ARG);
}
return (IDMAP_ERR_NOMAPPING);
return (IDMAP_ERR_INTERNAL);
}
/*
* smb_idmap_getid
*
* Maps the given Windows SID to a Unix ID using the
* simple mapping API.
*/
{
return (IDMAP_ERR_SID);
switch (*idtype) {
case SMB_IDMAP_USER:
break;
case SMB_IDMAP_GROUP:
break;
case SMB_IDMAP_UNKNOWN:
break;
default:
ASSERT(0);
return (IDMAP_ERR_ARG);
}
}
/*
* smb_idmap_batch_create
*
* Creates and initializes the context for batch ID mapping.
*/
{
return (IDMAP_SUCCESS);
}
/*
* smb_idmap_batch_destroy
*
* Frees the batch ID mapping context.
* If ID mapping is Solaris -> Windows it frees memories
* allocated for binary SIDs.
*/
void
{
char *domsid;
int i;
if (sib->sib_idmaph)
/*
* SIDs are allocated only when mapping
*/
/*
* SID prefixes are allocated only when mapping
*/
if (domsid)
}
}
}
/*
* smb_idmap_batch_getid
*
* Queue a request to map the given SID to a UID or GID.
*
* sim->sim_id should point to variable that's supposed to
* of this function.
*
* If requested ID type is known, it's passed as 'idtype',
* if it's unknown it'll be returned in sim->sim_idtype.
*/
{
return (IDMAP_ERR_SID);
switch (idtype) {
case SMB_IDMAP_USER:
break;
case SMB_IDMAP_GROUP:
break;
case SMB_IDMAP_UNKNOWN:
break;
default:
ASSERT(0);
return (IDMAP_ERR_ARG);
}
return (idm_stat);
}
/*
* smb_idmap_batch_getsid
*
*
* sim->sim_domsid and sim->sim_rid will contain the mapping
* result upon successful process of the batched request.
*/
{
switch (idtype) {
case SMB_IDMAP_USER:
break;
case SMB_IDMAP_GROUP:
break;
case SMB_IDMAP_OWNERAT:
/* Current Owner S-1-5-32-766 */
break;
case SMB_IDMAP_GROUPAT:
/* Current Group S-1-5-32-767 */
break;
case SMB_IDMAP_EVERYONE:
/* Everyone S-1-1-0 */
break;
default:
ASSERT(0);
return (IDMAP_ERR_ARG);
}
return (idm_stat);
}
/*
* smb_idmap_batch_getmappings
*
* trigger ID mapping service to get the mappings for queued
* requests.
*
* Checks the result of all the queued requests.
* If this is a Solaris -> Windows mapping it generates
* binary SIDs from returned (domsid, rid) pairs.
*/
{
int i;
if (idm_stat != IDMAP_SUCCESS)
return (idm_stat);
/*
* Check the status for all the queued requests
*/
}
if (smb_idmap_batch_binsid(sib) != 0)
return (idm_stat);
}
/*
* smb_idmap_batch_binsid
*
* Convert sidrids to binary sids
*
* Returns 0 if successful and non-zero upon failure.
*/
static int
{
int i;
/* This operation is not required */
return (0);
return (1);
return (1);
}
return (0);
}