2006-05-02 17:08:38 +04:00
/*
Unix SMB / CIFS implementation .
dcerpc torture tests
Copyright ( C ) Andrew Tridgell 2003
Copyright ( C ) Rafal Szczesniak 2006
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
2006-05-02 17:08:38 +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/>.
2006-05-02 17:08:38 +04:00
*/
# include "includes.h"
# include "librpc/gen_ndr/ndr_lsa.h"
2020-12-02 19:24:22 +03:00
# include "lib/cmdline/cmdline.h"
2010-04-14 00:06:51 +04:00
# include "torture/rpc/torture_rpc.h"
2006-05-02 17:08:38 +04:00
/*
This test initiates multiple rpc bind requests and verifies
whether all of them are served .
*/
2007-10-07 02:28:14 +04:00
bool torture_async_bind ( struct torture_context * torture )
2006-05-02 17:08:38 +04:00
{
NTSTATUS status ;
TALLOC_CTX * mem_ctx ;
int i ;
const char * binding_string ;
struct cli_credentials * creds ;
2006-05-05 13:52:12 +04:00
extern int torture_numasync ;
2006-05-02 17:08:38 +04:00
2006-05-05 13:52:12 +04:00
struct composite_context * * bind_req ;
2014-01-10 16:46:34 +04:00
struct dcerpc_pipe * * pipes ;
2007-08-20 00:46:45 +04:00
const struct ndr_interface_table * * table ;
2006-05-02 17:08:38 +04:00
2007-10-07 02:28:14 +04:00
if ( ! torture_setting_bool ( torture , " async " , false ) ) {
2006-05-07 23:26:48 +04:00
printf ( " async bind test disabled - enable async tests to use \n " ) ;
2007-10-07 02:28:14 +04:00
return true ;
2006-05-03 15:24:17 +04:00
}
2006-05-05 13:52:12 +04:00
2006-10-18 18:23:19 +04:00
binding_string = torture_setting_string ( torture , " binding " , NULL ) ;
2006-05-02 17:08:38 +04:00
/* talloc context */
mem_ctx = talloc_init ( " torture_async_bind " ) ;
2007-10-07 02:28:14 +04:00
if ( mem_ctx = = NULL ) return false ;
2006-05-02 17:08:38 +04:00
2006-05-05 13:52:12 +04:00
bind_req = talloc_array ( torture , struct composite_context * , torture_numasync ) ;
2007-10-07 02:28:14 +04:00
if ( bind_req = = NULL ) return false ;
2014-01-10 16:46:34 +04:00
pipes = talloc_array ( torture , struct dcerpc_pipe * , torture_numasync ) ;
if ( pipes = = NULL ) return false ;
2007-08-20 00:46:45 +04:00
table = talloc_array ( torture , const struct ndr_interface_table * , torture_numasync ) ;
2007-10-07 02:28:14 +04:00
if ( table = = NULL ) return false ;
2006-05-05 13:52:12 +04:00
2006-05-02 17:08:38 +04:00
/* credentials */
2020-12-02 19:24:22 +03:00
creds = samba_cmdline_get_creds ( ) ;
2006-05-02 17:08:38 +04:00
2006-05-05 13:52:12 +04:00
/* send bind requests */
for ( i = 0 ; i < torture_numasync ; i + + ) {
2007-08-20 01:23:03 +04:00
table [ i ] = & ndr_table_lsarpc ;
2006-10-13 17:01:48 +04:00
bind_req [ i ] = dcerpc_pipe_connect_send ( mem_ctx , binding_string ,
2008-04-17 03:03:18 +04:00
table [ i ] , creds , torture - > ev , torture - > lp_ctx ) ;
2006-05-02 17:08:38 +04:00
}
2006-05-05 13:52:12 +04:00
/* recv bind requests */
for ( i = 0 ; i < torture_numasync ; i + + ) {
2014-01-10 16:46:34 +04:00
status = dcerpc_pipe_connect_recv ( bind_req [ i ] , mem_ctx , & pipes [ i ] ) ;
2006-05-05 13:52:12 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
printf ( " async rpc connection failed: %s \n " , nt_errstr ( status ) ) ;
2007-10-07 02:28:14 +04:00
return false ;
2006-05-05 13:52:12 +04:00
}
2006-05-02 17:08:38 +04:00
}
talloc_free ( mem_ctx ) ;
2007-10-07 02:28:14 +04:00
return true ;
2006-05-02 17:08:38 +04:00
}