smbd_mlsvc_doorsvc.c revision 3ad684d66b78e06edd37e2c4fd3b3949f095194b
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * CDDL HEADER START
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms of the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Common Development and Distribution License (the "License").
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You may not use this file except in compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing permissions
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL HEADER in each
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below this CDDL HEADER, with the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * fields enclosed by brackets "[]" replaced with your own identifying
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * information: Portions Copyright [yyyy] [name of copyright owner]
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * CDDL HEADER END
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Use is subject to license terms.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster#pragma ident "%Z%%M% %I% %E% SMI"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic int smb_winpipe_cookie = 0x50495045; /* PIPE */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic pthread_mutex_t smb_winpipe_mutex = PTHREAD_MUTEX_INITIALIZER;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterstatic void smb_winpipe_request(void *, char *, size_t, door_desc_t *, uint_t);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Create the winpipe door service.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the door descriptor on success. Otherwise returns -1.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster (void) pthread_mutex_unlock(&smb_winpipe_mutex);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (-1);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((smb_winpipe_fd = door_create(smb_winpipe_request,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster &smb_winpipe_cookie, (DOOR_UNREF | DOOR_REFUSE_DESC))) < 0) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster (void) pthread_mutex_unlock(&smb_winpipe_mutex);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Stop the winpipe door service.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster (void) pthread_mutex_unlock(&smb_winpipe_mutex);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fostersmb_user_ctx_mkabsolute(uint8_t *buf, uint32_t len)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster xdrmem_create(&xdrs, (const caddr_t)buf, len, XDR_DECODE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster obj = (smb_dr_user_ctx_t *)malloc(sizeof (smb_dr_user_ctx_t));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster syslog(LOG_ERR, "smb_user_ctx_mkabsolute: resource shortage");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster syslog(LOG_ERR, "smb_user_ctx_mkabsolute: XDR decode error");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster xdr_free(xdr_smb_dr_user_ctx_t, (char *)user_ctx);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Winpipe door service request handler.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Door arg data is a previously marshalled in to flat buffer
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * that contains no pointers. This data is first unmarshalled into
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * common structures. The data from the door *argp contains a header structure,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * mlsvc_door_hdr_t. Following are its members.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * thread_id - kernel thread id
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * version number - possible use at a leter point
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * call_type - rpc_transact, rpc_read or rpc_write
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * length - max number of bytes that can be returned
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * rpc_ctx - some rpc context info such as domain, user account, ...
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * smb_pipe_t - pipeid, pipename, pipelen and data
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Convert the data and call mlrpc_process. The returned outpipe contains
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the relevant data to be returned to the client.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Outgoing data must be marshalled again before returning.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fostersmb_winpipe_request(void *cookie, char *argp, size_t arg_size,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((cookie != &smb_winpipe_cookie) || (argp == NULL) ||
goto zero_exit;
if (!user_ctx) {
goto zero_exit;
goto zero_exit;
goto zero_exit;
goto zero_exit;
goto zero_exit;
goto zero_exit;
goto zero_exit;
goto zero_exit;
bytes_off = 0;
sizeof (uint32_t));