smbd_mlsvc_doorsvc.c revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <door.h>
#include <errno.h>
#include <syslog.h>
#include <pthread.h>
#include <smbsrv/mlsvc_util.h>
#include <smbsrv/smb_winpipe.h>
static int smb_updoor_id = -1;
#define START_OUTDOOR_SIZE 65536
#define MAX_INPIPE_LEN 65536
static smb_dr_user_ctx_t *
{
if (!obj) {
xdr_destroy(&xdrs);
return (NULL);
}
}
xdr_destroy(&xdrs);
return (obj);
}
static void
{
if (user_ctx) {
}
}
/*
* Function: smb_mlsvc_door_server
*
* This is the userland winpipe door entry point.
* Door arg data is a previously marshalled in to flat buffer
* that contains no pointers. This data is first unmarshalled into
* common structures. The data from the door *argp contains a header structure,
* mlsvc_door_hdr_t. Following are its members.
* thread_id - kernel thread id
* version number - possible use at a leter point
* call_type - rpc_transact, rpc_read or rpc_write
* length - max number of bytes that can be returned
* rpc_ctx - some rpc context info such as domain, user account, ...
* smb_pipe_t - pipeid, pipename, pipelen and data
*
* After converting the data, mlsvc_rpc_process is called
* The returning outpipe contains the relevant data to be
* returned to the windows client.
*
* Outgoing data must be marshalled again before returning.
*/
/*ARGSUSED*/
void
{
int bplen = 0;
int total_pipelen;
int tbytes = 0;
int bytes_off = 0;
struct mlsvc_rpc_context *context;
int current_out_len;
char lfp[START_OUTDOOR_SIZE];
/* flush is a special case, just free the buffers and return */
if (!context) {
goto zero_exit;
}
}
}
goto zero_exit;
}
if (!user_ctx) {
goto zero_exit;
}
if (! inpipe) {
goto zero_exit;
}
if (!context) {
goto zero_exit;
}
/*
* If RPC_TRANSACT, save len, set cookie to 0 and store
* outpipe pointer into rpc_context. This will be used later
* by RPC_READ. See if we have pending writes.
* Clear the in context if we do.
*/
goto zero_exit;
}
/*
* if no outpipe yet, initialize it
*/
}
}
/*
* init pipe context for subsequent calls
*/
}
/*
* the first write we need to allocate
* the maximum inpipe len
*/
}
goto zero_exit;
}
/*
* if we get another RPC_WRITE then we need to append
*/
goto zero_exit;
}
if (! obuf) {
goto zero_exit;
}
/*
* check if this is the first transfer
* pipe and cookie management
*/
goto zero_exit;
} else {
} else {
}
}
if (! outpipe) {
goto zero_exit;
}
} else {
} else {
}
}
bytes_off = 0;
tbytes = 0;
/*NOTREACHED*/
if (obuf)
if (inpipe)
(void) door_return(0, 0, NULL, 0);
}
/*
* smb_mlsvc_srv_start
*
* Start the mlsvc door service.
*/
int
{
int newfd;
(void) pthread_mutex_lock(&smb_winpipe_user_mutex);
if (smb_updoor_id != -1) {
(void) pthread_mutex_unlock(&smb_winpipe_user_mutex);
return (-1);
}
errno = 0;
smb_updoor_id = -1;
(void) pthread_mutex_unlock(&smb_winpipe_user_mutex);
return (-1);
}
(void) unlink(SMB_WINPIPE_DOOR_UP_PATH);
(void) door_revoke(smb_updoor_id);
smb_updoor_id = -1;
(void) pthread_mutex_unlock(&smb_winpipe_user_mutex);
return (-1);
}
(void) fdetach(SMB_WINPIPE_DOOR_UP_PATH);
(void) door_revoke(smb_updoor_id);
smb_updoor_id = -1;
(void) pthread_mutex_unlock(&smb_winpipe_user_mutex);
return (-1);
}
(void) pthread_mutex_unlock(&smb_winpipe_user_mutex);
return (0);
}
/*
* smb_mlsvc_srv_stop
*
* Stop the mlsvc door service.
* We will eventually call this based on some signals
* No one calls this just yet, if the process dies all this stuff happens
* by default
*/
void
{
(void) pthread_mutex_lock(&smb_winpipe_user_mutex);
if (smb_updoor_id != -1) {
(void) fdetach(SMB_WINPIPE_DOOR_UP_PATH);
(void) door_revoke(smb_updoor_id);
smb_updoor_id = -1;
}
(void) pthread_mutex_unlock(&smb_winpipe_user_mutex);
}