2001-08-27 22:01:05 +04:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
2001-08-27 22:01:05 +04:00
SMB torture tester - scanning functions
Copyright ( C ) Andrew Tridgell 2001
2011-01-15 18:07:31 +03:00
2001-08-27 22:01:05 +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-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2001-08-27 22:01:05 +04:00
( at your option ) any later version .
2011-01-15 18:07:31 +03:00
2001-08-27 22:01:05 +04: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 .
2011-01-15 18:07:31 +03:00
2001-08-27 22:01:05 +04:00
You should have received a copy of the GNU General Public License
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2001-08-27 22:01:05 +04:00
*/
# include "includes.h"
2011-02-26 01:20:06 +03:00
# include "system/filesys.h"
2009-11-24 13:43:56 +03:00
# include "torture/proto.h"
2011-05-06 13:47:43 +04:00
# include "libsmb/libsmb.h"
2001-08-27 22:01:05 +04:00
# define VERBOSE 0
# define OP_MIN 0
# define OP_MAX 20
2007-12-05 04:05:33 +03:00
# define DATA_SIZE 1024
# define PARAM_SIZE 1024
2001-08-27 22:01:05 +04:00
/****************************************************************************
look for a partial hit
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-01-03 11:28:12 +03:00
static void trans2_check_hit ( const char * format , int op , int level , NTSTATUS status )
2001-08-27 22:01:05 +04:00
{
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_V ( status ) = = NT_STATUS_V ( NT_STATUS_INVALID_LEVEL ) | |
NT_STATUS_V ( status ) = = NT_STATUS_V ( NT_STATUS_NOT_IMPLEMENTED ) | |
NT_STATUS_V ( status ) = = NT_STATUS_V ( NT_STATUS_NOT_SUPPORTED ) | |
NT_STATUS_V ( status ) = = NT_STATUS_V ( NT_STATUS_UNSUCCESSFUL ) | |
NT_STATUS_V ( status ) = = NT_STATUS_V ( NT_STATUS_INVALID_INFO_CLASS ) ) {
return ;
}
2001-08-27 22:01:05 +04:00
# if VERBOSE
2001-09-04 15:52:42 +04:00
printf ( " possible %s hit op=%3d level=%5d status=%s \n " ,
2002-03-17 07:36:35 +03:00
format , op , level , nt_errstr ( status ) ) ;
2001-08-27 22:01:05 +04:00
# endif
}
/****************************************************************************
check for existance of a trans2 call
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-09-04 15:52:42 +04:00
static NTSTATUS try_trans2 ( struct cli_state * cli ,
2001-08-27 22:01:05 +04:00
int op ,
2011-01-16 15:12:16 +03:00
uint8_t * param , uint8_t * data ,
uint32_t param_len , uint32_t data_len ,
uint32_t * rparam_len , uint32_t * rdata_len )
2001-08-27 22:01:05 +04:00
{
2011-01-16 15:12:16 +03:00
uint16_t setup [ 1 ] ;
uint8_t * rparam = NULL , * rdata = NULL ;
NTSTATUS status ;
SSVAL ( setup + 0 , 0 , op ) ;
2001-08-27 22:01:05 +04:00
2011-01-16 15:12:16 +03:00
status = cli_trans ( talloc_tos ( ) , cli , SMBtrans2 ,
NULL , - 1 , /* name, fid */
op , 0 ,
NULL , 0 , 0 , /* setup */
param , param_len , 2 ,
data , data_len , cli - > max_xmit ,
NULL , /* recv_flags2 */
NULL , 0 , NULL , /* rsetup */
& rparam , 0 , rparam_len ,
& rdata , 0 , rdata_len ) ;
2001-08-27 22:01:05 +04:00
2011-01-16 15:12:16 +03:00
TALLOC_FREE ( rdata ) ;
TALLOC_FREE ( rparam ) ;
2001-08-27 22:01:05 +04:00
2011-01-16 15:12:16 +03:00
return status ;
2001-08-27 22:01:05 +04:00
}
2001-09-04 15:52:42 +04:00
static NTSTATUS try_trans2_len ( struct cli_state * cli ,
2003-01-03 11:28:12 +03:00
const char * format ,
2001-08-27 22:01:05 +04:00
int op , int level ,
2011-01-16 15:12:16 +03:00
uint8_t * param , uint8_t * data ,
uint32_t param_len , uint32_t * data_len ,
uint32_t * rparam_len , uint32_t * rdata_len )
2001-08-27 22:01:05 +04:00
{
2001-09-04 15:52:42 +04:00
NTSTATUS ret = NT_STATUS_OK ;
2001-08-27 22:01:05 +04:00
ret = try_trans2 ( cli , op , param , data , param_len ,
2007-12-05 04:05:33 +03:00
DATA_SIZE , rparam_len , rdata_len ) ;
2001-08-27 22:01:05 +04:00
# if VERBOSE
2002-03-17 07:36:35 +03:00
printf ( " op=%d level=%d ret=%s \n " , op , level , nt_errstr ( ret ) ) ;
2001-08-27 22:01:05 +04:00
# endif
2001-09-04 15:52:42 +04:00
if ( ! NT_STATUS_IS_OK ( ret ) ) return ret ;
2001-08-27 22:01:05 +04:00
* data_len = 0 ;
2007-12-05 04:05:33 +03:00
while ( * data_len < DATA_SIZE ) {
2001-08-27 22:01:05 +04:00
ret = try_trans2 ( cli , op , param , data , param_len ,
* data_len , rparam_len , rdata_len ) ;
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( ret ) ) break ;
2001-08-27 22:01:05 +04:00
* data_len + = 2 ;
}
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( ret ) ) {
2001-08-27 22:01:05 +04:00
printf ( " found %s level=%d data_len=%d rparam_len=%d rdata_len=%d \n " ,
format , level , * data_len , * rparam_len , * rdata_len ) ;
} else {
trans2_check_hit ( format , op , level , ret ) ;
}
return ret ;
}
/****************************************************************************
check for existance of a trans2 call
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-19 04:40:25 +04:00
static bool scan_trans2 ( struct cli_state * cli , int op , int level ,
2003-01-03 11:28:12 +03:00
int fnum , int dnum , const char * fname )
2001-08-27 22:01:05 +04:00
{
2011-01-16 15:12:16 +03:00
uint32_t data_len = 0 ;
uint32_t param_len = 0 ;
uint32_t rparam_len , rdata_len ;
2011-07-07 17:38:02 +04:00
uint8_t * param = NULL ;
uint8_t data [ DATA_SIZE ] ;
const char * newfname ;
const char * dname ;
2001-08-27 23:46:22 +04:00
NTSTATUS status ;
2001-08-27 22:01:05 +04:00
memset ( data , 0 , sizeof ( data ) ) ;
data_len = 4 ;
/* try with a info level only */
2011-07-07 17:38:02 +04:00
TALLOC_FREE ( param ) ;
param = talloc_array ( talloc_tos ( ) , uint8_t , 2 ) ;
if ( param = = NULL ) return True ;
2001-08-27 22:01:05 +04:00
SSVAL ( param , 0 , level ) ;
2011-07-07 17:38:02 +04:00
param_len = talloc_get_size ( param ) ;
2001-08-27 22:01:05 +04:00
status = try_trans2_len ( cli , " void " , op , level , param , data , param_len , & data_len ,
& rparam_len , & rdata_len ) ;
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( status ) ) return True ;
2001-08-27 22:01:05 +04:00
/* try with a file descriptor */
2011-07-07 17:38:02 +04:00
TALLOC_FREE ( param ) ;
param = talloc_array ( talloc_tos ( ) , uint8_t , 6 ) ;
if ( param = = NULL ) return True ;
2001-08-27 22:01:05 +04:00
SSVAL ( param , 0 , fnum ) ;
SSVAL ( param , 2 , level ) ;
SSVAL ( param , 4 , 0 ) ;
2011-07-07 17:38:02 +04:00
param_len = talloc_get_size ( param ) ;
2001-08-27 22:01:05 +04:00
status = try_trans2_len ( cli , " fnum " , op , level , param , data , param_len , & data_len ,
& rparam_len , & rdata_len ) ;
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( status ) ) return True ;
2001-08-27 22:01:05 +04:00
/* try with a notify style */
2011-07-07 17:38:02 +04:00
TALLOC_FREE ( param ) ;
param = talloc_array ( talloc_tos ( ) , uint8_t , 6 ) ;
if ( param = = NULL ) return True ;
2001-08-27 22:01:05 +04:00
SSVAL ( param , 0 , dnum ) ;
SSVAL ( param , 2 , dnum ) ;
SSVAL ( param , 4 , level ) ;
2011-07-07 17:38:02 +04:00
param_len = talloc_get_size ( param ) ;
2001-08-27 22:01:05 +04:00
status = try_trans2_len ( cli , " notify " , op , level , param , data , param_len , & data_len ,
& rparam_len , & rdata_len ) ;
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( status ) ) return True ;
2001-08-27 22:01:05 +04:00
/* try with a file name */
2011-07-07 17:38:02 +04:00
TALLOC_FREE ( param ) ;
param = talloc_array ( talloc_tos ( ) , uint8_t , 6 ) ;
if ( param = = NULL ) return True ;
2001-08-27 22:01:05 +04:00
SSVAL ( param , 0 , level ) ;
SSVAL ( param , 2 , 0 ) ;
SSVAL ( param , 4 , 0 ) ;
2011-07-07 17:38:02 +04:00
param = trans2_bytes_push_str ( param , cli_ucs2 ( cli ) ,
fname , strlen ( fname ) + 1 , NULL ) ;
if ( param = = NULL ) return True ;
2001-08-27 22:01:05 +04:00
2011-07-07 17:38:02 +04:00
param_len = talloc_get_size ( param ) ;
2001-08-27 22:01:05 +04:00
status = try_trans2_len ( cli , " fname " , op , level , param , data , param_len , & data_len ,
& rparam_len , & rdata_len ) ;
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( status ) ) return True ;
2001-08-27 22:01:05 +04:00
/* try with a new file name */
2011-07-07 17:38:02 +04:00
newfname = " \\ newfile.dat " ;
TALLOC_FREE ( param ) ;
param = talloc_array ( talloc_tos ( ) , uint8_t , 6 ) ;
if ( param = = NULL ) return True ;
2001-08-27 22:01:05 +04:00
SSVAL ( param , 0 , level ) ;
SSVAL ( param , 2 , 0 ) ;
SSVAL ( param , 4 , 0 ) ;
2011-07-07 17:38:02 +04:00
param = trans2_bytes_push_str ( param , cli_ucs2 ( cli ) ,
newfname , strlen ( newfname ) + 1 , NULL ) ;
if ( param = = NULL ) return True ;
2001-08-27 22:01:05 +04:00
2011-07-07 17:38:02 +04:00
param_len = talloc_get_size ( param ) ;
2001-08-27 22:01:05 +04:00
status = try_trans2_len ( cli , " newfile " , op , level , param , data , param_len , & data_len ,
& rparam_len , & rdata_len ) ;
2011-07-07 17:38:02 +04:00
cli_unlink ( cli , newfname , FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN ) ;
cli_rmdir ( cli , newfname ) ;
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( status ) ) return True ;
2001-08-27 22:01:05 +04:00
/* try dfs style */
2011-07-07 17:38:02 +04:00
dname = " \\ testdir " ;
cli_mkdir ( cli , dname ) ;
TALLOC_FREE ( param ) ;
param = talloc_array ( talloc_tos ( ) , uint8_t , 2 ) ;
if ( param = = NULL ) return True ;
2001-08-27 22:01:05 +04:00
SSVAL ( param , 0 , level ) ;
2011-07-07 17:38:02 +04:00
param = trans2_bytes_push_str ( param , cli_ucs2 ( cli ) ,
dname , strlen ( dname ) + 1 , NULL ) ;
if ( param = = NULL ) return True ;
2001-08-27 22:01:05 +04:00
2011-07-07 17:38:02 +04:00
param_len = talloc_get_size ( param ) ;
2001-08-27 22:01:05 +04:00
status = try_trans2_len ( cli , " dfs " , op , level , param , data , param_len , & data_len ,
& rparam_len , & rdata_len ) ;
2011-07-07 17:38:02 +04:00
cli_rmdir ( cli , dname ) ;
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( status ) ) return True ;
2001-08-27 22:01:05 +04:00
return False ;
}
2007-10-19 04:40:25 +04:00
bool torture_trans2_scan ( int dummy )
2001-08-27 22:01:05 +04:00
{
2003-04-23 12:12:34 +04:00
static struct cli_state * cli ;
2001-08-27 22:01:05 +04:00
int op , level ;
2003-01-03 11:28:12 +03:00
const char * fname = " \\ scanner.dat " ;
2009-05-01 02:26:43 +04:00
uint16_t fnum , dnum ;
2001-08-27 22:01:05 +04:00
printf ( " starting trans2 scan test \n " ) ;
2006-07-31 13:41:25 +04:00
if ( ! torture_open_connection ( & cli , 0 ) ) {
2001-08-27 22:01:05 +04:00
return False ;
}
2009-05-01 02:26:43 +04:00
if ( ! NT_STATUS_IS_OK ( cli_open ( cli , fname , O_RDWR | O_CREAT | O_TRUNC ,
DENY_NONE , & fnum ) ) ) {
printf ( " open of %s failed \n " , fname ) ;
return false ;
}
if ( ! NT_STATUS_IS_OK ( cli_open ( cli , " \\ " , O_RDONLY , DENY_NONE , & dnum ) ) ) {
printf ( " open of \\ failed \n " ) ;
return false ;
}
2001-08-27 22:01:05 +04:00
for ( op = OP_MIN ; op < = OP_MAX ; op + + ) {
printf ( " Scanning op=%d \n " , op ) ;
for ( level = 0 ; level < = 50 ; level + + ) {
2003-04-23 12:12:34 +04:00
scan_trans2 ( cli , op , level , fnum , dnum , fname ) ;
2001-08-27 22:01:05 +04:00
}
for ( level = 0x100 ; level < = 0x130 ; level + + ) {
2003-04-23 12:12:34 +04:00
scan_trans2 ( cli , op , level , fnum , dnum , fname ) ;
2001-08-27 22:01:05 +04:00
}
for ( level = 1000 ; level < 1050 ; level + + ) {
2003-04-23 12:12:34 +04:00
scan_trans2 ( cli , op , level , fnum , dnum , fname ) ;
2001-08-27 22:01:05 +04:00
}
}
2003-04-23 12:12:34 +04:00
torture_close_connection ( cli ) ;
2001-08-27 22:01:05 +04:00
printf ( " trans2 scan finished \n " ) ;
return True ;
}
/****************************************************************************
look for a partial hit
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-01-03 11:28:12 +03:00
static void nttrans_check_hit ( const char * format , int op , int level , NTSTATUS status )
2001-08-27 22:01:05 +04:00
{
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_V ( status ) = = NT_STATUS_V ( NT_STATUS_INVALID_LEVEL ) | |
NT_STATUS_V ( status ) = = NT_STATUS_V ( NT_STATUS_NOT_IMPLEMENTED ) | |
NT_STATUS_V ( status ) = = NT_STATUS_V ( NT_STATUS_NOT_SUPPORTED ) | |
NT_STATUS_V ( status ) = = NT_STATUS_V ( NT_STATUS_UNSUCCESSFUL ) | |
NT_STATUS_V ( status ) = = NT_STATUS_V ( NT_STATUS_INVALID_INFO_CLASS ) ) {
return ;
}
2001-08-27 22:01:05 +04:00
# if VERBOSE
printf ( " possible %s hit op=%3d level=%5d status=%s \n " ,
2002-03-17 07:36:35 +03:00
format , op , level , nt_errstr ( status ) ) ;
2001-08-27 22:01:05 +04:00
# endif
}
/****************************************************************************
check for existance of a nttrans call
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-09-04 15:52:42 +04:00
static NTSTATUS try_nttrans ( struct cli_state * cli ,
2011-01-16 14:33:24 +03:00
int op ,
uint8_t * param , uint8_t * data ,
int32_t param_len , uint32_t data_len ,
uint32_t * rparam_len ,
uint32_t * rdata_len )
2001-08-27 22:01:05 +04:00
{
2011-01-16 14:33:24 +03:00
uint8_t * rparam = NULL , * rdata = NULL ;
NTSTATUS status ;
2001-08-27 22:01:05 +04:00
2011-01-16 14:33:24 +03:00
status = cli_trans ( talloc_tos ( ) , cli , SMBnttrans ,
NULL , - 1 , /* name, fid */
op , 0 ,
NULL , 0 , 0 , /* setup */
param , param_len , 2 ,
data , data_len , cli - > max_xmit ,
NULL , /* recv_flags2 */
NULL , 0 , NULL , /* rsetup */
& rparam , 0 , rparam_len ,
& rdata , 0 , rdata_len ) ;
2001-09-17 15:37:57 +04:00
SAFE_FREE ( rdata ) ;
SAFE_FREE ( rparam ) ;
2001-08-27 22:01:05 +04:00
2011-01-16 14:33:24 +03:00
return status ;
2001-08-27 22:01:05 +04:00
}
2001-09-04 15:52:42 +04:00
static NTSTATUS try_nttrans_len ( struct cli_state * cli ,
2003-01-03 11:28:12 +03:00
const char * format ,
2001-08-27 22:01:05 +04:00
int op , int level ,
2011-01-16 14:33:24 +03:00
uint8_t * param , uint8_t * data ,
int param_len , uint32_t * data_len ,
uint32_t * rparam_len , uint32_t * rdata_len )
2001-08-27 22:01:05 +04:00
{
2001-09-04 15:52:42 +04:00
NTSTATUS ret = NT_STATUS_OK ;
2001-08-27 22:01:05 +04:00
ret = try_nttrans ( cli , op , param , data , param_len ,
2007-12-05 04:05:33 +03:00
DATA_SIZE , rparam_len , rdata_len ) ;
2001-08-27 22:01:05 +04:00
# if VERBOSE
2002-03-17 07:36:35 +03:00
printf ( " op=%d level=%d ret=%s \n " , op , level , nt_errstr ( ret ) ) ;
2001-08-27 22:01:05 +04:00
# endif
2001-09-04 15:52:42 +04:00
if ( ! NT_STATUS_IS_OK ( ret ) ) return ret ;
2001-08-27 22:01:05 +04:00
* data_len = 0 ;
2007-12-05 04:05:33 +03:00
while ( * data_len < DATA_SIZE ) {
2001-08-27 22:01:05 +04:00
ret = try_nttrans ( cli , op , param , data , param_len ,
* data_len , rparam_len , rdata_len ) ;
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( ret ) ) break ;
2001-08-27 22:01:05 +04:00
* data_len + = 2 ;
}
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( ret ) ) {
2001-08-27 22:01:05 +04:00
printf ( " found %s level=%d data_len=%d rparam_len=%d rdata_len=%d \n " ,
format , level , * data_len , * rparam_len , * rdata_len ) ;
} else {
nttrans_check_hit ( format , op , level , ret ) ;
}
return ret ;
}
/****************************************************************************
check for existance of a nttrans call
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-19 04:40:25 +04:00
static bool scan_nttrans ( struct cli_state * cli , int op , int level ,
2003-01-03 11:28:12 +03:00
int fnum , int dnum , const char * fname )
2001-08-27 22:01:05 +04:00
{
2011-01-16 14:33:24 +03:00
uint32_t data_len = 0 ;
uint32_t param_len = 0 ;
uint32_t rparam_len , rdata_len ;
uint8_t param [ PARAM_SIZE ] , data [ DATA_SIZE ] ;
2001-08-27 23:46:22 +04:00
NTSTATUS status ;
2001-08-27 22:01:05 +04:00
memset ( data , 0 , sizeof ( data ) ) ;
data_len = 4 ;
/* try with a info level only */
param_len = 2 ;
SSVAL ( param , 0 , level ) ;
status = try_nttrans_len ( cli , " void " , op , level , param , data , param_len , & data_len ,
& rparam_len , & rdata_len ) ;
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( status ) ) return True ;
2001-08-27 22:01:05 +04:00
/* try with a file descriptor */
param_len = 6 ;
SSVAL ( param , 0 , fnum ) ;
SSVAL ( param , 2 , level ) ;
SSVAL ( param , 4 , 0 ) ;
status = try_nttrans_len ( cli , " fnum " , op , level , param , data , param_len , & data_len ,
& rparam_len , & rdata_len ) ;
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( status ) ) return True ;
2001-08-27 22:01:05 +04:00
/* try with a notify style */
param_len = 6 ;
SSVAL ( param , 0 , dnum ) ;
SSVAL ( param , 2 , dnum ) ;
SSVAL ( param , 4 , level ) ;
status = try_nttrans_len ( cli , " notify " , op , level , param , data , param_len , & data_len ,
& rparam_len , & rdata_len ) ;
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( status ) ) return True ;
2001-08-27 22:01:05 +04:00
/* try with a file name */
param_len = 6 ;
SSVAL ( param , 0 , level ) ;
SSVAL ( param , 2 , 0 ) ;
SSVAL ( param , 4 , 0 ) ;
param_len + = clistr_push ( cli , & param [ 6 ] , fname , - 1 , STR_TERMINATE ) ;
status = try_nttrans_len ( cli , " fname " , op , level , param , data , param_len , & data_len ,
& rparam_len , & rdata_len ) ;
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( status ) ) return True ;
2001-08-27 22:01:05 +04:00
/* try with a new file name */
param_len = 6 ;
SSVAL ( param , 0 , level ) ;
SSVAL ( param , 2 , 0 ) ;
SSVAL ( param , 4 , 0 ) ;
param_len + = clistr_push ( cli , & param [ 6 ] , " \\ newfile.dat " , - 1 , STR_TERMINATE ) ;
status = try_nttrans_len ( cli , " newfile " , op , level , param , data , param_len , & data_len ,
& rparam_len , & rdata_len ) ;
2011-04-29 07:23:14 +04:00
cli_unlink ( cli , " \\ newfile.dat " , FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN ) ;
2001-08-27 22:01:05 +04:00
cli_rmdir ( cli , " \\ newfile.dat " ) ;
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( status ) ) return True ;
2001-08-27 22:01:05 +04:00
/* try dfs style */
cli_mkdir ( cli , " \\ testdir " ) ;
param_len = 2 ;
SSVAL ( param , 0 , level ) ;
param_len + = clistr_push ( cli , & param [ 2 ] , " \\ testdir " , - 1 , STR_TERMINATE ) ;
status = try_nttrans_len ( cli , " dfs " , op , level , param , data , param_len , & data_len ,
& rparam_len , & rdata_len ) ;
cli_rmdir ( cli , " \\ testdir " ) ;
2001-09-04 15:52:42 +04:00
if ( NT_STATUS_IS_OK ( status ) ) return True ;
2001-08-27 22:01:05 +04:00
return False ;
}
2007-10-19 04:40:25 +04:00
bool torture_nttrans_scan ( int dummy )
2001-08-27 22:01:05 +04:00
{
2003-04-23 12:12:34 +04:00
static struct cli_state * cli ;
2001-08-27 22:01:05 +04:00
int op , level ;
2003-01-03 11:28:12 +03:00
const char * fname = " \\ scanner.dat " ;
2009-05-01 02:26:43 +04:00
uint16_t fnum , dnum ;
2001-08-27 22:01:05 +04:00
printf ( " starting nttrans scan test \n " ) ;
2006-07-31 13:41:25 +04:00
if ( ! torture_open_connection ( & cli , 0 ) ) {
2001-08-27 22:01:05 +04:00
return False ;
}
2009-05-01 02:26:43 +04:00
cli_open ( cli , fname , O_RDWR | O_CREAT | O_TRUNC ,
DENY_NONE , & fnum ) ;
cli_open ( cli , " \\ " , O_RDONLY , DENY_NONE , & dnum ) ;
2001-08-27 22:01:05 +04:00
for ( op = OP_MIN ; op < = OP_MAX ; op + + ) {
printf ( " Scanning op=%d \n " , op ) ;
for ( level = 0 ; level < = 50 ; level + + ) {
2003-04-23 12:12:34 +04:00
scan_nttrans ( cli , op , level , fnum , dnum , fname ) ;
2001-08-27 22:01:05 +04:00
}
for ( level = 0x100 ; level < = 0x130 ; level + + ) {
2003-04-23 12:12:34 +04:00
scan_nttrans ( cli , op , level , fnum , dnum , fname ) ;
2001-08-27 22:01:05 +04:00
}
for ( level = 1000 ; level < 1050 ; level + + ) {
2003-04-23 12:12:34 +04:00
scan_nttrans ( cli , op , level , fnum , dnum , fname ) ;
2001-08-27 22:01:05 +04:00
}
}
2003-04-23 12:12:34 +04:00
torture_close_connection ( cli ) ;
2001-08-27 22:01:05 +04:00
printf ( " nttrans scan finished \n " ) ;
return True ;
}