srvsvc_svc.c revision 29bd28862cfb8abbd3a0f0a4b17e08bbc3652836
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Server Service RPC (SRVSVC) server-side interface definition.
* The server service provides a remote administration interface.
*
* values.
*/
#include <unistd.h>
#include <netdb.h>
#include <strings.h>
#include <time.h>
#include <thread.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <libshare.h>
#include <smbsrv/libmlsvc.h>
#include <smbsrv/netrauth.h>
#include <smbsrv/smb_common_door.h>
#include "mlsvc.h"
/*
* Qualifier types for NetConnectEnum.
*/
#define SRVSVC_CONNECT_ENUM_NULL 0
#define SRVSVC_CONNECT_ENUM_SHARE 1
#define SRVSVC_CONNECT_ENUM_WKSTN 2
/*
* prefmaxlen: Client specified response buffer limit.
* resume_handle: Cookie used to track enumeration across multiple calls.
* n_total: Total number of entries.
* n_enum: Number of entries to enumerate (derived from prefmaxlen).
* n_skip: Number of entries to skip (from incoming resume handle).
* n_read: Number of objects returned for current enumeration request.
*/
typedef struct srvsvc_enum {
typedef struct srvsvc_sd {
} srvsvc_sd_t;
typedef struct srvsvc_netshare_setinfo {
char *nss_netname;
char *nss_comment;
char *nss_path;
typedef union srvsvc_netshare_getinfo {
struct mslm_NetShareInfo_0 nsg_info0;
struct mslm_NetShareInfo_1 nsg_info1;
struct mslm_NetShareInfo_2 nsg_info2;
struct mslm_NetShareInfo_501 nsg_info501;
struct mslm_NetShareInfo_502 nsg_info502;
struct mslm_NetShareInfo_503 nsg_info503;
struct mslm_NetShareInfo_1004 nsg_info1004;
struct mslm_NetShareInfo_1005 nsg_info1005;
struct mslm_NetShareInfo_1006 nsg_info1006;
struct mslm_NetShareInfo_1501 nsg_info1501;
struct mslm_NetFileEnum *);
struct mslm_NetFileEnum *);
ndr_xa_t *);
ndr_xa_t *);
ndr_xa_t *);
ndr_xa_t *);
ndr_xa_t *);
struct mslm_infonres *, srvsvc_enum_t *, int);
struct mslm_infonres *, srvsvc_enum_t *, int);
struct mslm_infonres *, srvsvc_enum_t *, int);
struct mslm_infonres *, srvsvc_enum_t *, int);
struct mslm_infonres *, srvsvc_enum_t *, int);
srvsvc_enum_t *, smb_share_t *, void *);
void *);
static char *srvsvc_share_mkpath(ndr_xa_t *, char *);
static int srvsvc_netconnect_qualifier(const char *);
static uint32_t srvsvc_sa_add(char *, char *, char *);
static uint32_t srvsvc_sa_delete(char *);
static char empty_string[1];
static ndr_stub_table_t srvsvc_stub_table[];
static ndr_service_t srvsvc_service = {
"SRVSVC", /* name */
"Server services", /* desc */
"\\srvsvc", /* endpoint */
PIPE_NTSVCS, /* sec_addr_port */
"4b324fc8-1670-01d3-1278-5a47bf6ee188", 3, /* abstract */
0, /* no bind_instance_size */
0, /* no bind_req() */
0, /* no unbind_and_close() */
0, /* use generic_call_stub() */
srvsvc_stub_table /* stub_table */
};
/*
* srvsvc_initialize
*
* This function registers the SRVSVC RPC interface with the RPC runtime
* library. It must be called in order to use either the client side
* or the server side functions.
*/
void
srvsvc_initialize(void)
{
(void) ndr_svc_register(&srvsvc_service);
}
/*
* srvsvc_s_NetConnectEnum
*
* List tree connections made to a share on this server or all tree
* connections established from a specific client. Administrator,
* Server Operator, Print Operator or Power User group membership
* is required to use this interface.
*
* There are three information levels: 0, 1, and 50. We don't support
* level 50, which is only used by Windows 9x clients.
*
* It seems Server Manger (srvmgr) only sends workstation as the qualifier
* and the Computer Management Interface on Windows 2000 doesn't request
* a list of connections.
*
* Return Values:
* ERROR_SUCCESS Success
* ERROR_ACCESS_DENIED Caller does not have access to this call.
* ERROR_INVALID_PARAMETER One of the parameters is invalid.
* ERROR_INVALID_LEVEL Unknown information level specified.
* ERROR_MORE_DATA Partial date returned, more entries available.
* ERROR_NOT_ENOUGH_MEMORY Insufficient memory is available.
* NERR_NetNameNotFound The share qualifier cannot be found.
* NERR_BufTooSmall The supplied buffer is too small.
*/
static int
{
char *qualifier;
int qualtype;
if (!ndr_is_poweruser(mxa)) {
return (NDR_DRC_OK);
}
if (qualtype == SRVSVC_CONNECT_ENUM_NULL) {
return (NDR_DRC_OK);
}
case 0:
break;
}
break;
case 1:
break;
}
break;
case 50:
break;
default:
break;
}
if (status != ERROR_SUCCESS)
return (NDR_DRC_OK);
}
static DWORD
{
return (ERROR_NOT_ENOUGH_MEMORY);
return (ERROR_SUCCESS);
}
static DWORD
{
return (ERROR_NOT_ENOUGH_MEMORY);
return (ERROR_SUCCESS);
}
/*
* srvsvc_netconnect_qualifier
*
* The qualifier is a string that specifies a share name or computer name
* for the connections of interest. If it is a share name then all the
* connections made to that share name are listed. If it is a computer
* name (it starts with two backslash characters), then NetConnectEnum
* lists all connections made from that computer to the specified server.
*/
static int
srvsvc_netconnect_qualifier(const char *qualifier)
{
return (SRVSVC_CONNECT_ENUM_NULL);
return (SRVSVC_CONNECT_ENUM_NULL);
return (SRVSVC_CONNECT_ENUM_WKSTN);
} else {
if (!smb_shr_exists((char *)qualifier))
return (SRVSVC_CONNECT_ENUM_NULL);
return (SRVSVC_CONNECT_ENUM_SHARE);
}
}
/*
* srvsvc_s_NetFileEnum
*
* Return information on open files or named pipes. Only members of the
* Administrators or Server Operators local groups are allowed to make
* this call. Currently, we only support Administrators.
*
* If basepath is null, all open resources are enumerated. If basepath
* is non-null, only resources that have basepath as a prefix should
* be returned.
*
* If username is specified (non-null), only files opened by username
* should be returned.
*
* Notes:
* 1. We don't validate the servername because we would have to check
* all primary IPs and the ROI seems unlikely to be worth it.
* 2. Both basepath and username are currently ignored because both
* Server Manger (NT 4.0) and CMI (Windows 2000) always set them to null.
*
* The level of information requested may be one of:
*
* 2 Return the file identification number.
* This level is not supported on Windows Me/98/95.
*
* 3 Return information about the file.
* This level is not supported on Windows Me/98/95.
*
* 50 Windows Me/98/95: Return information about the file.
*
* Note:
* If pref_max_len is unlimited and resume_handle is null, the client
* expects to receive all data in a single call.
* If we are unable to do fit all data in a single response, we would
* normally return ERROR_MORE_DATA with a partial list.
*
* Unfortunately, when both of these conditions occur, Server Manager
* pops up an error box with the message "more data available" and
* doesn't display any of the returned data. In this case, it is
* probably better to return ERROR_SUCCESS with the partial list.
* Windows 2000 doesn't have this problem because it always sends a
* non-null resume_handle.
*
* Return Values:
* ERROR_SUCCESS Success
* ERROR_ACCESS_DENIED Caller does not have access to this call.
* ERROR_INVALID_PARAMETER One of the parameters is invalid.
* ERROR_INVALID_LEVEL Unknown information level specified.
* ERROR_MORE_DATA Partial date returned, more entries available.
* ERROR_NOT_ENOUGH_MEMORY Insufficient memory is available.
* NERR_BufTooSmall The supplied buffer is too small.
*/
static int
{
if (!ndr_is_admin(mxa)) {
return (NDR_DRC_OK);
}
case 2:
break;
case 3:
break;
case 50:
break;
default:
break;
}
if (status != ERROR_SUCCESS) {
return (NDR_DRC_OK);
}
if (param->resume_handle)
*param->resume_handle = 0;
return (NDR_DRC_OK);
}
/*
* Build level 2 file information.
*
* On success, the caller expects that the info2, fi2 and entries_read
* fields have been set up.
*/
static DWORD
{
struct mslm_NetFileInfoBuf2 *fi2;
uint32_t entries_read = 0;
int i;
return (ERROR_NOT_ENOUGH_MEMORY);
return (ERROR_NOT_ENOUGH_MEMORY);
for (i = 0; i < 128; ++i) {
continue;
++entries_read;
++fi2;
}
return (ERROR_SUCCESS);
}
/*
* Build level 3 file information.
*
* On success, the caller expects that the info3, fi3 and entries_read
* fields have been set up.
*/
static DWORD
{
struct mslm_NetFileInfoBuf3 *fi3;
uint32_t entries_read = 0;
int i;
return (ERROR_NOT_ENOUGH_MEMORY);
return (ERROR_NOT_ENOUGH_MEMORY);
for (i = 0; i < 128; ++i) {
continue;
++entries_read;
++fi3;
}
return (ERROR_SUCCESS);
}
/*
* srvsvc_s_NetFileClose
*
* NetFileClose forces a file to close. This function can be used when
* an error prevents closure by any other means. Use NetFileClose with
* caution because it does not flush data, cached on a client, to the
* file before closing the file.
*
* Return Values
* ERROR_SUCCESS Operation succeeded.
* ERROR_ACCESS_DENIED Operation denied.
* NERR_FileIdNotFound No open file with the specified id.
*
* Note: MSDN suggests that the error code should be ERROR_FILE_NOT_FOUND
* but network captures using NT show NERR_FileIdNotFound.
* The NetFileClose2 MSDN page has the right error code.
*/
static int
{
if (!ndr_is_admin(mxa)) {
return (NDR_DRC_OK);
}
return (NDR_DRC_OK);
}
/*
* srvsvc_s_NetShareGetInfo
*
* Returns Win32 error codes.
*/
static int
{
struct mslm_NetShareInfo_0 *info0;
struct mslm_NetShareInfo_1 *info1;
struct mslm_NetShareInfo_2 *info2;
struct mslm_NetShareInfo_501 *info501;
struct mslm_NetShareInfo_502 *info502;
struct mslm_NetShareInfo_503 *info503;
struct mslm_NetShareInfo_1004 *info1004;
struct mslm_NetShareInfo_1005 *info1005;
struct mslm_NetShareInfo_1006 *info1006;
struct mslm_NetShareInfo_1501 *info1501;
if (status != NERR_Success) {
return (NDR_DRC_OK);
}
return (NDR_DRC_OK);
}
case 0:
break;
case 1:
break;
case 2:
info2->shi2_passwd = 0;
info2->shi2_permissions = 0;
info2->shi2_current_uses = 0;
break;
case 501:
info501->shi501_reserved = 0;
break;
case 502:
info502->shi502_passwd = 0;
info502->shi502_permissions = 0;
info502->shi502_current_uses = 0;
if (status == ERROR_SUCCESS) {
} else {
info502->shi502_reserved = 0;
}
break;
case 503:
info503->shi503_permissions = 0;
info503->shi503_current_uses = 0;
if (status == ERROR_SUCCESS) {
} else {
info503->shi503_reserved = 0;
}
break;
case 1004:
break;
case 1005:
info1005->shi1005_flags = 0;
case SMB_SHRF_CSC_DISABLED:
break;
case SMB_SHRF_CSC_AUTO:
break;
case SMB_SHRF_CSC_VDO:
break;
case SMB_SHRF_CSC_MANUAL:
default:
/*
* Default to CSC_CACHE_MANUAL_REINT.
*/
break;
}
break;
case 1006:
break;
case 1501:
if (status == ERROR_SUCCESS) {
} else {
info503->shi503_reserved = 0;
}
break;
default:
break;
}
if (status != ERROR_SUCCESS)
else
return (NDR_DRC_OK);
}
static uint32_t
{
if (status != ERROR_SUCCESS) {
if (status == ERROR_PATH_NOT_FOUND) {
}
return (status);
}
return (ERROR_NOT_ENOUGH_MEMORY);
if (status == ERROR_PATH_NOT_FOUND) {
}
return (status);
}
/*
* srvsvc_s_NetShareSetInfo
*
* This call is made by SrvMgr to set share information.
* Only power users groups can manage shares.
*
* To avoid misleading errors, we don't report an error
* when a FS doesn't support ACLs on shares.
*
* Returns Win32 error codes.
*/
static int
{
struct mslm_NetShareInfo_0 *info0;
struct mslm_NetShareInfo_1 *info1;
struct mslm_NetShareInfo_2 *info2;
struct mslm_NetShareInfo_501 *info501;
struct mslm_NetShareInfo_502 *info502;
struct mslm_NetShareInfo_503 *info503;
struct mslm_NetShareInfo_1004 *info1004;
struct mslm_NetShareInfo_1005 *info1005;
struct mslm_NetShareInfo_1501 *info1501;
if (!ndr_is_poweruser(mxa)) {
goto netsharesetinfo_exit;
}
goto netsharesetinfo_exit;
}
goto netsharesetinfo_exit;
}
case 0:
break;
case 1:
break;
case 2:
break;
case 501:
info501 = (struct mslm_NetShareInfo_501 *)
break;
case 502:
info502 = (struct mslm_NetShareInfo_502 *)
break;
case 503:
info503 = (struct mslm_NetShareInfo_503 *)
break;
case 1004:
info1004 = (struct mslm_NetShareInfo_1004 *)
break;
case 1005:
info1005 = (struct mslm_NetShareInfo_1005 *)
break;
case 1006:
/*
* We don't limit the maximum number of concurrent
* connections to a share.
*/
break;
case 1501:
info1501 = (struct mslm_NetShareInfo_1501 *)
if (status == ERROR_PATH_NOT_FOUND)
}
break;
default:
break;
}
if (status != ERROR_SUCCESS)
return (NDR_DRC_OK);
}
static uint32_t
{
if (nerr == ERROR_PATH_NOT_FOUND)
nerr = NERR_Success;
}
return (nerr);
}
/*
* Update transient shares. This includes autohome shares.
*/
static uint32_t
{
if (nerr != NERR_Success)
return (nerr);
}
return (nerr);
}
return (NERR_Success);
}
static uint32_t
{
case CSC_CACHE_AUTO_REINT:
break;
case CSC_CACHE_VDO:
break;
case CSC_CACHE_NONE:
break;
case CSC_CACHE_MANUAL_REINT:
break;
default:
return (NERR_Success);
}
return (NERR_Success);
return (nerr);
}
return (smb_shr_modify(si));
}
/*
* srvsvc_s_NetSessionEnum
*
* Level 1 request is made by (Server Manager (srvmgr) on NT Server when
* the user info icon is selected.
*
* On success, the return value is NERR_Success.
* On error, the return value can be one of the following error codes:
*
* ERROR_ACCESS_DENIED The user does not have access to the requested
* information.
* ERROR_INVALID_LEVEL The value specified for the level is invalid.
* ERROR_INVALID_PARAMETER The specified parameter is invalid.
* ERROR_MORE_DATA More entries are available. Specify a large
* enough buffer to receive all entries.
* ERROR_NOT_ENOUGH_MEMORY Insufficient memory is available.
* NERR_ClientNameNotFound A session does not exist with the computer name.
* NERR_InvalidComputer The computer name is invalid.
* NERR_UserNotFound The user name could not be found.
*/
static int
{
struct mslm_infonres *infonres;
return (NDR_DRC_OK);
}
infonres->entriesread = 0;
param->total_entries = 0;
return (NDR_DRC_OK);
case 0:
break;
case 1:
break;
case 2:
break;
case 10:
break;
case 502:
mxa);
break;
default:
break;
}
if (status != 0) {
return (NDR_DRC_OK);
}
return (NDR_DRC_OK);
}
/*
* mlsvc_NetSessionEnumLevel0
*
* Build the level 0 session information.
*/
static DWORD
{
struct mslm_SESSION_INFO_0 *info0;
char *workstation;
char ipaddr_buf[INET6_ADDRSTRLEN];
int i;
ulist = smb_ulist_alloc();
return (ERROR_NOT_ENOUGH_MEMORY);
if (mlsvc_get_user_list(ulist) != 0) {
return (ERROR_NOT_ENOUGH_MEMORY);
}
return (ERROR_NOT_ENOUGH_MEMORY);
}
for (i = 0; i < n_sessions; ++i, user++) {
}
return (ERROR_NOT_ENOUGH_MEMORY);
}
}
return (ERROR_SUCCESS);
}
/*
* mlsvc_NetSessionEnumLevel1
*
* Build the level 1 session information.
*/
static DWORD
{
struct mslm_SESSION_INFO_1 *info1;
char *workstation;
char account[MAXNAMELEN];
char ipaddr_buf[INET6_ADDRSTRLEN];
int i;
ulist = smb_ulist_alloc();
return (ERROR_NOT_ENOUGH_MEMORY);
if (mlsvc_get_user_list(ulist) != 0) {
return (ERROR_NOT_ENOUGH_MEMORY);
}
return (ERROR_NOT_ENOUGH_MEMORY);
}
for (i = 0; i < n_sessions; ++i, user++) {
}
return (ERROR_NOT_ENOUGH_MEMORY);
}
info1[i].sesi1_itime = 0;
info1[i].sesi1_uflags =
}
return (ERROR_SUCCESS);
}
/*
* mlsvc_NetSessionEnumLevel2
*
* Build the level 2 session information.
*/
static DWORD
{
struct mslm_SESSION_INFO_2 *info2;
char *workstation;
char account[MAXNAMELEN];
char ipaddr_buf[INET6_ADDRSTRLEN];
int i;
return (ERROR_NOT_ENOUGH_MEMORY);
if (mlsvc_get_user_list(ulist) != 0) {
return (ERROR_NOT_ENOUGH_MEMORY);
}
return (ERROR_NOT_ENOUGH_MEMORY);
}
for (i = 0; i < n_sessions; ++i, user++) {
}
return (ERROR_NOT_ENOUGH_MEMORY);
}
info2[i].sesi2_itime = 0;
info2[i].sesi2_uflags =
}
return (ERROR_SUCCESS);
}
/*
* mlsvc_NetSessionEnumLevel10
*
* Build the level 10 session information.
*/
static DWORD
{
struct mslm_SESSION_INFO_10 *info10;
char *workstation;
char account[MAXNAMELEN];
char ipaddr_buf[INET6_ADDRSTRLEN];
int i;
return (ERROR_NOT_ENOUGH_MEMORY);
if (mlsvc_get_user_list(ulist) != 0) {
return (ERROR_NOT_ENOUGH_MEMORY);
}
return (ERROR_NOT_ENOUGH_MEMORY);
}
for (i = 0; i < n_sessions; ++i, user++) {
}
return (ERROR_NOT_ENOUGH_MEMORY);
}
info10[i].sesi10_itime = 0;
}
return (ERROR_SUCCESS);
}
/*
* mlsvc_NetSessionEnumLevel502
*
* Build the level 502 session information.
*/
static DWORD
{
struct mslm_SESSION_INFO_502 *info502;
char *workstation;
char account[MAXNAMELEN];
char ipaddr_buf[INET6_ADDRSTRLEN];
int i;
return (ERROR_NOT_ENOUGH_MEMORY);
if (mlsvc_get_user_list(ulist) != 0) {
return (ERROR_NOT_ENOUGH_MEMORY);
}
return (ERROR_NOT_ENOUGH_MEMORY);
}
for (i = 0; i < n_sessions; ++i, user++) {
}
return (ERROR_NOT_ENOUGH_MEMORY);
}
info502[i].sesi502_itime = 0;
info502[i].sesi502_uflags =
}
return (ERROR_SUCCESS);
}
/*
* srvsvc_s_NetSessionDel
*
* Ends a network session between a server and a workstation.
* On NT only members of the Administrators or Account Operators
* local groups are permitted to use NetSessionDel.
*
* Return Values
* If the function succeeds, the return value is NERR_Success/
* ERROR_SUCCESS. If the function fails, the return value can be
* one of the following error codes:
*
* ERROR_ACCESS_DENIED The user does not have access to the
* requested information.
* ERROR_INVALID_PARAMETER The specified parameter is invalid.
* ERROR_NOT_ENOUGH_MEMORY Insufficient memory is available.
* NERR_ClientNameNotFound A session does not exist with that
* computer name.
*/
static int
{
if (!ndr_is_poweruser(mxa)) {
return (NDR_DRC_OK);
}
return (NDR_DRC_OK);
}
/*
* SRVSVC NetServerGetInfo
*
* IN LPTSTR servername,
* IN DWORD level,
* OUT union switch(level) {
* case 100: mslm_SERVER_INFO_100 *p100;
* case 101: mslm_SERVER_INFO_101 *p101;
* case 102: mslm_SERVER_INFO_102 *p102;
* ...
* default: char *nullptr;
* } bufptr,
* OUT DWORD status
*/
static int
{
struct mslm_SERVER_INFO_100 *info100;
struct mslm_SERVER_INFO_101 *info101;
struct mslm_SERVER_INFO_102 *info102;
struct mslm_SERVER_INFO_502 *info502;
struct mslm_SERVER_INFO_503 *info503;
char sys_comment[SMB_PI_MAX_COMMENT];
char hostname[NETBIOS_NAME_SZ];
return (ERROR_NOT_ENOUGH_MEMORY);
}
sizeof (sys_comment));
if (*sys_comment == '\0')
case 100:
break;
case 101:
info101->sv101_version_minor = 0;
break;
case 102:
info102->sv102_version_minor = 0;
/*
* The following level 102 fields are defaulted to zero
* by virtue of the call to bzero above.
*
* sv102_users
* sv102_disc
* sv102_hidden
* sv102_announce
* sv102_anndelta
* sv102_licenses
* sv102_userpath
*/
break;
case 502:
#ifdef SRVSVC_SATISFY_SMBTORTURE
break;
#else
return (NDR_DRC_OK);
#endif /* SRVSVC_SATISFY_SMBTORTURE */
case 503:
#ifdef SRVSVC_SATISFY_SMBTORTURE
break;
#else
return (NDR_DRC_OK);
#endif /* SRVSVC_SATISFY_SMBTORTURE */
default:
sizeof (struct mslm_NetServerGetInfo_result));
return (NDR_DRC_OK);
}
return (NDR_DRC_OK);
}
/*
* NetRemoteTOD
*
* Returns information about the time of day on this server.
*
* typedef struct _TIME_OF_DAY_INFO {
* DWORD tod_elapsedt; // seconds since 00:00:00 January 1 1970 GMT
* DWORD tod_msecs; // arbitrary milliseconds (since reset)
* DWORD tod_hours; // current hour [0-23]
* DWORD tod_mins; // current minute [0-59]
* DWORD tod_secs; // current second [0-59]
* DWORD tod_hunds; // current hundredth (0.01) second [0-99]
* LONG tod_timezone; // time zone of the server
* DWORD tod_tinterval; // clock tick time interval
* DWORD tod_day; // day of the month [1-31]
* DWORD tod_month; // month of the year [1-12]
* DWORD tod_year; // current year
* DWORD tod_weekday; // day of the week since Sunday [0-6]
* } TIME_OF_DAY_INFO;
*
* The time zone of the server is calculated in minutes from Greenwich
* Mean Time (GMT). For time zones west of Greenwich, the value is
* positive; for time zones east of Greenwich, the value is negative.
* A value of -1 indicates that the time zone is undefined.
*
* The clock tick value represents a resolution of one ten-thousandth
* (0.0001) second.
*/
static int
{
struct mslm_TIME_OF_DAY_INFO *tod;
(void) gettimeofday(&time_val, 0);
return (ERROR_NOT_ENOUGH_MEMORY);
}
return (NDR_DRC_OK);
}
/*
* srvsvc_s_NetNameValidate
*
* Perform name validation.
*
* The share name is considered invalid if it contains any of the
* following character (MSDN 236388).
*
* " / \ [ ] : | < > + ; , ? * =
*
* Returns Win32 error codes.
*/
/*ARGSUSED*/
static int
{
char *name;
int len;
return (NDR_DRC_OK);
}
return (NDR_DRC_OK);
}
case NAMETYPE_SHARE:
if (smb_shr_chkname(name))
else
break;
case NAMETYPE_USER:
case NAMETYPE_PASSWORD:
case NAMETYPE_GROUP:
case NAMETYPE_COMPUTER:
case NAMETYPE_EVENT:
case NAMETYPE_DOMAIN:
case NAMETYPE_SERVICE:
case NAMETYPE_NET:
case NAMETYPE_MESSAGE:
case NAMETYPE_MESSAGEDEST:
case NAMETYPE_SHAREPASSWORD:
case NAMETYPE_WORKGROUP:
break;
default:
break;
}
return (NDR_DRC_OK);
}
/*
* srvsvc_s_NetShareAdd
*
* Add a new share. Only power users groups can manage shares.
*
* This interface is used by the rmtshare command from the NT resource
* kit. Rmtshare allows a client to add or remove shares on a server
* from the client's command line.
*
* Returns Win32 error codes.
*/
static int
{
struct mslm_NetShareInfo_2 *info2;
struct mslm_NetShareInfo_502 *info502;
char realpath[MAXPATHLEN];
if (!ndr_is_poweruser(mxa)) {
return (NDR_DRC_OK);
}
case 2:
break;
case 502:
info502 = (struct mslm_NetShareInfo_502 *)
break;
default:
return (NDR_DRC_OK);
}
return (NDR_DRC_OK);
}
return (NDR_DRC_OK);
}
/*
* Derive the real path which will be stored in the
* directory field of the smb_share_t structure
* from the path field in this RPC request.
*/
if (parm_stat != NERR_Success) {
return (NDR_DRC_OK);
}
(char *)info2->shi2_comment);
}
return (NDR_DRC_OK);
}
/*
* srvsvc_estimate_objcnt
*
* Estimate the number of objects that will fit in prefmaxlen.
*/
static uint32_t
{
if (obj_size == 0)
return (0);
return (0);
return (n_obj);
}
/*
* srvsvc_s_NetShareEnum
*
* Enumerate all shares (see also NetShareEnumSticky).
*
* Request for various levels of information about our shares.
* Level 0: share names.
* Level 1: share name, share type and comment field.
* Level 2: everything that we know about the shares.
* Level 501: level 1 + flags (flags must be zero).
* Level 502: level 2 + security descriptor.
*/
static int
{
struct mslm_infonres *infonres;
return (NDR_DRC_OK);
}
infonres->entriesread = 0;
else
if (param->resume_handle) {
}
case 0:
break;
case 1:
break;
case 2:
break;
case 501:
break;
case 502:
break;
default:
break;
}
if (status != 0) {
return (NDR_DRC_OK);
}
if (param->resume_handle)
*param->resume_handle = 0;
return (NDR_DRC_OK);
}
if (param->resume_handle &&
} else {
*param->resume_handle = 0;
}
}
return (NDR_DRC_OK);
}
/*
* srvsvc_s_NetShareEnumSticky
*
* Enumerate sticky shares: all shares except those marked STYPE_SPECIAL.
* Except for excluding STYPE_SPECIAL shares, NetShareEnumSticky is the
* same as NetShareEnum.
*
* Request for various levels of information about our shares.
* Level 0: share names.
* Level 1: share name, share type and comment field.
* Level 2: everything that we know about the shares.
* Level 501: not valid for this request.
* Level 502: level 2 + security descriptor.
*
* We set n_skip to resume_handle, which is used to find the appropriate
* place to resume. The resume_handle is similar to the readdir cookie.
*/
static int
{
struct mslm_infonres *infonres;
return (NDR_DRC_OK);
}
infonres->entriesread = 0;
else
if (param->resume_handle) {
}
case 0:
break;
case 1:
break;
case 2:
break;
case 502:
break;
case 501:
default:
break;
}
if (status != ERROR_SUCCESS) {
return (NDR_DRC_OK);
}
if (param->resume_handle)
*param->resume_handle = 0;
return (NDR_DRC_OK);
}
if (param->resume_handle &&
} else {
*param->resume_handle = 0;
}
}
return (NDR_DRC_OK);
}
/*
* NetShareEnum Level 0
*/
static DWORD
{
struct mslm_NetShareInfo_0 *info0;
return (ERROR_SUCCESS);
return (ERROR_NOT_ENOUGH_MEMORY);
continue;
}
++se->se_resume_handle;
continue;
continue;
break;
}
if (status != ERROR_SUCCESS)
break;
}
}
return (ERROR_SUCCESS);
}
/*
* NetShareEnum Level 1
*/
static DWORD
{
struct mslm_NetShareInfo_1 *info1;
return (ERROR_SUCCESS);
return (ERROR_NOT_ENOUGH_MEMORY);
continue;
}
++se->se_resume_handle;
continue;
continue;
break;
}
if (status != ERROR_SUCCESS)
break;
}
}
return (ERROR_SUCCESS);
}
/*
* NetShareEnum Level 2
*/
static DWORD
{
struct mslm_NetShareInfo_2 *info2;
return (ERROR_SUCCESS);
return (ERROR_NOT_ENOUGH_MEMORY);
continue;
}
++se->se_resume_handle;
continue;
continue;
break;
}
if (status != ERROR_SUCCESS)
break;
}
}
return (ERROR_SUCCESS);
}
/*
* NetShareEnum Level 501
*/
static DWORD
{
struct mslm_NetShareInfo_501 *info501;
return (ERROR_SUCCESS);
return (ERROR_NOT_ENOUGH_MEMORY);
continue;
}
++se->se_resume_handle;
continue;
continue;
break;
}
if (status != ERROR_SUCCESS)
break;
}
}
return (ERROR_SUCCESS);
}
/*
* NetShareEnum Level 502
*/
static DWORD
{
struct mslm_NetShareInfo_502 *info502;
return (ERROR_SUCCESS);
return (ERROR_NOT_ENOUGH_MEMORY);
continue;
}
++se->se_resume_handle;
continue;
continue;
break;
}
if (status != ERROR_SUCCESS)
break;
}
}
return (ERROR_SUCCESS);
}
/*
* mlsvc_NetShareEnumCommon
*
* Build the levels 0, 1, 2, 501 and 502 share information. This function
* is called by the various NetShareEnum levels for each share. If
* we cannot build the share data for some reason, we return an error
* but the actual value of the error is not important to the caller.
* The caller just needs to know not to include this info in the RPC
* response.
*
* Returns:
* ERROR_SUCCESS
* ERROR_NOT_ENOUGH_MEMORY
* ERROR_INVALID_LEVEL
*/
static DWORD
{
struct mslm_NetShareInfo_0 *info0;
struct mslm_NetShareInfo_1 *info1;
struct mslm_NetShareInfo_2 *info2;
struct mslm_NetShareInfo_501 *info501;
struct mslm_NetShareInfo_502 *info502;
return (ERROR_NOT_ENOUGH_MEMORY);
case 0:
break;
case 1:
break;
case 2:
info2[i].shi2_permissions = 0;
info2[i].shi2_current_uses = 0;
break;
case 501:
info501[i].shi501_reserved = 0;
break;
case 502:
info502[i].shi502_permissions = 0;
info502[i].shi502_current_uses = 0;
} else {
info502[i].shi502_reserved = 0;
}
break;
default:
return (ERROR_INVALID_LEVEL);
}
return (ERROR_SUCCESS);
}
/*
* srvsvc_add_autohome
*
* Add the autohome share for the user. The share must not be a permanent
* share to avoid duplicates.
*/
static boolean_t
{
return (B_FALSE);
return (B_FALSE);
return (status == ERROR_SUCCESS);
}
/*
* srvsvc_share_mkpath
*
* Create the share path required by the share enum calls. The path
* is created in a heap buffer ready for use by the caller.
*
* Some Windows over-the-wire backup applications do not work unless a
* drive letter is present in the share path. We don't care about the
* drive letter since the path is fully qualified with the volume name.
*
* Windows clients seem to be mostly okay with forward slashes in
* share paths but they cannot handle one immediately after the drive
* letter, i.e. B:/. For consistency we convert all the slashes in
* the path.
*
* Returns a pointer to a heap buffer containing the share path, which
* could be a null pointer if the heap allocation fails.
*/
static char *
{
char tmpbuf[MAXPATHLEN];
char *p;
/*
*/
p = path;
p += strspn(p, "/");
p += strcspn(p, "/");
p += strspn(p, "/");
}
static int
{
char *path;
return (NDR_DRC_OK);
}
return (NDR_DRC_OK);
}
}
return (NDR_DRC_OK);
}
/*
* srvsvc_s_NetShareDel
*
* Delete a share. Only the administrator, or a member of the domain
* administrators group, is allowed to delete shares.
*
* This interface is used by the rmtshare command from the NT resource
* kit. Rmtshare allows a client to add or remove shares on a server
* from the client's command line.
*
* Returns Win32 error codes.
*/
static int
{
if (!ndr_is_poweruser(mxa) ||
return (NDR_DRC_OK);
}
return (NDR_DRC_OK);
}
/*
* srvsvc_s_NetGetFileSecurity
*
*
* Right now, just returns ERROR_ACCESS_DENIED, because we cannot
* get the requested SD here in RPC code.
*/
/*ARGSUSED*/
static int
{
return (NDR_DRC_OK);
}
/*
* srvsvc_s_NetSetFileSecurity
*
*
* Right now, just returns ERROR_ACCESS_DENIED, because we cannot
* set the requested SD here in RPC code.
*/
/*ARGSUSED*/
static int
{
return (NDR_DRC_OK);
}
/*
* If the default "smb" share group exists then return the group
* handle, otherwise create the group and return the handle.
*
* All shares created via the srvsvc will be added to the "smb"
* group.
*/
static sa_group_t
{
int err;
return (group);
return (NULL);
(void) sa_remove_group(group);
}
return (group);
}
/*
* Stores the given share in sharemgr
*/
static uint32_t
{
int err;
return (NERR_InternalError);
return (NERR_InternalError);
}
return (NERR_InternalError);
}
}
if (new_share)
(void) sa_remove_share(share);
return (NERR_InternalError);
}
}
return (status);
}
/*
* Removes the share from sharemgr
*/
static uint32_t
srvsvc_sa_delete(char *sharename)
{
return (NERR_InternalError);
}
return (status);
}
/*
* Update the share information.
*/
static uint32_t
{
return (NERR_InternalError);
return (NERR_InternalError);
}
return (NERR_InternalError);
}
info->nss_netname);
}
}
if (renamed) {
if (nerr != NERR_Success)
return (nerr);
}
return (nerr);
}
/*
* Update the share flags.
*/
static uint32_t
{
char *value;
return (NERR_InternalError);
return (NERR_InternalError);
}
return (NERR_InternalError);
}
return (NERR_InternalError);
}
return (NERR_Success);
}
static ndr_stub_table_t srvsvc_stub_table[] = {
{0}
};