2008-11-11 14:36:07 +03:00
/*
Unix SMB / CIFS implementation .
test suite for rpc ntsvcs operations
Copyright ( C ) Guenther Deschner 2008
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
the Free Software Foundation ; either version 3 of the License , or
( 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
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "includes.h"
2010-04-14 00:06:51 +04:00
# include "torture/rpc/torture_rpc.h"
2008-11-11 14:36:07 +03:00
# include "librpc/gen_ndr/ndr_ntsvcs_c.h"
static bool test_PNP_GetVersion ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
2010-03-18 12:26:43 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2008-11-11 14:36:07 +03:00
NTSTATUS status ;
struct PNP_GetVersion r ;
uint16_t version = 0 ;
r . out . version = & version ;
2010-03-18 12:26:43 +03:00
status = dcerpc_PNP_GetVersion_r ( b , tctx , & r ) ;
2008-11-11 14:36:07 +03:00
torture_assert_ntstatus_ok ( tctx , status , " PNP_GetVersion " ) ;
torture_assert_werr_ok ( tctx , r . out . result , " PNP_GetVersion " ) ;
torture_assert_int_equal ( tctx , version , 0x400 , " invalid version " ) ;
return true ;
}
static bool test_PNP_GetDeviceListSize ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
2010-03-18 12:26:43 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2008-11-11 14:36:07 +03:00
struct PNP_GetDeviceListSize r ;
uint32_t size = 0 ;
r . in . devicename = NULL ;
2009-04-10 02:42:35 +04:00
r . in . flags = CM_GETIDLIST_FILTER_SERVICE ;
2008-11-11 14:36:07 +03:00
r . out . size = & size ;
2009-04-10 02:42:35 +04:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-18 12:26:43 +03:00
dcerpc_PNP_GetDeviceListSize_r ( b , tctx , & r ) ,
2009-04-10 02:42:35 +04:00
" PNP_GetDeviceListSize " ) ;
torture_assert_werr_equal ( tctx , r . out . result , WERR_CM_INVALID_POINTER ,
" PNP_GetDeviceListSize " ) ;
r . in . devicename = " Spooler " ;
2008-11-11 14:36:07 +03:00
2009-04-10 02:42:35 +04:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-18 12:26:43 +03:00
dcerpc_PNP_GetDeviceListSize_r ( b , tctx , & r ) ,
2009-04-10 02:42:35 +04:00
" PNP_GetDeviceListSize " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" PNP_GetDeviceListSize " ) ;
2008-11-11 14:36:07 +03:00
return true ;
}
static bool test_PNP_GetDeviceList ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
2010-03-18 12:26:43 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2008-11-11 14:36:07 +03:00
struct PNP_GetDeviceList r ;
uint16_t * buffer = NULL ;
uint32_t length = 0 ;
buffer = talloc_array ( tctx , uint16_t , 0 ) ;
r . in . filter = NULL ;
2009-04-10 02:42:35 +04:00
r . in . flags = CM_GETIDLIST_FILTER_SERVICE ;
2008-11-11 14:36:07 +03:00
r . in . length = & length ;
r . out . length = & length ;
r . out . buffer = buffer ;
2009-04-10 02:42:35 +04:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-18 12:26:43 +03:00
dcerpc_PNP_GetDeviceList_r ( b , tctx , & r ) ,
2009-04-10 02:42:35 +04:00
" PNP_GetDeviceList failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result , WERR_CM_INVALID_POINTER ,
" PNP_GetDeviceList failed " ) ;
r . in . filter = " Spooler " ;
torture_assert_ntstatus_ok ( tctx ,
2010-03-18 12:26:43 +03:00
dcerpc_PNP_GetDeviceList_r ( b , tctx , & r ) ,
2009-04-10 02:42:35 +04:00
" PNP_GetDeviceList failed " ) ;
2008-11-11 14:36:07 +03:00
if ( W_ERROR_EQUAL ( r . out . result , WERR_CM_BUFFER_SMALL ) ) {
struct PNP_GetDeviceListSize s ;
2009-04-10 02:42:35 +04:00
s . in . devicename = " Spooler " ;
s . in . flags = CM_GETIDLIST_FILTER_SERVICE ;
2008-11-11 14:36:07 +03:00
s . out . size = & length ;
2009-04-10 02:42:35 +04:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-18 12:26:43 +03:00
dcerpc_PNP_GetDeviceListSize_r ( b , tctx , & s ) ,
2009-04-10 02:42:35 +04:00
" PNP_GetDeviceListSize failed " ) ;
torture_assert_werr_ok ( tctx , s . out . result ,
" PNP_GetDeviceListSize failed " ) ;
2008-11-11 14:36:07 +03:00
}
buffer = talloc_array ( tctx , uint16_t , length ) ;
r . in . length = & length ;
r . out . length = & length ;
r . out . buffer = buffer ;
2009-04-10 02:42:35 +04:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-18 12:26:43 +03:00
dcerpc_PNP_GetDeviceList_r ( b , tctx , & r ) ,
2009-04-10 02:42:35 +04:00
" PNP_GetDeviceList failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" PNP_GetDeviceList failed " ) ;
2008-11-11 14:36:07 +03:00
return true ;
}
2008-11-14 02:30:11 +03:00
static bool test_PNP_GetDeviceRegProp ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
2010-03-18 12:26:43 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2008-11-14 02:30:11 +03:00
NTSTATUS status ;
struct PNP_GetDeviceRegProp r ;
enum winreg_Type reg_data_type = REG_NONE ;
uint32_t buffer_size = 0 ;
uint32_t needed = 0 ;
uint8_t * buffer ;
buffer = talloc ( tctx , uint8_t ) ;
r . in . devicepath = " ACPI \\ ACPI0003 \\ 1 " ;
r . in . property = DEV_REGPROP_DESC ;
r . in . flags = 0 ;
r . in . reg_data_type = & reg_data_type ;
r . in . buffer_size = & buffer_size ;
r . in . needed = & needed ;
r . out . buffer = buffer ;
r . out . reg_data_type = & reg_data_type ;
r . out . buffer_size = & buffer_size ;
r . out . needed = & needed ;
2010-03-18 12:26:43 +03:00
status = dcerpc_PNP_GetDeviceRegProp_r ( b , tctx , & r ) ;
2008-11-14 02:30:11 +03:00
torture_assert_ntstatus_ok ( tctx , status , " PNP_GetDeviceRegProp " ) ;
if ( W_ERROR_EQUAL ( r . out . result , WERR_CM_BUFFER_SMALL ) ) {
buffer = talloc_array ( tctx , uint8_t , needed ) ;
r . in . buffer_size = & needed ;
2010-03-18 12:26:43 +03:00
status = dcerpc_PNP_GetDeviceRegProp_r ( b , tctx , & r ) ;
2008-11-14 02:30:11 +03:00
torture_assert_ntstatus_ok ( tctx , status , " PNP_GetDeviceRegProp " ) ;
}
return true ;
}
2008-11-11 14:36:07 +03:00
struct torture_suite * torture_rpc_ntsvcs ( TALLOC_CTX * mem_ctx )
{
struct torture_rpc_tcase * tcase ;
2010-12-11 05:26:31 +03:00
struct torture_suite * suite = torture_suite_create ( mem_ctx , " ntsvcs " ) ;
2008-11-11 14:36:07 +03:00
tcase = torture_suite_add_rpc_iface_tcase ( suite , " ntsvcs " ,
& ndr_table_ntsvcs ) ;
2014-01-14 19:37:36 +04:00
torture_rpc_tcase_add_test ( tcase , " PNP_GetDeviceRegProp " ,
test_PNP_GetDeviceRegProp ) ;
torture_rpc_tcase_add_test ( tcase , " PNP_GetDeviceList " ,
test_PNP_GetDeviceList ) ;
torture_rpc_tcase_add_test ( tcase , " PNP_GetDeviceListSize " ,
test_PNP_GetDeviceListSize ) ;
torture_rpc_tcase_add_test ( tcase , " PNP_GetVersion " ,
test_PNP_GetVersion ) ;
2008-11-11 14:36:07 +03:00
return suite ;
}