smb_common_tree.c revision 6537f381d2d9e7b4e2f7b29c3e7a3f13be036f2e
/*
* 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"
/*
* Common code for tree connections.
*/
#include <smbsrv/smb_incl.h>
#include <smbsrv/smb_fsops.h>
#include <smbsrv/smb_door_svc.h>
#define SMB_TREE_EMSZ 64
#define ADMINISTRATORS_SID "S-1-5-32-544"
int smb_tcon_mute = 0;
void smbsr_share_report(struct smb_request *, char *, char *, char *);
int smb_get_stype(const char *, const char *, int32_t *);
/*
* smbsr_connect_tree
*
* Set up a share. A Uniform Naming Convention (UNC) string is suppose to
* be in the form: \\HOST\SHARENAME. A sharename alone is also acceptable.
* We don't actually audit the host, we just ensure that the \ are present
* and extract the share name. Share names are case insensitive so we map
* the share name to lower-case. So it is important that all internal
* mechanisms (user interface, etc. use lower-case names.
*/
int
{
char errmsg[SMB_TREE_EMSZ];
char *sharename;
char *access_msg;
int rc;
errmsg[0] = '\0';
if (sharename[0] == '\\') {
/*
* Looks like a UNC path, make sure the format is correct.
*/
return (ERRinvnetname);
}
return (ERRinvnetname);
}
++sharename;
/*
* This should be a sharename: no embedded '\' allowed.
*/
return (ERRinvnetname);
}
return (ERROR_BAD_DEV_TYPE);
}
access_msg = "access denied";
/*
* Windows 2000 may try to connect to user shares using
* an anonymous IPC connection. NT returns access denied.
*/
return (rc);
}
if (SMB_TREE_IS_READ_ONLY(sr))
access_msg = "ro access granted";
else
access_msg = "rw access granted";
}
return (0);
}
/*
* smbsr_share_report
*
* Report share access result to syslog.
*/
/*ARGSUSED*/
void
char *access_msg, char *errmsg)
{
if (smb_tcon_mute)
return;
/*
* Only report normal users, i.e. ignore W2K misuse
* of the IPC connection by filtering out internal
* names such as nobody and root.
*/
return;
}
}
}
/*
* smbsr_setup_share
*
* This is where the real of setting up share is done.
* Note that ambiguities are resolved by assuming that a directory
* is being requested.
*
* Returns 0 on success or a non-zero error code on failure.
*/
int
char *errmsg)
{
char last_component[MAXNAMELEN];
char *resource;
int rc;
int is_admin;
/*
* XXX Host based access control check to go here.
*/
if (STYPE_ISIPC(stype)) {
return (ERRaccess);
}
return (ERRaccess);
return (0);
}
/*
* From here on we can assume that this is a disk share.
*/
return (ERRaccess);
}
/*
* Handle the default administration shares: C$, D$ etc.
* Only a user with admin rights is allowed to map these
* shares.
*/
if (is_admin == NERR_InternalError) {
return (ERRaccess);
}
if (is_admin) {
if (sid) {
if (rc == 0) {
return (ERRaccess);
}
}
}
NERR_Success) {
return (ERRinvnetname);
}
#ifdef HOST_ACCESS
/*
* XXX This needs some sharemgr work
*/
if (hostaccess == APRV_ACC_RO)
#endif /* HOST_ACCESS */
/*
* No password or password OK. Now check that the directory
* actually exists.
*
* The snode reference from smb_pathname_reduce() will not be
* released in this routine (except in an error path) because
* trees need a reference to their root node. The reference
* will be released upon tree deallocation.
*/
if (rc) {
return (ERRinvnetname);
}
if (rc) {
rc = ERRinvnetname;
goto error_out;
}
rc = ERRinvnetname;
goto error_out;
}
goto error_out;
}
return (0);
if (snode)
return (rc);
}
/*
* smb_get_stype
*
* Map the service to a resource type. Valid values for service
* (CIFS/1.0 section 4.1.4) are:
*
* A: Disk share
* LPT1: Printer
* IPC Named pipe
* COMM Communications device
* ????? Any type of device (wildcard)
*
* We support IPC and disk shares; anything else is currently treated
* as an error. IPC$ is reserved as the named pipe share.
*/
int
{
const char *any = "?????";
return (0);
}
}
return (-1);
return (0);
}
return (-1);
}
/*
* smbsr_rq_notify
*
* Notify all requests, except sr, associated with the specified tree
* that it's time to complete.
* It's assumed that the tree has already been clipped from the session
* list so that no new requests can be added to the list while we're in
* here.
*
* Note that sr may be null.
*
* Returns:
*/
void
{
struct smb_request *asr;
while (asr) {
}
}
}