smbd_share_doorsvc.c revision 148c5f43199ca0b43fc8e3b643aab11cd66ea327
/*
* 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
*/
/*
*/
/*
* LanMan share door server
*/
#include <door.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <syslog.h>
#include <string.h>
#include <strings.h>
#include <pthread.h>
#include <smbsrv/smb_share.h>
#include "smbd.h"
#define SMB_SHARE_DSRV_VERSION 1
static int smb_share_dsrv_fd = -1;
static smbd_door_t smb_share_sdh;
/*
* Start the LanMan share door service.
* Returns 0 on success. Otherwise, -1.
*/
int
smbd_share_start(void)
{
int newfd;
(void) pthread_mutex_lock(&smb_share_dsrv_mtx);
if (smb_share_dsrv_fd != -1) {
(void) pthread_mutex_unlock(&smb_share_dsrv_mtx);
return (smb_share_dsrv_fd);
}
(void) pthread_mutex_unlock(&smb_share_dsrv_mtx);
return (-1);
}
(void) unlink(SMB_SHARE_DNAME);
(void) door_revoke(smb_share_dsrv_fd);
smb_share_dsrv_fd = -1;
(void) pthread_mutex_unlock(&smb_share_dsrv_mtx);
return (-1);
}
(void) fdetach(SMB_SHARE_DNAME);
(void) door_revoke(smb_share_dsrv_fd);
smb_share_dsrv_fd = -1;
(void) pthread_mutex_unlock(&smb_share_dsrv_mtx);
return (-1);
}
(void) pthread_mutex_unlock(&smb_share_dsrv_mtx);
return (smb_share_dsrv_fd);
}
/*
* Stop the LanMan share door service.
*/
void
smbd_share_stop(void)
{
(void) pthread_mutex_lock(&smb_share_dsrv_mtx);
if (smb_share_dsrv_fd != -1) {
(void) fdetach(SMB_SHARE_DNAME);
(void) door_revoke(smb_share_dsrv_fd);
smb_share_dsrv_fd = -1;
}
(void) pthread_mutex_unlock(&smb_share_dsrv_mtx);
}
/*
* This function with which the LMSHARE door is associated
* will invoke the appropriate CIFS share management function
* based on the request type of the door call.
*/
/*ARGSUSED*/
static void
{
int req_type;
char buf[SMB_SHARE_DSIZE];
unsigned int used;
unsigned int dec_status;
unsigned int enc_status;
char *sharename, *sharename2;
int offset;
}
switch (req_type) {
case SMB_SHROP_NUM_SHARES:
goto decode_error;
rc = smb_shr_count();
break;
case SMB_SHROP_DELETE:
goto decode_error;
}
break;
case SMB_SHROP_RENAME:
goto decode_error;
}
break;
case SMB_SHROP_ADD:
goto decode_error;
break;
case SMB_SHROP_MODIFY:
goto decode_error;
}
break;
case SMB_SHROP_LIST:
goto decode_error;
sizeof (smb_shrlist_t));
break;
default:
goto decode_error;
}
}
return;
}