2004-10-31 18:40:08 +00:00
/*
Unix SMB / CIFS implementation .
test suite for remoteactivation operations
Copyright ( C ) Jelmer Vernooij 2004
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 2 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"
2004-11-01 10:30:34 +00:00
# include "librpc/gen_ndr/ndr_remact.h"
# include "librpc/gen_ndr/ndr_epmapper.h"
2004-10-31 18:40:08 +00:00
# define CLSID_TEST "00000316-0000-0000-C000-000000000046"
# define CLSID_SIMPLE "5e9ddec7-5767-11cf-beab-00aa006c3606"
# define CLSID_COFFEEMACHINE "DB7C21F8-FE33-4C11-AEA5-CEB56F076FBB"
static int test_RemoteActivation ( struct dcerpc_pipe * p , TALLOC_CTX * mem_ctx )
{
struct RemoteActivation r ;
NTSTATUS status ;
struct GUID iids [ 2 ] ;
2005-02-10 05:09:35 +00:00
uint16_t protseq [ 3 ] = { EPM_PROTOCOL_TCP , EPM_PROTOCOL_NCALRPC , EPM_PROTOCOL_UUID } ;
2004-10-31 18:40:08 +00:00
ZERO_STRUCT ( r . in ) ;
r . in . this . version . MajorVersion = 5 ;
r . in . this . version . MinorVersion = 1 ;
2004-11-25 20:03:46 +00:00
r . in . this . cid = GUID_random ( ) ;
2004-10-31 18:40:08 +00:00
GUID_from_string ( CLSID_SIMPLE , & r . in . Clsid ) ;
r . in . ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY ;
2004-11-02 15:32:58 +00:00
r . in . num_protseqs = 3 ;
2004-10-31 18:40:08 +00:00
r . in . protseq = protseq ;
2004-11-07 16:47:46 +00:00
r . in . Interfaces = 2 ;
2004-10-31 18:40:08 +00:00
GUID_from_string ( DCERPC_IUNKNOWN_UUID , & iids [ 0 ] ) ;
2004-11-07 16:47:46 +00:00
GUID_from_string ( DCERPC_ISTREAM_UUID , & iids [ 1 ] ) ;
2004-10-31 18:40:08 +00:00
r . in . pIIDs = iids ;
status = dcerpc_RemoteActivation ( p , mem_ctx , & r ) ;
if ( NT_STATUS_IS_ERR ( status ) ) {
fprintf ( stderr , " RemoteActivation: %s \n " , nt_errstr ( status ) ) ;
return 0 ;
}
if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
fprintf ( stderr , " RemoteActivation: %s \n " , win_errstr ( r . out . result ) ) ;
return 0 ;
}
2004-11-01 12:40:43 +00:00
if ( ! W_ERROR_IS_OK ( r . out . hr ) ) {
fprintf ( stderr , " RemoteActivation: %s \n " , win_errstr ( r . out . hr ) ) ;
2004-10-31 18:40:08 +00:00
return 0 ;
}
2004-11-02 17:38:11 +00:00
if ( ! W_ERROR_IS_OK ( r . out . results [ 0 ] ) ) {
fprintf ( stderr , " RemoteActivation: %s \n " , win_errstr ( r . out . results [ 0 ] ) ) ;
return 0 ;
}
2004-11-03 20:32:28 +00:00
GUID_from_string ( DCERPC_ICLASSFACTORY_UUID , & iids [ 0 ] ) ;
2004-11-07 16:47:46 +00:00
r . in . Interfaces = 1 ;
2004-11-02 17:38:11 +00:00
r . in . Mode = MODE_GET_CLASS_OBJECT ;
status = dcerpc_RemoteActivation ( p , mem_ctx , & r ) ;
if ( NT_STATUS_IS_ERR ( status ) ) {
fprintf ( stderr , " RemoteActivation(GetClassObject): %s \n " , nt_errstr ( status ) ) ;
return 0 ;
}
if ( ! W_ERROR_IS_OK ( r . out . result ) ) {
fprintf ( stderr , " RemoteActivation(GetClassObject): %s \n " , win_errstr ( r . out . result ) ) ;
return 0 ;
}
if ( ! W_ERROR_IS_OK ( r . out . hr ) ) {
fprintf ( stderr , " RemoteActivation(GetClassObject): %s \n " , win_errstr ( r . out . hr ) ) ;
return 0 ;
}
if ( ! W_ERROR_IS_OK ( r . out . results [ 0 ] ) ) {
fprintf ( stderr , " RemoteActivation: %s \n " , win_errstr ( r . out . results [ 0 ] ) ) ;
return 0 ;
}
2004-10-31 18:40:08 +00:00
return 1 ;
}
BOOL torture_rpc_remact ( void )
{
NTSTATUS status ;
struct dcerpc_pipe * p ;
TALLOC_CTX * mem_ctx ;
BOOL ret = True ;
mem_ctx = talloc_init ( " torture_rpc_remact " ) ;
status = torture_rpc_connection ( & p ,
DCERPC_IREMOTEACTIVATION_NAME ,
DCERPC_IREMOTEACTIVATION_UUID ,
DCERPC_IREMOTEACTIVATION_VERSION ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return False ;
}
if ( ! test_RemoteActivation ( p , mem_ctx ) )
ret = False ;
2005-01-27 07:08:20 +00:00
talloc_free ( mem_ctx ) ;
2004-10-31 18:40:08 +00:00
torture_rpc_close ( p ) ;
return ret ;
}