2007-11-06 02:49:54 +03:00
/*
2003-11-13 12:26:53 +03:00
Unix SMB / CIFS implementation .
2006-09-19 00:00:51 +04:00
test suite for rpc dfs operations
2003-11-13 12:26:53 +03:00
Copyright ( C ) Andrew Tridgell 2003
2007-11-06 02:49:54 +03:00
2003-11-13 12:26:53 +03: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
2008-03-28 09:08:49 +03:00
the Free Software Foundation ; either version 3 of the License , or
2003-11-13 12:26:53 +03:00
( at your option ) any later version .
2007-11-06 02:49:54 +03:00
2003-11-13 12:26:53 +03:00
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 .
2007-11-06 02:49:54 +03:00
2003-11-13 12:26:53 +03:00
You should have received a copy of the GNU General Public License
2007-08-28 20:24:18 +04:00
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
2003-11-13 12:26:53 +03:00
*/
# include "includes.h"
2010-04-14 00:06:51 +04:00
# include "torture/rpc/torture_rpc.h"
2006-03-15 02:35:30 +03:00
# include "librpc/gen_ndr/ndr_dfs_c.h"
2006-09-21 06:45:02 +04:00
# include "libnet/libnet.h"
# include "torture/util.h"
# include "libcli/libcli.h"
# include "lib/cmdline/popt_common.h"
# define SMBTORTURE_DFS_SHARENAME "smbtorture_dfs_share"
# define SMBTORTURE_DFS_DIRNAME "\\smbtorture_dfs_dir"
# define SMBTORTURE_DFS_PATHNAME "C:"SMBTORTURE_DFS_DIRNAME
# define IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(x,y)\
if ( x = = DFS_MANAGER_VERSION_W2K3 ) { \
if ( ! W_ERROR_EQUAL ( y , WERR_NOT_SUPPORTED ) ) { \
printf ( " expected WERR_NOT_SUPPORTED \n " ) ; \
2007-10-07 02:28:14 +04:00
return false ; \
2006-09-21 06:45:02 +04:00
} \
2007-10-07 02:28:14 +04:00
return true ; \
2006-09-21 06:45:02 +04:00
} \
2010-03-20 00:37:53 +03:00
static bool test_NetShareAdd ( struct torture_context * tctx ,
2007-11-06 02:49:54 +03:00
const char * host ,
const char * sharename ,
const char * dir )
2006-09-21 06:45:02 +04:00
{
NTSTATUS status ;
struct srvsvc_NetShareInfo2 i ;
struct libnet_context * libnetctx ;
struct libnet_AddShare r ;
printf ( " Creating share %s \n " , sharename ) ;
2008-04-14 20:43:37 +04:00
if ( ! ( libnetctx = libnet_context_init ( tctx - > ev , tctx - > lp_ctx ) ) ) {
2007-10-07 02:28:14 +04:00
return false ;
2006-09-21 06:45:02 +04:00
}
libnetctx - > cred = cmdline_credentials ;
i . name = sharename ;
i . type = STYPE_DISKTREE ;
i . path = dir ;
i . max_users = ( uint32_t ) - 1 ;
i . comment = " created by smbtorture " ;
i . password = NULL ;
i . permissions = 0x0 ;
i . current_users = 0x0 ;
r . level = 2 ;
r . in . server_name = host ;
r . in . share = i ;
2010-03-20 00:37:53 +03:00
status = libnet_AddShare ( libnetctx , tctx , & r ) ;
2006-09-21 06:45:02 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2007-11-06 02:49:54 +03:00
d_printf ( " Failed to add new share: %s (%s) \n " ,
2006-09-21 06:45:02 +04:00
nt_errstr ( status ) , r . out . error_string ) ;
2007-10-07 02:28:14 +04:00
return false ;
2006-09-21 06:45:02 +04:00
}
2007-10-07 02:28:14 +04:00
return true ;
2006-09-21 06:45:02 +04:00
}
2010-03-20 00:37:53 +03:00
static bool test_NetShareDel ( struct torture_context * tctx ,
2007-11-06 02:49:54 +03:00
const char * host ,
const char * sharename )
2006-09-21 06:45:02 +04:00
{
NTSTATUS status ;
struct libnet_context * libnetctx ;
struct libnet_DelShare r ;
2010-03-20 00:37:53 +03:00
torture_comment ( tctx , " Deleting share %s \n " , sharename ) ;
2006-09-21 06:45:02 +04:00
2008-04-14 20:43:37 +04:00
if ( ! ( libnetctx = libnet_context_init ( tctx - > ev , tctx - > lp_ctx ) ) ) {
2007-10-07 02:28:14 +04:00
return false ;
2006-09-21 06:45:02 +04:00
}
libnetctx - > cred = cmdline_credentials ;
r . in . share_name = sharename ;
r . in . server_name = host ;
2010-03-20 00:37:53 +03:00
status = libnet_DelShare ( libnetctx , tctx , & r ) ;
2006-09-21 06:45:02 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2007-11-06 02:49:54 +03:00
d_printf ( " Failed to delete share: %s (%s) \n " ,
2006-09-21 06:45:02 +04:00
nt_errstr ( status ) , r . out . error_string ) ;
2007-10-07 02:28:14 +04:00
return false ;
2006-09-21 06:45:02 +04:00
}
2007-10-07 02:28:14 +04:00
return true ;
2006-09-21 06:45:02 +04:00
}
2007-11-06 02:49:54 +03:00
static bool test_CreateDir ( TALLOC_CTX * mem_ctx ,
struct smbcli_state * * cli ,
2007-12-03 17:53:07 +03:00
struct torture_context * tctx ,
2007-11-06 02:49:54 +03:00
const char * host ,
const char * share ,
2006-09-21 06:45:02 +04:00
const char * dir )
{
printf ( " Creating directory %s \n " , dir ) ;
2008-04-23 00:37:54 +04:00
if ( ! torture_open_connection_share ( mem_ctx , cli , tctx , host , share , tctx - > ev ) ) {
2007-10-07 02:28:14 +04:00
return false ;
2006-09-21 06:45:02 +04:00
}
if ( ! torture_setup_dir ( * cli , dir ) ) {
2007-10-07 02:28:14 +04:00
return false ;
2006-09-21 06:45:02 +04:00
}
2007-10-07 02:28:14 +04:00
return true ;
2006-09-21 06:45:02 +04:00
}
2010-03-20 00:37:53 +03:00
static bool test_DeleteDir ( struct torture_context * tctx ,
struct smbcli_state * cli ,
2007-11-06 02:49:54 +03:00
const char * dir )
2006-09-21 06:45:02 +04:00
{
2010-03-20 00:37:53 +03:00
torture_comment ( tctx , " Deleting directory %s \n " , dir ) ;
2006-09-21 06:45:02 +04:00
if ( smbcli_deltree ( cli - > tree , dir ) = = - 1 ) {
2007-11-06 02:49:54 +03:00
printf ( " Unable to delete dir %s - %s \n " , dir ,
smbcli_errstr ( cli - > tree ) ) ;
2007-10-07 02:28:14 +04:00
return false ;
2006-09-21 06:45:02 +04:00
}
2007-10-07 02:28:14 +04:00
return true ;
2006-09-21 06:45:02 +04:00
}
2003-11-13 12:26:53 +03:00
2010-03-20 00:37:53 +03:00
static bool test_GetManagerVersion_opts ( struct torture_context * tctx ,
struct dcerpc_binding_handle * b ,
enum dfs_ManagerVersion * version_p )
2003-11-13 12:26:53 +03:00
{
2004-08-13 05:31:11 +04:00
struct dfs_GetManagerVersion r ;
2010-03-20 00:37:53 +03:00
enum dfs_ManagerVersion version ;
2003-11-13 12:26:53 +03:00
2010-03-20 00:37:53 +03:00
r . out . version = & version ;
2003-11-13 12:26:53 +03:00
2010-03-20 00:37:53 +03:00
torture_assert_ntstatus_ok ( tctx ,
dcerpc_dfs_GetManagerVersion_r ( b , tctx , & r ) ,
" GetManagerVersion failed " ) ;
if ( version_p ) {
* version_p = version ;
2007-08-28 20:24:18 +04:00
}
2003-11-13 12:26:53 +03:00
2007-10-07 02:28:14 +04:00
return true ;
2003-11-13 12:26:53 +03:00
}
2010-03-20 00:37:53 +03:00
static bool test_GetManagerVersion ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
return test_GetManagerVersion_opts ( tctx , b , NULL ) ;
}
static bool test_ManagerInitialize ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
2006-09-21 10:06:59 +04:00
{
enum dfs_ManagerVersion version ;
struct dfs_ManagerInitialize r ;
2010-03-20 00:37:53 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
const char * host = torture_setting_string ( tctx , " host " , NULL ) ;
2006-09-21 10:06:59 +04:00
2010-03-20 00:37:53 +03:00
torture_comment ( tctx , " Testing ManagerInitialize \n " ) ;
2006-09-21 10:06:59 +04:00
2010-03-20 00:37:53 +03:00
torture_assert ( tctx ,
test_GetManagerVersion_opts ( tctx , b , & version ) ,
" GetManagerVersion failed " ) ;
2006-09-21 10:06:59 +04:00
r . in . servername = host ;
r . in . flags = 0 ;
2010-03-20 00:37:53 +03:00
torture_assert_ntstatus_ok ( tctx ,
dcerpc_dfs_ManagerInitialize_r ( b , tctx , & r ) ,
" ManagerInitialize failed " ) ;
if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
torture_warning ( tctx , " dfs_ManagerInitialize failed - %s \n " ,
2007-11-06 02:49:54 +03:00
win_errstr ( r . out . result ) ) ;
2006-09-21 10:06:59 +04:00
IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3 ( version , r . out . result ) ;
2007-10-07 02:28:14 +04:00
return false ;
2006-09-21 10:06:59 +04:00
}
2007-10-07 02:28:14 +04:00
return true ;
2006-09-21 10:06:59 +04:00
}
2010-03-20 00:37:53 +03:00
static bool test_GetInfoLevel ( struct torture_context * tctx ,
struct dcerpc_binding_handle * b ,
2007-11-06 02:49:54 +03:00
uint16_t level ,
2007-08-28 20:24:18 +04:00
const char * root )
2003-11-14 16:16:34 +03:00
{
struct dfs_GetInfo r ;
2009-06-19 04:52:53 +04:00
union dfs_Info info ;
2006-09-21 00:40:45 +04:00
2010-03-20 00:37:53 +03:00
torture_comment ( tctx , " Testing GetInfo level %u on '%s' \n " , level , root ) ;
2006-09-21 00:40:45 +04:00
2010-03-20 00:37:53 +03:00
r . in . dfs_entry_path = root ;
2006-09-21 07:36:10 +04:00
r . in . servername = NULL ;
r . in . sharename = NULL ;
2003-11-14 16:16:34 +03:00
r . in . level = level ;
2009-06-19 04:52:53 +04:00
r . out . info = & info ;
2003-11-14 16:16:34 +03:00
2010-03-20 00:37:53 +03:00
torture_assert_ntstatus_ok ( tctx ,
dcerpc_dfs_GetInfo_r ( b , tctx , & r ) ,
" GetInfo failed " ) ;
if ( ! W_ERROR_IS_OK ( r . out . result ) & &
! W_ERROR_EQUAL ( WERR_NO_MORE_ITEMS , r . out . result ) ) {
torture_warning ( tctx , " dfs_GetInfo failed - %s \n " , win_errstr ( r . out . result ) ) ;
2007-10-07 02:28:14 +04:00
return false ;
2007-08-28 20:24:18 +04:00
}
2003-11-14 16:16:34 +03:00
2007-10-07 02:28:14 +04:00
return true ;
2003-11-14 16:16:34 +03:00
}
2010-03-20 00:37:53 +03:00
static bool test_GetInfo ( struct torture_context * tctx ,
struct dcerpc_binding_handle * b ,
2007-11-06 02:49:54 +03:00
const char * root )
2003-11-14 16:16:34 +03:00
{
2007-10-07 02:28:14 +04:00
bool ret = true ;
2006-09-21 00:40:45 +04:00
/* 103, 104, 105, 106 is only available on Set */
2006-09-23 13:13:48 +04:00
uint16_t levels [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 100 , 101 , 102 , 103 , 104 , 105 , 106 } ;
2003-11-14 16:16:34 +03:00
int i ;
2006-09-21 00:40:45 +04:00
2003-11-14 16:16:34 +03:00
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
2010-03-20 00:37:53 +03:00
if ( ! test_GetInfoLevel ( tctx , b , levels [ i ] , root ) ) {
2007-10-07 02:28:14 +04:00
ret = false ;
2003-11-14 16:16:34 +03:00
}
}
return ret ;
}
2010-03-20 00:37:53 +03:00
static bool test_EnumLevelEx ( struct torture_context * tctx ,
struct dcerpc_binding_handle * b ,
2007-11-06 02:49:54 +03:00
uint16_t level ,
const char * dfs_name )
2006-09-21 00:40:45 +04:00
{
struct dfs_EnumEx rex ;
uint32_t total = 0 ;
struct dfs_EnumStruct e ;
struct dfs_Info1 s ;
struct dfs_EnumArray1 e1 ;
2007-10-07 02:28:14 +04:00
bool ret = true ;
2007-11-06 02:49:54 +03:00
2006-09-21 00:40:45 +04:00
rex . in . level = level ;
rex . in . bufsize = ( uint32_t ) - 1 ;
rex . in . total = & total ;
rex . in . info = & e ;
rex . in . dfs_name = dfs_name ;
e . level = rex . in . level ;
e . e . info1 = & e1 ;
e . e . info1 - > count = 0 ;
e . e . info1 - > s = & s ;
s . path = NULL ;
2010-03-20 00:37:53 +03:00
torture_comment ( tctx , " Testing EnumEx level %u on '%s' \n " , level , dfs_name ) ;
2006-09-21 00:40:45 +04:00
2010-03-20 00:37:53 +03:00
torture_assert_ntstatus_ok ( tctx ,
dcerpc_dfs_EnumEx_r ( b , tctx , & rex ) ,
" EnumEx failed " ) ;
torture_assert_werr_ok ( tctx , rex . out . result ,
" EnumEx failed " ) ;
2006-09-21 00:40:45 +04:00
if ( level = = 1 & & rex . out . total ) {
int i ;
for ( i = 0 ; i < * rex . out . total ; i + + ) {
2010-03-20 00:37:53 +03:00
const char * root = rex . out . info - > e . info1 - > s [ i ] . path ;
if ( ! test_GetInfo ( tctx , b , root ) ) {
2007-10-07 02:28:14 +04:00
ret = false ;
2006-09-21 00:40:45 +04:00
}
}
}
if ( level = = 300 & & rex . out . total ) {
int i , k ;
for ( i = 0 ; i < * rex . out . total ; i + + ) {
uint16_t levels [ ] = { 1 , 2 , 3 , 4 , 200 } ; /* 300 */
2010-03-20 00:37:53 +03:00
const char * root = rex . out . info - > e . info300 - > s [ i ] . dom_root ;
2006-09-21 00:40:45 +04:00
for ( k = 0 ; k < ARRAY_SIZE ( levels ) ; k + + ) {
2010-03-20 00:37:53 +03:00
if ( ! test_EnumLevelEx ( tctx , b ,
2007-11-06 02:49:54 +03:00
levels [ k ] , root ) )
{
2007-10-07 02:28:14 +04:00
ret = false ;
2006-09-21 00:40:45 +04:00
}
}
2010-03-20 00:37:53 +03:00
if ( ! test_GetInfo ( tctx , b , root ) ) {
2007-10-07 02:28:14 +04:00
ret = false ;
2006-09-21 00:40:45 +04:00
}
}
}
return ret ;
}
2010-03-20 00:37:53 +03:00
static bool test_EnumLevel ( struct torture_context * tctx ,
struct dcerpc_binding_handle * b ,
2007-11-06 02:49:54 +03:00
uint16_t level )
2003-11-13 12:26:53 +03:00
{
struct dfs_Enum r ;
2004-05-25 20:24:13 +04:00
uint32_t total = 0 ;
2003-11-14 10:20:46 +03:00
struct dfs_EnumStruct e ;
2003-11-14 10:56:43 +03:00
struct dfs_Info1 s ;
2003-11-14 11:27:39 +03:00
struct dfs_EnumArray1 e1 ;
2007-10-07 02:28:14 +04:00
bool ret = true ;
2007-11-06 02:49:54 +03:00
2003-11-14 11:27:39 +03:00
r . in . level = level ;
2004-05-25 20:24:13 +04:00
r . in . bufsize = ( uint32_t ) - 1 ;
2003-11-14 10:20:46 +03:00
r . in . total = & total ;
r . in . info = & e ;
2003-11-14 10:56:43 +03:00
e . level = r . in . level ;
2003-11-14 11:27:39 +03:00
e . e . info1 = & e1 ;
2003-11-14 10:56:43 +03:00
e . e . info1 - > count = 0 ;
e . e . info1 - > s = & s ;
s . path = NULL ;
2007-11-06 02:49:54 +03:00
2010-03-20 00:37:53 +03:00
torture_comment ( tctx , " Testing Enum level %u \n " , level ) ;
2007-08-28 20:24:18 +04:00
2010-03-20 00:37:53 +03:00
torture_assert_ntstatus_ok ( tctx ,
dcerpc_dfs_Enum_r ( b , tctx , & r ) ,
" Enum failed " ) ;
if ( ! W_ERROR_IS_OK ( r . out . result ) & &
! W_ERROR_EQUAL ( WERR_NO_MORE_ITEMS , r . out . result ) ) {
torture_warning ( tctx , " dfs_Enum failed - %s \n " , win_errstr ( r . out . result ) ) ;
2007-10-07 02:28:14 +04:00
return false ;
2007-08-28 20:24:18 +04:00
}
2003-11-13 12:26:53 +03:00
2003-11-14 16:16:34 +03:00
if ( level = = 1 & & r . out . total ) {
int i ;
for ( i = 0 ; i < * r . out . total ; i + + ) {
const char * root = r . out . info - > e . info1 - > s [ i ] . path ;
2010-03-20 00:37:53 +03:00
if ( ! test_GetInfo ( tctx , b , root ) ) {
2007-10-07 02:28:14 +04:00
ret = false ;
2003-11-14 16:16:34 +03:00
}
}
}
return ret ;
2003-11-13 12:26:53 +03:00
}
2003-11-14 16:16:34 +03:00
2010-03-20 00:37:53 +03:00
static bool test_Enum ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
2003-11-14 11:27:39 +03:00
{
2007-10-07 02:28:14 +04:00
bool ret = true ;
2007-11-02 17:11:54 +03:00
uint16_t levels [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 200 , 300 } ;
2003-11-14 11:27:39 +03:00
int i ;
2010-03-20 00:37:53 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2006-09-21 00:40:45 +04:00
2003-11-14 11:27:39 +03:00
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
2010-03-20 00:37:53 +03:00
if ( ! test_EnumLevel ( tctx , b , levels [ i ] ) ) {
2007-10-07 02:28:14 +04:00
ret = false ;
2003-11-14 11:27:39 +03:00
}
}
2006-09-21 00:40:45 +04:00
return ret ;
}
2010-03-20 00:37:53 +03:00
static bool test_EnumEx ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
2006-09-21 00:40:45 +04:00
{
2007-10-07 02:28:14 +04:00
bool ret = true ;
2007-11-02 17:11:54 +03:00
uint16_t levels [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 200 , 300 } ;
2006-09-21 00:40:45 +04:00
int i ;
2010-03-20 00:37:53 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
const char * host = torture_setting_string ( tctx , " host " , NULL ) ;
2006-09-21 00:40:45 +04:00
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
2010-03-20 00:37:53 +03:00
if ( ! test_EnumLevelEx ( tctx , b , levels [ i ] , host ) ) {
2007-10-07 02:28:14 +04:00
ret = false ;
2006-09-21 00:40:45 +04:00
}
}
2003-11-14 11:27:39 +03:00
return ret ;
}
2010-03-20 00:37:53 +03:00
static bool test_RemoveStdRoot ( struct torture_context * tctx ,
struct dcerpc_binding_handle * b ,
2007-11-06 02:49:54 +03:00
const char * host ,
const char * sharename )
2006-09-21 06:45:02 +04:00
{
2006-09-22 14:37:43 +04:00
struct dfs_RemoveStdRoot r ;
2006-09-21 06:45:02 +04:00
2010-03-20 00:37:53 +03:00
torture_comment ( tctx , " Testing RemoveStdRoot \n " ) ;
2006-09-21 06:45:02 +04:00
r . in . servername = host ;
r . in . rootshare = sharename ;
2006-09-22 14:37:43 +04:00
r . in . flags = 0 ;
2006-09-21 06:45:02 +04:00
2010-03-20 00:37:53 +03:00
torture_assert_ntstatus_ok ( tctx ,
dcerpc_dfs_RemoveStdRoot_r ( b , tctx , & r ) ,
" RemoveStdRoot failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" dfs_RemoveStdRoot failed " ) ;
2006-09-21 06:45:02 +04:00
2007-10-07 02:28:14 +04:00
return true ;
2006-09-21 06:45:02 +04:00
}
2010-03-20 00:37:53 +03:00
static bool test_AddStdRoot ( struct torture_context * tctx ,
struct dcerpc_binding_handle * b ,
2007-11-06 02:49:54 +03:00
const char * host ,
const char * sharename )
2006-09-21 06:45:02 +04:00
{
2006-09-22 14:37:43 +04:00
struct dfs_AddStdRoot r ;
2006-09-21 06:45:02 +04:00
2010-03-20 00:37:53 +03:00
torture_comment ( tctx , " Testing AddStdRoot \n " ) ;
2006-09-21 06:45:02 +04:00
r . in . servername = host ;
r . in . rootshare = sharename ;
2006-09-22 14:37:43 +04:00
r . in . comment = " standard dfs standalone DFS root created by smbtorture (dfs_AddStdRoot) " ;
2006-09-21 06:45:02 +04:00
r . in . flags = 0 ;
2010-03-20 00:37:53 +03:00
torture_assert_ntstatus_ok ( tctx ,
dcerpc_dfs_AddStdRoot_r ( b , tctx , & r ) ,
" AddStdRoot failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" AddStdRoot failed " ) ;
2006-09-21 06:45:02 +04:00
2007-10-07 02:28:14 +04:00
return true ;
2006-09-21 06:45:02 +04:00
}
2006-09-22 14:37:43 +04:00
2010-03-20 00:37:53 +03:00
static bool test_AddStdRootForced ( struct torture_context * tctx ,
struct dcerpc_binding_handle * b ,
2007-11-06 02:49:54 +03:00
const char * host ,
const char * sharename )
2006-09-21 06:45:02 +04:00
{
2006-09-22 14:37:43 +04:00
struct dfs_AddStdRootForced r ;
enum dfs_ManagerVersion version ;
2006-09-21 06:45:02 +04:00
2010-03-20 00:37:53 +03:00
torture_comment ( tctx , " Testing AddStdRootForced \n " ) ;
2006-09-22 14:37:43 +04:00
2010-03-20 00:37:53 +03:00
torture_assert ( tctx ,
test_GetManagerVersion_opts ( tctx , b , & version ) ,
" GetManagerVersion failed " ) ;
2006-09-21 06:45:02 +04:00
r . in . servername = host ;
r . in . rootshare = sharename ;
2006-09-22 14:37:43 +04:00
r . in . comment = " standard dfs forced standalone DFS root created by smbtorture (dfs_AddStdRootForced) " ;
r . in . store = SMBTORTURE_DFS_PATHNAME ;
2006-09-21 06:45:02 +04:00
2010-03-20 00:37:53 +03:00
torture_assert_ntstatus_ok ( tctx ,
dcerpc_dfs_AddStdRootForced_r ( b , tctx , & r ) ,
" AddStdRootForced failed " ) ;
if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
torture_warning ( tctx , " dfs_AddStdRootForced failed - %s \n " ,
2007-11-06 02:49:54 +03:00
win_errstr ( r . out . result ) ) ;
2006-09-22 14:37:43 +04:00
IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3 ( version , r . out . result ) ;
2007-10-07 02:28:14 +04:00
return false ;
2006-09-21 06:45:02 +04:00
}
2010-03-20 00:37:53 +03:00
return test_RemoveStdRoot ( tctx , b , host , sharename ) ;
2006-09-21 06:45:02 +04:00
}
2010-03-20 00:37:53 +03:00
static void test_cleanup_stdroot ( struct torture_context * tctx ,
struct dcerpc_binding_handle * b ,
2007-11-06 02:49:54 +03:00
const char * host ,
const char * sharename ,
2006-09-21 06:45:02 +04:00
const char * dir )
{
struct smbcli_state * cli ;
2010-03-20 00:37:53 +03:00
torture_comment ( tctx , " Cleaning up StdRoot \n " ) ;
2006-09-21 06:45:02 +04:00
2010-03-20 00:37:53 +03:00
test_RemoveStdRoot ( tctx , b , host , sharename ) ;
test_NetShareDel ( tctx , host , sharename ) ;
if ( torture_open_connection_share ( tctx , & cli , tctx , host , " C$ " , tctx - > ev ) ) {
test_DeleteDir ( tctx , cli , dir ) ;
torture_close_connection ( cli ) ;
}
2006-09-21 06:45:02 +04:00
}
2010-03-20 00:37:53 +03:00
static bool test_StdRoot ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
2006-09-21 06:45:02 +04:00
{
const char * sharename = SMBTORTURE_DFS_SHARENAME ;
const char * dir = SMBTORTURE_DFS_DIRNAME ;
const char * path = SMBTORTURE_DFS_PATHNAME ;
struct smbcli_state * cli ;
2007-11-25 15:38:07 +03:00
bool ret = true ;
2010-03-20 00:37:53 +03:00
const char * host = torture_setting_string ( tctx , " host " , NULL ) ;
struct dcerpc_binding_handle * b = p - > binding_handle ;
2006-09-21 06:45:02 +04:00
2010-03-20 00:37:53 +03:00
torture_comment ( tctx , " Testing StdRoot \n " ) ;
2006-09-21 06:45:02 +04:00
2010-03-20 00:37:53 +03:00
test_cleanup_stdroot ( tctx , b , host , sharename , dir ) ;
2006-09-21 06:45:02 +04:00
2010-03-20 00:37:53 +03:00
torture_assert ( tctx ,
test_CreateDir ( tctx , & cli , tctx , host , " C$ " , dir ) ,
" failed to connect C$ share and to create directory " ) ;
torture_assert ( tctx ,
test_NetShareAdd ( tctx , host , sharename , path ) ,
" failed to create new share " ) ;
ret & = test_AddStdRoot ( tctx , b , host , sharename ) ;
ret & = test_RemoveStdRoot ( tctx , b , host , sharename ) ;
ret & = test_AddStdRootForced ( tctx , b , host , sharename ) ;
ret & = test_NetShareDel ( tctx , host , sharename ) ;
ret & = test_DeleteDir ( tctx , cli , dir ) ;
2006-09-21 06:45:02 +04:00
torture_close_connection ( cli ) ;
return ret ;
}
2010-03-20 00:37:53 +03:00
static bool test_GetDcAddress ( struct torture_context * tctx ,
struct dcerpc_binding_handle * b ,
2007-11-06 03:24:07 +03:00
const char * host )
{
struct dfs_GetDcAddress r ;
uint8_t is_root = 0 ;
uint32_t ttl = 0 ;
const char * ptr ;
2010-03-20 00:37:53 +03:00
torture_comment ( tctx , " Testing GetDcAddress \n " ) ;
2007-11-06 03:24:07 +03:00
ptr = host ;
r . in . servername = host ;
r . in . server_fullname = r . out . server_fullname = & ptr ;
r . in . is_root = r . out . is_root = & is_root ;
r . in . ttl = r . out . ttl = & ttl ;
2010-03-20 00:37:53 +03:00
torture_assert_ntstatus_ok ( tctx ,
dcerpc_dfs_GetDcAddress_r ( b , tctx , & r ) ,
" GetDcAddress failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" dfs_GetDcAddress failed " ) ;
2007-11-06 03:24:07 +03:00
return true ;
}
2010-03-20 00:37:53 +03:00
static bool test_SetDcAddress ( struct torture_context * tctx ,
struct dcerpc_binding_handle * b ,
2007-11-06 03:24:07 +03:00
const char * host )
{
struct dfs_SetDcAddress r ;
2010-03-20 00:37:53 +03:00
torture_comment ( tctx , " Testing SetDcAddress \n " ) ;
2007-11-06 03:24:07 +03:00
r . in . servername = host ;
r . in . server_fullname = host ;
r . in . flags = 0 ;
r . in . ttl = 1000 ;
2010-03-20 00:37:53 +03:00
torture_assert_ntstatus_ok ( tctx ,
dcerpc_dfs_SetDcAddress_r ( b , tctx , & r ) ,
" SetDcAddress failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" dfs_SetDcAddress failed " ) ;
2007-11-06 03:24:07 +03:00
return true ;
}
2010-03-20 00:37:53 +03:00
static bool test_DcAddress ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
2007-11-06 03:24:07 +03:00
{
2010-03-20 00:37:53 +03:00
const char * host = torture_setting_string ( tctx , " host " , NULL ) ;
struct dcerpc_binding_handle * b = p - > binding_handle ;
if ( ! test_GetDcAddress ( tctx , b , host ) ) {
2007-11-06 03:24:07 +03:00
return false ;
}
2010-03-20 00:37:53 +03:00
if ( ! test_SetDcAddress ( tctx , b , host ) ) {
2007-11-06 03:24:07 +03:00
return false ;
}
return true ;
}
2010-03-20 00:37:53 +03:00
static bool test_FlushFtTable ( struct torture_context * tctx ,
struct dcerpc_binding_handle * b ,
2007-11-06 03:39:47 +03:00
const char * host ,
const char * sharename )
{
struct dfs_FlushFtTable r ;
enum dfs_ManagerVersion version ;
2010-03-20 00:37:53 +03:00
torture_comment ( tctx , " Testing FlushFtTable \n " ) ;
2007-11-06 03:39:47 +03:00
2010-03-20 00:37:53 +03:00
torture_assert ( tctx ,
test_GetManagerVersion_opts ( tctx , b , & version ) ,
" GetManagerVersion failed " ) ;
2007-11-06 03:39:47 +03:00
r . in . servername = host ;
r . in . rootshare = sharename ;
2010-03-20 00:37:53 +03:00
torture_assert_ntstatus_ok ( tctx ,
dcerpc_dfs_FlushFtTable_r ( b , tctx , & r ) ,
" FlushFtTable failed " ) ;
if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
torture_warning ( tctx , " dfs_FlushFtTable failed - %s \n " ,
2007-11-06 03:39:47 +03:00
win_errstr ( r . out . result ) ) ;
IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3 ( version , r . out . result ) ;
return false ;
}
return true ;
}
2010-03-20 00:37:53 +03:00
static bool test_FtRoot ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
2007-11-06 03:39:47 +03:00
{
const char * sharename = SMBTORTURE_DFS_SHARENAME ;
2010-03-20 00:37:53 +03:00
const char * host = torture_setting_string ( tctx , " host " , NULL ) ;
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-06 03:39:47 +03:00
2010-03-20 00:37:53 +03:00
return test_FlushFtTable ( tctx , b , host , sharename ) ;
2007-11-06 03:39:47 +03:00
}
2010-03-20 00:37:53 +03:00
struct torture_suite * torture_rpc_dfs ( TALLOC_CTX * mem_ctx )
2003-11-13 12:26:53 +03:00
{
2010-03-20 00:37:53 +03:00
struct torture_rpc_tcase * tcase ;
struct torture_suite * suite = torture_suite_create ( mem_ctx , " DFS " ) ;
2003-11-13 12:26:53 +03:00
2010-03-20 00:37:53 +03:00
tcase = torture_suite_add_rpc_iface_tcase ( suite , " netdfs " ,
& ndr_table_netdfs ) ;
2010-03-11 14:51:46 +03:00
2010-03-20 00:37:53 +03:00
torture_rpc_tcase_add_test ( tcase , " GetManagerVersion " , test_GetManagerVersion ) ;
torture_rpc_tcase_add_test ( tcase , " ManagerInitialize " , test_ManagerInitialize ) ;
torture_rpc_tcase_add_test ( tcase , " Enum " , test_Enum ) ;
torture_rpc_tcase_add_test ( tcase , " EnumEx " , test_EnumEx ) ;
torture_rpc_tcase_add_test ( tcase , " StdRoot " , test_StdRoot ) ;
torture_rpc_tcase_add_test ( tcase , " FtRoot " , test_FtRoot ) ;
torture_rpc_tcase_add_test ( tcase , " DcAddress " , test_DcAddress ) ;
2006-10-16 17:06:41 +04:00
2010-03-20 00:37:53 +03:00
return suite ;
2003-11-13 12:26:53 +03:00
}