2004-04-08 23:06:37 +04:00
/*
Unix SMB / CIFS implementation .
endpoint server for the srvsvc pipe
2006-05-21 16:15:04 +04:00
Copyright ( C ) Stefan ( metze ) Metzmacher 2004 - 2006
2004-04-08 23:06:37 +04:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2004-04-08 23:06:37 +04:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2004-04-08 23:06:37 +04:00
*/
# include "includes.h"
2006-07-23 22:43:07 +04:00
# include "ntvfs/ntvfs.h"
2004-11-02 10:42:47 +03:00
# include "rpc_server/dcerpc_server.h"
2004-11-01 13:30:34 +03:00
# include "librpc/gen_ndr/ndr_srvsvc.h"
2004-04-08 23:06:37 +04:00
# include "rpc_server/common/common.h"
2010-10-21 10:12:31 +04:00
# include "rpc_server/common/share.h"
2006-04-26 16:07:01 +04:00
# include "auth/auth.h"
# include "libcli/security/security.h"
2004-12-06 14:10:15 +03:00
# include "system/time.h"
2006-05-21 16:15:04 +04:00
# include "rpc_server/srvsvc/proto.h"
2007-09-08 16:42:09 +04:00
# include "param/param.h"
2004-04-08 23:06:37 +04:00
2020-08-07 23:27:39 +03:00
# undef strcasecmp
# undef strncasecmp
2006-04-26 16:07:01 +04:00
# define SRVSVC_CHECK_ADMIN_ACCESS do { \
2018-11-03 03:19:51 +03:00
struct auth_session_info * si = dcesrv_call_session_info ( dce_call ) ; \
struct security_token * t = si - > security_token ; \
2006-04-26 16:07:01 +04:00
if ( ! security_token_has_builtin_administrators ( t ) & & \
2010-09-21 01:14:38 +04:00
! security_token_has_sid ( t , & global_sid_Builtin_Server_Operators ) ) { \
2006-04-26 16:07:01 +04:00
return WERR_ACCESS_DENIED ; \
} \
} while ( 0 )
2004-04-08 23:06:37 +04:00
/*
srvsvc_NetCharDevEnum
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetCharDevEnum ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-05-04 10:07:52 +04:00
struct srvsvc_NetCharDevEnum * r )
2004-04-08 23:06:37 +04:00
{
2008-10-30 18:34:28 +03:00
* r - > out . totalentries = 0 ;
2004-04-08 23:06:37 +04:00
2008-10-30 18:34:28 +03:00
switch ( r - > in . info_ctr - > level ) {
2004-04-08 23:06:37 +04:00
case 0 :
2008-10-30 18:34:28 +03:00
r - > out . info_ctr - > ctr . ctr0 = talloc ( mem_ctx , struct srvsvc_NetCharDevCtr0 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info_ctr - > ctr . ctr0 ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 18:34:28 +03:00
r - > out . info_ctr - > ctr . ctr0 - > count = 0 ;
r - > out . info_ctr - > ctr . ctr0 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-08 23:06:37 +04:00
case 1 :
2008-10-30 18:34:28 +03:00
r - > out . info_ctr - > ctr . ctr1 = talloc ( mem_ctx , struct srvsvc_NetCharDevCtr1 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info_ctr - > ctr . ctr1 ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 18:34:28 +03:00
r - > out . info_ctr - > ctr . ctr1 - > count = 0 ;
r - > out . info_ctr - > ctr . ctr1 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-08 23:06:37 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-04-08 23:06:37 +04:00
}
}
/*
srvsvc_NetCharDevGetInfo
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetCharDevGetInfo ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetCharDevGetInfo * r )
{
2008-10-29 22:44:04 +03:00
ZERO_STRUCTP ( r - > out . info ) ;
2004-12-31 08:34:31 +03:00
2004-04-08 23:06:37 +04:00
switch ( r - > in . level ) {
case 0 :
2004-12-31 08:34:31 +03:00
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
case 1 :
2004-12-31 08:34:31 +03:00
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-04-08 23:06:37 +04:00
}
}
/*
srvsvc_NetCharDevControl
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetCharDevControl ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetCharDevControl * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NetCharDevQEnum
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetCharDevQEnum ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-05-04 10:07:52 +04:00
struct srvsvc_NetCharDevQEnum * r )
2004-04-08 23:06:37 +04:00
{
2008-10-30 18:49:21 +03:00
* r - > out . totalentries = 0 ;
2004-04-08 23:06:37 +04:00
2008-10-30 18:49:21 +03:00
switch ( r - > in . info_ctr - > level ) {
2004-04-08 23:06:37 +04:00
case 0 :
2004-12-31 08:34:31 +03:00
{
2008-10-30 18:49:21 +03:00
r - > out . info_ctr - > ctr . ctr0 = talloc ( mem_ctx , struct srvsvc_NetCharDevQCtr0 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info_ctr - > ctr . ctr0 ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 18:49:21 +03:00
r - > out . info_ctr - > ctr . ctr0 - > count = 0 ;
r - > out . info_ctr - > ctr . ctr0 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
case 1 :
2004-12-31 08:34:31 +03:00
{
2008-10-30 18:49:21 +03:00
r - > out . info_ctr - > ctr . ctr1 = talloc ( mem_ctx , struct srvsvc_NetCharDevQCtr1 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info_ctr - > ctr . ctr1 ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 18:49:21 +03:00
r - > out . info_ctr - > ctr . ctr1 - > count = 0 ;
r - > out . info_ctr - > ctr . ctr1 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-04-08 23:06:37 +04:00
}
}
/*
srvsvc_NetCharDevQGetInfo
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetCharDevQGetInfo ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-05-04 10:07:52 +04:00
struct srvsvc_NetCharDevQGetInfo * r )
2004-04-08 23:06:37 +04:00
{
2008-10-29 22:50:15 +03:00
ZERO_STRUCTP ( r - > out . info ) ;
2004-12-31 08:34:31 +03:00
2004-04-08 23:06:37 +04:00
switch ( r - > in . level ) {
case 0 :
2004-12-31 08:34:31 +03:00
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
case 1 :
2004-12-31 08:34:31 +03:00
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-04-08 23:06:37 +04:00
}
}
/*
srvsvc_NetCharDevQSetInfo
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetCharDevQSetInfo ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetCharDevQSetInfo * r )
{
switch ( r - > in . level ) {
2004-12-31 08:34:31 +03:00
case 0 :
{
2004-04-08 23:06:37 +04:00
if ( r - > in . parm_error ) {
r - > out . parm_error = r - > in . parm_error ;
}
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
case 1 :
2004-12-31 08:34:31 +03:00
{
2004-04-08 23:06:37 +04:00
if ( r - > in . parm_error ) {
r - > out . parm_error = r - > in . parm_error ;
}
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-04-08 23:06:37 +04:00
}
}
/*
srvsvc_NetCharDevQPurge
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetCharDevQPurge ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetCharDevQPurge * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NetCharDevQPurgeSelf
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetCharDevQPurgeSelf ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-05-04 10:07:52 +04:00
struct srvsvc_NetCharDevQPurgeSelf * r )
2004-04-08 23:06:37 +04:00
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NetConnEnum
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetConnEnum ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetConnEnum * r )
{
2008-10-30 18:59:03 +03:00
* r - > out . totalentries = 0 ;
2004-04-08 23:06:37 +04:00
2008-10-30 18:59:03 +03:00
switch ( r - > in . info_ctr - > level ) {
2004-05-04 10:07:52 +04:00
case 0 :
2004-12-31 08:34:31 +03:00
{
2008-10-30 18:59:03 +03:00
r - > out . info_ctr - > ctr . ctr0 = talloc ( mem_ctx , struct srvsvc_NetConnCtr0 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info_ctr - > ctr . ctr0 ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 18:59:03 +03:00
r - > out . info_ctr - > ctr . ctr0 - > count = 0 ;
r - > out . info_ctr - > ctr . ctr0 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-05-04 10:07:52 +04:00
case 1 :
2004-12-31 08:34:31 +03:00
{
2008-10-30 18:59:03 +03:00
r - > out . info_ctr - > ctr . ctr1 = talloc ( mem_ctx , struct srvsvc_NetConnCtr1 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info_ctr - > ctr . ctr1 ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 18:59:03 +03:00
r - > out . info_ctr - > ctr . ctr1 - > count = 0 ;
r - > out . info_ctr - > ctr . ctr1 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-04-08 23:06:37 +04:00
}
}
/*
srvsvc_NetFileEnum
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetFileEnum ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-05-04 10:07:52 +04:00
struct srvsvc_NetFileEnum * r )
2004-04-08 23:06:37 +04:00
{
2008-10-30 19:05:11 +03:00
* r - > out . totalentries = 0 ;
2004-04-08 23:06:37 +04:00
2008-10-30 19:05:11 +03:00
switch ( r - > in . info_ctr - > level ) {
2004-05-04 10:07:52 +04:00
case 2 :
2004-12-31 08:34:31 +03:00
{
2008-10-30 19:05:11 +03:00
r - > out . info_ctr - > ctr . ctr2 = talloc ( mem_ctx , struct srvsvc_NetFileCtr2 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info_ctr - > ctr . ctr2 ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 19:05:11 +03:00
r - > out . info_ctr - > ctr . ctr2 - > count = 0 ;
r - > out . info_ctr - > ctr . ctr2 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-05-04 10:07:52 +04:00
case 3 :
2004-12-31 08:34:31 +03:00
{
2008-10-30 19:05:11 +03:00
r - > out . info_ctr - > ctr . ctr3 = talloc ( mem_ctx , struct srvsvc_NetFileCtr3 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info_ctr - > ctr . ctr3 ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 19:05:11 +03:00
r - > out . info_ctr - > ctr . ctr3 - > count = 0 ;
r - > out . info_ctr - > ctr . ctr3 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-04-08 23:06:37 +04:00
}
}
/*
srvsvc_NetFileGetInfo
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetFileGetInfo ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-05-04 10:07:52 +04:00
struct srvsvc_NetFileGetInfo * r )
2004-04-08 23:06:37 +04:00
{
2008-10-29 22:53:28 +03:00
ZERO_STRUCTP ( r - > out . info ) ;
2004-12-31 08:34:31 +03:00
2004-04-08 23:06:37 +04:00
switch ( r - > in . level ) {
2004-05-04 10:07:52 +04:00
case 2 :
2004-12-31 08:34:31 +03:00
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-05-04 10:07:52 +04:00
case 3 :
2004-12-31 08:34:31 +03:00
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-04-08 23:06:37 +04:00
}
}
/*
srvsvc_NetFileClose
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetFileClose ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetFileClose * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NetSessEnum
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetSessEnum ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetSessEnum * r )
{
2008-10-30 19:21:31 +03:00
* r - > out . totalentries = 0 ;
2004-04-08 23:06:37 +04:00
2008-10-30 19:21:31 +03:00
switch ( r - > in . info_ctr - > level ) {
2004-05-04 10:07:52 +04:00
case 0 :
2004-12-31 08:34:31 +03:00
{
2008-10-30 19:21:31 +03:00
r - > out . info_ctr - > ctr . ctr0 = talloc ( mem_ctx , struct srvsvc_NetSessCtr0 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info_ctr - > ctr . ctr0 ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 19:21:31 +03:00
r - > out . info_ctr - > ctr . ctr0 - > count = 0 ;
r - > out . info_ctr - > ctr . ctr0 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-05-04 10:07:52 +04:00
case 1 :
2004-12-31 08:34:31 +03:00
{
2008-10-30 19:21:31 +03:00
r - > out . info_ctr - > ctr . ctr1 = talloc ( mem_ctx , struct srvsvc_NetSessCtr1 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info_ctr - > ctr . ctr1 ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 19:21:31 +03:00
r - > out . info_ctr - > ctr . ctr1 - > count = 0 ;
r - > out . info_ctr - > ctr . ctr1 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-05-04 10:07:52 +04:00
case 2 :
2004-12-31 08:34:31 +03:00
{
2008-10-30 19:21:31 +03:00
r - > out . info_ctr - > ctr . ctr2 = talloc ( mem_ctx , struct srvsvc_NetSessCtr2 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info_ctr - > ctr . ctr2 ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 19:21:31 +03:00
r - > out . info_ctr - > ctr . ctr2 - > count = 0 ;
r - > out . info_ctr - > ctr . ctr2 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-05-04 10:07:52 +04:00
case 10 :
2004-12-31 08:34:31 +03:00
{
2008-10-30 19:21:31 +03:00
r - > out . info_ctr - > ctr . ctr10 = talloc ( mem_ctx , struct srvsvc_NetSessCtr10 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info_ctr - > ctr . ctr10 ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 19:21:31 +03:00
r - > out . info_ctr - > ctr . ctr10 - > count = 0 ;
r - > out . info_ctr - > ctr . ctr10 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-05-04 10:07:52 +04:00
case 502 :
2004-12-31 08:34:31 +03:00
{
2008-10-30 19:21:31 +03:00
r - > out . info_ctr - > ctr . ctr502 = talloc ( mem_ctx , struct srvsvc_NetSessCtr502 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info_ctr - > ctr . ctr502 ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 19:21:31 +03:00
r - > out . info_ctr - > ctr . ctr502 - > count = 0 ;
r - > out . info_ctr - > ctr . ctr502 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-04-08 23:06:37 +04:00
}
}
/*
srvsvc_NetSessDel
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetSessDel ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetSessDel * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NetShareAdd
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetShareAdd ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetShareAdd * r )
{
switch ( r - > in . level ) {
2004-12-31 08:34:31 +03:00
case 0 :
{
2004-04-08 23:06:37 +04:00
if ( r - > in . parm_error ) {
r - > out . parm_error = r - > in . parm_error ;
}
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
case 1 :
2004-12-31 08:34:31 +03:00
{
2004-04-08 23:06:37 +04:00
if ( r - > in . parm_error ) {
r - > out . parm_error = r - > in . parm_error ;
}
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
case 2 :
2004-12-31 08:34:31 +03:00
{
2006-09-17 04:15:13 +04:00
NTSTATUS nterr ;
struct share_info * info ;
struct share_context * sctx ;
2009-11-21 21:08:42 +03:00
unsigned int count = 8 ;
unsigned int i ;
2006-09-17 04:15:13 +04:00
2010-07-16 08:32:42 +04:00
nterr = share_get_context_by_name ( mem_ctx , lpcfg_share_backend ( dce_call - > conn - > dce_ctx - > lp_ctx ) , dce_call - > event_ctx , dce_call - > conn - > dce_ctx - > lp_ctx , & sctx ) ;
2006-09-17 04:15:13 +04:00
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
/* there are no more than 8 options in struct srvsvc_NetShareInfo2 */
info = talloc_array ( mem_ctx , struct share_info , count ) ;
W_ERROR_HAVE_NO_MEMORY ( info ) ;
i = 0 ;
info [ i ] . name = SHARE_TYPE ;
info [ i ] . type = SHARE_INFO_STRING ;
2008-10-29 16:52:49 +03:00
switch ( r - > in . info - > info2 - > type ) {
2010-12-19 20:10:29 +03:00
case STYPE_DISKTREE :
2006-09-17 04:15:13 +04:00
info [ i ] . value = talloc_strdup ( info , " DISK " ) ;
break ;
2010-12-19 20:10:29 +03:00
case STYPE_PRINTQ :
2006-09-17 04:15:13 +04:00
info [ i ] . value = talloc_strdup ( info , " PRINTER " ) ;
break ;
2010-12-19 20:10:29 +03:00
case STYPE_IPC :
2006-09-17 04:15:13 +04:00
info [ i ] . value = talloc_strdup ( info , " IPC " ) ;
break ;
default :
2015-12-03 17:24:27 +03:00
return WERR_INVALID_PARAMETER ;
2006-09-17 04:15:13 +04:00
}
W_ERROR_HAVE_NO_MEMORY ( info [ i ] . value ) ;
i + + ;
2008-10-29 16:52:49 +03:00
if ( r - > in . info - > info2 - > path & & r - > in . info - > info2 - > path [ 0 ] ) {
2006-09-17 04:15:13 +04:00
info [ i ] . name = SHARE_PATH ;
info [ i ] . type = SHARE_INFO_STRING ;
/* Windows will send a path in a form of C:\example\path */
2008-10-29 16:52:49 +03:00
if ( r - > in . info - > info2 - > path [ 1 ] = = ' : ' ) {
info [ i ] . value = talloc_strdup ( info , & r - > in . info - > info2 - > path [ 2 ] ) ;
2006-09-17 04:15:13 +04:00
} else {
/* very strange let's try to set as is */
2008-10-29 16:52:49 +03:00
info [ i ] . value = talloc_strdup ( info , r - > in . info - > info2 - > path ) ;
2006-09-17 04:15:13 +04:00
}
W_ERROR_HAVE_NO_MEMORY ( info [ i ] . value ) ;
all_string_sub ( ( char * ) info [ i ] . value , " \\ " , " / " , 0 ) ;
i + + ;
}
2008-10-29 16:52:49 +03:00
if ( r - > in . info - > info2 - > comment & & r - > in . info - > info2 - > comment [ 0 ] ) {
2006-09-17 04:15:13 +04:00
info [ i ] . name = SHARE_COMMENT ;
info [ i ] . type = SHARE_INFO_STRING ;
2008-10-29 16:52:49 +03:00
info [ i ] . value = talloc_strdup ( info , r - > in . info - > info2 - > comment ) ;
2006-09-17 04:15:13 +04:00
W_ERROR_HAVE_NO_MEMORY ( info [ i ] . value ) ;
i + + ;
}
2008-10-29 16:52:49 +03:00
if ( r - > in . info - > info2 - > password & & r - > in . info - > info2 - > password [ 0 ] ) {
2006-09-17 04:15:13 +04:00
info [ i ] . name = SHARE_PASSWORD ;
info [ i ] . type = SHARE_INFO_STRING ;
2008-10-29 16:52:49 +03:00
info [ i ] . value = talloc_strdup ( info , r - > in . info - > info2 - > password ) ;
2006-09-17 04:15:13 +04:00
W_ERROR_HAVE_NO_MEMORY ( info [ i ] . value ) ;
i + + ;
}
info [ i ] . name = SHARE_MAX_CONNECTIONS ;
info [ i ] . type = SHARE_INFO_INT ;
info [ i ] . value = talloc ( info , int ) ;
2008-10-29 16:52:49 +03:00
* ( ( int * ) info [ i ] . value ) = r - > in . info - > info2 - > max_users ;
2006-09-17 04:15:13 +04:00
i + + ;
/* TODO: security descriptor */
2008-10-29 16:52:49 +03:00
nterr = share_create ( sctx , r - > in . info - > info2 - > name , info , i ) ;
2006-09-17 04:15:13 +04:00
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
2004-04-08 23:06:37 +04:00
if ( r - > in . parm_error ) {
r - > out . parm_error = r - > in . parm_error ;
}
2006-09-17 04:15:13 +04:00
return WERR_OK ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
case 501 :
2004-12-31 08:34:31 +03:00
{
2004-04-08 23:06:37 +04:00
if ( r - > in . parm_error ) {
r - > out . parm_error = r - > in . parm_error ;
}
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
case 502 :
2004-12-31 08:34:31 +03:00
{
2006-09-15 09:18:53 +04:00
NTSTATUS nterr ;
struct share_info * info ;
struct share_context * sctx ;
2009-11-21 21:08:42 +03:00
unsigned int count = 10 ;
unsigned int i ;
2006-09-15 20:27:55 +04:00
2010-07-16 08:32:42 +04:00
nterr = share_get_context_by_name ( mem_ctx , lpcfg_share_backend ( dce_call - > conn - > dce_ctx - > lp_ctx ) , dce_call - > event_ctx , dce_call - > conn - > dce_ctx - > lp_ctx , & sctx ) ;
2006-09-15 09:18:53 +04:00
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
2006-09-17 04:15:13 +04:00
/* there are no more than 10 options in struct srvsvc_NetShareInfo502 */
info = talloc_array ( mem_ctx , struct share_info , count ) ;
2006-09-15 09:18:53 +04:00
W_ERROR_HAVE_NO_MEMORY ( info ) ;
2006-09-17 04:15:13 +04:00
i = 0 ;
info [ i ] . name = SHARE_TYPE ;
info [ i ] . type = SHARE_INFO_STRING ;
2008-10-29 16:52:49 +03:00
switch ( r - > in . info - > info502 - > type ) {
2006-09-15 09:18:53 +04:00
case 0x00 :
2006-09-17 04:15:13 +04:00
info [ i ] . value = talloc_strdup ( info , " DISK " ) ;
2006-09-15 09:18:53 +04:00
break ;
case 0x01 :
2006-09-17 04:15:13 +04:00
info [ i ] . value = talloc_strdup ( info , " PRINTER " ) ;
2006-09-15 09:18:53 +04:00
break ;
case 0x03 :
2006-09-17 04:15:13 +04:00
info [ i ] . value = talloc_strdup ( info , " IPC " ) ;
2006-09-15 09:18:53 +04:00
break ;
default :
2015-12-03 17:24:27 +03:00
return WERR_INVALID_PARAMETER ;
2006-09-15 09:18:53 +04:00
}
2006-09-17 04:15:13 +04:00
W_ERROR_HAVE_NO_MEMORY ( info [ i ] . value ) ;
i + + ;
2006-09-15 09:18:53 +04:00
2008-10-29 16:52:49 +03:00
if ( r - > in . info - > info502 - > path & & r - > in . info - > info502 - > path [ 0 ] ) {
2006-09-17 04:15:13 +04:00
info [ i ] . name = SHARE_PATH ;
info [ i ] . type = SHARE_INFO_STRING ;
2006-09-15 20:27:55 +04:00
/* Windows will send a path in a form of C:\example\path */
2008-10-29 16:52:49 +03:00
if ( r - > in . info - > info502 - > path [ 1 ] = = ' : ' ) {
info [ i ] . value = talloc_strdup ( info , & r - > in . info - > info502 - > path [ 2 ] ) ;
2006-09-15 20:27:55 +04:00
} else {
/* very strange let's try to set as is */
2008-10-29 16:52:49 +03:00
info [ i ] . value = talloc_strdup ( info , r - > in . info - > info502 - > path ) ;
2006-09-15 20:27:55 +04:00
}
2006-09-17 04:15:13 +04:00
W_ERROR_HAVE_NO_MEMORY ( info [ i ] . value ) ;
all_string_sub ( ( char * ) info [ i ] . value , " \\ " , " / " , 0 ) ;
i + + ;
2006-09-15 09:18:53 +04:00
}
2008-10-29 16:52:49 +03:00
if ( r - > in . info - > info502 - > comment & & r - > in . info - > info502 - > comment [ 0 ] ) {
2006-09-17 04:15:13 +04:00
info [ i ] . name = SHARE_COMMENT ;
info [ i ] . type = SHARE_INFO_STRING ;
2008-10-29 16:52:49 +03:00
info [ i ] . value = talloc_strdup ( info , r - > in . info - > info502 - > comment ) ;
2006-09-17 04:15:13 +04:00
W_ERROR_HAVE_NO_MEMORY ( info [ i ] . value ) ;
i + + ;
2006-09-15 09:18:53 +04:00
}
2008-10-29 16:52:49 +03:00
if ( r - > in . info - > info502 - > password & & r - > in . info - > info502 - > password [ 0 ] ) {
2006-09-17 04:15:13 +04:00
info [ i ] . name = SHARE_PASSWORD ;
info [ i ] . type = SHARE_INFO_STRING ;
2008-10-29 16:52:49 +03:00
info [ i ] . value = talloc_strdup ( info , r - > in . info - > info502 - > password ) ;
2006-09-17 04:15:13 +04:00
W_ERROR_HAVE_NO_MEMORY ( info [ i ] . value ) ;
i + + ;
2006-09-15 09:18:53 +04:00
}
2006-09-17 04:15:13 +04:00
info [ i ] . name = SHARE_MAX_CONNECTIONS ;
info [ i ] . type = SHARE_INFO_INT ;
info [ i ] . value = talloc ( info , int ) ;
2008-10-29 16:52:49 +03:00
* ( ( int * ) info [ i ] . value ) = r - > in . info - > info502 - > max_users ;
2006-09-17 04:15:13 +04:00
i + + ;
2006-09-15 09:18:53 +04:00
/* TODO: security descriptor */
2008-10-29 16:52:49 +03:00
nterr = share_create ( sctx , r - > in . info - > info502 - > name , info , i ) ;
2006-09-15 09:18:53 +04:00
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
2004-04-08 23:06:37 +04:00
if ( r - > in . parm_error ) {
r - > out . parm_error = r - > in . parm_error ;
}
2006-09-15 09:18:53 +04:00
return WERR_OK ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-04-08 23:06:37 +04:00
}
}
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_fiel_ShareInfo ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2006-07-23 22:43:07 +04:00
struct share_config * scfg , uint32_t level ,
union srvsvc_NetShareInfo * info )
2004-12-31 08:34:31 +03:00
{
struct dcesrv_context * dce_ctx = dce_call - > conn - > dce_ctx ;
switch ( level ) {
case 0 :
{
2006-07-23 22:43:07 +04:00
info - > info0 - > name = talloc_strdup ( mem_ctx , scfg - > name ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info - > info0 - > name ) ;
return WERR_OK ;
}
case 1 :
{
2006-07-23 22:43:07 +04:00
info - > info1 - > name = talloc_strdup ( mem_ctx , scfg - > name ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info - > info1 - > name ) ;
2006-07-23 22:43:07 +04:00
info - > info1 - > type = dcesrv_common_get_share_type ( mem_ctx , dce_ctx , scfg ) ;
2014-01-17 01:16:12 +04:00
info - > info1 - > comment = share_string_option ( mem_ctx , scfg , SHARE_COMMENT , " " ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info - > info1 - > comment ) ;
return WERR_OK ;
}
case 2 :
{
2006-07-23 22:43:07 +04:00
info - > info2 - > name = talloc_strdup ( mem_ctx , scfg - > name ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info - > info2 - > name ) ;
2006-07-23 22:43:07 +04:00
info - > info2 - > type = dcesrv_common_get_share_type ( mem_ctx , dce_ctx , scfg ) ;
2014-01-17 01:16:12 +04:00
info - > info2 - > comment = share_string_option ( mem_ctx , scfg , SHARE_COMMENT , " " ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info - > info2 - > comment ) ;
2006-07-23 22:43:07 +04:00
info - > info2 - > permissions = dcesrv_common_get_share_permissions ( mem_ctx , dce_ctx , scfg ) ;
info - > info2 - > max_users = share_int_option ( scfg , SHARE_MAX_CONNECTIONS , SHARE_MAX_CONNECTIONS_DEFAULT ) ;
info - > info2 - > current_users = dcesrv_common_get_share_current_users ( mem_ctx , dce_ctx , scfg ) ;
info - > info2 - > path = dcesrv_common_get_share_path ( mem_ctx , dce_ctx , scfg ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info - > info2 - > path ) ;
2014-01-17 01:16:12 +04:00
info - > info2 - > password = share_string_option ( mem_ctx , scfg , SHARE_PASSWORD , NULL ) ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
case 501 :
{
2006-07-23 22:43:07 +04:00
info - > info501 - > name = talloc_strdup ( mem_ctx , scfg - > name ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info - > info501 - > name ) ;
2006-07-23 22:43:07 +04:00
info - > info501 - > type = dcesrv_common_get_share_type ( mem_ctx , dce_ctx , scfg ) ;
2014-01-17 01:16:12 +04:00
info - > info501 - > comment = share_string_option ( mem_ctx , scfg , SHARE_COMMENT , " " ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info - > info501 - > comment ) ;
2006-07-23 22:43:07 +04:00
info - > info501 - > csc_policy = share_int_option ( scfg , SHARE_CSC_POLICY , SHARE_CSC_POLICY_DEFAULT ) ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
case 502 :
{
2006-07-23 22:43:07 +04:00
info - > info502 - > name = talloc_strdup ( mem_ctx , scfg - > name ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info - > info502 - > name ) ;
2006-07-23 22:43:07 +04:00
info - > info502 - > type = dcesrv_common_get_share_type ( mem_ctx , dce_ctx , scfg ) ;
2014-01-17 01:16:12 +04:00
info - > info502 - > comment = share_string_option ( mem_ctx , scfg , SHARE_COMMENT , " " ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info - > info502 - > comment ) ;
2006-07-23 22:43:07 +04:00
info - > info502 - > permissions = dcesrv_common_get_share_permissions ( mem_ctx , dce_ctx , scfg ) ;
info - > info502 - > max_users = share_int_option ( scfg , SHARE_MAX_CONNECTIONS , SHARE_MAX_CONNECTIONS_DEFAULT ) ;
info - > info502 - > current_users = dcesrv_common_get_share_current_users ( mem_ctx , dce_ctx , scfg ) ;
info - > info502 - > path = dcesrv_common_get_share_path ( mem_ctx , dce_ctx , scfg ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info - > info502 - > path ) ;
2014-01-17 01:16:12 +04:00
info - > info502 - > password = share_string_option ( mem_ctx , scfg , SHARE_PASSWORD , NULL ) ;
2008-10-29 23:04:31 +03:00
info - > info502 - > sd_buf . sd = dcesrv_common_get_security_descriptor ( mem_ctx , dce_ctx , scfg ) ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
case 1005 :
{
2006-07-23 22:43:07 +04:00
info - > info1005 - > dfs_flags = dcesrv_common_get_share_dfs_flags ( mem_ctx , dce_ctx , scfg ) ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-12-31 08:34:31 +03:00
}
}
2004-04-08 23:06:37 +04:00
/*
srvsvc_NetShareEnumAll
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetShareEnumAll ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-12-31 08:34:31 +03:00
struct srvsvc_NetShareEnumAll * r )
2004-04-08 23:06:37 +04:00
{
2006-07-23 22:43:07 +04:00
NTSTATUS nterr ;
int numshares = 0 ;
const char * * snames ;
struct share_context * sctx ;
struct share_config * scfg ;
2004-12-31 08:34:31 +03:00
2008-10-30 20:02:40 +03:00
* r - > out . totalentries = 0 ;
2004-04-08 23:06:37 +04:00
2004-12-31 08:34:31 +03:00
/* TODO: - paging of results
*/
2010-07-16 08:32:42 +04:00
nterr = share_get_context_by_name ( mem_ctx , lpcfg_share_backend ( dce_call - > conn - > dce_ctx - > lp_ctx ) , dce_call - > event_ctx , dce_call - > conn - > dce_ctx - > lp_ctx , & sctx ) ;
2006-07-23 22:43:07 +04:00
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
nterr = share_list_all ( mem_ctx , sctx , & numshares , & snames ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
2008-10-30 20:02:40 +03:00
switch ( r - > in . info_ctr - > level ) {
2004-12-31 08:34:31 +03:00
case 0 :
{
2009-11-21 21:08:42 +03:00
unsigned int i ;
2004-12-31 08:34:31 +03:00
struct srvsvc_NetShareCtr0 * ctr0 ;
2004-04-08 23:06:37 +04:00
2005-01-27 10:08:20 +03:00
ctr0 = talloc ( mem_ctx , struct srvsvc_NetShareCtr0 ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( ctr0 ) ;
2004-04-08 23:06:37 +04:00
2006-07-23 22:43:07 +04:00
ctr0 - > count = numshares ;
2004-12-31 08:34:31 +03:00
ctr0 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-12-31 08:34:31 +03:00
if ( ctr0 - > count = = 0 ) {
2008-10-30 20:02:40 +03:00
r - > out . info_ctr - > ctr . ctr0 = ctr0 ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
2004-04-08 23:06:37 +04:00
}
2005-01-27 10:08:20 +03:00
ctr0 - > array = talloc_array ( mem_ctx , struct srvsvc_NetShareInfo0 , ctr0 - > count ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( ctr0 - > array ) ;
2006-07-23 22:43:07 +04:00
for ( i = 0 ; i < ctr0 - > count ; i + + ) {
2004-12-31 08:34:31 +03:00
WERROR status ;
union srvsvc_NetShareInfo info ;
2004-04-08 23:06:37 +04:00
2006-07-23 22:43:07 +04:00
nterr = share_get_config ( mem_ctx , sctx , snames [ i ] , & scfg ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
DEBUG ( 1 , ( " ERROR: Service [%s] disappeared after enumeration " , snames [ i ] ) ) ;
2015-12-03 17:24:22 +03:00
return WERR_GEN_FAILURE ;
2006-07-23 22:43:07 +04:00
}
2004-12-31 08:34:31 +03:00
info . info0 = & ctr0 - > array [ i ] ;
2008-10-30 20:02:40 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . info_ctr - > level , & info ) ;
2004-12-31 08:34:31 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return status ;
}
2006-07-23 22:43:07 +04:00
talloc_free ( scfg ) ;
2004-04-08 23:06:37 +04:00
}
2006-07-23 22:43:07 +04:00
talloc_free ( snames ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 20:02:40 +03:00
r - > out . info_ctr - > ctr . ctr0 = ctr0 ;
* r - > out . totalentries = r - > out . info_ctr - > ctr . ctr0 - > count ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
case 1 :
{
2009-11-21 21:08:42 +03:00
unsigned int i ;
2004-12-31 08:34:31 +03:00
struct srvsvc_NetShareCtr1 * ctr1 ;
2004-04-08 23:06:37 +04:00
2005-01-27 10:08:20 +03:00
ctr1 = talloc ( mem_ctx , struct srvsvc_NetShareCtr1 ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( ctr1 ) ;
2004-04-08 23:06:37 +04:00
2006-07-23 22:43:07 +04:00
ctr1 - > count = numshares ;
2004-12-31 08:34:31 +03:00
ctr1 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-12-31 08:34:31 +03:00
if ( ctr1 - > count = = 0 ) {
2008-10-30 20:02:40 +03:00
r - > out . info_ctr - > ctr . ctr1 = ctr1 ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
2004-04-08 23:06:37 +04:00
}
2005-01-27 10:08:20 +03:00
ctr1 - > array = talloc_array ( mem_ctx , struct srvsvc_NetShareInfo1 , ctr1 - > count ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( ctr1 - > array ) ;
for ( i = 0 ; i < ctr1 - > count ; i + + ) {
WERROR status ;
union srvsvc_NetShareInfo info ;
2004-04-08 23:06:37 +04:00
2006-07-23 22:43:07 +04:00
nterr = share_get_config ( mem_ctx , sctx , snames [ i ] , & scfg ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
DEBUG ( 1 , ( " ERROR: Service [%s] disappeared after enumeration " , snames [ i ] ) ) ;
2015-12-03 17:24:22 +03:00
return WERR_GEN_FAILURE ;
2006-07-23 22:43:07 +04:00
}
2004-12-31 08:34:31 +03:00
info . info1 = & ctr1 - > array [ i ] ;
2008-10-30 20:02:40 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . info_ctr - > level , & info ) ;
2004-12-31 08:34:31 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return status ;
}
2006-07-23 22:43:07 +04:00
talloc_free ( scfg ) ;
2004-04-08 23:06:37 +04:00
}
2006-07-23 22:43:07 +04:00
talloc_free ( snames ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 20:02:40 +03:00
r - > out . info_ctr - > ctr . ctr1 = ctr1 ;
* r - > out . totalentries = r - > out . info_ctr - > ctr . ctr1 - > count ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
case 2 :
{
2009-11-21 21:08:42 +03:00
unsigned int i ;
2004-12-31 08:34:31 +03:00
struct srvsvc_NetShareCtr2 * ctr2 ;
2004-04-08 23:06:37 +04:00
2006-04-26 16:07:01 +04:00
SRVSVC_CHECK_ADMIN_ACCESS ;
2005-01-27 10:08:20 +03:00
ctr2 = talloc ( mem_ctx , struct srvsvc_NetShareCtr2 ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( ctr2 ) ;
2004-04-08 23:06:37 +04:00
2006-07-23 22:43:07 +04:00
ctr2 - > count = numshares ;
2004-12-31 08:34:31 +03:00
ctr2 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-12-31 08:34:31 +03:00
if ( ctr2 - > count = = 0 ) {
2008-10-30 20:02:40 +03:00
r - > out . info_ctr - > ctr . ctr2 = ctr2 ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
2004-04-08 23:06:37 +04:00
}
2005-01-27 10:08:20 +03:00
ctr2 - > array = talloc_array ( mem_ctx , struct srvsvc_NetShareInfo2 , ctr2 - > count ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( ctr2 - > array ) ;
for ( i = 0 ; i < ctr2 - > count ; i + + ) {
WERROR status ;
union srvsvc_NetShareInfo info ;
2004-04-08 23:06:37 +04:00
2006-07-23 22:43:07 +04:00
nterr = share_get_config ( mem_ctx , sctx , snames [ i ] , & scfg ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
DEBUG ( 1 , ( " ERROR: Service [%s] disappeared after enumeration " , snames [ i ] ) ) ;
2015-12-03 17:24:22 +03:00
return WERR_GEN_FAILURE ;
2006-07-23 22:43:07 +04:00
}
2004-12-31 08:34:31 +03:00
info . info2 = & ctr2 - > array [ i ] ;
2008-10-30 20:02:40 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . info_ctr - > level , & info ) ;
2004-12-31 08:34:31 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return status ;
}
2006-07-23 22:43:07 +04:00
talloc_free ( scfg ) ;
2004-04-08 23:06:37 +04:00
}
2006-07-23 22:43:07 +04:00
talloc_free ( snames ) ;
2004-04-08 23:06:37 +04:00
2008-10-30 20:02:40 +03:00
r - > out . info_ctr - > ctr . ctr2 = ctr2 ;
* r - > out . totalentries = r - > out . info_ctr - > ctr . ctr2 - > count ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
case 501 :
{
2009-11-21 21:08:42 +03:00
unsigned int i ;
2004-12-31 08:34:31 +03:00
struct srvsvc_NetShareCtr501 * ctr501 ;
2004-04-08 23:06:37 +04:00
2006-04-26 16:07:01 +04:00
SRVSVC_CHECK_ADMIN_ACCESS ;
2005-01-27 10:08:20 +03:00
ctr501 = talloc ( mem_ctx , struct srvsvc_NetShareCtr501 ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( ctr501 ) ;
2004-04-08 23:06:37 +04:00
2006-07-23 22:43:07 +04:00
ctr501 - > count = numshares ;
2004-12-31 08:34:31 +03:00
ctr501 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-12-31 08:34:31 +03:00
if ( ctr501 - > count = = 0 ) {
2008-10-30 20:02:40 +03:00
r - > out . info_ctr - > ctr . ctr501 = ctr501 ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
2004-04-08 23:06:37 +04:00
}
2005-01-27 10:08:20 +03:00
ctr501 - > array = talloc_array ( mem_ctx , struct srvsvc_NetShareInfo501 , ctr501 - > count ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( ctr501 - > array ) ;
for ( i = 0 ; i < ctr501 - > count ; i + + ) {
WERROR status ;
union srvsvc_NetShareInfo info ;
2004-04-08 23:06:37 +04:00
2006-07-23 22:43:07 +04:00
nterr = share_get_config ( mem_ctx , sctx , snames [ i ] , & scfg ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
DEBUG ( 1 , ( " ERROR: Service [%s] disappeared after enumeration " , snames [ i ] ) ) ;
2015-12-03 17:24:22 +03:00
return WERR_GEN_FAILURE ;
2006-07-23 22:43:07 +04:00
}
2004-12-31 08:34:31 +03:00
info . info501 = & ctr501 - > array [ i ] ;
2008-10-30 20:02:40 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . info_ctr - > level , & info ) ;
2004-12-31 08:34:31 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return status ;
}
2006-07-23 22:43:07 +04:00
talloc_free ( scfg ) ;
2004-04-08 23:06:37 +04:00
}
2006-07-23 22:43:07 +04:00
talloc_free ( snames ) ;
2004-12-31 08:34:31 +03:00
2008-10-30 20:02:40 +03:00
r - > out . info_ctr - > ctr . ctr501 = ctr501 ;
* r - > out . totalentries = r - > out . info_ctr - > ctr . ctr501 - > count ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
case 502 :
{
2009-11-21 21:08:42 +03:00
unsigned int i ;
2004-12-31 08:34:31 +03:00
struct srvsvc_NetShareCtr502 * ctr502 ;
2006-04-26 16:07:01 +04:00
SRVSVC_CHECK_ADMIN_ACCESS ;
2005-01-27 10:08:20 +03:00
ctr502 = talloc ( mem_ctx , struct srvsvc_NetShareCtr502 ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( ctr502 ) ;
2006-07-23 22:43:07 +04:00
ctr502 - > count = numshares ;
2004-12-31 08:34:31 +03:00
ctr502 - > array = NULL ;
2004-04-08 23:06:37 +04:00
2004-12-31 08:34:31 +03:00
if ( ctr502 - > count = = 0 ) {
2008-10-30 20:02:40 +03:00
r - > out . info_ctr - > ctr . ctr502 = ctr502 ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
2004-04-08 23:06:37 +04:00
}
2005-01-27 10:08:20 +03:00
ctr502 - > array = talloc_array ( mem_ctx , struct srvsvc_NetShareInfo502 , ctr502 - > count ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( ctr502 - > array ) ;
2004-04-08 23:06:37 +04:00
2004-12-31 08:34:31 +03:00
for ( i = 0 ; i < ctr502 - > count ; i + + ) {
WERROR status ;
union srvsvc_NetShareInfo info ;
2006-07-23 22:43:07 +04:00
nterr = share_get_config ( mem_ctx , sctx , snames [ i ] , & scfg ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
DEBUG ( 1 , ( " ERROR: Service [%s] disappeared after enumeration " , snames [ i ] ) ) ;
2015-12-03 17:24:22 +03:00
return WERR_GEN_FAILURE ;
2006-07-23 22:43:07 +04:00
}
2004-12-31 08:34:31 +03:00
info . info502 = & ctr502 - > array [ i ] ;
2008-10-30 20:02:40 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . info_ctr - > level , & info ) ;
2004-12-31 08:34:31 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return status ;
}
2006-07-23 22:43:07 +04:00
talloc_free ( scfg ) ;
2004-04-08 23:06:37 +04:00
}
2006-07-23 22:43:07 +04:00
talloc_free ( snames ) ;
2004-12-31 08:34:31 +03:00
2008-10-30 20:02:40 +03:00
r - > out . info_ctr - > ctr . ctr502 = ctr502 ;
* r - > out . totalentries = r - > out . info_ctr - > ctr . ctr502 - > count ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
2004-04-08 23:06:37 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-04-08 23:06:37 +04:00
}
}
/*
srvsvc_NetShareGetInfo
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetShareGetInfo ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-12-31 08:34:31 +03:00
struct srvsvc_NetShareGetInfo * r )
2004-04-08 23:06:37 +04:00
{
2006-07-23 22:43:07 +04:00
NTSTATUS nterr ;
struct share_context * sctx = NULL ;
struct share_config * scfg = NULL ;
2004-12-31 08:34:31 +03:00
2008-10-29 17:38:18 +03:00
ZERO_STRUCTP ( r - > out . info ) ;
2004-12-31 08:34:31 +03:00
/* TODO: - access check
*/
if ( strcmp ( " " , r - > in . share_name ) = = 0 ) {
2015-12-03 17:24:27 +03:00
return WERR_INVALID_PARAMETER ;
2004-12-31 08:34:31 +03:00
}
2010-07-16 08:32:42 +04:00
nterr = share_get_context_by_name ( mem_ctx , lpcfg_share_backend ( dce_call - > conn - > dce_ctx - > lp_ctx ) , dce_call - > event_ctx , dce_call - > conn - > dce_ctx - > lp_ctx , & sctx ) ;
2006-07-23 22:43:07 +04:00
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
nterr = share_get_config ( mem_ctx , sctx , r - > in . share_name , & scfg ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
switch ( r - > in . level ) {
2004-05-04 10:07:52 +04:00
case 0 :
2004-12-31 08:34:31 +03:00
{
WERROR status ;
union srvsvc_NetShareInfo info ;
2004-04-08 23:06:37 +04:00
2005-01-27 10:08:20 +03:00
info . info0 = talloc ( mem_ctx , struct srvsvc_NetShareInfo0 ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info . info0 ) ;
2004-05-04 10:07:52 +04:00
2007-01-17 17:49:36 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . level , & info ) ;
2004-12-31 08:34:31 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return status ;
}
2008-10-29 17:38:18 +03:00
r - > out . info - > info0 = info . info0 ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
2004-05-04 10:07:52 +04:00
case 1 :
2004-12-31 08:34:31 +03:00
{
WERROR status ;
union srvsvc_NetShareInfo info ;
2004-04-08 23:06:37 +04:00
2005-01-27 10:08:20 +03:00
info . info1 = talloc ( mem_ctx , struct srvsvc_NetShareInfo1 ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info . info1 ) ;
2007-01-17 17:49:36 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . level , & info ) ;
2004-12-31 08:34:31 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return status ;
}
2004-05-04 10:07:52 +04:00
2008-10-29 17:38:18 +03:00
r - > out . info - > info1 = info . info1 ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
2004-05-04 10:07:52 +04:00
case 2 :
2004-12-31 08:34:31 +03:00
{
WERROR status ;
union srvsvc_NetShareInfo info ;
2004-04-08 23:06:37 +04:00
2006-04-26 16:07:01 +04:00
SRVSVC_CHECK_ADMIN_ACCESS ;
2005-01-27 10:08:20 +03:00
info . info2 = talloc ( mem_ctx , struct srvsvc_NetShareInfo2 ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info . info2 ) ;
2007-01-17 17:49:36 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . level , & info ) ;
2004-12-31 08:34:31 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return status ;
}
2004-05-04 10:07:52 +04:00
2008-10-29 17:38:18 +03:00
r - > out . info - > info2 = info . info2 ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
2004-05-04 10:07:52 +04:00
case 501 :
2004-12-31 08:34:31 +03:00
{
WERROR status ;
union srvsvc_NetShareInfo info ;
2004-04-08 23:06:37 +04:00
2005-01-27 10:08:20 +03:00
info . info501 = talloc ( mem_ctx , struct srvsvc_NetShareInfo501 ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info . info501 ) ;
2007-01-17 17:49:36 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . level , & info ) ;
2004-12-31 08:34:31 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return status ;
}
2004-05-04 10:07:52 +04:00
2008-10-29 17:38:18 +03:00
r - > out . info - > info501 = info . info501 ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
2004-05-04 10:07:52 +04:00
case 502 :
2004-12-31 08:34:31 +03:00
{
WERROR status ;
union srvsvc_NetShareInfo info ;
2004-04-08 23:06:37 +04:00
2006-04-26 16:07:01 +04:00
SRVSVC_CHECK_ADMIN_ACCESS ;
2005-01-27 10:08:20 +03:00
info . info502 = talloc ( mem_ctx , struct srvsvc_NetShareInfo502 ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info . info502 ) ;
2007-01-17 17:49:36 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . level , & info ) ;
2004-12-31 08:34:31 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return status ;
}
2008-10-29 17:38:18 +03:00
r - > out . info - > info502 = info . info502 ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
case 1005 :
{
WERROR status ;
union srvsvc_NetShareInfo info ;
2005-01-27 10:08:20 +03:00
info . info1005 = talloc ( mem_ctx , struct srvsvc_NetShareInfo1005 ) ;
2004-12-31 08:34:31 +03:00
W_ERROR_HAVE_NO_MEMORY ( info . info1005 ) ;
2007-01-17 17:49:36 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . level , & info ) ;
2004-12-31 08:34:31 +03:00
if ( ! W_ERROR_IS_OK ( status ) ) {
return status ;
}
2004-05-04 10:07:52 +04:00
2008-10-29 17:38:18 +03:00
r - > out . info - > info1005 = info . info1005 ;
2004-12-31 08:34:31 +03:00
return WERR_OK ;
}
2004-04-08 23:06:37 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-04-08 23:06:37 +04:00
}
}
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_fill_share_info ( struct share_info * info , int * count ,
2006-09-21 00:32:36 +04:00
const char * share_name , int level ,
const char * name ,
const char * path ,
const char * comment ,
const char * password ,
enum srvsvc_ShareType type ,
int32_t max_users ,
uint32_t csc_policy ,
struct security_descriptor * sd )
2004-04-08 23:06:37 +04:00
{
2009-11-21 21:08:42 +03:00
unsigned int i = 0 ;
2006-09-15 20:27:55 +04:00
2006-09-21 00:32:36 +04:00
if ( level = = 501 ) {
info [ i ] . name = SHARE_CSC_POLICY ;
info [ i ] . type = SHARE_INFO_INT ;
info [ i ] . value = talloc ( info , int ) ;
* ( ( int * ) info [ i ] . value ) = csc_policy ;
i + + ;
2006-09-15 20:27:55 +04:00
}
2006-09-21 00:32:36 +04:00
switch ( level ) {
2006-09-17 04:15:13 +04:00
2006-09-21 00:32:36 +04:00
case 502 :
/* TODO: check if unknown is csc_policy */
2006-09-17 04:15:13 +04:00
2006-09-21 00:32:36 +04:00
/* TODO: security descriptor */
2006-09-17 04:15:13 +04:00
2006-09-21 00:32:36 +04:00
case 2 :
if ( path & & path [ 0 ] ) {
2006-09-17 04:15:13 +04:00
info [ i ] . name = SHARE_PATH ;
info [ i ] . type = SHARE_INFO_STRING ;
/* Windows will send a path in a form of C:\example\path */
2006-09-21 00:32:36 +04:00
if ( path [ 1 ] = = ' : ' ) {
info [ i ] . value = talloc_strdup ( info , & path [ 2 ] ) ;
2006-09-17 04:15:13 +04:00
} else {
/* very strange let's try to set as is */
2006-09-21 00:32:36 +04:00
info [ i ] . value = talloc_strdup ( info , path ) ;
2006-09-17 04:15:13 +04:00
}
W_ERROR_HAVE_NO_MEMORY ( info [ i ] . value ) ;
all_string_sub ( ( char * ) info [ i ] . value , " \\ " , " / " , 0 ) ;
i + + ;
}
2006-09-21 00:32:36 +04:00
if ( password & & password [ 0 ] ) {
2006-09-17 04:15:13 +04:00
info [ i ] . name = SHARE_PASSWORD ;
info [ i ] . type = SHARE_INFO_STRING ;
2006-09-21 00:32:36 +04:00
info [ i ] . value = talloc_strdup ( info , password ) ;
2006-09-17 04:15:13 +04:00
W_ERROR_HAVE_NO_MEMORY ( info [ i ] . value ) ;
i + + ;
}
info [ i ] . name = SHARE_MAX_CONNECTIONS ;
info [ i ] . type = SHARE_INFO_INT ;
info [ i ] . value = talloc ( info , int ) ;
2006-09-21 00:32:36 +04:00
* ( ( int * ) info [ i ] . value ) = max_users ;
2006-09-17 04:15:13 +04:00
i + + ;
2017-07-26 18:39:04 +03:00
FALL_THROUGH ;
2006-09-15 20:27:55 +04:00
case 501 :
2006-09-21 00:32:36 +04:00
case 1 :
2006-09-17 04:15:13 +04:00
info [ i ] . name = SHARE_TYPE ;
info [ i ] . type = SHARE_INFO_STRING ;
2006-09-21 00:32:36 +04:00
switch ( type ) {
2006-09-17 04:15:13 +04:00
case 0x00 :
info [ i ] . value = talloc_strdup ( info , " DISK " ) ;
break ;
case 0x01 :
info [ i ] . value = talloc_strdup ( info , " PRINTER " ) ;
break ;
case 0x03 :
info [ i ] . value = talloc_strdup ( info , " IPC " ) ;
break ;
default :
2015-12-03 17:24:27 +03:00
return WERR_INVALID_PARAMETER ;
2006-09-17 04:15:13 +04:00
}
W_ERROR_HAVE_NO_MEMORY ( info [ i ] . value ) ;
i + + ;
2017-07-26 18:39:04 +03:00
FALL_THROUGH ;
2006-09-21 00:32:36 +04:00
case 1004 :
if ( comment ) {
info [ i ] . name = SHARE_COMMENT ;
2006-09-17 04:15:13 +04:00
info [ i ] . type = SHARE_INFO_STRING ;
2006-09-21 00:32:36 +04:00
info [ i ] . value = talloc_strdup ( info , comment ) ;
2006-09-17 04:15:13 +04:00
W_ERROR_HAVE_NO_MEMORY ( info [ i ] . value ) ;
i + + ;
}
2017-07-26 18:39:04 +03:00
FALL_THROUGH ;
2006-09-21 00:32:36 +04:00
case 0 :
if ( name & &
strcasecmp ( share_name , name ) ! = 0 ) {
info [ i ] . name = SHARE_NAME ;
2006-09-17 04:15:13 +04:00
info [ i ] . type = SHARE_INFO_STRING ;
2006-09-21 00:32:36 +04:00
info [ i ] . value = talloc_strdup ( info , name ) ;
2006-09-17 04:15:13 +04:00
W_ERROR_HAVE_NO_MEMORY ( info [ i ] . value ) ;
i + + ;
}
2006-09-21 00:32:36 +04:00
break ;
2006-09-17 04:15:13 +04:00
2006-09-21 00:32:36 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2006-09-21 00:32:36 +04:00
}
2006-09-17 04:15:13 +04:00
2006-09-21 00:32:36 +04:00
* count = i ;
2006-09-17 04:15:13 +04:00
2006-09-21 00:32:36 +04:00
return WERR_OK ;
}
2006-09-17 04:15:13 +04:00
2006-09-21 00:32:36 +04:00
/*
srvsvc_NetShareSetInfo
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetShareSetInfo ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2006-09-21 00:32:36 +04:00
struct srvsvc_NetShareSetInfo * r )
{
NTSTATUS nterr ;
WERROR status ;
struct share_context * sctx = NULL ;
struct share_info * info ;
int count ;
2006-09-17 04:15:13 +04:00
2006-09-21 00:32:36 +04:00
/* TODO: - access check
*/
/* there are no more than 10 options in all struct srvsvc_NetShareInfoXXX */
info = talloc_array ( mem_ctx , struct share_info , 10 ) ;
W_ERROR_HAVE_NO_MEMORY ( info ) ;
if ( strcmp ( " " , r - > in . share_name ) = = 0 ) {
2015-12-03 17:24:27 +03:00
return WERR_INVALID_PARAMETER ;
2006-09-21 00:32:36 +04:00
}
2010-07-16 08:32:42 +04:00
nterr = share_get_context_by_name ( mem_ctx , lpcfg_share_backend ( dce_call - > conn - > dce_ctx - > lp_ctx ) , dce_call - > event_ctx , dce_call - > conn - > dce_ctx - > lp_ctx , & sctx ) ;
2006-09-21 00:32:36 +04:00
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
switch ( r - > in . level ) {
case 0 :
{
2007-01-17 17:49:36 +03:00
status = dcesrv_srvsvc_fill_share_info ( info , & count ,
2006-09-21 00:32:36 +04:00
r - > in . share_name , r - > in . level ,
2008-10-29 17:11:27 +03:00
r - > in . info - > info0 - > name ,
2006-09-21 00:32:36 +04:00
NULL ,
NULL ,
NULL ,
0 ,
0 ,
0 ,
NULL ) ;
2009-09-07 16:52:37 +04:00
if ( ! W_ERROR_EQUAL ( status , WERR_OK ) ) {
2006-09-21 00:32:36 +04:00
return status ;
2006-09-17 04:15:13 +04:00
}
2006-09-21 00:32:36 +04:00
break ;
}
case 1 :
{
2007-01-17 17:49:36 +03:00
status = dcesrv_srvsvc_fill_share_info ( info , & count ,
2006-09-21 00:32:36 +04:00
r - > in . share_name , r - > in . level ,
2008-10-29 17:11:27 +03:00
r - > in . info - > info1 - > name ,
2006-09-21 00:32:36 +04:00
NULL ,
2008-10-29 17:11:27 +03:00
r - > in . info - > info1 - > comment ,
2006-09-21 00:32:36 +04:00
NULL ,
2008-10-29 17:11:27 +03:00
r - > in . info - > info1 - > type ,
2006-09-21 00:32:36 +04:00
0 ,
0 ,
NULL ) ;
2009-09-07 16:52:37 +04:00
if ( ! W_ERROR_EQUAL ( status , WERR_OK ) ) {
2006-09-21 00:32:36 +04:00
return status ;
}
break ;
}
case 2 :
{
2007-01-17 17:49:36 +03:00
status = dcesrv_srvsvc_fill_share_info ( info , & count ,
2006-09-21 00:32:36 +04:00
r - > in . share_name , r - > in . level ,
2008-10-29 17:11:27 +03:00
r - > in . info - > info2 - > name ,
r - > in . info - > info2 - > path ,
r - > in . info - > info2 - > comment ,
r - > in . info - > info2 - > password ,
r - > in . info - > info2 - > type ,
r - > in . info - > info2 - > max_users ,
2006-09-21 00:32:36 +04:00
0 ,
NULL ) ;
2009-09-07 16:52:37 +04:00
if ( ! W_ERROR_EQUAL ( status , WERR_OK ) ) {
2006-09-21 00:32:36 +04:00
return status ;
}
break ;
}
case 501 :
{
2007-01-17 17:49:36 +03:00
status = dcesrv_srvsvc_fill_share_info ( info , & count ,
2006-09-21 00:32:36 +04:00
r - > in . share_name , r - > in . level ,
2008-10-29 17:11:27 +03:00
r - > in . info - > info501 - > name ,
2006-09-21 00:32:36 +04:00
NULL ,
2008-10-29 17:11:27 +03:00
r - > in . info - > info501 - > comment ,
2006-09-21 00:32:36 +04:00
NULL ,
2008-10-29 17:11:27 +03:00
r - > in . info - > info501 - > type ,
2006-09-21 00:32:36 +04:00
0 ,
2008-10-29 17:11:27 +03:00
r - > in . info - > info501 - > csc_policy ,
2006-09-21 00:32:36 +04:00
NULL ) ;
2009-09-07 16:52:37 +04:00
if ( ! W_ERROR_EQUAL ( status , WERR_OK ) ) {
2006-09-21 00:32:36 +04:00
return status ;
}
break ;
}
case 502 :
{
2007-01-17 17:49:36 +03:00
status = dcesrv_srvsvc_fill_share_info ( info , & count ,
2006-09-21 00:32:36 +04:00
r - > in . share_name , r - > in . level ,
2008-10-29 17:11:27 +03:00
r - > in . info - > info502 - > name ,
r - > in . info - > info502 - > path ,
r - > in . info - > info502 - > comment ,
r - > in . info - > info502 - > password ,
r - > in . info - > info502 - > type ,
r - > in . info - > info502 - > max_users ,
2006-09-21 00:32:36 +04:00
0 ,
2008-10-29 17:11:27 +03:00
r - > in . info - > info502 - > sd_buf . sd ) ;
2009-09-07 16:52:37 +04:00
if ( ! W_ERROR_EQUAL ( status , WERR_OK ) ) {
2006-09-21 00:32:36 +04:00
return status ;
}
break ;
2006-09-15 20:27:55 +04:00
}
case 1004 :
{
2007-01-17 17:49:36 +03:00
status = dcesrv_srvsvc_fill_share_info ( info , & count ,
2006-09-21 00:32:36 +04:00
r - > in . share_name , r - > in . level ,
NULL ,
NULL ,
2008-10-29 17:11:27 +03:00
r - > in . info - > info1004 - > comment ,
2006-09-21 00:32:36 +04:00
NULL ,
0 ,
0 ,
0 ,
NULL ) ;
2009-09-07 16:52:37 +04:00
if ( ! W_ERROR_EQUAL ( status , WERR_OK ) ) {
2006-09-21 00:32:36 +04:00
return status ;
}
break ;
2006-09-15 20:27:55 +04:00
}
case 1005 :
{
2006-09-17 04:15:13 +04:00
/* r->in.info.dfs_flags; */
2006-09-15 20:27:55 +04:00
2006-09-17 04:15:13 +04:00
if ( r - > in . parm_error ) {
r - > out . parm_error = r - > in . parm_error ;
}
return WERR_OK ;
2006-09-15 20:27:55 +04:00
}
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2006-09-15 20:27:55 +04:00
}
2006-09-21 00:32:36 +04:00
nterr = share_set ( sctx , r - > in . share_name , info , count ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
if ( r - > in . parm_error ) {
r - > out . parm_error = r - > in . parm_error ;
}
return WERR_OK ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NetShareDelSticky
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetShareDelSticky ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetShareDelSticky * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NetShareCheck
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetShareCheck ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetShareCheck * r )
{
2006-09-15 20:27:55 +04:00
NTSTATUS nterr ;
struct share_context * sctx = NULL ;
struct share_config * scfg = NULL ;
char * device ;
const char * * names ;
2009-11-21 21:08:42 +03:00
int count ;
2010-03-01 23:11:39 +03:00
int i ;
2006-09-15 20:27:55 +04:00
2008-10-29 16:19:14 +03:00
* r - > out . type = 0 ;
2004-12-31 10:42:57 +03:00
/* TODO: - access check
*/
if ( strcmp ( " " , r - > in . device_name ) = = 0 ) {
2008-10-29 16:19:14 +03:00
* r - > out . type = STYPE_IPC ;
2004-12-31 10:42:57 +03:00
return WERR_OK ;
}
2006-09-15 20:27:55 +04:00
/* copy the path skipping C:\ */
if ( strncasecmp ( r - > in . device_name , " C: " , 2 ) = = 0 ) {
device = talloc_strdup ( mem_ctx , & r - > in . device_name [ 2 ] ) ;
} else {
/* no chance we have a share that doesn't start with C:\ */
2015-12-03 17:24:35 +03:00
return WERR_NERR_DEVICENOTSHARED ;
2006-09-15 20:27:55 +04:00
}
all_string_sub ( device , " \\ " , " / " , 0 ) ;
2010-07-16 08:32:42 +04:00
nterr = share_get_context_by_name ( mem_ctx , lpcfg_share_backend ( dce_call - > conn - > dce_ctx - > lp_ctx ) , dce_call - > event_ctx , dce_call - > conn - > dce_ctx - > lp_ctx , & sctx ) ;
2006-09-15 20:27:55 +04:00
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
nterr = share_list_all ( mem_ctx , sctx , & count , & names ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
for ( i = 0 ; i < count ; i + + ) {
const char * path ;
const char * type ;
nterr = share_get_config ( mem_ctx , sctx , names [ i ] , & scfg ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
2014-01-17 01:16:12 +04:00
path = share_string_option ( mem_ctx , scfg , SHARE_PATH , NULL ) ;
2006-09-15 20:27:55 +04:00
if ( ! path ) continue ;
2014-01-17 01:16:12 +04:00
if ( strcmp ( device , path ) = = 0 ) {
type = share_string_option ( mem_ctx , scfg , SHARE_TYPE , NULL ) ;
2006-09-15 20:27:55 +04:00
if ( ! type ) continue ;
if ( strcmp ( type , " DISK " ) = = 0 ) {
2008-10-29 16:19:14 +03:00
* r - > out . type = STYPE_DISKTREE ;
2006-09-15 20:27:55 +04:00
return WERR_OK ;
}
if ( strcmp ( type , " IPC " ) = = 0 ) {
2008-10-29 16:19:14 +03:00
* r - > out . type = STYPE_IPC ;
2006-09-15 20:27:55 +04:00
return WERR_OK ;
}
if ( strcmp ( type , " PRINTER " ) = = 0 ) {
2008-10-29 16:19:14 +03:00
* r - > out . type = STYPE_PRINTQ ;
2006-09-15 20:27:55 +04:00
return WERR_OK ;
}
}
2004-12-31 10:42:57 +03:00
}
2015-12-03 17:24:35 +03:00
return WERR_NERR_DEVICENOTSHARED ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NetSrvGetInfo
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetSrvGetInfo ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetSrvGetInfo * r )
{
2004-12-31 05:48:11 +03:00
struct dcesrv_context * dce_ctx = dce_call - > conn - > dce_ctx ;
2010-07-16 08:32:42 +04:00
struct dcerpc_server_info * server_info = lpcfg_dcerpc_server_info ( mem_ctx , dce_ctx - > lp_ctx ) ;
2019-11-05 13:58:43 +03:00
const struct loadparm_substitution * lp_sub =
lpcfg_noop_substitution ( ) ;
2004-12-30 20:01:49 +03:00
2008-10-29 22:39:57 +03:00
ZERO_STRUCTP ( r - > out . info ) ;
2004-12-30 20:01:49 +03:00
2004-12-31 05:48:11 +03:00
switch ( r - > in . level ) {
case 100 :
{
struct srvsvc_NetSrvInfo100 * info100 ;
2005-01-27 10:08:20 +03:00
info100 = talloc ( mem_ctx , struct srvsvc_NetSrvInfo100 ) ;
2004-12-31 05:48:11 +03:00
W_ERROR_HAVE_NO_MEMORY ( info100 ) ;
info100 - > platform_id = dcesrv_common_get_platform_id ( mem_ctx , dce_ctx ) ;
info100 - > server_name = dcesrv_common_get_server_name ( mem_ctx , dce_ctx , r - > in . server_unc ) ;
W_ERROR_HAVE_NO_MEMORY ( info100 - > server_name ) ;
2008-10-29 22:39:57 +03:00
r - > out . info - > info100 = info100 ;
2004-12-31 05:48:11 +03:00
return WERR_OK ;
}
case 101 :
{
struct srvsvc_NetSrvInfo101 * info101 ;
2005-01-27 10:08:20 +03:00
info101 = talloc ( mem_ctx , struct srvsvc_NetSrvInfo101 ) ;
2004-12-31 05:48:11 +03:00
W_ERROR_HAVE_NO_MEMORY ( info101 ) ;
info101 - > platform_id = dcesrv_common_get_platform_id ( mem_ctx , dce_ctx ) ;
info101 - > server_name = dcesrv_common_get_server_name ( mem_ctx , dce_ctx , r - > in . server_unc ) ;
W_ERROR_HAVE_NO_MEMORY ( info101 - > server_name ) ;
2008-11-01 17:50:52 +03:00
info101 - > version_major = server_info - > version_major ;
info101 - > version_minor = server_info - > version_minor ;
2008-04-17 14:23:44 +04:00
info101 - > server_type = dcesrv_common_get_server_type ( mem_ctx , dce_call - > event_ctx , dce_ctx ) ;
2019-11-05 13:58:43 +03:00
info101 - > comment = lpcfg_server_string ( dce_ctx - > lp_ctx , lp_sub , mem_ctx ) ;
2004-12-31 05:48:11 +03:00
W_ERROR_HAVE_NO_MEMORY ( info101 - > comment ) ;
2008-10-29 22:39:57 +03:00
r - > out . info - > info101 = info101 ;
2004-12-31 05:48:11 +03:00
return WERR_OK ;
}
2006-09-10 04:41:15 +04:00
case 102 :
{
struct srvsvc_NetSrvInfo102 * info102 ;
info102 = talloc ( mem_ctx , struct srvsvc_NetSrvInfo102 ) ;
W_ERROR_HAVE_NO_MEMORY ( info102 ) ;
info102 - > platform_id = dcesrv_common_get_platform_id ( mem_ctx , dce_ctx ) ;
info102 - > server_name = dcesrv_common_get_server_name ( mem_ctx , dce_ctx , r - > in . server_unc ) ;
W_ERROR_HAVE_NO_MEMORY ( info102 - > server_name ) ;
2008-11-01 17:50:52 +03:00
info102 - > version_major = server_info - > version_major ;
info102 - > version_minor = server_info - > version_minor ;
2008-04-17 14:23:44 +04:00
info102 - > server_type = dcesrv_common_get_server_type ( mem_ctx , dce_call - > event_ctx , dce_ctx ) ;
2019-11-05 13:58:43 +03:00
info102 - > comment = lpcfg_server_string ( dce_ctx - > lp_ctx , lp_sub , mem_ctx ) ;
2006-09-10 04:41:15 +04:00
W_ERROR_HAVE_NO_MEMORY ( info102 - > comment ) ;
info102 - > users = dcesrv_common_get_users ( mem_ctx , dce_ctx ) ;
info102 - > disc = dcesrv_common_get_disc ( mem_ctx , dce_ctx ) ;
info102 - > hidden = dcesrv_common_get_hidden ( mem_ctx , dce_ctx ) ;
info102 - > announce = dcesrv_common_get_announce ( mem_ctx , dce_ctx ) ;
info102 - > anndelta = dcesrv_common_get_anndelta ( mem_ctx , dce_ctx ) ;
info102 - > licenses = dcesrv_common_get_licenses ( mem_ctx , dce_ctx ) ;
info102 - > userpath = dcesrv_common_get_userpath ( mem_ctx , dce_ctx ) ;
W_ERROR_HAVE_NO_MEMORY ( info102 - > userpath ) ;
2008-10-29 22:39:57 +03:00
r - > out . info - > info102 = info102 ;
2006-09-10 04:41:15 +04:00
return WERR_OK ;
}
2004-12-31 05:48:11 +03:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-12-31 05:48:11 +03:00
}
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NetSrvSetInfo
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetSrvSetInfo ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetSrvSetInfo * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NetDiskEnum
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetDiskEnum ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetDiskEnum * r )
{
2008-10-30 13:21:52 +03:00
r - > out . info - > disks = NULL ;
r - > out . info - > count = 0 ;
* r - > out . totalentries = 0 ;
2004-04-08 23:06:37 +04:00
switch ( r - > in . level ) {
2004-12-31 08:34:31 +03:00
case 0 :
{
2006-09-10 07:58:00 +04:00
/* we can safely hardcode the reply and report we have only one disk (C:) */
/* for some reason Windows wants 2 entries with the second being empty */
2008-10-30 13:21:52 +03:00
r - > out . info - > disks = talloc_array ( mem_ctx , struct srvsvc_NetDiskInfo0 , 2 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info - > disks ) ;
r - > out . info - > count = 2 ;
2006-09-10 07:58:00 +04:00
2008-10-30 13:21:52 +03:00
r - > out . info - > disks [ 0 ] . disk = talloc_strdup ( mem_ctx , " C: " ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info - > disks [ 0 ] . disk ) ;
2006-09-10 07:58:00 +04:00
2008-10-30 13:21:52 +03:00
r - > out . info - > disks [ 1 ] . disk = talloc_strdup ( mem_ctx , " " ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . info - > disks [ 1 ] . disk ) ;
2006-09-10 07:58:00 +04:00
2008-10-30 13:21:52 +03:00
* r - > out . totalentries = 1 ;
2006-09-10 07:58:00 +04:00
r - > out . resume_handle = r - > in . resume_handle ;
return WERR_OK ;
2004-12-31 08:34:31 +03:00
}
2004-04-08 23:06:37 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-04-08 23:06:37 +04:00
}
}
/*
2005-12-25 00:32:52 +03:00
srvsvc_NetServerStatisticsGet
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetServerStatisticsGet ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetServerStatisticsGet * r )
2004-04-08 23:06:37 +04:00
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
2005-12-25 00:32:52 +03:00
srvsvc_NetTransportAdd
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetTransportAdd ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetTransportAdd * r )
2004-04-08 23:06:37 +04:00
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NetTransportEnum
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetTransportEnum ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NetTransportEnum * r )
{
2008-10-29 18:33:47 +03:00
r - > out . transports - > level = r - > in . transports - > level ;
* r - > out . totalentries = 0 ;
if ( r - > out . resume_handle ) {
* r - > out . resume_handle = 0 ;
}
2004-04-19 22:21:53 +04:00
2008-10-29 18:33:47 +03:00
switch ( r - > in . transports - > level ) {
2004-12-31 08:34:31 +03:00
case 0 :
{
2008-10-29 18:33:47 +03:00
r - > out . transports - > ctr . ctr0 = talloc ( mem_ctx , struct srvsvc_NetTransportCtr0 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . transports - > ctr . ctr0 ) ;
2004-04-19 22:21:53 +04:00
2008-10-29 18:33:47 +03:00
r - > out . transports - > ctr . ctr0 - > count = 0 ;
r - > out . transports - > ctr . ctr0 - > array = NULL ;
2004-04-19 22:21:53 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
case 1 :
{
2008-10-29 18:33:47 +03:00
r - > out . transports - > ctr . ctr1 = talloc ( mem_ctx , struct srvsvc_NetTransportCtr1 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . transports - > ctr . ctr1 ) ;
2004-04-19 22:21:53 +04:00
2008-10-29 18:33:47 +03:00
r - > out . transports - > ctr . ctr1 - > count = 0 ;
r - > out . transports - > ctr . ctr1 - > array = NULL ;
2004-04-19 22:21:53 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
case 2 :
{
2008-10-29 18:33:47 +03:00
r - > out . transports - > ctr . ctr2 = talloc ( mem_ctx , struct srvsvc_NetTransportCtr2 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . transports - > ctr . ctr2 ) ;
2004-04-19 22:21:53 +04:00
2008-10-29 18:33:47 +03:00
r - > out . transports - > ctr . ctr2 - > count = 0 ;
r - > out . transports - > ctr . ctr2 - > array = NULL ;
2004-04-19 22:21:53 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
case 3 :
{
2008-10-29 18:33:47 +03:00
r - > out . transports - > ctr . ctr3 = talloc ( mem_ctx , struct srvsvc_NetTransportCtr3 ) ;
W_ERROR_HAVE_NO_MEMORY ( r - > out . transports - > ctr . ctr3 ) ;
2004-04-19 22:21:53 +04:00
2008-10-29 18:33:47 +03:00
r - > out . transports - > ctr . ctr3 - > count = 0 ;
r - > out . transports - > ctr . ctr3 - > array = NULL ;
2004-04-19 22:21:53 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-12-31 08:34:31 +03:00
}
2004-04-19 22:21:53 +04:00
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2004-04-19 22:21:53 +04:00
}
2004-04-08 23:06:37 +04:00
}
/*
2005-12-25 00:32:52 +03:00
srvsvc_NetTransportDel
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetTransportDel ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetTransportDel * r )
2004-04-08 23:06:37 +04:00
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
2004-07-19 14:15:33 +04:00
srvsvc_NetRemoteTOD
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetRemoteTOD ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-07-19 14:15:33 +04:00
struct srvsvc_NetRemoteTOD * r )
2004-04-08 23:06:37 +04:00
{
2004-12-06 14:10:15 +03:00
struct timeval tval ;
time_t t ;
struct tm tm ;
2008-10-29 16:01:04 +03:00
struct srvsvc_NetRemoteTODInfo * info ;
2004-12-06 14:10:15 +03:00
2008-10-29 16:01:04 +03:00
info = talloc ( mem_ctx , struct srvsvc_NetRemoteTODInfo ) ;
W_ERROR_HAVE_NO_MEMORY ( info ) ;
2004-12-06 14:10:15 +03:00
GetTimeOfDay ( & tval ) ;
t = tval . tv_sec ;
gmtime_r ( & t , & tm ) ;
2008-10-29 16:01:04 +03:00
info - > elapsed = t ;
2004-12-31 05:48:11 +03:00
/* TODO: fake the uptime: just return the milliseconds till 0:00:00 today */
2008-10-29 16:01:04 +03:00
info - > msecs = ( tm . tm_hour * 60 * 60 * 1000 )
+ ( tm . tm_min * 60 * 1000 )
+ ( tm . tm_sec * 1000 )
+ ( tval . tv_usec / 1000 ) ;
info - > hours = tm . tm_hour ;
info - > mins = tm . tm_min ;
info - > secs = tm . tm_sec ;
info - > hunds = tval . tv_usec / 10000 ;
info - > timezone = get_time_zone ( t ) / 60 ;
info - > tinterval = 310 ; /* just return the same as windows */
info - > day = tm . tm_mday ;
info - > month = tm . tm_mon + 1 ;
info - > year = tm . tm_year + 1900 ;
info - > weekday = tm . tm_wday ;
* r - > out . info = info ;
2004-12-06 14:10:15 +03:00
return WERR_OK ;
2004-04-08 23:06:37 +04:00
}
/*
2005-12-25 00:32:52 +03:00
srvsvc_NetPathType
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetPathType ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetPathType * r )
2004-04-08 23:06:37 +04:00
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
2005-12-25 00:32:52 +03:00
srvsvc_NetPathCanonicalize
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetPathCanonicalize ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetPathCanonicalize * r )
2004-04-08 23:06:37 +04:00
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
2005-12-25 00:32:52 +03:00
srvsvc_NetPathCompare
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetPathCompare ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetPathCompare * r )
2004-04-08 23:06:37 +04:00
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
2005-12-25 00:32:52 +03:00
srvsvc_NetNameValidate
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetNameValidate ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetNameValidate * r )
2004-04-08 23:06:37 +04:00
{
2006-09-12 06:24:21 +04:00
int len ;
if ( ( r - > in . flags ! = 0x0 ) & & ( r - > in . flags ! = 0x80000000 ) ) {
return WERR_INVALID_NAME ;
}
switch ( r - > in . name_type ) {
case 1 :
case 2 :
case 3 :
case 4 :
case 5 :
case 6 :
case 7 :
case 8 :
return WERR_NOT_SUPPORTED ;
case 9 : /* validate share name */
len = strlen_m ( r - > in . name ) ;
if ( ( r - > in . flags = = 0x0 ) & & ( len > 81 ) ) {
return WERR_INVALID_NAME ;
}
if ( ( r - > in . flags = = 0x80000000 ) & & ( len > 13 ) ) {
return WERR_INVALID_NAME ;
}
if ( ! dcesrv_common_validate_share_name ( mem_ctx , r - > in . name ) ) {
return WERR_INVALID_NAME ;
}
return WERR_OK ;
case 10 :
case 11 :
case 12 :
case 13 :
return WERR_NOT_SUPPORTED ;
default :
2015-12-03 17:24:27 +03:00
return WERR_INVALID_PARAMETER ;
2006-09-12 06:24:21 +04:00
}
2004-04-08 23:06:37 +04:00
}
/*
2005-12-25 00:32:52 +03:00
srvsvc_NetPRNameCompare
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetPRNameCompare ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetPRNameCompare * r )
2004-04-08 23:06:37 +04:00
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NetShareEnum
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetShareEnum ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetShareEnum * r )
2004-04-08 23:06:37 +04:00
{
2006-07-23 22:43:07 +04:00
NTSTATUS nterr ;
int numshares = 0 ;
const char * * snames ;
struct share_context * sctx ;
struct share_config * scfg ;
2006-04-26 16:07:01 +04:00
struct dcesrv_context * dce_ctx = dce_call - > conn - > dce_ctx ;
2008-10-30 20:21:49 +03:00
* r - > out . totalentries = 0 ;
2006-04-26 16:07:01 +04:00
/* TODO: - paging of results
*/
2010-07-16 08:32:42 +04:00
nterr = share_get_context_by_name ( mem_ctx , lpcfg_share_backend ( dce_call - > conn - > dce_ctx - > lp_ctx ) , dce_call - > event_ctx , dce_call - > conn - > dce_ctx - > lp_ctx , & sctx ) ;
2006-07-23 22:43:07 +04:00
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
nterr = share_list_all ( mem_ctx , sctx , & numshares , & snames ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
2008-10-30 20:21:49 +03:00
switch ( r - > in . info_ctr - > level ) {
2006-04-26 16:07:01 +04:00
case 0 :
{
2009-11-21 21:08:42 +03:00
unsigned int i , y = 0 ;
unsigned int count ;
2006-04-26 16:07:01 +04:00
struct srvsvc_NetShareCtr0 * ctr0 ;
ctr0 = talloc ( mem_ctx , struct srvsvc_NetShareCtr0 ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr0 ) ;
2006-07-23 22:43:07 +04:00
count = numshares ;
2006-04-26 16:07:01 +04:00
ctr0 - > count = count ;
ctr0 - > array = NULL ;
if ( ctr0 - > count = = 0 ) {
2008-10-30 20:21:49 +03:00
r - > out . info_ctr - > ctr . ctr0 = ctr0 ;
2006-04-26 16:07:01 +04:00
return WERR_OK ;
}
ctr0 - > array = talloc_array ( mem_ctx , struct srvsvc_NetShareInfo0 , count ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr0 - > array ) ;
for ( i = 0 ; i < count ; i + + ) {
WERROR status ;
union srvsvc_NetShareInfo info ;
2006-07-23 22:43:07 +04:00
enum srvsvc_ShareType type ;
2006-04-26 16:07:01 +04:00
2006-07-23 22:43:07 +04:00
nterr = share_get_config ( mem_ctx , sctx , snames [ i ] , & scfg ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
DEBUG ( 1 , ( " ERROR: Service [%s] disappeared after enumeration " , snames [ i ] ) ) ;
2015-12-03 17:24:22 +03:00
return WERR_GEN_FAILURE ;
2006-07-23 22:43:07 +04:00
}
type = dcesrv_common_get_share_type ( mem_ctx , dce_ctx , scfg ) ;
2006-04-26 16:07:01 +04:00
if ( type & STYPE_HIDDEN ) {
ctr0 - > count - - ;
2006-07-23 22:43:07 +04:00
talloc_free ( scfg ) ;
2006-04-26 16:07:01 +04:00
continue ;
}
info . info0 = & ctr0 - > array [ y ] ;
2008-10-30 20:21:49 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . info_ctr - > level , & info ) ;
2006-04-26 16:07:01 +04:00
W_ERROR_NOT_OK_RETURN ( status ) ;
2006-07-23 22:43:07 +04:00
talloc_free ( scfg ) ;
2006-04-26 16:07:01 +04:00
y + + ;
}
2006-07-23 22:43:07 +04:00
talloc_free ( snames ) ;
2006-04-26 16:07:01 +04:00
2008-10-30 20:21:49 +03:00
r - > out . info_ctr - > ctr . ctr0 = ctr0 ;
* r - > out . totalentries = r - > out . info_ctr - > ctr . ctr0 - > count ;
2006-04-26 16:07:01 +04:00
return WERR_OK ;
}
case 1 :
{
2009-11-21 21:08:42 +03:00
unsigned int i , y = 0 ;
unsigned int count ;
2006-04-26 16:07:01 +04:00
struct srvsvc_NetShareCtr1 * ctr1 ;
ctr1 = talloc ( mem_ctx , struct srvsvc_NetShareCtr1 ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr1 ) ;
2006-07-23 22:43:07 +04:00
count = numshares ;
2006-04-26 16:07:01 +04:00
ctr1 - > count = count ;
ctr1 - > array = NULL ;
if ( ctr1 - > count = = 0 ) {
2008-10-30 20:21:49 +03:00
r - > out . info_ctr - > ctr . ctr1 = ctr1 ;
2006-04-26 16:07:01 +04:00
return WERR_OK ;
}
ctr1 - > array = talloc_array ( mem_ctx , struct srvsvc_NetShareInfo1 , count ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr1 - > array ) ;
for ( i = 0 ; i < count ; i + + ) {
WERROR status ;
union srvsvc_NetShareInfo info ;
2006-07-23 22:43:07 +04:00
enum srvsvc_ShareType type ;
2006-04-26 16:07:01 +04:00
2006-07-23 22:43:07 +04:00
nterr = share_get_config ( mem_ctx , sctx , snames [ i ] , & scfg ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
DEBUG ( 1 , ( " ERROR: Service [%s] disappeared after enumeration " , snames [ i ] ) ) ;
2015-12-03 17:24:22 +03:00
return WERR_GEN_FAILURE ;
2006-07-23 22:43:07 +04:00
}
type = dcesrv_common_get_share_type ( mem_ctx , dce_ctx , scfg ) ;
2006-04-26 16:07:01 +04:00
if ( type & STYPE_HIDDEN ) {
ctr1 - > count - - ;
2006-07-23 22:43:07 +04:00
talloc_free ( scfg ) ;
2006-04-26 16:07:01 +04:00
continue ;
}
info . info1 = & ctr1 - > array [ y ] ;
2008-10-30 20:21:49 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . info_ctr - > level , & info ) ;
2006-04-26 16:07:01 +04:00
W_ERROR_NOT_OK_RETURN ( status ) ;
2006-07-23 22:43:07 +04:00
talloc_free ( scfg ) ;
2006-04-26 16:07:01 +04:00
y + + ;
}
2006-07-23 22:43:07 +04:00
talloc_free ( snames ) ;
2006-04-26 16:07:01 +04:00
2008-10-30 20:21:49 +03:00
r - > out . info_ctr - > ctr . ctr1 = ctr1 ;
* r - > out . totalentries = r - > out . info_ctr - > ctr . ctr1 - > count ;
2006-04-26 16:07:01 +04:00
return WERR_OK ;
}
case 2 :
{
2009-11-21 21:08:42 +03:00
unsigned int i , y = 0 ;
unsigned int count ;
2006-04-26 16:07:01 +04:00
struct srvsvc_NetShareCtr2 * ctr2 ;
SRVSVC_CHECK_ADMIN_ACCESS ;
ctr2 = talloc ( mem_ctx , struct srvsvc_NetShareCtr2 ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr2 ) ;
2006-07-23 22:43:07 +04:00
count = numshares ;
2006-04-26 16:07:01 +04:00
ctr2 - > count = count ;
ctr2 - > array = NULL ;
if ( ctr2 - > count = = 0 ) {
2008-10-30 20:21:49 +03:00
r - > out . info_ctr - > ctr . ctr2 = ctr2 ;
2006-04-26 16:07:01 +04:00
return WERR_OK ;
}
ctr2 - > array = talloc_array ( mem_ctx , struct srvsvc_NetShareInfo2 , count ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr2 - > array ) ;
for ( i = 0 ; i < count ; i + + ) {
WERROR status ;
union srvsvc_NetShareInfo info ;
2006-07-23 22:43:07 +04:00
enum srvsvc_ShareType type ;
nterr = share_get_config ( mem_ctx , sctx , snames [ i ] , & scfg ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
DEBUG ( 1 , ( " ERROR: Service [%s] disappeared after enumeration " , snames [ i ] ) ) ;
2015-12-03 17:24:22 +03:00
return WERR_GEN_FAILURE ;
2006-07-23 22:43:07 +04:00
}
2006-04-26 16:07:01 +04:00
2006-07-23 22:43:07 +04:00
type = dcesrv_common_get_share_type ( mem_ctx , dce_ctx , scfg ) ;
2006-04-26 16:07:01 +04:00
if ( type & STYPE_HIDDEN ) {
ctr2 - > count - - ;
2006-07-23 22:43:07 +04:00
talloc_free ( scfg ) ;
2006-04-26 16:07:01 +04:00
continue ;
}
info . info2 = & ctr2 - > array [ y ] ;
2008-10-30 20:21:49 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . info_ctr - > level , & info ) ;
2006-04-26 16:07:01 +04:00
W_ERROR_NOT_OK_RETURN ( status ) ;
2006-07-23 22:43:07 +04:00
talloc_free ( scfg ) ;
2006-04-26 16:07:01 +04:00
y + + ;
}
2006-07-23 22:43:07 +04:00
talloc_free ( snames ) ;
2006-04-26 16:07:01 +04:00
2008-10-30 20:21:49 +03:00
r - > out . info_ctr - > ctr . ctr2 = ctr2 ;
* r - > out . totalentries = r - > out . info_ctr - > ctr . ctr2 - > count ;
2006-04-26 16:07:01 +04:00
return WERR_OK ;
}
case 502 :
{
2009-11-21 21:08:42 +03:00
unsigned int i , y = 0 ;
unsigned int count ;
2006-04-26 16:07:01 +04:00
struct srvsvc_NetShareCtr502 * ctr502 ;
SRVSVC_CHECK_ADMIN_ACCESS ;
ctr502 = talloc ( mem_ctx , struct srvsvc_NetShareCtr502 ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr502 ) ;
2006-07-23 22:43:07 +04:00
count = numshares ;
2006-04-26 16:07:01 +04:00
ctr502 - > count = count ;
ctr502 - > array = NULL ;
if ( ctr502 - > count = = 0 ) {
2008-10-30 20:21:49 +03:00
r - > out . info_ctr - > ctr . ctr502 = ctr502 ;
2006-04-26 16:07:01 +04:00
return WERR_OK ;
}
ctr502 - > array = talloc_array ( mem_ctx , struct srvsvc_NetShareInfo502 , count ) ;
W_ERROR_HAVE_NO_MEMORY ( ctr502 - > array ) ;
for ( i = 0 ; i < count ; i + + ) {
WERROR status ;
union srvsvc_NetShareInfo info ;
2006-07-23 22:43:07 +04:00
enum srvsvc_ShareType type ;
nterr = share_get_config ( mem_ctx , sctx , snames [ i ] , & scfg ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
DEBUG ( 1 , ( " ERROR: Service [%s] disappeared after enumeration " , snames [ i ] ) ) ;
2015-12-03 17:24:22 +03:00
return WERR_GEN_FAILURE ;
2006-07-23 22:43:07 +04:00
}
2006-04-26 16:07:01 +04:00
2006-07-23 22:43:07 +04:00
type = dcesrv_common_get_share_type ( mem_ctx , dce_ctx , scfg ) ;
2006-04-26 16:07:01 +04:00
if ( type & STYPE_HIDDEN ) {
ctr502 - > count - - ;
2006-07-23 22:43:07 +04:00
talloc_free ( scfg ) ;
2006-04-26 16:07:01 +04:00
continue ;
}
info . info502 = & ctr502 - > array [ y ] ;
2008-10-30 20:21:49 +03:00
status = dcesrv_srvsvc_fiel_ShareInfo ( dce_call , mem_ctx , scfg , r - > in . info_ctr - > level , & info ) ;
2006-04-26 16:07:01 +04:00
W_ERROR_NOT_OK_RETURN ( status ) ;
2006-07-23 22:43:07 +04:00
talloc_free ( scfg ) ;
2006-04-26 16:07:01 +04:00
y + + ;
}
2006-07-23 22:43:07 +04:00
talloc_free ( snames ) ;
2006-04-26 16:07:01 +04:00
2008-10-30 20:21:49 +03:00
r - > out . info_ctr - > ctr . ctr502 = ctr502 ;
* r - > out . totalentries = r - > out . info_ctr - > ctr . ctr502 - > count ;
2006-04-26 16:07:01 +04:00
return WERR_OK ;
}
default :
2015-12-03 17:24:42 +03:00
return WERR_INVALID_LEVEL ;
2006-04-26 16:07:01 +04:00
}
2004-04-08 23:06:37 +04:00
}
/*
2005-12-25 00:32:52 +03:00
srvsvc_NetShareDelStart
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetShareDelStart ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetShareDelStart * r )
2004-04-08 23:06:37 +04:00
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
2005-12-25 00:32:52 +03:00
srvsvc_NetShareDelCommit
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetShareDelCommit ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetShareDelCommit * r )
2004-04-08 23:06:37 +04:00
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
2005-12-25 00:32:52 +03:00
srvsvc_NetGetFileSecurity
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetGetFileSecurity ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetGetFileSecurity * r )
2004-04-08 23:06:37 +04:00
{
2018-11-03 03:19:51 +03:00
struct auth_session_info * session_info =
dcesrv_call_session_info ( dce_call ) ;
2006-05-21 16:15:04 +04:00
struct sec_desc_buf * sd_buf ;
struct ntvfs_context * ntvfs_ctx = NULL ;
struct ntvfs_request * ntvfs_req ;
union smb_fileinfo * io ;
NTSTATUS nt_status ;
nt_status = srvsvc_create_ntvfs_context ( dce_call , mem_ctx , r - > in . share , & ntvfs_ctx ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) return ntstatus_to_werror ( nt_status ) ;
ntvfs_req = ntvfs_request_create ( ntvfs_ctx , mem_ctx ,
2018-11-03 03:19:51 +03:00
session_info ,
2006-05-21 16:15:04 +04:00
0 ,
dce_call - > time ,
NULL , NULL , 0 ) ;
W_ERROR_HAVE_NO_MEMORY ( ntvfs_req ) ;
sd_buf = talloc ( mem_ctx , struct sec_desc_buf ) ;
W_ERROR_HAVE_NO_MEMORY ( sd_buf ) ;
io = talloc ( mem_ctx , union smb_fileinfo ) ;
W_ERROR_HAVE_NO_MEMORY ( io ) ;
io - > query_secdesc . level = RAW_FILEINFO_SEC_DESC ;
io - > query_secdesc . in . file . path = r - > in . file ;
io - > query_secdesc . in . secinfo_flags = r - > in . securityinformation ;
nt_status = ntvfs_qpathinfo ( ntvfs_req , io ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) return ntstatus_to_werror ( nt_status ) ;
sd_buf - > sd = io - > query_secdesc . out . sd ;
2008-10-29 15:52:23 +03:00
* r - > out . sd_buf = sd_buf ;
2006-05-21 16:15:04 +04:00
return WERR_OK ;
2004-04-08 23:06:37 +04:00
}
/*
2005-12-25 00:32:52 +03:00
srvsvc_NetSetFileSecurity
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetSetFileSecurity ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetSetFileSecurity * r )
2004-04-08 23:06:37 +04:00
{
2018-11-03 03:19:51 +03:00
struct auth_session_info * session_info =
dcesrv_call_session_info ( dce_call ) ;
2006-05-21 16:15:04 +04:00
struct ntvfs_context * ntvfs_ctx ;
struct ntvfs_request * ntvfs_req ;
union smb_setfileinfo * io ;
NTSTATUS nt_status ;
nt_status = srvsvc_create_ntvfs_context ( dce_call , mem_ctx , r - > in . share , & ntvfs_ctx ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) return ntstatus_to_werror ( nt_status ) ;
ntvfs_req = ntvfs_request_create ( ntvfs_ctx , mem_ctx ,
2018-11-03 03:19:51 +03:00
session_info ,
2006-05-21 16:15:04 +04:00
0 ,
dce_call - > time ,
NULL , NULL , 0 ) ;
W_ERROR_HAVE_NO_MEMORY ( ntvfs_req ) ;
io = talloc ( mem_ctx , union smb_setfileinfo ) ;
W_ERROR_HAVE_NO_MEMORY ( io ) ;
2017-11-19 19:51:30 +03:00
io - > set_secdesc . level = RAW_SFILEINFO_SEC_DESC ;
2006-05-21 16:15:04 +04:00
io - > set_secdesc . in . file . path = r - > in . file ;
io - > set_secdesc . in . secinfo_flags = r - > in . securityinformation ;
2008-10-29 15:50:17 +03:00
io - > set_secdesc . in . sd = r - > in . sd_buf - > sd ;
2006-05-21 16:15:04 +04:00
nt_status = ntvfs_setpathinfo ( ntvfs_req , io ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) return ntstatus_to_werror ( nt_status ) ;
return WERR_OK ;
2004-04-08 23:06:37 +04:00
}
/*
2005-12-25 00:32:52 +03:00
srvsvc_NetServerTransportAddEx
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetServerTransportAddEx ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetServerTransportAddEx * r )
2004-04-08 23:06:37 +04:00
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
2005-12-25 00:32:52 +03:00
srvsvc_NetServerSetServiceBitsEx
2004-04-08 23:06:37 +04:00
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetServerSetServiceBitsEx ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetServerSetServiceBitsEx * r )
2004-04-08 23:06:37 +04:00
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NETRDFSGETVERSION
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NETRDFSGETVERSION ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NETRDFSGETVERSION * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NETRDFSCREATELOCALPARTITION
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NETRDFSCREATELOCALPARTITION ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NETRDFSCREATELOCALPARTITION * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NETRDFSDELETELOCALPARTITION
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NETRDFSDELETELOCALPARTITION ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NETRDFSDELETELOCALPARTITION * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NETRDFSSETLOCALVOLUMESTATE
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NETRDFSSETLOCALVOLUMESTATE ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NETRDFSSETLOCALVOLUMESTATE * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NETRDFSSETSERVERINFO
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NETRDFSSETSERVERINFO ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NETRDFSSETSERVERINFO * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NETRDFSCREATEEXITPOINT
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NETRDFSCREATEEXITPOINT ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NETRDFSCREATEEXITPOINT * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NETRDFSDELETEEXITPOINT
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NETRDFSDELETEEXITPOINT ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NETRDFSDELETEEXITPOINT * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NETRDFSMODIFYPREFIX
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NETRDFSMODIFYPREFIX ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NETRDFSMODIFYPREFIX * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NETRDFSFIXLOCALVOLUME
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NETRDFSFIXLOCALVOLUME ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NETRDFSFIXLOCALVOLUME * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NETRDFSMANAGERREPORTSITEINFO
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NETRDFSMANAGERREPORTSITEINFO ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NETRDFSMANAGERREPORTSITEINFO * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
/*
srvsvc_NETRSERVERTRANSPORTDELEX
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NETRSERVERTRANSPORTDELEX ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-08 23:06:37 +04:00
struct srvsvc_NETRSERVERTRANSPORTDELEX * r )
{
2004-05-25 04:51:47 +04:00
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
2004-04-08 23:06:37 +04:00
}
2005-12-25 00:32:52 +03:00
/*
srvsvc_NetShareDel
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetShareDel ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetShareDel * r )
{
2006-09-15 09:18:53 +04:00
NTSTATUS nterr ;
struct share_context * sctx ;
2010-07-16 08:32:42 +04:00
nterr = share_get_context_by_name ( mem_ctx , lpcfg_share_backend ( dce_call - > conn - > dce_ctx - > lp_ctx ) , dce_call - > event_ctx , dce_call - > conn - > dce_ctx - > lp_ctx , & sctx ) ;
2006-09-15 09:18:53 +04:00
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
nterr = share_remove ( sctx , r - > in . share_name ) ;
if ( ! NT_STATUS_IS_OK ( nterr ) ) {
return ntstatus_to_werror ( nterr ) ;
}
return WERR_OK ;
2005-12-25 00:32:52 +03:00
}
/*
srvsvc_NetSetServiceBits
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NetSetServiceBits ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NetSetServiceBits * r )
{
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
}
/*
srvsvc_NETRPRNAMECANONICALIZE
*/
2007-01-17 17:49:36 +03:00
static WERROR dcesrv_srvsvc_NETRPRNAMECANONICALIZE ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2005-12-25 00:32:52 +03:00
struct srvsvc_NETRPRNAMECANONICALIZE * r )
{
DCESRV_FAULT ( DCERPC_FAULT_OP_RNG_ERROR ) ;
}
2004-04-08 23:06:37 +04:00
/* include the generated boilerplate */
# include "librpc/gen_ndr/ndr_srvsvc_s.c"