smbd_door_server.c revision dc20a3024900c47dd2ee44b9707e6df38f7d62a5
/*
* 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"
/*
* SMBd door server
*/
#include <door.h>
#include <errno.h>
#include <syslog.h>
#include <unistd.h>
#include <stdio.h>
#include <synch.h>
#include <string.h>
#include <fcntl.h>
#include <pthread.h>
#include <syslog.h>
#include <assert.h>
#include <alloca.h>
#include <smbsrv/libsmbns.h>
#include <smbsrv/libsmbrdr.h>
#include <smbsrv/smb_common_door.h>
static int smb_door_fildes = -1;
static mutex_t smb_doorsrv_mutex;
/*
* smb_doorsrv_start
*
* Start the SMBd door service.
* Returns 0 on success. Otherwise, -1.
*/
int
{
int newfd;
(void) mutex_lock(&smb_doorsrv_mutex);
if (smb_door_fildes != -1) {
(void) mutex_unlock(&smb_doorsrv_mutex);
return (0);
}
SMBD_DOOR_COOKIE, DOOR_UNREF)) < 0) {
(void) mutex_unlock(&smb_doorsrv_mutex);
return (-1);
}
(void) unlink(SMBD_DOOR_NAME);
(void) door_revoke(smb_door_fildes);
smb_door_fildes = -1;
(void) mutex_unlock(&smb_doorsrv_mutex);
return (-1);
}
(void) fdetach(SMBD_DOOR_NAME);
(void) door_revoke(smb_door_fildes);
smb_door_fildes = -1;
(void) mutex_unlock(&smb_doorsrv_mutex);
return (-1);
}
(void) mutex_unlock(&smb_doorsrv_mutex);
return (0);
}
/*
* smb_doorsrv_stop
*
* Stop the smbd door service.
*/
void
smb_doorsrv_stop(void)
{
(void) mutex_lock(&smb_doorsrv_mutex);
if (smb_door_fildes != -1) {
(void) fdetach(SMBD_DOOR_NAME);
(void) door_revoke(smb_door_fildes);
smb_door_fildes = -1;
}
(void) mutex_unlock(&smb_doorsrv_mutex);
}
/*
* smb_srv_door
*
*/
/*ARGSUSED*/
void
{
char *buf;
int buflen;
unsigned int used;
unsigned int dec_status;
unsigned int enc_status;
char *domain;
char *user;
char *passwd;
if (dec_ctx == 0)
return;
(void) smb_dr_decode_finish(dec_ctx);
return;
}
if (enc_ctx == 0) {
(void) smb_dr_decode_finish(dec_ctx);
return;
}
switch (req_type) {
case SMBD_DOOR_PARAM_GET: {
char value[MAX_VALUE_BUFLEN];
if (dec_status != 0)
goto decode_error;
break;
}
case SMBD_DOOR_PARAM_SET: {
if (dec_status != 0) {
goto decode_error;
}
else
break;
}
case SMBD_DOOR_NETBIOS_RECONFIG: {
break;
}
case SMBD_DOOR_JOIN:
if (dec_status != 0 ||
goto decode_error;
}
sizeof (jdi.domain_name));
sizeof (jdi.domain_username));
sizeof (jdi.domain_passwd));
break;
default:
goto decode_error;
}
goto encode_error;
return;
return;
}