smb_share_doorclnt.c revision 3ad684d66b78e06edd37e2c4fd3b3949f095194b
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* User-space door client for LanMan share management.
*/
#include <syslog.h>
#include <door.h>
#include <fcntl.h>
#include <stdarg.h>
#include <errno.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <thread.h>
#include <synch.h>
#include <smbsrv/lmshare_door.h>
static int lmshrd_fildes = -1;
static uint64_t lmshrd_door_ncall = 0;
static mutex_t lmshrd_mutex;
char *lmshrd_desc[] = {
"",
"LmshrdNumShares",
"LmshrdDelete",
"LmshrdRename",
"LmshrdGetinfo",
"LmshrdAdd",
"LmshrdSetinfo",
"LmshrdExists",
"LmshrdIsSpecial",
"LmshrdIsRestricted",
"LmshrdIsAdmin",
"LmshrdIsValid",
"LmshrdIsDir",
"LmshrdList",
"LmshrdNumTrans",
"N/A",
0
};
/*
* Open the lmshrd door. This is a private call for use by
* lmshrd_door_enter() and must be called with lmshrd_mutex held.
*
* Returns the door fd on success. Otherwise, -1.
*/
static int
lmshrd_door_open(void)
{
if (lmshrd_fildes == -1) {
lmshrd_fildes = -1;
else
lmshrd_door_ncall = 0;
}
return (lmshrd_fildes);
}
/*
* Close the lmshrd door.
*/
void
lmshrd_door_close(void)
{
(void) mutex_lock(&lmshrd_mutex);
if (lmshrd_fildes != -1) {
while (lmshrd_door_ncall > 0)
if (lmshrd_fildes != -1) {
(void) close(lmshrd_fildes);
lmshrd_fildes = -1;
}
}
(void) mutex_unlock(&lmshrd_mutex);
}
/*
* Entry handler for lmshrd door calls.
*/
static door_arg_t *
lmshrd_door_enter(void)
{
char *buf;
(void) mutex_lock(&lmshrd_mutex);
if (lmshrd_door_open() == -1) {
(void) mutex_unlock(&lmshrd_mutex);
return (NULL);
}
}
(void) mutex_unlock(&lmshrd_mutex);
return (arg);
}
/*
* Exit handler for lmshrd door calls.
*/
static void
{
if (errmsg)
(void) mutex_lock(&lmshrd_mutex);
(void) cond_signal(&lmshrd_cv);
(void) mutex_unlock(&lmshrd_mutex);
}
/*
* Return 0 upon success. Otherwise, -1.
*/
static int
{
if (status != LMSHR_DOOR_SRV_SUCCESS) {
if (status == LMSHR_DOOR_SRV_ERROR)
(void) smb_dr_get_uint32(dec_ctx);
return (-1);
}
return (0);
}
{
return (NERR_InternalError);
if (rc != 0) {
return (NERR_InternalError);
}
return (NERR_InternalError);
}
if (lmshrd_door_check_status(dec_ctx) != 0) {
(void) smb_dr_decode_finish(dec_ctx);
return (NERR_InternalError);
}
if (smb_dr_decode_finish(dec_ctx) != 0) {
return (NERR_InternalError);
}
return (NERR_Success);
}
int
lmshrd_num_shares(void)
{
int rc;
return (-1);
if (rc != 0) {
return (-1);
}
return (-1);
}
if (lmshrd_door_check_status(dec_ctx) != 0) {
(void) smb_dr_decode_finish(dec_ctx);
return (-1);
}
if (smb_dr_decode_finish(dec_ctx) != 0) {
return (-1);
}
return (num_shares);
}
lmshrd_delete(char *share_name)
{
return (NERR_InternalError);
if (rc != 0) {
return (NERR_InternalError);
}
return (NERR_InternalError);
}
if (lmshrd_door_check_status(dec_ctx) != 0) {
(void) smb_dr_decode_finish(dec_ctx);
return (NERR_InternalError);
}
if (smb_dr_decode_finish(dec_ctx) != 0) {
return (NERR_InternalError);
}
return (rc);
}
{
return (NERR_InternalError);
if (rc != 0) {
return (NERR_InternalError);
}
return (NERR_InternalError);
}
if (lmshrd_door_check_status(dec_ctx) != 0) {
(void) smb_dr_decode_finish(dec_ctx);
return (NERR_InternalError);
}
if (smb_dr_decode_finish(dec_ctx) != 0) {
return (NERR_InternalError);
}
return (rc);
}
{
return (NERR_InternalError);
if (rc != 0) {
return (NERR_InternalError);
}
return (NERR_InternalError);
}
if (lmshrd_door_check_status(dec_ctx) != 0) {
(void) smb_dr_decode_finish(dec_ctx);
return (NERR_InternalError);
}
if (smb_dr_decode_finish(dec_ctx) != 0) {
return (NERR_InternalError);
}
return (rc);
}
{
return (NERR_InternalError);
if (rc != 0) {
return (NERR_InternalError);
}
return (NERR_InternalError);
}
if (lmshrd_door_check_status(dec_ctx) != 0) {
(void) smb_dr_decode_finish(dec_ctx);
return (NERR_InternalError);
}
if (smb_dr_decode_finish(dec_ctx) != 0) {
return (NERR_InternalError);
}
return (rc);
}
{
return (NERR_InternalError);
if (rc != 0) {
return (NERR_InternalError);
}
return (NERR_InternalError);
}
if (lmshrd_door_check_status(dec_ctx) != 0) {
(void) smb_dr_decode_finish(dec_ctx);
return (NERR_InternalError);
}
if (smb_dr_decode_finish(dec_ctx) != 0) {
return (NERR_InternalError);
}
return (rc);
}
static int
{
int rc;
return (NERR_InternalError);
if (rc != 0) {
return (NERR_InternalError);
}
return (NERR_InternalError);
}
if (lmshrd_door_check_status(dec_ctx) != 0) {
(void) smb_dr_decode_finish(dec_ctx);
return (NERR_InternalError);
}
if (smb_dr_decode_finish(dec_ctx) != 0) {
return (NERR_InternalError);
}
return (rc);
}
int
lmshrd_exists(char *share_name)
{
}
int
lmshrd_is_special(char *share_name)
{
}
int
lmshrd_is_restricted(char *share_name)
{
}
int
lmshrd_is_admin(char *share_name)
{
}
int
lmshrd_is_valid(char *share_name)
{
}
int
lmshrd_is_dir(char *path)
{
}