smb_idmap.c revision 9fb67ea305c66b6a297583b9b0db6796b0dfe497
/*
* 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 <syslog.h>
#include <strings.h>
#include <synch.h>
static idmap_handle_t *smb_idmap_hd;
static mutex_t smb_idmap_mutex;
static void
smb_idmap_reset(void)
{
(void) mutex_lock(&smb_idmap_mutex);
if (smb_idmap_hd != NULL) {
(void) idmap_fini(smb_idmap_hd);
smb_idmap_hd = NULL;
}
(void) mutex_unlock(&smb_idmap_mutex);
}
/*
* Report an idmap error. If the error appears to be connection
* related, use fini to reset. A new handle will be generated on
* the next open.
*/
void
{
if (stat != IDMAP_SUCCESS) {
if (s == NULL)
s = "smb_idmap_check";
switch (stat) {
case IDMAP_ERR_RPC_HANDLE:
case IDMAP_ERR_RPC:
case IDMAP_ERR_CLIENT_HANDLE:
break;
default:
break;
}
}
}
static idmap_handle_t *
smb_idmap_enter(void)
{
(void) mutex_lock(&smb_idmap_mutex);
if (smb_idmap_hd == NULL) {
"smb_idmap_enter: idmap_init failed: %s",
(void) mutex_unlock(&smb_idmap_mutex);
return (NULL);
}
}
return (smb_idmap_hd);
}
static void
smb_idmap_exit(void)
{
(void) mutex_unlock(&smb_idmap_mutex);
}
/*
* smb_idmap_getsid
*
*/
{
if (stat != IDMAP_SUCCESS)
return (stat);
if (stat != IDMAP_SUCCESS) {
return (stat);
}
if (stat != IDMAP_SUCCESS) {
return (stat);
}
return (IDMAP_SUCCESS);
}
/*
* smb_idmap_getid
*
* Tries to get a mapping for the given SID
*/
{
if (stat != IDMAP_SUCCESS)
return (stat);
if (stat != IDMAP_SUCCESS) {
return (stat);
}
if (stat != IDMAP_SUCCESS) {
return (stat);
}
return (IDMAP_SUCCESS);
}
/*
* smb_idmap_batch_create
*
* Creates and initializes the context for batch ID mapping.
*/
{
if (!sib)
return (IDMAP_ERR_ARG);
return (IDMAP_ERR_OTHER);
if (stat != IDMAP_SUCCESS) {
return (stat);
}
return (IDMAP_ERR_MEMORY);
return (IDMAP_SUCCESS);
}
/*
* smb_idmap_batch_destroy
*
* Frees the batch ID mapping context.
*/
void
{
int i;
return;
if (sib->sib_idmaph) {
}
return;
/*
* SIDs are allocated only when mapping
*/
}
}
}
/*
* 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.
*/
{
char sidstr[SMB_SID_STRSZ];
int flag = 0;
return (IDMAP_ERR_ARG);
return (IDMAP_ERR_MEMORY);
switch (idtype) {
case SMB_IDMAP_USER:
break;
case SMB_IDMAP_GROUP:
break;
case SMB_IDMAP_UNKNOWN:
break;
default:
return (IDMAP_ERR_ARG);
}
return (stat);
}
/*
* smb_idmap_batch_getsid
*
*
* sim->sim_domsid and sim->sim_rid will contain the mapping
* result upon successful process of the batched request.
*/
{
int flag = 0;
return (IDMAP_ERR_ARG);
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:
return (IDMAP_ERR_ARG);
}
return (stat);
}
/*
* smb_idmap_batch_getmappings
*
* trigger ID mapping service to get the mappings for queued
* requests.
*
* Checks the result of all the queued requests.
*/
{
int i;
(void) mutex_lock(&smb_idmap_mutex);
(void) mutex_unlock(&smb_idmap_mutex);
return (stat);
}
/*
* Check the status for all the queued requests
*/
}
(void) mutex_unlock(&smb_idmap_mutex);
}
}
if (smb_idmap_batch_binsid(sib) != 0)
(void) mutex_unlock(&smb_idmap_mutex);
return (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);
}