/*
* 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 2015 Nexenta Systems, Inc. All rights reserved.
*/
#include <assert.h>
#include <syslog.h>
#include <door.h>
#include <fcntl.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <smbsrv/wintypes.h>
#include <smbsrv/smb_door.h>
static int smb_door_call_private(int, smb_doorarg_t *);
static int smb_door_decode(smb_doorarg_t *);
/*
* Given a SID, make a door call to get the associated name.
*
* Returns 0 if the door call is successful, otherwise -1.
*
* If 0 is returned, the lookup result will be available in a_status.
* NT_STATUS_SUCCESS The SID was mapped to a name.
* NT_STATUS_NONE_MAPPED The SID could not be mapped to a name.
*/
int
{
int rc;
if (rc != 0)
return (rc);
}
/*
* Given a name, make a door call to get the associated SID.
*
* Returns 0 if the door call is successful, otherwise -1.
*
* If 0 is returned, the lookup result will be available in a_status.
* NT_STATUS_SUCCESS The name was mapped to a SID.
* NT_STATUS_NONE_MAPPED The name could not be mapped to a SID.
*/
int
{
int rc;
} else {
}
if (rc != 0)
return (rc);
}
int
{
int rc;
if (rc != 0) {
/*
* This usually means the SMB service is not running.
*/
return (rc);
}
return (0);
}
/*
* Get information about the Domain Controller in the joined resource domain.
*
* Returns NT status codes.
*/
{
struct hostent *h;
int rc;
*namebuf = '\0';
&dcname, smb_string_xdr);
if (rc != 0) {
return (NT_STATUS_INTERNAL_ERROR);
}
} else {
freehostent(h);
}
}
return (NT_STATUS_SUCCESS);
}
{
return (FALSE);
return (FALSE);
return (FALSE);
return (FALSE);
return (TRUE);
}
{
return (FALSE);
return (FALSE);
return (FALSE);
return (TRUE);
}
/*
* Parameters:
* fqdn (input) - fully-qualified domain name
* buf (output) - fully-qualified hostname of the AD server found
* by this function.
* buflen (input) - length of the 'buf'
*
* Return:
* B_TRUE if an AD server is found. Otherwise, returns B_FALSE;
*
* The buffer passed in should be big enough to hold a fully-qualified
* hostname (MAXHOSTNAMELEN); otherwise, a truncated string will be
* returned. On error, an empty string will be returned.
*/
{
int rc;
if (buf)
*buf = '\0';
return (B_FALSE);
}
*buf = '\0';
&server, smb_string_xdr);
if (rc != 0)
}
}
return (found);
}
void
smb_notify_dc_changed(void)
{
int rc;
if (rc != 0)
}
/*
* After a successful door call the local door_arg->data_ptr is assigned
* to the caller's arg->rbuf so that arg has references to both input and
* response buffers, which is required by smb_door_free.
*
* On success, the object referenced by rsp_data will have been populated
* by passing rbuf through the rsp_xdr function.
*/
static int
{
int fd;
int rc;
char *door_name;
return (-1);
}
return (-1);
}
return (-1);
}
return (-1);
}
return (rc);
}
/*
* We use a copy of the door arg because doorfs may change data_ptr
* and we want to detect that when freeing the door buffers. After
* this call, response data must be referenced via rbuf and rsize.
*/
static int
{
int rc;
int i;
for (i = 0; i < SMB_DOOR_CALL_RETRIES; ++i) {
errno = 0;
break;
return (-1);
}
if (errno == 0)
return (-1);
}
return (rc);
}
static int
{
char *buf;
return (-1);
xdr_destroy(&xdrs);
return (-1);
}
xdr_destroy(&xdrs);
return (-1);
}
}
xdr_destroy(&xdrs);
return (0);
}
/*
* Decode the response in rbuf and rsize.
*/
static int
{
return (-1);
}
xdr_destroy(&xdrs);
return (-1);
}
xdr_destroy(&xdrs);
return (-1);
}
xdr_destroy(&xdrs);
return (-1);
}
}
xdr_destroy(&xdrs);
return (0);
}
static void
{
}
static boolean_t
{
return (B_FALSE);
}
return (B_FALSE);
}
return (B_TRUE);
}
/*
* Free resources allocated for a door call. If the result buffer provided
* by the client is too small, doorfs will have allocated a new buffer,
* which must be unmapped here.
*
* This function must be called to free both the argument and result door
* buffers regardless of the status of the door call.
*/
static void
{
}