smb_usr.c revision 1b34bc4aa5ecbd590d45845d21c8478049df6dcf
/*
* Copyright (c) 2000-2001 Boris Popov
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Boris Popov.
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: smb_usr.c,v 1.15 2004/12/13 00:25:18 lindak Exp $
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef APPLE
#include <sys/smb_apple.h>
#include <sys/smb_iconv.h>
#else
#include <netsmb/smb_osdep.h>
#endif
#include <netsmb/smb_conn.h>
#include <netsmb/smb_subr.h>
/*
* helpers for nsmb device. Can be moved to the smb_dev.c file.
*/
/*
* Moved the access checks here, just becuase
* this was a more convenient place to do it
* than in every function calling this.
*/
static int
{
/*
* Only superuser can specify a UID or GID.
*/
else {
/*
* Do we have the privilege to create with the
* specified uid? (does uid == cr->cr_uid, etc.)
* MacOS would want suser(), or similar here.
*/
return (EPERM);
}
else {
/*
* Do we have the privilege to create with the
* specified gid? (one of our groups?)
*/
secpolicy_vnode_create_gid(cr) == 0)
else
return (EPERM);
}
/*
* Valid codesets? XXX
*/
if (dp->ioc_localcs[0] == 0) {
#ifdef NOTYETRESOLVED
SMBERROR("no local charset ? dp->ioc_localcs[0]: %d\n",
dp->ioc_localcs[0]);
return (EINVAL);
#endif
} else
/*
* Check for valid sa_family.
* XXX: Just NetBIOS for now.
*/
return (EINVAL);
/* If specified, local AF must be the same. */
return (EINVAL);
}
return (EFAULT);
}
return (0);
}
static void
{
}
static void
{
}
}
static int
{
return (0);
}
int
{
int error = 0;
return (EINVAL);
return (EINVAL);
if (error)
goto out;
if (error == 0)
out:
return (error);
}
int
{
int error = 0;
return (EINVAL);
if (error)
return (error);
if (error)
goto out;
}
if (error == 0) {
/*
* Used to copyout ioc_outtok, outtoklen here,
* but that's now in smb_dev. (our caller)
*
* If this call asked for extended security and
* the server does not support it, clear the
* flag so the caller knows this.
*
* XXX: Should just add sv_caps to ioc_ssn,
* set the new sv_caps field here, and let
* let the copyout of ioc_ssn handle it.
*/
SMBSDEBUG("turned off extended security");
}
}
out:
return (error);
}
int
{
int error;
return (EINVAL);
if (error)
goto out;
/*
* Moved the copyout of ioc_outtok to
* smb_dev.c (our caller)
*/
out:
return (error);
}
int
{
int error;
return (EINVAL);
if (error)
goto out;
}
out:
if (sspecp)
return (error);
}
/*
* Connect to the resource specified by smbioc_ossn structure.
* It may either find an existing connection or try to establish a new one.
* If no errors occured smb_vc returned locked and referenced.
*/
int
{
char *p;
int error;
case SMB_COM_TRANSACTION2:
case SMB_COM_TREE_CONNECT:
case SMB_COM_TREE_DISCONNECT:
case SMB_COM_NEGOTIATE:
case SMB_COM_LOGOFF_ANDX:
return (EPERM);
}
if (error)
return (error);
if (error)
goto bad;
if (error)
goto bad;
if (error)
goto bad;
goto bad;
}
if (error)
goto bad;
goto bad;
}
bad:
return (error);
}
static int
{
int error;
if (len == 0)
return (0);
if (error)
return (error);
}
int
{
return (EINVAL);
return (ENOMEM);
scred);
if (error)
return (error);
if (len > 1)
goto bad;
}
}
t2p->t2_maxscount = 0;
dp->ioc_tparam);
if (error)
goto bad;
if (error)
goto bad;
if (error)
goto bad;
#ifdef lint
m = m;
#endif
goto bad;
}
if (error) {
goto bad;
}
} else
dp->ioc_rparamcnt = 0;
#ifdef lint
m = m;
#endif
goto bad;
}
if (error) {
goto bad;
}
} else
dp->ioc_rdatacnt = 0;
bad:
return (error);
}
/*
* Helper for nsmb_ioctl cases
* SMBIOC_READ, SMBIOC_WRITE
*/
int
{
int error;
switch (cmd) {
case SMBIOC_READ:
break;
case SMBIOC_WRITE:
break;
default:
return (ENODEV);
}
/*
* On return ioc_cnt holds the
* number of bytes transferred.
*/
return (error);
}