smb_opipe.c revision b819cea2f73f98c5662230cc9affc8cc84f77fcf
/*
* 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 2011 Nexenta Systems, Inc. All rights reserved.
*/
/*
* This module provides the interface to NDR RPC.
*/
#include <sys/door_data.h>
#include <smbsrv/smb_kproto.h>
#define SMB_OPIPE_ISOPEN(OPIPE) \
static char *smb_opipe_lookup(const char *);
static int smb_opipe_exec(smb_opipe_t *);
static void smb_opipe_enter(smb_opipe_t *);
static void smb_opipe_exit(smb_opipe_t *);
{
return (opipe);
}
void
{
}
/*
* smb_opipe_open
*
* Open a well-known RPC named pipe. This routine should be called if
* a file open is requested on a share of type STYPE_IPC.
* If we recognize the pipe, we setup a new ofile.
*
* Returns 0 on success, Otherwise an NT status is returned to indicate
* an error.
*/
int
{
char *pipe_name;
return (NT_STATUS_OBJECT_NAME_NOT_FOUND);
/*
* If printing is disabled, pretend spoolss does not exist.
*/
return (NT_STATUS_OBJECT_NAME_NOT_FOUND);
op->create_options = 0;
SMB_UNIQ_FID(), &err);
smb_ofile_close(of, 0);
return (NT_STATUS_OBJECT_NAME_NOT_FOUND);
}
| SMB_PIPE_UNLIMITED_INSTANCES; /* 0x05ff */
/*
* p_data points to the offset within p_doorbuf at which
* data will be written or read.
*/
/*
* On error, reset the header to clear the fid,
* which avoids confusion when smb_opipe_close() is
* called by smb_ofile_close().
*/
smb_ofile_close(of, 0);
return (NT_STATUS_NO_MEMORY);
}
return (NT_STATUS_SUCCESS);
}
/*
* smb_opipe_lookup
*
* Lookup a path to see if it's a well-known RPC named pipe that we support.
* The full pipe path will be in the form \\PIPE\\SERVICE. The first part
* can be assumed, so all we need here are the service names.
*
* Returns a pointer to the pipe name (without any leading \'s) on success.
* Otherwise returns a null pointer.
*/
static char *
smb_opipe_lookup(const char *path)
{
static char *named_pipes[] = {
"lsass",
"LSARPC",
"NETLOGON",
"SAMR",
"SPOOLSS",
"SRVSVC",
"SVCCTL",
"WINREG",
"WKSSVC",
"EVENTLOG",
"NETDFS"
};
const char *name;
int i;
return (NULL);
path += 4;
}
for (i = 0; i < sizeof (named_pipes) / sizeof (named_pipes[0]); ++i) {
return (named_pipes[i]);
}
return (NULL);
}
/*
* Initialize the opipe header and context, and make the door call.
*/
static int
{
return (-1);
return (-1);
return (-1);
return (smb_opipe_door_call(opipe));
}
/*
* smb_opipe_close
*
*/
void
{
if (SMB_OPIPE_ISOPEN(opipe)) {
(void) smb_opipe_door_call(opipe);
}
}
static int
{
}
/*
* smb_opipe_transact
*
* This is the entry point for RPC bind and request transactions.
* The fid is an arbitrary id used to associate RPC requests with a
* particular binding handle.
*
* If the data to be returned is larger than the client expects, we
* return as much as the client can handle and report a buffer overflow
* warning, which informs the client that we have more data to return.
* The residual data remains in the pipe until the client claims it or
* closes the pipe.
*/
{
int mdrcnt;
int nbytes;
int rc;
else
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
return (SDRC_ERROR);
}
if (rc != 0) {
return (SDRC_ERROR);
}
if (nbytes) {
}
/*
* The pipe contains more data than mdrcnt, warn the
* client that there is more data in the pipe.
* Typically, the client will call SmbReadX, which
* will call smb_opipe_read, to get the data.
*/
}
return (SDRC_SUCCESS);
}
/*
* smb_opipe_write
*
* Write RPC request data to the pipe. The client should call smb_opipe_read
* to complete the exchange and obtain the RPC response.
*
* Returns 0 on success or an errno on failure.
*/
int
{
int rc;
if (!SMB_OPIPE_ISOPEN(opipe)) {
return (EBADF);
}
return (ENOMEM);
}
}
/*
* smb_opipe_read
*
* This interface may be called because smb_opipe_transact could not return
* all of the data in the original transaction or to form the second half
* of a transaction set up using smb_opipe_write. Either way, we just need
* to read data from the pipe and return it.
*
* The response data is encoded into raw_data as required by the smb_read
* functions. The uio_resid value indicates the number of bytes read.
*/
int
{
int rc;
return (EIO);
if (!SMB_OPIPE_ISOPEN(opipe)) {
return (EBADF);
}
return (ENOMEM);
}
return (EIO);
}
if (nbytes) {
}
return (rc);
}
static int
{
int rc;
return (ENOMEM);
}
return (rc);
}
/*
* Named pipe I/O is serialized per fid to ensure that each request
* has exclusive opipe access for the duration of the request.
*/
static void
{
}
/*
* Exit busy state. If we have exec'd an RPC, we may have
* to wait for notification that processing has completed.
*/
static void
{
}